/* ═══════════════════════════════════════════════════════════════════════
   Network Analyzer — site.css
   Dark-panel dashboard theme
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #0f1117;
    --surface:      #1a1d27;
    --surface2:     #22263a;
    --surface3:     #2a2f45;
    --border:       #2e3350;
    --border-light: #3d4468;
    --text:         #e2e8f0;
    --text-muted:   #8892aa;
    --text-dim:     #5a6280;
    --accent:       #4f8ef7;
    --accent-hover: #6aa3ff;

    --good:         #22c55e;
    --good-bg:      #0d2b1a;
    --good-text:    #86efac;
    --warn:         #f59e0b;
    --warn-bg:      #2b1f00;
    --warn-text:    #fcd34d;
    --bad:          #ef4444;
    --bad-bg:       #2b0f0f;
    --bad-text:     #fca5a5;
    --info-color:   #38bdf8;
    --info-bg:      #0c2233;
    --info-text:    #7dd3fc;

    --radius:       10px;
    --radius-sm:    6px;
    --shadow:       0 4px 24px rgba(0,0,0,.45);
    --transition:   0.18s ease;
    --font:         'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono:    'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 15px;
    line-height: 1.6;
}

/* ── Login page ───────────────────────────────────────────────────────── */
.login-body {
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}
.login-wrap {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}
.login-card {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 2.25rem;
    box-shadow: 0 8px 32px rgba(0,0,0,.45);
}
.login-brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--accent);
    margin-bottom: 1.5rem;
}
.login-heading {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--text);
}
.login-errors p { margin: 0 0 .25rem; font-size: .88rem; }
.btn-login {
    width: 100%;
    margin-top: .5rem;
    padding: .65rem 1rem;
    font-size: .95rem;
}
.login-remember { margin-top: .25rem; }
.login-footer    { font-size: .75rem; color: var(--text-dim); text-align: center; }

/* ── Navbar user / logout ─────────────────────────────────────────────── */
.nav-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-left: auto;
    font-size: .82rem;
    color: var(--text-dim);
}
.nav-user .btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: .2rem .65rem;
    font-size: .78rem;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}
.nav-user .btn-logout:hover { border-color: var(--accent); color: var(--accent); }

/* ── Navbar ───────────────────────────────────────────────────────────── */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
.nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -.01em;
}
.nav-brand svg { color: var(--accent); flex-shrink: 0; }
.nav-brand:hover { color: var(--accent-hover); }
.nav-links { list-style: none; display: flex; gap: .25rem; }
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: .35rem .8rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    transition: background var(--transition), color var(--transition);
}
.nav-links a:hover { background: var(--surface2); color: var(--text); }

/* ── Main content ─────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

/* ── Footer ───────────────────────────────────────────────────────────── */
.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    text-align: center;
    padding: .9rem 1rem;
    color: var(--text-dim);
    font-size: .8rem;
}

/* ── Alert ────────────────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: .9rem;
}
.alert-info  { background: var(--info-bg); color: var(--info-text); border: 1px solid #1a4a6a; }
.alert-stale {
    display: flex; align-items: flex-start; gap: .6rem;
    background: var(--warn-bg); color: var(--warn-text);
    border: 1px solid var(--warn);
}
.alert-stale svg { flex-shrink: 0; margin-top: .15rem; }

.stale-badge {
    display: inline-block;
    margin-left: .35rem;
    font-size: .8rem;
    color: var(--warn-text);
    vertical-align: middle;
}

/* ── Page header ──────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.subtitle { color: var(--text-muted); font-size: .9rem; margin-top: .25rem; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background var(--transition), color var(--transition),
                border-color var(--transition), opacity var(--transition);
    white-space: nowrap;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-outline  { background: transparent; color: var(--text-muted); border: 1px solid var(--border-light); }
.btn-outline:hover { background: var(--surface2); color: var(--text); }
.btn-lg { padding: .7rem 1.8rem; font-size: 1rem; }
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: .25rem .4rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    transition: color var(--transition), background var(--transition);
    line-height: 1;
}
.btn-icon:hover { color: var(--text); background: var(--surface3); }
.btn-icon[aria-expanded="true"] { transform: rotate(180deg); color: var(--accent); }

/* ── Spinner ──────────────────────────────────────────────────────────── */
.spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Hero ─────────────────────────────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 3rem 1rem 2rem;
}
.hero-icon {
    width: 80px; height: 80px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.25rem;
    color: var(--accent);
}
.hero h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: .5rem; }
.hero-sub { color: var(--text-muted); max-width: 580px; margin: 0 auto; font-size: .95rem; }

