/* RUM & Code v6 — Sidebar Dashboard */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #090b10; --surface: #11131b; --surface-2: #181c28; --surface-3: #1f2535; --border: #252b3d;
    --text: #e0e2ea; --text-muted: #6a7094; --text-dim: #4a5070;
    --green: #34d399; --green-bg: rgba(52,211,153,.07);
    --yellow: #fbbf24; --yellow-bg: rgba(251,191,36,.07);
    --red: #f87171; --red-bg: rgba(248,113,113,.07);
    --blue: #60a5fa; --blue-bg: rgba(96,165,250,.07);
    --purple: #a78bfa; --cyan: #22d3ee;
    --accent: #60a5fa;
    --mono: 'JetBrains Mono', monospace;
    --sans: 'DM Sans', -apple-system, sans-serif;

    --fs-hero: 2rem; --fs-score: 1.75rem; --fs-h1: 1.125rem; --fs-h3: 0.9375rem;
    --fs-body: 0.9375rem; --fs-small: 0.8125rem; --fs-xs: 0.75rem;
    --fs-pill: 0.6875rem; --fs-label: 0.6875rem;

    --sidebar-w: 240px;
    --topbar-h: 54px;
}

body { font-family: var(--sans); background: var(--bg); color: var(--text); line-height: 1.6; font-size: var(--fs-body); }
code { font-family: var(--mono); font-size: .85em; background: var(--surface-3); padding: 2px 6px; border-radius: 4px; color: var(--cyan); word-break: break-all; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ════════════════ SIDEBAR LAYOUT ════════════════ */
.dash-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.sidebar-brand {
    padding: 16px 20px 12px; border-bottom: 1px solid var(--border);
}
.sidebar-brand-row { display: flex; align-items: center; gap: 9px; }
.sidebar-brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); flex-shrink: 0; }
.sidebar-brand h1 { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; }
.sidebar-site-switch {
    margin-top: 10px; width: 100%;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    padding: 7px 10px; border-radius: 8px; font-size: 12px; font-family: var(--sans); cursor: pointer;
}
.sidebar-site-switch:focus { outline: none; border-color: var(--accent); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-group { margin-bottom: 4px; }
.nav-group-label {
    font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px;
    color: var(--text-dim); padding: 10px 20px 3px; user-select: none;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 16px; margin: 1px 8px; border-radius: 8px;
    font-size: 13px; font-weight: 500; color: var(--text-muted);
    text-decoration: none !important; transition: all .12s; position: relative;
}
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: var(--accent); background: var(--blue-bg); font-weight: 600; }
.nav-item.active::before {
    content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px;
    background: var(--accent); border-radius: 0 3px 3px 0;
}
.nav-icon { width: 18px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; opacity: .6; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge {
    margin-left: auto; font-family: var(--mono); font-size: 10px; font-weight: 700;
    padding: 1px 7px; border-radius: 10px; min-width: 20px; text-align: center;
}
.nav-badge-red { background: var(--red-bg); color: var(--red); }
.nav-badge-yellow { background: var(--yellow-bg); color: var(--yellow); }

.sidebar-footer { border-top: 1px solid var(--border); padding: 12px 16px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 4px; }
.sidebar-avatar {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: var(--accent); flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.sidebar-actions { display: flex; gap: 6px; margin-top: 8px; }
.sidebar-actions a {
    flex: 1; text-align: center; font-size: 11px; font-weight: 500; color: var(--text-muted);
    padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border);
    text-decoration: none !important; transition: .15s;
}
.sidebar-actions a:hover { color: var(--text); border-color: var(--text-muted); }

/* Main content */
.dash-main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar */
.topbar {
    height: var(--topbar-h); flex-shrink: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
    padding: 0 24px; position: sticky; top: 0; z-index: 50;
    backdrop-filter: blur(12px); background: rgba(17,19,27,.85);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.mobile-toggle {
    display: none; background: none; border: 1px solid var(--border); color: var(--text-muted);
    width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 16px;
    align-items: center; justify-content: center; transition: .15s;
}
.mobile-toggle:hover { color: var(--text); border-color: var(--text-muted); }

.btn-report {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 600; color: #fff;
    padding: 6px 14px; border-radius: 7px;
    background: linear-gradient(135deg, var(--accent), #818cf8);
    text-decoration: none !important; transition: opacity .15s; border: none; cursor: pointer;
}
.btn-report:hover { opacity: .88; }

/* Content */
.dash-content { flex: 1; padding: 20px 24px; max-width: 1400px; width: 100%; }

/* ════════════════ LEGACY CONTAINER ════════════════ */
.container { max-width: 1400px; margin: 0 auto; padding: 20px 24px; }
.header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.header h1 { font-family: var(--mono); font-size: var(--fs-h1); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.header .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.header-right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ════════════════ FILTER CONTROLS ════════════════ */
.filter-pills { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.filter-pills a { padding: 5px 12px; font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); border-right: 1px solid var(--border); transition: .15s; }
.filter-pills a:last-child { border-right: none; }
.filter-pills a:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }
.filter-pills a.on { color: var(--accent); background: var(--blue-bg); }

select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 5px 10px; border-radius: 7px; font-size: var(--fs-xs); font-family: var(--sans); cursor: pointer; }
select:focus { outline: none; border-color: var(--accent); }

/* ════════════════ TABS (hidden in sidebar layout) ════════════════ */
.tabs { display: none; }
.panel { display: none; }
.panel.show { display: block; }

/* ════════════════ GRIDS ════════════════ */
.grid-5 { display: grid; grid-template-columns: repeat(5,1fr); gap: 10px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px,1fr)); gap: 12px; margin-bottom: 16px; }
@media(max-width:1200px) { .grid-5 { grid-template-columns: repeat(3,1fr); } }
@media(max-width:900px) { .grid-2, .grid-5, .grid-3 { grid-template-columns: 1fr; } }

