:root {
    --navy: #10233f;
    --navy-2: #18365f;
    --orange: #f47a24;
    --orange-soft: #fff0e5;
    --ink: #1b2637;
    --muted: #68758a;
    --line: #dfe5ec;
    --surface: #ffffff;
    --background: #f4f6f9;
    --green: #19724a;
    --green-soft: #e7f6ef;
    --red: #b43a3a;
    --red-soft: #fdeaea;
    --yellow: #8a6100;
    --yellow-soft: #fff5d9;
    --shadow: 0 12px 32px rgba(16, 35, 63, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--background);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    line-height: 1.5;
}
a { color: var(--navy-2); text-decoration: none; font-weight: 650; }
a:hover { color: var(--orange); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.8rem, 3vw, 2.4rem); letter-spacing: -0.035em; }
h2 { margin-bottom: 1rem; font-size: 1.22rem; letter-spacing: -0.02em; }
h3 { margin-bottom: 0.4rem; }
small { color: var(--muted); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 245px 1fr; }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.5rem 1.1rem;
    color: white;
    background: linear-gradient(180deg, var(--navy) 0%, #0b1b32 100%);
    display: flex;
    flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 0.75rem; color: inherit; }
.brand:hover { color: inherit; }
.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 12px;
    color: white;
    background: var(--orange);
    font-size: 1.35rem;
    font-weight: 850;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; }
