:root {
    --bg: #08090d;
    --bg-panel: #11141c;
    --bg-soft: #171b25;
    --border: #242938;
    --border-strong: #343b4f;
    --text: #f5f7fb;
    --text-muted: #a3adbf;
    --text-subtle: #717b8f;
    --accent: #7c9cff;
    --accent-strong: #9db4ff;
    --success: #3ddc97;
    --warning: #f5b84b;
    --danger: #ff5c7a;
    --info: #48c7ff;
    --radius: 8px;
    --sidebar: 264px;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at 20% 0%, rgba(124, 156, 255, 0.12), transparent 30%), linear-gradient(180deg, #0b0d13 0%, var(--bg) 42%);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; padding: 18px;
    background: rgba(10, 12, 18, 0.86); border-right: 1px solid var(--border); backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 10px 10px 24px; }
.brand-mark {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius);
    background: linear-gradient(135deg, #7c9cff, #37d6a6); color: #05060a; font-weight: 900;
}
.brand-title { display: block; font-size: 0.9rem; font-weight: 700; }
.brand-subtitle { display: block; color: var(--text-subtle); font-size: 0.72rem; }
.nav-menu { display: grid; gap: 5px; }
.nav-link {
    display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 9px 10px;
    border-radius: var(--radius); color: var(--text-muted); font-size: 0.9rem; border: 1px solid transparent; cursor: pointer;
}
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--bg-soft); border-color: var(--border); }
.nav-link.report-only { display: none; }
.nav-link.report-only.visible { display: flex; }
.sidebar-footer {
    position: absolute; right: 18px; bottom: 18px; left: 18px; padding: 12px;
    border: 1px solid var(--border); border-radius: var(--radius); background: rgba(17, 20, 28, 0.72);
    color: var(--text-subtle); font-size: 0.78rem;
}
.main-content { min-width: 0; padding: 22px; }
.report-page .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
.report-page .sidebar { padding: 14px; }
.report-page .main-content { padding: 18px; }
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; padding: 14px 16px;
    background: rgba(13, 15, 21, 0.78); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(16px);
}
.topbar h1 { margin: 0; font-size: 1rem; }
.topbar p { margin: 3px 0 0; color: var(--text-subtle); font-size: 0.82rem; }
.topbar-actions, .button-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.status-pill, .badge, .severity-badge {
    display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 3px 9px;
    border-radius: 999px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--text-muted);
    font-size: 0.74rem; font-weight: 650; white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--success); box-shadow: 0 0 14px var(--success); }