/* ════════════════ CARDS ════════════════ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.card h3 { font-size: var(--fs-h3); font-weight: 600; margin-bottom: 10px; }
.chart-h { height: 220px; position: relative; }

/* ════════════════ METRIC CARDS ════════════════ */
.mc { position: relative; overflow: hidden; }
.mc .mc-n { font-family: var(--mono); font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); letter-spacing: .5px; }
.mc .mc-v { font-family: var(--mono); font-size: var(--fs-hero); font-weight: 700; letter-spacing: -1px; margin: 4px 0; }
.mc .mc-s { font-size: var(--fs-pill); color: var(--text-muted); display: flex; gap: 6px; align-items: center; }
.mc .mc-t { font-family: var(--mono); font-size: var(--fs-pill); font-weight: 600; }
.mc .mc-t.up { color: var(--red); }
.mc .mc-t.dn { color: var(--green); }
.mc .mc-bar { display: flex; height: 3px; border-radius: 2px; overflow: hidden; margin-top: 8px; gap: 1px; }

/* ════════════════ SCORE ROW ════════════════ */
.score-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.score-box { text-align: center; flex: 1; min-width: 100px; }
.score-box .big { font-family: var(--mono); font-size: var(--fs-score); font-weight: 700; }
.score-box .lbl { font-size: var(--fs-label); color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }

/* ════════════════ TABLES ════════════════ */
table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
th { text-align: left; padding: 8px 12px; font-weight: 600; color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .5px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
th:first-child { border-radius: 6px 0 0 0; }
th:last-child { border-radius: 0 6px 0 0; }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--surface-2); }

/* ════════════════ PILLS & CHIPS ════════════════ */
.pill { font-family: var(--mono); font-size: var(--fs-pill); font-weight: 600; padding: 2px 8px; border-radius: 4px; display: inline-block; }
.pill-pass { background: var(--green-bg); color: var(--green); }
.pill-fail { background: var(--red-bg); color: var(--red); }
.pill-warn { background: var(--yellow-bg); color: var(--yellow); }
.pill-na { background: var(--surface-3); color: var(--text-muted); }

.chip { font-family: var(--mono); font-size: var(--fs-xs); padding: 2px 8px; border-radius: 4px; background: var(--surface-3); color: var(--text-muted); display: inline-block; }
.chip.hot { background: var(--red-bg); color: var(--red); }