/* ── Upload card ──────────────────────────────────────────────────────── */
.upload-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 680px;
    margin: 0 auto 2.5rem;
    box-shadow: var(--shadow);
}

/* ── Drop zone ────────────────────────────────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-sm);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: border-color var(--transition), background var(--transition);
    outline: none;
}
.drop-zone:hover, .drop-zone:focus { border-color: var(--accent); background: rgba(79,142,247,.04); }
.drop-zone.drag-over { border-color: var(--accent); background: rgba(79,142,247,.08); }
.drop-zone.has-file  { border-color: var(--good); }
.drop-zone svg { color: var(--text-muted); margin-bottom: .75rem; }
.drop-text { font-size: 1rem; font-weight: 600; margin-bottom: .35rem; }
.drop-hint { color: var(--text-muted); font-size: .82rem; }
.drop-filename {
    margin-top: .75rem;
    font-size: .88rem;
    color: var(--good-text);
    font-family: var(--font-mono);
    word-break: break-all;
}
.file-input-hidden {
    position: absolute; inset: 0;
    opacity: 0; cursor: pointer;
    width: 100%; height: 100%;
}

.upload-actions { margin-top: 1.5rem; display: flex; justify-content: center; }

/* ── Validation ───────────────────────────────────────────────────────── */
.validation-summary {
    background: var(--bad-bg);
    border: 1px solid #5a1a1a;
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
    color: var(--bad-text);
    font-size: .88rem;
    margin-bottom: 1rem;
}
.validation-summary ul { padding-left: 1.25rem; margin: 0; }
.field-validation-error { color: var(--bad-text); font-size: .82rem; margin-top: .3rem; display: block; }
.field-validation-error[hidden] { display: none; }

/* ── Feature grid ─────────────────────────────────────────────────────── */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    max-width: 900px;
    margin: 0 auto;
}
.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem 1.5rem;
}
.feature-card h3 { font-size: .95rem; font-weight: 700; margin-bottom: .5rem; color: var(--accent); }
.feature-card p  { font-size: .85rem; color: var(--text-muted); }

/* ── Score banner ─────────────────────────────────────────────────────── */
.score-banner {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 2rem 2.5rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow);
    background: var(--surface);
}
.score-banner.score-good { border-color: var(--good); background: linear-gradient(135deg, var(--surface) 70%, var(--good-bg)); }
.score-banner.score-warn { border-color: var(--warn); background: linear-gradient(135deg, var(--surface) 70%, var(--warn-bg)); }
.score-banner.score-bad  { border-color: var(--bad);  background: linear-gradient(135deg, var(--surface) 70%, var(--bad-bg));  }

.score-banner-main {
    display: flex;
    align-items: center;
    gap: 2.5rem;
    flex-wrap: wrap;
}
.score-banner-text h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: .5rem; }
.exec-summary { color: var(--text-muted); font-size: .9rem; max-width: 700px; margin-bottom: .9rem; }

/* ── Score dial ───────────────────────────────────────────────────────── */
.score-dial {
    position: relative;
    width: 120px; height: 120px;
    flex-shrink: 0;
}
.dial-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dial-track {
    fill: none;
    stroke: var(--surface3);
    stroke-width: 10;
}
.dial-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 326.7;
    transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1);
}
.score-banner.score-good .dial-fill { stroke: var(--good); }
.score-banner.score-warn .dial-fill { stroke: var(--warn); }
.score-banner.score-bad  .dial-fill { stroke: var(--bad);  }

.dial-label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.dial-pct {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.03em;
}
.dial-pct small { font-size: .75rem; font-weight: 600; }
.dial-grade {
    font-size: .72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: .15rem;
}

