/* MESS Dashboard -- Dark Theme */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2333;
    --bg-hover: #242d3d;
    --border-color: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-yellow: #d29922;
    --accent-red: #f85149;
    --accent-orange: #db6d28;
    --accent-purple: #6e40c9;
    --sidebar-width: 220px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    line-height: 1.5;
}

/* ===================== Sidebar ===================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-logo {
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
}

.sidebar-logo h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Account switcher */
.account-switcher {
    margin-top: 10px;
}

.account-switcher select {
    width: 100%;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.account-switcher select:hover {
    border-color: var(--accent-blue);
}

.account-label {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 0;
}

.sidebar nav { flex: 1; }

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar nav a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar nav a.active {
    background: var(--bg-tertiary);
    color: var(--accent-blue);
    border-left-color: var(--accent-blue);
}

.sidebar nav a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar nav a.active svg { opacity: 1; }

.sidebar-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-muted);
}

/* ===================== Main Content ===================== */
.main {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
}

.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.page-header .header-meta {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    gap: 16px;
    align-items: center;
}

.page-header .header-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===================== Stats Bar ===================== */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px 20px;
    text-align: center;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.stat-card .value.good { color: var(--accent-green); }
.stat-card .value.warn { color: var(--accent-yellow); }
.stat-card .value.bad { color: var(--accent-red); }
.stat-card .value.neutral { color: var(--text-primary); }

/* ===================== Health Checklist ===================== */
.health-checklist {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 28px;
}

.health-checklist h2 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.checklist-subtitle { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; margin-top: -8px; }
.check-items { display: flex; flex-wrap: wrap; gap: 12px; }

.check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px 16px;
    cursor: pointer;
    transition: opacity 0.2s;
    flex: 1;
    min-width: 220px;
}

.check-item:hover { border-color: var(--accent-blue); }
.check-item.done { opacity: 0.5; text-decoration: line-through; }
.check-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent-green); cursor: pointer; flex-shrink: 0; }
.check-item a { color: var(--accent-blue); text-decoration: none; font-size: 14px; font-weight: 500; }
.check-item a:hover { text-decoration: underline; }

/* History strip */
.history-strip { display: flex; gap: 6px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-color); }
.history-strip .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-right: 4px; }

.history-dot {
    width: 24px; height: 24px; border-radius: 4px; display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600; cursor: default; position: relative;
}
.history-dot.done { background: rgba(63,185,80,0.2); color: var(--accent-green); border: 1px solid rgba(63,185,80,0.3); }
.history-dot.partial { background: rgba(210,153,34,0.2); color: var(--accent-yellow); border: 1px solid rgba(210,153,34,0.3); }
.history-dot.missed { background: rgba(248,81,73,0.1); color: var(--text-muted); border: 1px solid var(--border-color); }
.history-dot.today { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
.history-dot .tooltip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 4px; padding: 4px 8px; font-size: 11px; white-space: nowrap; z-index: 10; margin-bottom: 4px; color: var(--text-secondary); }
.history-dot:hover .tooltip { display: block; }

/* ===================== Section Groups ===================== */
.section-group {
    margin-bottom: 2rem;
}

.group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.group-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 10px;
    border-radius: 4px;
    white-space: nowrap;
}

.group-label.critical { background: rgba(248, 81, 73, 0.15); color: var(--accent-red); }
.group-label.monitoring { background: rgba(210, 153, 34, 0.15); color: var(--accent-yellow); }
.group-label.optimization { background: rgba(88, 166, 255, 0.15); color: var(--accent-blue); }

.group-title {
    font-size: 13px;
    color: var(--text-secondary);
}

.group-count {
    font-size: 12px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
}

.group-count.has-alerts { background: rgba(248,81,73,0.15); color: var(--accent-red); }

/* ===================== Status Items (expandable cards) ===================== */
.status-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 3px solid transparent;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.status-item.border-critical { border-left-color: var(--accent-red); }
.status-item.border-high { border-left-color: var(--accent-orange); }
.status-item.border-medium { border-left-color: var(--accent-yellow); }

.status-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.status-header:hover { background: var(--bg-tertiary); }
.status-icon { font-size: 16px; flex-shrink: 0; }
.status-label { font-weight: 600; font-size: 14px; }
.status-summary { color: var(--text-secondary); font-size: 13px; margin-left: 4px; flex: 1; }