.severity-badge.high, .severity-badge.critical { border-color: rgba(255, 92, 122, 0.38); background: rgba(255, 92, 122, 0.12); color: #ffb5c3; }
.severity-badge.medium, .severity-badge.warning { border-color: rgba(245, 184, 75, 0.36); background: rgba(245, 184, 75, 0.12); color: #ffd68c; }
.severity-badge.unknown, .severity-badge.info { border-color: rgba(72, 199, 255, 0.32); background: rgba(72, 199, 255, 0.1); color: #a9e7ff; }

.btn, .btn-premium, .btn-outline, .btn-login {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 13px;
    border-radius: var(--radius); border: 1px solid var(--border-strong); background: #f4f7fb; color: #08090d;
    font-weight: 700; cursor: pointer;
}
.btn:hover, .btn-premium:hover, .btn-login:hover { background: #ffffff; }
.btn-secondary, .btn-outline { background: var(--bg-soft); color: var(--text); }
.btn-danger { background: rgba(255, 92, 122, 0.12); color: #ffd7df; border-color: rgba(255, 92, 122, 0.35); }
.btn-sm { min-height: 30px; padding: 5px 9px; font-size: 0.76rem; }

.content-section { display: none; }
.content-section.active, .content-section:first-child { display: block; }
.page-grid { display: grid; gap: 18px; }
.hero-panel, .panel, .metric-card, .upload-panel, .empty-state, .loading-state {
    border: 1px solid var(--border); border-radius: var(--radius); background: rgba(17, 20, 28, 0.86); box-shadow: var(--shadow);
}
.hero-panel { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr); gap: 18px; padding: 24px; }
.eyebrow { margin: 0 0 10px; color: var(--accent-strong); font-size: 0.75rem; font-weight: 800; text-transform: uppercase; }
.hero-panel h2, .section-title { margin: 0; font-size: clamp(1.55rem, 3vw, 2.25rem); letter-spacing: 0; line-height: 1.08; }
.hero-panel p, .section-copy { max-width: 760px; margin: 10px 0 0; color: var(--text-muted); }
.metrics-grid { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)); gap: 12px; }
.metric-card { padding: 15px; }
.metric-label { display: flex; justify-content: space-between; gap: 10px; color: var(--text-subtle); font-size: 0.76rem; }
.metric-value { margin-top: 10px; font-size: 1.55rem; font-weight: 800; }
.metric-note { margin-top: 4px; color: var(--text-subtle); font-size: 0.75rem; }
.two-column { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.report-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 22vw); gap: 14px; align-items: start; }
.panel { padding: 16px; min-width: 0; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.panel-title { margin: 0; font-size: 0.98rem; }
.panel-subtitle { margin: 2px 0 0; color: var(--text-subtle); font-size: 0.78rem; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 1120px; }
.findings-table { min-width: 0; table-layout: fixed; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; font-size: 0.8rem; }
th { position: sticky; top: 0; background: #121722; color: var(--text-subtle); font-size: 0.72rem; text-transform: uppercase; }
tr:hover td { background: rgba(124, 156, 255, 0.045); }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-severity { width: 88px; }
.col-domain { width: 88px; }
.col-component { width: 104px; }
.col-time { width: 168px; }
.col-file { width: auto; max-width: none; }
.col-summary { min-width: 360px; max-width: 560px; }
.col-confidence { width: 92px; }
.col-action { width: 74px; text-align: left; }
.finding-summary-row td {
    padding-top: 0;
    background: rgba(8, 9, 13, 0.32);
}
.finding-summary-block {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 10px;
    padding: 8px 10px 11px 84px;
    color: var(--text-muted);
    line-height: 1.45;
}
.summary-label {
    color: var(--text-subtle);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}
.finding-detail-row td {
    padding: 0 10px 14px 84px;
    background: rgba(8, 9, 13, 0.5);
}
.inline-detail-panel {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: rgba(17, 20, 28, 0.96);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.inline-detail-panel .evidence-box {
    max-height: 560px;
}
.domain-list { display: grid; gap: 10px; }
.domain-row { display: grid; grid-template-columns: 84px minmax(0, 1fr) 42px; gap: 10px; align-items: center; color: var(--text-muted); font-size: 0.8rem; }
.bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--bg-soft); }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--success)); }
.upload-panel { padding: 18px; }
.dropzone {
    position: relative; display: grid; place-items: center; min-height: 220px; padding: 24px; border: 1px dashed var(--border-strong);
    border-radius: var(--radius); background: rgba(8, 9, 13, 0.45); text-align: center; cursor: pointer;
}
.file-picker {
    width: min(520px, 100%);
    margin-top: 18px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #0a0d13;
    color: var(--text);
    cursor: pointer;
}
.file-picker::file-selector-button {
    margin-right: 12px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: #f4f7fb;
    color: #08090d;
    font-weight: 700;
    cursor: pointer;
}
.dropzone-title { display: block; margin-top: 10px; font-weight: 800; }
.dropzone-copy { display: block; margin-top: 4px; color: var(--text-subtle); font-size: 0.82rem; }
.form-input, .filter-input, select { width: 100%; min-height: 38px; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--border); background: #0a0d13; color: var(--text); }
.filter-grid { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) 150px 130px; gap: 10px; margin-bottom: 12px; }
.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; padding: 0 0 18px 22px; border-left: 1px solid var(--border-strong); }
.timeline-item::before { content: ""; position: absolute; top: 3px; left: -5px; width: 9px; height: 9px; border-radius: 999px; background: var(--accent); }
.timeline-time { color: var(--accent-strong); font-size: 0.75rem; font-weight: 800; }
.timeline-title { margin-top: 4px; font-size: 0.84rem; font-weight: 700; }
.timeline-meta { margin-top: 4px; color: var(--text-subtle); font-size: 0.75rem; }
.detail-panel { position: sticky; top: 18px; max-height: calc(100vh - 36px); overflow: auto; }
.detail-panel-wide {
    position: static;
    max-height: none;
    overflow: visible;
}
.evidence-box { max-height: 360px; overflow: auto; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: #07080c; color: #cbd5e1; font-size: 0.78rem; }
.detail-panel-wide .evidence-box { max-height: 620px; }
.detail-panel-wide #detail-content {
    display: grid;
    gap: 14px;
}
.evidence-line { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 10px; padding: 2px 4px; border-radius: 4px; }
.evidence-line.target { background: rgba(124, 156, 255, 0.16); color: #ffffff; }
.empty-state, .loading-state { padding: 28px; text-align: center; color: var(--text-muted); }
.empty-state strong, .loading-state strong { display: block; margin-bottom: 6px; color: var(--text); }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: min(440px, 100%); padding: 26px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(17, 20, 28, 0.92); box-shadow: var(--shadow); }
.login-card h1 { margin: 16px 0 6px; font-size: 1.6rem; }
.login-card p { margin: 0 0 22px; color: var(--text-muted); }
.form-group { display: grid; gap: 7px; margin-bottom: 14px; }
.form-group label { color: var(--text-muted); font-size: 0.82rem; font-weight: 700; }
.flash-messages { margin-bottom: 14px; padding: 10px; border: 1px solid rgba(255, 92, 122, 0.35); border-radius: var(--radius); background: rgba(255, 92, 122, 0.1); color: #ffd7df; font-size: 0.84rem; }

@media (max-width: 1180px) {
    .metrics-grid { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
    .two-column, .hero-panel, .report-layout { grid-template-columns: 1fr; }
    .detail-panel { position: static; max-height: none; }
}
@media (max-width: 780px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .sidebar-footer { position: static; margin-top: 16px; }
    .main-content { padding: 14px; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .metrics-grid, .filter-grid { grid-template-columns: 1fr; }
}
