:root {
    --bg: #f3f7fb;
    --panel: #ffffff;
    --ink: #13213b;
    --muted: #657089;
    --line: #dbe4ef;
    --brand: #2456d6;
    --brand-2: #0f8f8c;
    --danger: #b42318;
    --ok: #097647;
    --shadow: 0 18px 45px rgba(24, 39, 75, .12);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button {
    border: 0;
    cursor: pointer;
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--ink);
    background: #eef3f9;
}
button.primary {
    color: white;
    background: linear-gradient(135deg, var(--brand), #1e3fb7);
    font-weight: 700;
}
button.ghost { background: transparent; color: var(--muted); text-align: left; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    background: #fff;
    color: var(--ink);
}
textarea { resize: vertical; }
label { display: grid; gap: 7px; color: #1b3675; font-weight: 700; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(26px, 4vw, 38px); margin-bottom: 6px; }
h2 { font-size: 20px; margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 13px; font-weight: 800; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at top, #ffffff 0, #eef5fc 52%, #e7f0fb 100%);
}
.login-shell { width: min(448px, calc(100% - 28px)); text-align: center; }
.login-card {
    margin-top: 18px;
    padding: 28px 24px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: var(--shadow);
    text-align: left;
}
.login-card p { color: var(--muted); line-height: 1.5; }
.brand-mark {
    width: 70px;
    height: 70px;
    margin: 0 auto 10px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: white;
    background: conic-gradient(from 20deg, #20324f, #78aeb8, #20324f);
    font-weight: 900;
    letter-spacing: 0;
}
.brand-mark.small {
    width: 38px;
    height: 38px;
    margin: 0;
    font-size: 13px;
}
.eyebrow {
    color: var(--brand-2);
    text-transform: uppercase;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: .08em;
}
.stack { display: grid; gap: 14px; }
.form-message { min-height: 22px; color: var(--danger); font-weight: 700; }
footer { margin-top: 28px; color: #9aa5b8; font-size: 13px; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px;
    background: #fff;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.logo-row { display: flex; align-items: center; gap: 10px; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav button {
    text-align: left;
    color: var(--muted);
    background: transparent;
    font-weight: 800;
}
.sidebar nav button.active {
    color: var(--brand);
    background: #eef4ff;
}
.content { padding: 26px; min-width: 0; }
.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
}
.topbar p:last-child { color: var(--muted); font-weight: 700; }
.view { display: none; }
.view.active { display: block; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}
.stats-grid article, .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(24, 39, 75, .06);
}
.stats-grid article { padding: 18px; }
.stats-grid span { color: var(--muted); font-weight: 700; }
.stats-grid strong { display: block; font-size: 34px; margin-top: 6px; }
.panel { padding: 20px; margin-bottom: 18px; }
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.table-wrap { overflow-x: auto; }
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef3f9;
    color: var(--muted);
    font-weight: 800;
    font-size: 12px;
}
.badge.ok { color: var(--ok); background: #eaf8f0; }
.muted-panel { background: #f9fbfd; }
.split {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.inline-form { display: flex; gap: 8px; }
.inline-form input { min-width: 0; }
.plain-list { padding: 0; margin: 14px 0 0; list-style: none; display: grid; gap: 8px; color: var(--muted); }
.plain-list li { padding: 8px 10px; background: #f5f8fc; border-radius: 8px; }
.privacy-note {
    margin: 0 0 14px;
    padding: 12px 14px;
    border-left: 4px solid var(--brand-2);
    border-radius: 8px;
    color: #24465b;
    background: #eefafa;
    line-height: 1.45;
    font-weight: 700;
}

.report-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.toolbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}
.toolbar-actions select { min-width: 260px; }
.program-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    margin: 10px 0 34px;
}
.program-card {
    min-height: 190px;
    padding: 24px;
    border-radius: 8px;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 22px;
    box-shadow: 0 12px 30px rgba(24, 39, 75, .16);
}
.program-card span {
    max-width: 220px;
    font-weight: 800;
    line-height: 1.35;
}
.program-card strong { font-size: 28px; }
.program-card.teal { background: linear-gradient(135deg, #1aa79b, #20b7a8); }
.program-card.blue { background: linear-gradient(135deg, #1678c8, #1da8e8); }
.program-card.rose { background: linear-gradient(135deg, #e43f63, #ef5575); }
.program-card.violet { background: linear-gradient(135deg, #3411d7, #4e1fe6); }
.progress {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .6);
    overflow: hidden;
}
.progress i {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: #8ee25a;
}
.program-card.rose .progress i { background: #c40022; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}
.summary-card {
    min-height: 230px;
    padding: 22px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(24, 39, 75, .06);
}
.summary-card strong {
    display: block;
    margin-top: 28px;
    font-size: 34px;
}
.summary-card p { color: var(--muted); line-height: 1.4; }
.summary-card h3 {
    margin: 0 0 8px;
    font-size: 16px;
}
.icon-pill {
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-right: 10px;
    border-radius: 8px;
    font-weight: 900;
}
.blue-soft { color: #2456d6; background: #e8f0ff; }
.amber-soft { color: #b55f00; background: #fff1c7; }
.green-soft { color: #168247; background: #ddf7e7; }
.badge.low, .badge.ok { color: var(--ok); background: #eaf8f0; }
.badge.moderate { color: #a65f00; background: #fff1d4; }
.badge.high { color: #b42318; background: #ffe7e9; }

.chart-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 18px;
}
.chart-panel { overflow: hidden; }
.chart-box {
    min-height: 340px;
    overflow-x: auto;
}
.chart-box svg {
    width: 100%;
    min-width: 520px;
    height: auto;
}
.chart-box.wide svg { min-width: 760px; }
.chart-label {
    fill: #4b5568;
    font-size: 12px;
    font-weight: 700;
}
.axis-label {
    fill: #657089;
    font-size: 12px;
    font-weight: 700;
}
.gauge-chart svg {
    width: 100%;
    height: 150px;
}
.gauge-label {
    fill: #fff;
    font-size: 13px;
    font-weight: 900;
}
.gauge-risk {
    fill: var(--ink);
    font-size: 20px;
    font-weight: 900;
}
.empty-chart {
    min-height: 240px;
    display: grid;
    place-items: center;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 8px;
}
.heatmap-wrap {
    overflow-x: auto;
}
.heatmap-table {
    min-width: 720px;
    border-collapse: separate;
    border-spacing: 4px;
}
.heatmap-table th {
    border: 0;
    background: #f5f8fc;
    border-radius: 6px;
    text-align: center;
}
.heatmap-table tbody th {
    min-width: 160px;
    text-align: left;
}
.heatmap-table td {
    min-width: 92px;
    height: 54px;
    border: 0;
    border-radius: 6px;
    text-align: center;
    color: #fff;
    font-weight: 900;
}
.heatmap-table td.low { background: #21a957; }
.heatmap-table td.moderate { background: #e28a22; }
.heatmap-table td.high { background: #d9384c; }
.heatmap-table td.insufficient { background: #9aa5b8; }
.risk-percent {
    background: #f8d7dc;
    font-weight: 800;
}
.classification {
    color: #fff;
    text-align: center;
    font-weight: 900;
}
.classification.low { background: #21a957; }
.classification.moderate { background: #f2d36d; color: #6d4a00; }
.classification.high { background: #efbcc5; color: #7a1626; }

dialog {
    width: min(520px, calc(100% - 24px));
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 22, 44, .36); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

.survey-page {
    min-height: 100vh;
    background: #f8fbff;
}
.survey-shell {
    width: min(840px, calc(100% - 28px));
    margin: 0 auto;
    padding: 30px 0;
}
.subtle { color: var(--muted); line-height: 1.6; }
.survey-form { display: grid; gap: 18px; margin-top: 18px; }
.question {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
}
.question strong { display: block; margin-bottom: 12px; }
.scale {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}
.scale label {
    display: grid;
    place-items: center;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-weight: 800;
    cursor: pointer;
}
.scale input { position: absolute; opacity: 0; pointer-events: none; }
.scale label:has(input:checked) {
    color: white;
    border-color: var(--brand);
    background: var(--brand);
}

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .sidebar nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .stats-grid, .split, .program-grid, .summary-grid, .chart-grid { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .report-toolbar, .toolbar-actions { align-items: stretch; flex-direction: column; }
    .toolbar-actions select { min-width: 0; }
}

@media (max-width: 560px) {
    .content { padding: 18px; }
    .sidebar nav { grid-template-columns: 1fr 1fr; }
    .scale { grid-template-columns: repeat(5, minmax(42px, 1fr)); }
    th, td { padding: 10px 8px; }
}

@media print {
    .sidebar, .topbar, .toolbar-actions, dialog { display: none !important; }
    .app-shell { display: block; }
    .content { padding: 0; }
    .panel, .summary-card, .program-card { box-shadow: none; break-inside: avoid; }
    body { background: #fff; }
}