/* ════════════════ RECOMMENDATIONS ════════════════ */
.rec { border-left: 3px solid var(--border); margin-bottom: 8px; }
.rec-critical { border-left-color: var(--red); }
.rec-warning { border-left-color: var(--yellow); }
.rec-success { border-left-color: var(--green); }
.rec .rec-h { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.rec .rec-b { font-family: var(--mono); font-size: var(--fs-pill); font-weight: 700; padding: 1px 6px; border-radius: 3px; text-transform: uppercase; }
.rec-critical .rec-b { background: var(--red-bg); color: var(--red); }
.rec-warning .rec-b { background: var(--yellow-bg); color: var(--yellow); }
.rec-success .rec-b { background: var(--green-bg); color: var(--green); }
.rec .rec-m { font-size: var(--fs-body); }
.rec ul { padding-left: 16px; margin-top: 4px; }
.rec li { font-size: var(--fs-small); color: var(--text-muted); margin-bottom: 2px; }

/* ════════════════ ATTRIBUTION ════════════════ */
.attr-item { padding: 8px 0; border-bottom: 1px solid var(--border); }
.attr-item:last-child { border-bottom: none; }
.attr-el { font-family: var(--mono); font-size: var(--fs-small); color: var(--cyan); word-break: break-all; }
.attr-chips { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }

.empty { text-align: center; padding: 32px; color: var(--text-muted); font-size: 13px; }

/* ════════════════ SITES OVERVIEW ════════════════ */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; margin-bottom: 16px; }
.site-tile { position: relative; transition: border-color .15s; }
.site-tile:hover { border-color: var(--blue); }
.site-tile .st-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.site-tile .st-name { font-weight: 600; font-size: var(--fs-body); }
.site-tile .st-domain { font-family: var(--mono); font-size: var(--fs-small); color: var(--text-muted); }
.site-tile .st-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.site-tile .st-m { text-align: center; }
.site-tile .st-m .st-mv { font-family: var(--mono); font-size: 1.125rem; font-weight: 700; }
.site-tile .st-m .st-ml { font-size: var(--fs-label); color: var(--text-muted); }

/* ════════════════ CrUX ════════════════ */
.crux-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.crux-row:last-child { border-bottom: none; }
.crux-label { font-family: var(--mono); font-size: var(--fs-small); font-weight: 600; width: 44px; color: var(--text-muted); }
.crux-bars { flex: 1; display: flex; gap: 8px; align-items: center; }
.crux-bar { height: 22px; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: var(--fs-xs); font-weight: 600; min-width: 38px; }