.status-count {
    font-size: 11px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 10px;
}

.status-count.has-alerts { background: rgba(248,81,73,0.15); color: var(--accent-red); }
.status-chevron { color: var(--text-muted); font-size: 12px; margin-left: 8px; transition: transform 0.2s; }
.status-item.open .status-chevron { transform: rotate(90deg); }

/* Expandable detail area */
.status-details {
    display: none;
    padding: 0 16px 14px;
    border-top: 1px solid var(--border-color);
}

.status-item.open .status-details { display: block; }

/* Seller Central link inside expanded */
.sc-link {
    padding: 8px 0 4px;
    font-size: 12px;
}

.sc-link a { color: var(--accent-blue); text-decoration: none; }
.sc-link a:hover { text-decoration: underline; }

/* ===================== Detail Rows ===================== */
.detail-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.detail-row:last-child { border-bottom: none; }

.detail-img {
    width: 48px; height: 48px; border-radius: 6px; object-fit: contain;
    background: #fff; flex-shrink: 0;
}

.detail-img-placeholder {
    width: 48px; height: 48px; border-radius: 6px; background: var(--bg-tertiary);
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    font-size: 9px; color: var(--text-muted);
}

.detail-info { flex: 1; min-width: 0; }

.detail-asin {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 12px;
}

.detail-asin a { color: var(--accent-blue); text-decoration: none; }
.detail-asin a:hover { text-decoration: underline; }

.detail-name { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-text { font-size: 13px; font-weight: 500; margin-top: 2px; }

.detail-action-text { font-size: 11px; color: var(--text-muted); flex-shrink: 0; max-width: 220px; }
.detail-action-links { display: flex; flex-wrap: wrap; gap: 4px; flex-shrink: 0; }

.detail-action-link {
    font-size: 11px; color: var(--accent-blue); background: rgba(88,166,255,0.1);
    border: 1px solid rgba(88,166,255,0.2); padding: 3px 10px; border-radius: 4px;
    text-decoration: none; font-weight: 500; white-space: nowrap;
}

.detail-action-link:hover { background: rgba(88,166,255,0.2); border-color: var(--accent-blue); }
.detail-action-link.removal { color: var(--accent-red); background: rgba(248,81,73,0.1); border-color: rgba(248,81,73,0.2); }
.detail-action-link.removal:hover { background: rgba(248,81,73,0.2); border-color: var(--accent-red); }

/* Severity */
.sev-critical { color: var(--accent-red); }
.sev-high { color: var(--accent-orange); }
.sev-medium { color: var(--accent-yellow); }
.sev-note { color: var(--text-muted); }

.sev-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sev-badge.critical { background: rgba(248,81,73,0.15); color: var(--accent-red); }
.sev-badge.high { background: rgba(219,109,40,0.15); color: var(--accent-orange); }
.sev-badge.medium { background: rgba(210,153,34,0.15); color: var(--accent-yellow); }

/* ===================== Trend Table ===================== */
.trend-section { margin-bottom: 2rem; }
.trend-table { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px 12px; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border-color); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border-color); }
tr:last-child td { border-bottom: none; }
.td-img { width: 36px; padding: 4px 8px; }
.td-img img { width: 36px; height: 36px; border-radius: 4px; object-fit: contain; background: #fff; }
.td-asin { font-family: 'SF Mono', 'Consolas', monospace; font-size: 11px; }
.td-asin a { color: var(--accent-blue); text-decoration: none; }
.td-asin a:hover { text-decoration: underline; }
.td-name { color: var(--text-secondary); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== Utilities ===================== */
.no-alerts { color: var(--accent-green); font-size: 16px; padding: 16px; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 2rem; }
.footer { margin-top: 2rem; padding-top: 16px; border-top: 1px solid var(--border-color); font-size: 12px; color: var(--text-muted); }
.empty-state { text-align: center; padding: 80px 24px; color: var(--text-muted); }
.empty-state h1 { font-size: 20px; margin-bottom: 8px; color: var(--text-secondary); }

/* ===================== Responsive ===================== */
@media (max-width: 900px) {
    .sidebar { display: none; }
    .main { margin-left: 0; padding: 16px; }
    .page-header h1 { font-size: 22px; }
    .stats-bar { grid-template-columns: repeat(2, 1fr); }
    .check-items { flex-direction: column; }
    .detail-row { flex-wrap: wrap; }
}