.brand small { margin-top: 0.1rem; color: #aebbd0; font-size: 0.72rem; font-weight: 500; }
.sidebar nav { display: grid; gap: 0.35rem; margin-top: 2.4rem; }
.sidebar nav a {
    padding: 0.78rem 0.9rem;
    border-radius: 9px;
    color: #c7d1df;
    font-size: 0.94rem;
}
.sidebar nav a:hover, .sidebar nav a.active { color: white; background: rgba(255, 255, 255, 0.1); }
.sidebar nav a.active { box-shadow: inset 3px 0 var(--orange); }
.sidebar-footer { margin-top: auto; padding: 1rem 0.8rem 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-footer span, .sidebar-footer small { display: block; }
.sidebar-footer small { color: #9eabc0; }
.sidebar-footer a { display: inline-block; margin-top: 0.75rem; color: #ffd0af; font-size: 0.85rem; }

.main-content { min-width: 0; padding: 2rem clamp(1.25rem, 3vw, 3.25rem) 4rem; }
.topbar { min-height: 74px; margin-bottom: 1.8rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.eyebrow {
    margin-bottom: 0.25rem;
    color: var(--orange);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.muted { color: var(--muted); }
.align-right { text-align: right; }
.text-sm { font-size: 1.25rem !important; }

.button {
    min-height: 42px;
    padding: 0.68rem 1rem;
    border: 1px solid transparent;
    border-radius: 9px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 750;
}
.button.primary { color: white; background: var(--orange); }
.button.primary:hover { color: white; background: #d96313; }
.button.secondary { color: var(--navy); background: white; border-color: var(--line); }
.button.full { width: 100%; }
.button-row { display: flex; justify-content: flex-end; gap: 0.75rem; }
.button-row form { margin: 0; }

.alert { margin-bottom: 1.2rem; padding: 0.8rem 1rem; border: 1px solid; border-radius: 10px; font-size: 0.9rem; }
.alert.success { color: var(--green); background: var(--green-soft); border-color: #b9e4cf; }
.alert.warning { color: var(--yellow); background: var(--yellow-soft); border-color: #f0da99; }
.alert.error { color: var(--red); background: var(--red-soft); border-color: #efbcbc; }

.panel {
    min-width: 0;
    padding: 1.4rem;
    border: 1px solid #e5e9ef;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.narrow-panel { max-width: 720px; }
.two-column { margin-top: 1.25rem; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .85fr); gap: 1.25rem; }
.two-column.form-layout { grid-template-columns: minmax(300px, .75fr) minmax(0, 1.35fr); }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.section-heading h2 { margin-bottom: 0.5rem; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.metric-card {
    padding: 1.25rem;
    border: 1px solid #e4e9ef;
    border-radius: 13px;
    background: white;
    box-shadow: var(--shadow);
}
.metric-card span, .metric-card small { display: block; }
.metric-card span { color: var(--muted); font-size: 0.83rem; font-weight: 650; }
.metric-card strong { display: block; margin: 0.35rem 0 0.25rem; color: var(--navy); font-size: 2rem; line-height: 1.1; }
.metric-card.accent { border-top: 3px solid var(--orange); }
.metric-card.danger { border-top: 3px solid var(--red); }
.analytics-metrics { scroll-margin-top: 1rem; }

.list { margin: 0 -0.25rem; }
.list-row { padding: 0.9rem 0.5rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-bottom: 1px solid #edf0f4; color: var(--ink); }
.list-row:last-child { border-bottom: 0; }
.list-row strong, .list-row small { display: block; }
.row-stats { color: var(--muted); font-size: 0.84rem; }
.row-stats b { margin-left: 0.6rem; color: var(--navy); }
.workflow-panel { background: linear-gradient(145deg, #fff 20%, #fff6ef 100%); }
.workflow-list { margin: 1.2rem 0 0; padding: 0; display: grid; gap: 1rem; list-style: none; }
.workflow-list li { display: flex; gap: 0.8rem; align-items: center; }
.workflow-list li > span { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--navy); font-size: 0.78rem; font-weight: 800; }
.workflow-list strong, .workflow-list small { display: block; }

.stack-form { display: grid; gap: 1rem; }
label { color: var(--navy); font-size: 0.84rem; font-weight: 700; }
input, select {
    width: 100%;
    min-height: 43px;
    margin-top: 0.35rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid #ccd4df;
    border-radius: 8px;
    color: var(--ink);
    background: white;
    font: inherit;
}
input:focus, select:focus { outline: 3px solid rgba(244, 122, 36, .15); border-color: var(--orange); }
input[type="file"] { padding: 0.5rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.field-help { margin: -0.35rem 0 0; color: var(--muted); font-size: 0.78rem; }
.inline-form select { min-width: 180px; margin: 0; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { padding: 0.75rem; color: var(--muted); background: #f7f8fa; text-align: left; font-size: 0.72rem; letter-spacing: .04em; text-transform: uppercase; }
td { padding: 0.85rem 0.75rem; border-bottom: 1px solid #e9edf2; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.compact td, .compact th { padding: 0.65rem; }
.cell-subtitle { display: block; margin-top: 0.15rem; }
.code { padding: 0.2rem 0.42rem; border-radius: 5px; color: var(--navy); background: #edf1f6; font-family: Consolas, monospace; font-size: .8rem; }
.action-links { display: flex; flex-wrap: wrap; gap: 0.65rem; white-space: nowrap; }
.action-links a { font-size: 0.8rem; }

.empty-state { padding: 2.4rem 1rem; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--navy); }
.empty-state .button { margin-top: 0.5rem; }
.info-card { margin-top: 1.2rem; padding: 1rem; border-radius: 9px; color: var(--muted); background: #f5f7fa; font-size: .84rem; }
.info-card strong { color: var(--navy); }
.info-card p { margin: .35rem 0 0; }
.pill { display: inline-block; padding: .28rem .55rem; border-radius: 999px; color: var(--navy); background: #eaf0f7; font-size: .72rem; font-weight: 750; }
.pill.orange { color: #9b4209; background: var(--orange-soft); }
.pill.subtle { font-weight: 650; }
.column-preview { display: flex; flex-wrap: wrap; gap: .55rem; }
.result-summary { margin: 1.4rem 0; display: flex; align-items: center; gap: .7rem; }
.result-summary strong { color: var(--orange); font-size: 2rem; }
.result-summary span { color: var(--muted); font-size: .85rem; }

.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.test-card { padding: 1.2rem; border: 1px solid var(--line); border-radius: 12px; }
.test-card h3 { margin-top: .8rem; }
.test-card p { color: var(--muted); }
.test-card-stats { margin: 1.1rem 0; padding: .8rem 0; display: flex; gap: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.test-card-stats strong { color: var(--navy); }

.tab-nav {
    position: sticky;
    top: 0;
    z-index: 5;
    margin-bottom: 1rem;
    padding: .65rem;
    display: flex;
    gap: .25rem;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 8px 24px rgba(16,35,63,.07);
}
.tab-nav a { padding: .5rem .7rem; border-radius: 7px; white-space: nowrap; font-size: .8rem; }
.tab-nav a:hover { background: var(--orange-soft); }
.section-anchor { margin-top: 1.25rem; scroll-margin-top: 78px; }
.definition-grid { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.definition-grid div { padding: .8rem; border-radius: 8px; background: #f6f8fa; }
.definition-grid dt { color: var(--muted); font-size: .75rem; }
.definition-grid dd { margin: .2rem 0 0; color: var(--navy); font-size: 1.3rem; font-weight: 800; }
.split-list { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.split-list > div { display: grid; gap: .45rem; }
.split-list span { padding: .5rem; border-radius: 6px; background: #f6f8fa; font-size: .82rem; }
.progress { width: 120px; height: 7px; margin-bottom: .25rem; overflow: hidden; border-radius: 999px; background: #e5eaf0; }
.progress span, .progress i { height: 100%; display: block; border-radius: inherit; background: var(--orange); }
.progress.large { width: 100%; height: 9px; }
.status { padding: .28rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 750; white-space: nowrap; }
.status.high-risk { color: var(--red); background: var(--red-soft); }
.status.attention { color: var(--yellow); background: var(--yellow-soft); }
.status.on-track { color: var(--green); background: var(--green-soft); }
.status.absent { color: var(--muted); background: #edf0f4; }
.ai-panel { border-color: #f7c5a2; background: linear-gradient(135deg, white, #fff4ec); }
.ai-panel h2 { margin-top: .8rem; }
.ai-note { max-width: 700px; color: var(--muted); }
.ai-provider { min-width: 220px; padding: .75rem; border-radius: 9px; background: rgba(255,255,255,.8); }
.ai-provider span, .ai-provider strong { display: block; }
.ai-provider span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.ai-provider strong { margin-top: .2rem; color: var(--navy); font-size: .88rem; }
.report-meta { margin: 1rem 0; display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; color: var(--muted); font-size: .8rem; }
.ai-diagnostics { margin: 1rem 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; }
.ai-diagnostics div { padding: .75rem; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.85); }
.ai-diagnostics span, .ai-diagnostics strong { display: block; }
.ai-diagnostics span { color: var(--muted); font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; }
.ai-diagnostics strong { margin-top: .2rem; color: var(--navy); font-size: .82rem; overflow-wrap: anywhere; }
.markdown-report { margin-top: 1rem; padding: clamp(1rem, 3vw, 2rem); border: 1px solid var(--line); border-radius: 10px; background: white; }
.markdown-report h2 { margin: 2rem 0 .75rem; padding-bottom: .45rem; border-bottom: 1px solid var(--line); color: var(--navy); }
.markdown-report h2:first-child { margin-top: 0; }
.markdown-report p, .markdown-report li { color: #334156; }
.markdown-report table { margin: 1rem 0; }
.markdown-report code { padding: .15rem .3rem; border-radius: 4px; background: #edf1f6; }
.markdown-report input[type="checkbox"] { width: auto; min-height: 0; margin: 0 .4rem 0 0; }
.ai-generate-form { margin-top: 1.2rem; display: flex; justify-content: flex-end; }
.progress-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.trend { padding: .28rem .5rem; border-radius: 999px; background: #edf0f4; color: var(--muted); font-size: .72rem; font-weight: 750; white-space: nowrap; }
.trend.improving { color: var(--green); background: var(--green-soft); }
.trend.declining, .trend.consistently-high-risk { color: var(--red); background: var(--red-soft); }
.trend.stable { color: var(--yellow); background: var(--yellow-soft); }

.topic-bars { display: grid; gap: 1rem; }
.topic-bars > div > span { margin-bottom: .4rem; display: flex; justify-content: space-between; }
.flag-group + .flag-group { margin-top: 1.5rem; }
.tag-row { margin-top: .7rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.tag { padding: .35rem .6rem; border-radius: 6px; font-size: .78rem; font-weight: 700; }
.danger-tag { color: var(--red); background: var(--red-soft); }
.success-tag { color: var(--green); background: var(--green-soft); }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, .75fr) minmax(500px, 1.25fr); background: white; }
.login-panel { width: min(470px, 100%); margin: auto; padding: 3rem; }
.login-brand { margin-bottom: 4rem; color: var(--navy); }
.login-brand small { color: var(--muted); }
.login-panel h1 { margin-bottom: .6rem; color: var(--navy); font-size: 2.5rem; }
.demo-note { margin-top: 1rem; padding: .7rem; border-radius: 7px; color: var(--muted); background: #f5f7f9; font-size: .77rem; }
.login-visual { padding: 3rem; display: grid; place-items: center; color: white; background: radial-gradient(circle at 75% 20%, #274f80 0, transparent 30%), linear-gradient(145deg, #132b4c, #08172b); }
.visual-card { max-width: 620px; }
.visual-card h2 { max-width: 540px; margin: 1.2rem 0; font-size: clamp(2.4rem, 5vw, 4.8rem); line-height: .98; letter-spacing: -.055em; }
.visual-card > p { max-width: 500px; color: #c0cbda; font-size: 1.05rem; }
.mini-stat-grid { margin-top: 3rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.mini-stat-grid div { padding: 1rem; border: 1px solid rgba(255,255,255,.14); border-radius: 10px; background: rgba(255,255,255,.05); }
.mini-stat-grid strong, .mini-stat-grid span { display: block; }
.mini-stat-grid strong { color: #ff9a52; font-size: 1.6rem; }
.mini-stat-grid span { color: #b8c4d3; font-size: .75rem; }

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .progress-kpis { grid-template-columns: repeat(2, 1fr); }
    .card-grid { grid-template-columns: repeat(2, 1fr); }
    .ai-diagnostics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .login-page { grid-template-columns: 1fr; }
    .login-visual { display: none; }
}
@media (max-width: 820px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 1rem; }
    .sidebar nav { margin-top: 1rem; display: flex; overflow-x: auto; }
    .sidebar nav a { white-space: nowrap; }
    .sidebar-footer { display: none; }
    .two-column, .two-column.form-layout { grid-template-columns: 1fr; }
    .main-content { padding: 1.4rem 1rem 3rem; }
}
@media (max-width: 560px) {
    .metric-grid, .card-grid, .form-grid { grid-template-columns: 1fr; }
    .progress-kpis { grid-template-columns: 1fr; }
    .ai-diagnostics { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .panel { padding: 1rem; }
    .definition-grid, .split-list { grid-template-columns: 1fr; }
    .login-panel { padding: 1.5rem; }
    .login-brand { margin-bottom: 3rem; }
}