/* ════════════════ ERRORS ════════════════ */
.error-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.error-row:last-child { border-bottom: none; }
.error-msg { font-family: var(--mono); font-size: var(--fs-small); color: var(--red); word-break: break-all; }
.error-loc { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.error-stats { display: flex; gap: 8px; margin-top: 4px; }

/* ════════════════ DATA HEALTH ════════════════ */
.health-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.health-item:last-child { border-bottom: none; }
.health-icon { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; margin-top: 1px; }
.health-pass .health-icon { background: var(--green-bg); color: var(--green); }
.health-warn .health-icon { background: var(--yellow-bg); color: var(--yellow); }
.health-fail .health-icon { background: var(--red-bg); color: var(--red); }
.health-label { font-size: var(--fs-body); font-weight: 600; }
.health-detail { font-size: var(--fs-small); color: var(--text-muted); margin-top: 2px; line-height: 1.5; }
.health-summary { display: flex; gap: 16px; margin-bottom: 16px; padding: 12px; background: var(--surface-2); border-radius: 8px; }
.health-summary-item { text-align: center; }
.health-summary-num { font-family: var(--mono); font-size: 20px; font-weight: 700; }
.health-summary-lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ════════════════ DEVICE BREAKDOWN ════════════════ */
.device-toggle a { font-size: var(--fs-xs) !important; }
.device-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.device-row:last-child { border-bottom: none; }
.device-icon { font-size: 14px; width: 20px; text-align: center; }
.device-name { font-size: var(--fs-small); font-weight: 600; width: 60px; }
.device-bar-track { flex: 1; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.device-bar-fill { height: 100%; border-radius: 3px; transition: width .3s ease; }
.device-pct { font-family: var(--mono); font-size: var(--fs-small); font-weight: 600; width: 40px; text-align: right; }
.device-count { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-muted); width: 50px; text-align: right; }

/* ════════════════ GEOGRAPHY ════════════════ */
.geo-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
.geo-map-wrap { position: relative; background: var(--surface-2); border-radius: 8px; padding: 16px; overflow: hidden; }
.geo-svg { width: 100%; height: auto; }
.geo-svg path { fill: var(--surface-3); stroke: var(--border); stroke-width: 0.5; transition: fill .15s; }
.geo-svg path.active { cursor: pointer; }
.geo-svg path.active:hover { opacity: .85; }
.geo-tooltip { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: var(--fs-xs); pointer-events: none; z-index: 10; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.geo-table-wrap { max-height: 350px; overflow-y: auto; }
.geo-flag { margin-right: 4px; }
.geo-pct-bar { display: inline-block; width: 50px; height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; vertical-align: middle; margin-right: 4px; }
.geo-pct-bar > div { height: 100%; border-radius: 2px; }

/* ════════════════ FORMS ════════════════ */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.form-card h2 { font-size: 14px; margin-bottom: 12px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
input[type="text"], input[type="email"], input[type="password"] {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 8px 12px;
    border-radius: 6px; font-size: 13px; font-family: var(--sans); flex: 1; min-width: 150px;
}
input:focus { outline: none; border-color: var(--blue); }
button, .btn { background: var(--blue); color: #fff; border: none; padding: 8px 16px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: var(--sans); }
button:hover, .btn:hover { opacity: 0.9; }
.btn-primary { background: var(--blue); }
.btn-danger, button.danger { background: var(--red); }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
button.ghost:hover { border-color: var(--text); color: var(--text); }
.msg { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; background: var(--surface); border: 1px solid var(--border); }

/* ════════════════ SITE MANAGEMENT ════════════════ */
.site-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 10px; }
.site-card .site-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.site-card .site-name { font-weight: 600; font-size: 15px; }
.site-card .site-name a { color: var(--blue); text-decoration: none; }
.site-card .site-domain { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.site-card .site-status { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.active-badge { background: rgba(52, 211, 153, 0.1); color: var(--green); }
.inactive-badge { background: rgba(248, 113, 113, 0.1); color: var(--red); }
.site-card .site-stats { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.site-card .site-key { font-family: var(--mono); font-size: 11px; color: var(--cyan); background: #222738; padding: 6px 10px; border-radius: 4px; margin-bottom: 10px; }
.site-card .site-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.snippet { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 12px; font-family: var(--mono); font-size: 11px; line-height: 1.7; color: var(--text-muted); overflow-x: auto; margin-top: 8px; white-space: pre; }

/* ════════════════ LOGIN ════════════════ */
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-card h1 { font-family: var(--mono); font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 4px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.login-card .subtitle { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 28px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input { width: 100%; padding: 10px 14px; border-radius: 8px; font-size: 14px; }
.error { background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.2); color: var(--red); padding: 10px 14px; border-radius: 8px; font-size: 12px; margin-bottom: 16px; }
.setup-note { background: rgba(96,165,250,.08); border: 1px solid rgba(96,165,250,.2); color: var(--blue); padding: 10px 14px; border-radius: 8px; font-size: 12px; margin-bottom: 16px; line-height: 1.5; }

/* ════════════════ MOBILE OVERLAY ════════════════ */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; }

/* ════════════════ RESPONSIVE ════════════════ */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .dash-main { margin-left: 0; }
    .mobile-toggle { display: flex; }
}
@media (max-width: 900px) {
    .geo-layout { grid-template-columns: 1fr; }
    .grid-2, .grid-5, .grid-3 { grid-template-columns: 1fr; }
    .dash-content { padding: 16px; }
}
@media (max-width: 600px) {
    .topbar { padding: 0 12px; gap: 6px; }
    .filter-pills a { padding: 4px 8px; font-size: 10px; }
    .score-row { gap: 6px; }
}