/* ── Score chips ──────────────────────────────────────────────────────── */
.score-chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip {
    padding: .2rem .65rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .02em;
    cursor: pointer;
    user-select: none;
    transition: opacity var(--transition), transform var(--transition), text-decoration var(--transition);
}
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip[data-filter]:hover { opacity: .85; transform: scale(1.05); }
.chip.chip-inactive {
    opacity: .3;
    text-decoration: line-through;
    filter: grayscale(0.6);
}
.chip-reset {
    background: var(--surface3);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
    font-size: .73rem;
    padding: .2rem .6rem;
}
.chip-reset:hover { background: var(--surface2); color: var(--text); }
.filter-hint {
    font-size: .78rem;
    color: var(--warn-text);
    margin-top: .35rem;
    font-style: italic;
}
.chip-critical { background: var(--bad-bg);  color: var(--bad-text);  border: 1px solid #5a1a1a; }
.chip-warning  { background: var(--warn-bg); color: var(--warn-text); border: 1px solid #5a3800; }
.chip-good     { background: var(--good-bg); color: var(--good-text); border: 1px solid #0d4a25; }
.chip-fair     { background: var(--surface3); color: var(--text-muted); border: 1px solid var(--border); }
.chip-poor     { background: var(--bad-bg);  color: var(--bad-text);  border: 1px solid #5a1a1a; }
/* Dimension filter chips (top findings) */
.chip[data-dim-filter]:hover { opacity: .85; transform: scale(1.05); }
.chip-dim-operational { background: #1a3a5c; color: #7ec8f4; border: 1px solid #2a5a8c; }
.chip-dim-security    { background: #3a1a4a; color: #d4a0f4; border: 1px solid #6a3a8c; }
.dim-chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
/* Section card header with optional right-side controls */
.section-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: .25rem;
}
.filter-empty-msg {
    padding: .6rem .75rem;
    color: var(--text-dim);
    font-size: .82rem;
    font-style: italic;
    text-align: center;
}
.filter-empty-rec {
    background: none !important;
    border: none !important;
    padding: .25rem 0 !important;
    color: var(--text-dim);
    font-size: .82rem;
    font-style: italic;
}

/* ── Score cards ──────────────────────────────────────────────────────── */
.score-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}
@media (max-width: 900px) { .score-cards { grid-template-columns: 1fr; } }
.score-card-full { grid-column: 1 / -1; }

.score-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.score-card-muted { opacity: .7; }
.score-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .35rem;
}
.score-card-header h2 { font-size: 1.05rem; font-weight: 700; }
.score-card-sub { color: var(--text-muted); font-size: .82rem; margin-bottom: 1.1rem; }

.score-pill {
    padding: .25rem .7rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
}
.score-pill.score-good { background: var(--good-bg); color: var(--good-text); }
.score-pill.score-warn { background: var(--warn-bg); color: var(--warn-text); }
.score-pill.score-bad  { background: var(--bad-bg);  color: var(--bad-text);  }
.score-pill.score-na   { background: var(--surface3); color: var(--text-muted); }

/* ── Category table ───────────────────────────────────────────────────── */
.category-table { border-top: 1px solid var(--border); }

.cat-row {
    display: grid;
    grid-template-columns: 1fr 1fr 3rem 3rem 2rem;
    align-items: center;
    gap: .6rem;
    padding: .55rem .1rem;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
}
.cat-row:last-of-type { border-bottom: none; }
.cat-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-bar-wrap {
    background: var(--surface3);
    border-radius: 999px;
    height: 7px;
    overflow: hidden;
}
.cat-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.8s cubic-bezier(.4,0,.2,1);
}
.cat-bar.score-good     { background: var(--good); }
.cat-bar.score-warn     { background: var(--warn); }
.cat-bar.score-bad      { background: var(--bad);  }
.cat-bar.score-critical { background: var(--bad);  }
.cat-score {
    font-weight: 700;
    font-size: .88rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.cat-score.score-good     { color: var(--good-text); }
.cat-score.score-warn     { color: var(--warn-text); }
.cat-score.score-bad      { color: var(--bad-text);  }
.cat-score.score-critical { color: var(--bad-text);  font-weight: 900; }
.cat-weight { color: var(--text-dim); font-size: .78rem; text-align: right; }

/* ── Category findings panel ──────────────────────────────────────────── */
.cat-findings {
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    padding: .9rem 1rem;
    animation: fadeIn .15s ease;
}
.cat-desc { color: var(--text-muted); font-size: .83rem; margin-bottom: .75rem; font-style: italic; }
.no-findings { color: var(--text-dim); font-size: .83rem; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ── Findings table ───────────────────────────────────────────────────── */
.findings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}
.findings-table th {
    text-align: left;
    color: var(--text-dim);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .4rem .6rem;
    border-bottom: 1px solid var(--border);
}
.findings-table td {
    padding: .45rem .6rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.findings-table tr:last-child td { border-bottom: none; }
.finding-row-critical { background: rgba(239,68,68,.05); }
.finding-row-warning  { background: rgba(245,158,11,.04); }
.finding-detail {
    color: var(--text-muted);
    font-size: .78rem;
    margin-top: .2rem;
    font-style: italic;
}
.findings-table-full { font-size: .85rem; }
.rank-cell { color: var(--text-dim); font-variant-numeric: tabular-nums; width: 2rem; }
.cat-name-cell { white-space: nowrap; color: var(--text-muted); }

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: var(--radius-sm);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}
.badge.critical, .badge-critical { background: var(--bad-bg);  color: var(--bad-text);  border: 1px solid #5a1a1a; }
.badge.warning,  .badge-warning  { background: var(--warn-bg); color: var(--warn-text); border: 1px solid #5a3800; }
.badge.info,     .badge-info     { background: var(--info-bg); color: var(--info-text); border: 1px solid #1a4a6a; }

.domain-badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: var(--radius-sm);
    font-size: .72rem;
    font-weight: 600;
    background: var(--surface3);
    color: var(--text-muted);
    border: 1px solid var(--border);
    white-space: nowrap;
}

/* ── Finding dimension badges ─────────────────────────────────────────── */
.dim-badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: var(--radius-sm);
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}
.dim-operational {
    background: #1a3a5c;
    color: #7ec8f4;
    border: 1px solid #2a5a8c;
}
.dim-security {
    background: #3a1a4a;
    color: #d4a0f4;
    border: 1px solid #6a3a8c;
}

/* ── Traffic direction badges ─────────────────────────────────────────── */
.dir-badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: var(--radius-sm);
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}
.dir-serverbound  { background: #1a3a2a; color: #6fdb9f; border: 1px solid #2a6a4a; }
.dir-clientbound  { background: #3a2a1a; color: #f4c06f; border: 1px solid #8c5a2a; }
.dir-bidirectional{ background: var(--surface3); color: var(--text-dim); border: 1px solid var(--border); }

/* ── Root Cause Analysis section ─────────────────────────────────────── */
.rca-section { margin-bottom: 1.75rem; }
.rca-list { display: flex; flex-direction: column; gap: .9rem; margin-top: .75rem; }
.rca-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .9rem 1.1rem;
    background: var(--surface2);
}
.rca-header {
    display: flex;
    align-items: center;
    gap: .9rem;
    margin-bottom: .45rem;
}
.rca-confidence {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    flex-shrink: 0;
    width: 52px;
}
.rca-conf-pct { font-size: .78rem; font-weight: 700; }
.conf-high   .rca-conf-pct { color: var(--good-text); }
.conf-medium .rca-conf-pct { color: var(--warn-text); }
.conf-low    .rca-conf-pct { color: var(--text-dim); }
.rca-conf-bar-wrap {
    width: 100%;
    height: 5px;
    background: var(--surface3);
    border-radius: 3px;
    overflow: hidden;
}
.rca-conf-bar-fill  { height: 100%; border-radius: 3px; }
.conf-high   .rca-conf-bar-fill { background: var(--good); }
.conf-medium .rca-conf-bar-fill { background: var(--warn); }
.conf-low    .rca-conf-bar-fill { background: var(--text-dim); }
.rca-headline { font-size: .95rem; font-weight: 600; margin: 0; }
.rca-detail   { font-size: .86rem; color: var(--text-muted); margin: 0 0 .55rem; line-height: 1.5; }
.rca-evidence { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.rca-evidence-label { font-size: .75rem; color: var(--text-dim); }
.rca-evidence-tag {
    font-size: .72rem;
    font-weight: 600;
    padding: .1rem .45rem;
    border-radius: var(--radius-sm);
    background: var(--surface3);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ── Trend sparkline (SystemDetail) ──────────────────────────────────── */
.trend-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1rem;
    padding: .6rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}
.trend-label { font-size: .82rem; color: var(--text-dim); white-space: nowrap; }
.sparkline   { display: block; flex-shrink: 0; }
.trend-delta, .run-delta {
    font-size: .8rem;
    font-weight: 700;
    white-space: nowrap;
}
.delta-up   { color: var(--good-text); }
.delta-down { color: var(--bad-text,  #f87171); }
.delta-flat { color: var(--text-dim); }

/* ── Top Talkers table ────────────────────────────────────────────────── */
.talkers-table-wrap { overflow-x: auto; }
.talkers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
.talkers-table th,
.talkers-table td {
    padding: .45rem .7rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.talkers-table th { color: var(--text-dim); font-weight: 600; font-size: .78rem; }
.talker-ip { font-family: monospace; }
.talker-bar-wrap {
    width: 120px;
    height: 8px;
    background: var(--surface3);
    border-radius: 4px;
    overflow: hidden;
}
.talker-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    min-width: 2px;
}

/* ── Section cards ────────────────────────────────────────────────────── */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}
.section-card h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: .35rem;
}
.section-sub { color: var(--text-muted); font-size: .85rem; margin-bottom: 1rem; }
.section-all-clear { border-color: var(--good); background: linear-gradient(135deg, var(--surface) 80%, var(--good-bg)); }
.section-all-clear h2 { color: var(--good-text); }

/* ── Recommendations ──────────────────────────────────────────────────── */
.rec-list { list-style: none; display: flex; flex-direction: column; gap: .9rem; }
.rec-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
}
.rec-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    margin-bottom: .5rem;
}
.rec-num {
    background: var(--surface3);
    color: var(--text-muted);
    font-size: .75rem;
    font-weight: 700;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.rec-title { font-weight: 600; font-size: .9rem; flex: 1; }
.rec-detail { color: var(--text-muted); font-size: .84rem; line-height: 1.55; }

/* ── Metadata grid ────────────────────────────────────────────────────── */
.section-meta h2 { margin-bottom: .9rem; }
.meta-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .4rem 1.5rem;
    font-size: .88rem;
}
.meta-grid dt { color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.meta-grid dd { font-family: var(--font-mono); font-size: .84rem; word-break: break-all; }

/* ── About page ───────────────────────────────────────────────────────── */
.about-grid { display: flex; flex-direction: column; gap: 1.25rem; }
.about-table { width: 100%; border-collapse: collapse; font-size: .87rem; margin-top: .75rem; }
.about-table th {
    text-align: left;
    color: var(--text-dim);
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .4rem .6rem;
    border-bottom: 1px solid var(--border);
}
.about-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.about-table tr:last-child td { border-bottom: none; }
.about-table td:nth-child(2) { font-weight: 700; color: var(--accent); white-space: nowrap; }
.section-card ul { padding-left: 1.5rem; color: var(--text-muted); font-size: .9rem; }
.section-card li { margin-bottom: .35rem; }
.section-card code {
    font-family: var(--font-mono);
    font-size: .82rem;
    background: var(--surface3);
    padding: .1rem .4rem;
    border-radius: 4px;
    color: var(--info-text);
}

/* ── Error card ───────────────────────────────────────────────────────── */
.card-error {
    background: var(--bad-bg);
    border: 1px solid #5a1a1a;
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    max-width: 620px;
    color: var(--bad-text);
    font-size: .9rem;
}
.card-error code { font-family: var(--font-mono); font-size: .82rem; }

.page-header-left { flex: 1; min-width: 0; }
.page-header-actions { display: flex; gap: .5rem; align-items: flex-start; flex-shrink: 0; flex-wrap: wrap; }

/* ── Responsive tweaks ────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .main-content { padding: 1.25rem 1rem 2rem; }
    .score-banner { padding: 1.25rem; }
    .score-banner-main { gap: 1.25rem; }
    .hero h1 { font-size: 1.5rem; }
    .cat-row { grid-template-columns: 1fr 1fr 2.5rem 2.5rem 2rem; font-size: .8rem; }
    .meta-grid { grid-template-columns: 1fr; }
    .meta-grid dt::after { content: ':'; }
    .findings-table-full { font-size: .78rem; }
}

/* ── Breadcrumb ───────────────────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .3rem;
    font-size: .82rem;
    color: var(--text-dim);
    margin-bottom: 1.2rem;
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-dim); }

/* ── Generic form card ────────────────────────────────────────────────── */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 540px;
    margin: 0 auto 2rem;
}
.form-card h2 { font-size: 1.2rem; margin-bottom: .3rem; }
.form-card-sub { color: var(--text-dim); font-size: .88rem; margin-bottom: 1.2rem; }
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: .4rem; }
.form-control {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: .5rem .75rem;
    font-size: .95rem;
    outline: none;
    transition: border-color .15s;
}
.form-control:focus { border-color: var(--accent); }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; flex-wrap: wrap; }
.required { color: var(--bad-text); font-size: .8rem; }
.optional  { color: var(--text-dim); font-weight: 400; font-size: .8rem; }
.btn-danger {
    background: var(--bad-bg);
    color: var(--bad-text);
    border: 1px solid #5a1a1a;
    border-radius: 6px;
    padding: .45rem 1rem;
    font-size: .88rem;
    cursor: pointer;
    text-decoration: none;
}
.btn-danger:hover { background: #3a1010; }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; }

/* ── Hierarchy index page ─────────────────────────────────────────────── */
.hierarchy-building {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.hierarchy-building-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .9rem 1.2rem;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
}
.hierarchy-building-title {
    display: flex;
    align-items: center;
    gap: .55rem;
    flex-wrap: wrap;
}
.hierarchy-building-name { font-weight: 700; font-size: 1rem; }
.hierarchy-meta { color: var(--text-dim); font-size: .82rem; }
.hierarchy-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.hierarchy-empty { color: var(--text-dim); font-size: .88rem; padding: .9rem 1.2rem; }
.hierarchy-systems { display: flex; flex-direction: column; }
.hierarchy-system-row {
    display: grid;
    grid-template-columns: 24px 1fr 80px 110px 160px 24px;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.2rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    transition: background .12s;
}
.hierarchy-system-row:last-child { border-bottom: none; }
.hierarchy-system-row:hover { background: var(--surface2); }
.hierarchy-sys-icon { color: var(--text-dim); }
.hierarchy-sys-name { font-weight: 600; font-size: .92rem; display: flex; flex-direction: column; gap: .2rem; }
.hierarchy-sys-runs { color: var(--text-dim); font-size: .82rem; text-align: right; }
.hierarchy-sys-score { font-weight: 700; font-size: .88rem; text-align: right; }
.hierarchy-sys-date  { color: var(--text-dim); font-size: .78rem; text-align: right; }
.hierarchy-sys-arrow { color: var(--text-dim); font-size: 1.1rem; text-align: right; }
.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    color: var(--text-dim);
    margin: 1rem 0;
}
.empty-state a { color: var(--accent); }

/* ── System detail / run history ─────────────────────────────────────── */
.run-history-table-wrap { overflow-x: auto; }
.run-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
.run-history-table th {
    background: var(--surface2);
    text-align: left;
    padding: .55rem .75rem;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.run-history-table td {
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.run-history-table tr:last-child td { border-bottom: none; }
.run-history-table tr:hover td { background: var(--surface2); }
.run-filename {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.run-actions { display: flex; gap: .4rem; white-space: nowrap; }

/* ── System picker on upload page ────────────────────────────────────── */
.system-picker {
    margin: 1rem 0 .5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.system-picker-toggle {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .8rem;
    background: var(--surface2);
}
.picker-chevron { font-size: 1.1rem; transition: transform .15s; }
.system-picker-selected { font-size: .88rem; font-weight: 600; color: var(--accent); }
.system-picker-panel {
    padding: .75rem 1rem;
    border-top: 1px solid var(--border);
}
.picker-label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .4rem; }
.picker-empty { color: var(--text-dim); font-size: .88rem; }
.picker-empty a { color: var(--accent); }

/* ── Analysis type checkboxes on upload page ─────────────────────────── */
.analysis-type-picker {
    margin: .75rem 0 .5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .75rem 1rem;
    background: var(--surface2);
}
.analysis-type-picker > .picker-label {
    margin-bottom: .6rem;
}
.analysis-type-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.analysis-type-option {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    cursor: pointer;
    flex: 1 1 200px;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    transition: border-color .15s, background .15s;
}
.analysis-type-option:hover { border-color: var(--accent); background: var(--surface3); }
.analysis-type-option input[type="checkbox"] { margin-top: .18rem; flex-shrink: 0; accent-color: var(--accent); }
.analysis-type-label { display: flex; flex-direction: column; }
.analysis-type-label strong { font-size: .92rem; }
.analysis-type-desc { font-size: .78rem; color: var(--text-dim); margin-top: .1rem; }

/* ── Print / Save as PDF ──────────────────────────────────────────────── */
@media print {
    /* Force light background so PDF is readable on white paper */
    :root {
        --bg:        #ffffff;
        --surface:   #f8f9fa;
        --surface2:  #f0f2f5;
        --surface3:  #e8eaed;
        --border:    #cccccc;
        --text:      #111111;
        --text-muted:#444444;
        --text-dim:  #666666;
        --good:      #16a34a;
        --good-bg:   #f0fdf4;
        --good-text: #15803d;
        --warn:      #d97706;
        --warn-bg:   #fffbeb;
        --warn-text: #b45309;
        --bad:       #dc2626;
        --bad-bg:    #fef2f2;
        --bad-text:  #b91c1c;
        --info-color:#0284c7;
        --info-bg:   #f0f9ff;
        --info-text: #0369a1;
        --accent:    #2563eb;
    }

    /* Hide interactive / navigation elements */
    .navbar, .site-footer, #printBtn,
    .btn-outline, .cat-toggle, .upload-actions,
    .score-chips, .dim-chips, .filter-hint,
    .feature-grid { display: none !important; }

    /* Reset page layout */
    body          { background: #fff; color: #111; font-size: 10pt; }
    .main-content { max-width: 100%; padding: 0 0 .5rem; }

    /* Tighten spacing so sections sit close together */
    .page-header  { margin-bottom: .6rem; }
    .score-banner { padding: .9rem 1.1rem; margin-bottom: .6rem; }
    .score-cards  { gap: .5rem; margin-bottom: .6rem; }
    .score-card   { padding: .75rem 1rem; }
    .section-card { padding: .75rem 1rem; margin-bottom: .5rem; }
    .rec-item     { padding: .5rem .75rem; }
    .rec-list     { gap: .4rem; }
    .rca-section  { margin-bottom: .5rem; }
    .section-sub  { margin-bottom: .5rem; }

    /* Page breaks — let content flow freely; only avoid breaks on small items */
    .score-banner         { page-break-after: avoid; }
    .rec-item             { page-break-inside: avoid; }
    .rca-card             { page-break-inside: avoid; }
    /* Prevent lone headings stranded at the bottom of a page */
    .section-card h2      { page-break-after: avoid; }
    .score-card-header    { page-break-after: avoid; }

    /* cat-findings panels are expanded before print via JS (beforeprint event).
       This rule is a CSS-only fallback for browsers that skip the JS event. */
    .cat-findings { display: block !important; }

    /* Stack score cards vertically for A4 width */
    .score-cards { grid-template-columns: 1fr; }

    /* Borders visible on white */
    .score-card, .section-card, .score-banner,
    .cat-findings, .rec-item {
        border: 1px solid #ccc;
        box-shadow: none;
        border-radius: 4px;
    }

    /* Dial: shrink and keep SVG visible in print (browsers can render SVG) */
    .score-dial   { width: 80px; height: 80px; flex-shrink: 0; }
    .dial-pct     { font-size: 1.2rem; }
    .dial-fill    { transition: none; }
    .score-banner-main { gap: 1.2rem; }

    /* Score banner colours */
    .score-banner { background: var(--surface) !important; }
    .score-banner.score-good { border-color: var(--good); }
    .score-banner.score-warn { border-color: var(--warn); }
    .score-banner.score-bad,
    .score-banner.score-critical { border-color: var(--bad); }

    /* Score pill colours */
    .score-pill.score-good  { background: var(--good-bg); color: var(--good-text); }
    .score-pill.score-warn  { background: var(--warn-bg); color: var(--warn-text); }
    .score-pill.score-bad,
    .score-pill.score-critical { background: var(--bad-bg); color: var(--bad-text); }

    /* Badge colours */
    .badge.critical { background: var(--bad-bg);  color: var(--bad-text);  }
    .badge.warning  { background: var(--warn-bg); color: var(--warn-text); }
    .badge.info     { background: var(--info-bg); color: var(--info-text); }

    /* Category bars */
    .cat-bar            { transition: none; }
    .cat-bar.score-good     { background: var(--good); }
    .cat-bar.score-warn     { background: var(--warn); }
    .cat-bar.score-bad,
    .cat-bar.score-critical { background: var(--bad);  }
    .cat-bar-wrap { background: #e5e7eb; }

    /* Table borders */
    .findings-table th, .findings-table td,
    .about-table   th, .about-table   td { border-color: #ddd; }

    /* Wrap long text in table cells so they don't overflow */
    .findings-table td { word-break: break-word; white-space: normal; }

    /* Headings */
    h1 { font-size: 15pt; }
    h2 { font-size: 12pt; }

    /* Print page margin */
    @page { margin: 1.2cm 1.5cm; }
}

/* -- User management & Audit Log -------------------------------------------- */

.data-table-wrap { overflow-x: auto; margin-top: 1rem; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    text-align: left;
    padding: 0.55rem 0.75rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-hover, rgba(0,0,0,0.025)); }

.row-actions { white-space: nowrap; text-align: right; }

/* Role badges */
.role-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.role-admin    { background: #fef2f2; color: #dc2626; }
.role-modify   { background: #fffbeb; color: #d97706; }
.role-readonly { background: #f0fdf4; color: #16a34a; }

/* Active / Inactive status */
.status-active   { color: #16a34a; font-weight: 600; font-size: 0.8rem; }
.status-inactive { color: #9ca3af; font-weight: 600; font-size: 0.8rem; }
.status-locked   { color: #d97706; font-weight: 700; font-size: 0.8rem; }
.status-subtext  { color: var(--text-dim); font-size: 0.75rem; margin-top: 0.1rem; }

/* Audit log */
.audit-table .audit-ts { font-family: var(--font-mono, monospace); font-size: 0.78rem; }

.audit-action {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
}
.audit-login, .audit-logout   { background: #eff6ff; color: #2563eb; }
.audit-runanalysis             { background: #f0fdf4; color: #16a34a; }
.audit-deleteanalysis, .audit-deletebuilding, .audit-deletesystem, .audit-deleteuser
                               { background: #fef2f2; color: #dc2626; }
.audit-createbuilding, .audit-createsystem, .audit-createuser
                               { background: #f0fdf4; color: #059669; }
.audit-updatebuilding, .audit-updatesystem, .audit-updateuser
                               { background: #fffbeb; color: #d97706; }

/* Audit log filter form */
.filter-form { display: flex; gap: 0.5rem; align-items: center; }
.form-control-sm { padding: 0.3rem 0.6rem; font-size: 0.825rem; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
    font-size: 0.875rem;
}
.pagination-info { color: var(--text-muted); }

/* Form inline checkbox group */
.form-group-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.form-group-inline label { margin-bottom: 0; font-weight: 600; }
.form-group-inline .form-hint { display: block; margin-top: 0.15rem; }

/* Form hint text */
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.25rem; display: block; }
