:root {
    color-scheme: light;
    --ink: #1c2630;
    --muted: #64717f;
    --line: #d8e1e5;
    --bg: #f5f8f7;
    --panel: #ffffff;
    --nav: #123f46;
    --nav-2: #0b6f89;
    --good: #2e8b57;
    --warn: #c98b1d;
    --bad: #c74949;
    --blue: #0b6f89;
    --focus: #1b8ca6;
    --shadow: 0 10px 28px rgba(24, 38, 48, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--ink);
}
textarea { resize: vertical; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
label input, label textarea, label select { color: var(--ink); font-weight: 500; }

.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.side {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px;
    background: linear-gradient(180deg, var(--nav), #173a40);
    color: #f7fbfb;
}
.brand { display: flex; align-items: center; min-height: 74px; padding: 10px; border-radius: 8px; background: rgba(255,255,255,.96); }
.brand img { width: 100%; max-height: 62px; object-fit: contain; }
.side-nav { display: grid; gap: 4px; }
.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,.82);
}
.side-nav a:hover, .side-nav a.active { background: rgba(255,255,255,.13); color: #fff; }
.icon { width: 18px; height: 18px; flex: 0 0 18px; }
.side-user { margin-top: auto; display: flex; gap: 10px; align-items: center; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.18); }
.side-user strong, .side-user small { display: block; }
.side-user small { color: rgba(255,255,255,.68); }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #f2f6f7; color: var(--nav); font-weight: 800; }
.side-actions { display: flex; gap: 12px; font-size: 13px; color: rgba(255,255,255,.76); }
.main { padding: 28px; min-width: 0; }

.page-head, .audit-topline {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.page-head h1, .audit-topline h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); line-height: 1.05; letter-spacing: 0; }
.page-head p, .audit-topline p { margin: 6px 0 0; color: var(--muted); max-width: 760px; }
.eyebrow { margin: 0 0 6px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.button, .icon-button, .link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 40px;
    padding: 9px 14px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font-weight: 800;
}
.button:hover, .icon-button:hover { border-color: var(--focus); }
.button.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.button.ghost { background: transparent; }
.button.small { min-height: 32px; padding: 6px 10px; font-size: 13px; }
.button.full { width: 100%; margin-top: 12px; }
.button.danger { color: #fff; background: var(--bad); border-color: var(--bad); }
.button.big-touch { min-height: 56px; padding: 14px 20px; font-size: 17px; }
.button:disabled { opacity: .48; cursor: not-allowed; }
.icon-button { width: 42px; padding: 0; font-size: 20px; }
.link-button { border: 0; background: transparent; color: var(--blue); padding: 0; min-height: 24px; font-size: 13px; }

.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { border-radius: 8px; padding: 10px 12px; background: #eaf3f5; border: 1px solid #cde2e8; color: #173a40; }
.flash.error { background: #fff0f0; border-color: #f0c8c8; color: #8f2929; }
.flash.success { background: #edf8f1; border-color: #c8e8d3; color: #245f3e; }
.flash.warning { background: #fff8e8; border-color: #efd89f; color: #76500c; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at 30% 20%, #eef8f1 0, transparent 34%), linear-gradient(135deg, #f5f8f7, #e8f0f2);
}
.auth-card { width: min(440px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 26px; box-shadow: var(--shadow); }
.auth-logo { width: 220px; max-width: 80%; display: block; margin-bottom: 20px; }
.auth-card h1 { margin: 0 0 4px; font-size: 32px; }
.auth-card p { color: var(--muted); margin-top: 0; }
.stack-form { display: grid; gap: 14px; }
.quiet-link { color: var(--blue); font-weight: 800; }

.filter-bar, .form-panel, .panel, .action-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.filter-bar { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 12px; align-items: end; padding: 14px; margin-bottom: 18px; }
.form-panel { padding: 18px; }
.form-grid, .settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.form-actions, .actions-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.inline-form { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.inline-form label { min-width: 280px; }

.kpi-grid, .summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; box-shadow: var(--shadow); }
.kpi span, .kpi small { display: block; color: var(--muted); }
.kpi strong { display: block; margin: 6px 0; font-size: 34px; line-height: 1; }
.kpi.good { border-left: 5px solid var(--good); }
.kpi.warn { border-left: 5px solid var(--warn); }
.kpi.bad { border-left: 5px solid var(--bad); }

.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.auditor-home { display: grid; gap: 16px; max-width: 880px; }
.next-audit-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.next-audit-panel h2 { margin: 0; font-size: 30px; }
.next-audit-panel p { margin: 6px 0 0; color: var(--muted); }
.simple-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.simple-kpis article {
    display: grid;
    gap: 4px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}
.simple-kpis span { color: var(--muted); font-weight: 800; }
.simple-kpis strong { font-size: 34px; line-height: 1; }
.simple-kpis article.good { border-left: 5px solid var(--good); }
.simple-kpis article.warn { border-left: 5px solid var(--warn); }
.simple-kpis article.bad { border-left: 5px solid var(--bad); }
.simple-audit-list { display: grid; gap: 8px; }
.simple-audit-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.simple-audit-list small, .muted-text { color: var(--muted); }
.simple-audit-list b { color: #fff; border-radius: 999px; padding: 5px 9px; }
.simple-audit-list b.good { background: var(--good); }
.simple-audit-list b.warn { background: var(--warn); }
.simple-audit-list b.bad { background: var(--bad); }
.panel { padding: 16px; }
.panel.wide { grid-column: span 2; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 19px; }
.panel-head span { color: var(--muted); font-size: 13px; }
.section-bars { display: grid; gap: 10px; }
.section-bar-row { display: grid; grid-template-columns: minmax(160px, 1.2fr) 2fr 54px; gap: 10px; align-items: center; }
.stacked-bar { height: 14px; display: flex; overflow: hidden; background: #e9eff0; border-radius: 999px; }
.stacked-bar i { display: block; height: 100%; }
.stacked-bar .good, .legend .good { background-color: var(--good); }
.stacked-bar .warn, .legend .warn { background-color: var(--warn); }
.stacked-bar .bad, .legend .bad { background-color: var(--bad); }
.muted { background-color: #dce4e6; }
.donut {
    width: 180px;
    aspect-ratio: 1;
    margin: 14px auto;
    border-radius: 50%;
    background: conic-gradient(var(--good) 0 var(--good-share), var(--warn) var(--good-share) calc(var(--good-share) + var(--warn-share)), var(--bad) 0 100%);
}
.legend { display: grid; gap: 6px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; }
.trend { height: 180px; display: flex; align-items: flex-end; gap: 8px; padding-top: 12px; border-bottom: 1px solid var(--line); }
.trend span { flex: 1; min-width: 18px; background: linear-gradient(180deg, #4aa879, var(--blue)); border-radius: 6px 6px 0 0; position: relative; }
.trend small { position: absolute; bottom: -24px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 11px; }
.heatmap { display: grid; gap: 10px; overflow-x: auto; }
.heat-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(58px, 1fr); gap: 6px; min-width: 520px; }
.heat-row span { display: grid; place-items: center; height: 36px; border-radius: 8px; color: #fff; font-weight: 800; }
.heat-row span.good, .score.good { background-color: var(--good); }
.heat-row span.warn, .score.warn { background-color: var(--warn); }
.heat-row span.bad, .score.bad { background-color: var(--bad); }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td small { display: block; color: var(--muted); }
.table-actions { text-align: right; }
.pill, .score {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #edf2f3;
    color: var(--ink);
    font-weight: 800;
}
.score.good { color: #fff; }
.score.warn { color: #fff; }
.score.bad { color: #fff; }

.audit-topline {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(245,248,247,.95);
    padding: 8px 0 16px;
    backdrop-filter: blur(10px);
}
.audit-top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.save-state { min-width: 92px; color: var(--muted); font-weight: 800; font-size: 13px; }
.save-state.saving { color: var(--warn); }
.save-state.error { color: var(--bad); }
.audit-grid { display: grid; grid-template-columns: 270px minmax(0, 780px); gap: 18px; align-items: start; }
.taste-mode .audit-grid { grid-template-columns: 220px minmax(0, 780px); }
.audit-nav { position: sticky; top: 92px; display: grid; gap: 10px; }
.section-list { display: grid; gap: 6px; }
.section-list button {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
    cursor: pointer;
    text-align: left;
}
.section-list button.active { border-color: var(--blue); box-shadow: inset 4px 0 0 var(--blue); }
.section-list small { color: var(--muted); }
[data-section-select] { display: none; }
.audit-sections { display: grid; gap: 14px; }
.audit-section { display: none; }
.audit-section.active { display: grid; gap: 14px; }
.section-heading { display: flex; justify-content: space-between; gap: 16px; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.section-heading h2 { margin: 0; font-size: 26px; }
.section-heading p { margin: 6px 0 0; color: var(--muted); }
.section-note { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; box-shadow: var(--shadow); }
.question-card { background: #fff; border: 1px solid var(--line); border-left: 5px solid #d7e0e2; border-radius: 8px; padding: 14px; box-shadow: var(--shadow); }
.question-card.good { border-left-color: var(--good); background: #fbfffc; }
.question-card.warn { border-left-color: var(--warn); background: #fffdf7; }
.question-card.bad { border-left-color: var(--bad); background: #fffafa; }
.question-card.is-current { outline: 2px solid rgba(27,140,166,.28); }
.question-head { display: grid; grid-template-columns: 34px 1fr 32px; gap: 10px; align-items: start; }
.question-index { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #edf3f4; font-weight: 900; color: var(--blue); }
.question-head h3 { margin: 0; font-size: 18px; }
.answer-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #edf3f4; font-weight: 900; }
.response-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 44px; gap: 8px; margin-top: 14px; }
.response-button { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff; cursor: pointer; font-weight: 800; }
.response-button span { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; border-radius: 50%; background: #edf3f4; }
.response-button[aria-pressed="true"].good { color: #fff; border-color: var(--good); background: var(--good); }
.response-button[aria-pressed="true"].warn { color: #fff; border-color: var(--warn); background: var(--warn); }
.response-button[aria-pressed="true"].bad { color: #fff; border-color: var(--bad); background: var(--bad); }
.comment-panel { display: none; margin-top: 12px; }
.comment-panel.open { display: block; }
.section-actions { display: flex; justify-content: space-between; gap: 10px; }
.locked-banner { display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 8px; background: #fff8e8; border: 1px solid #efd89f; color: #76500c; font-weight: 800; }
.help-dialog { border: 0; border-radius: 8px; padding: 0; max-width: 560px; box-shadow: var(--shadow); }
.help-dialog form { padding: 20px; display: grid; gap: 12px; }
.help-dialog p { white-space: pre-line; color: var(--ink); }

.split-grid { display: grid; grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
.table-action-group { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.archived-row { opacity: .72; }
.list { display: grid; gap: 8px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff; }
.list-row span, .plain-list span { color: var(--muted); }
.list-row strong, .list-row small { display: block; }
.template-list { display: grid; gap: 14px; }
.plain-list { margin: 0; padding-left: 20px; color: var(--muted); }
.plain-list li { margin: 4px 0; }
.toggle { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; color: var(--ink); }
.toggle input { width: auto; }
.action-panel { margin-top: 16px; padding: 16px; }

.intervention-list { display: grid; gap: 12px; }
.intervention-list.compact .intervention-row { display: grid; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--line); }
blockquote { margin: 10px 0 0; padding: 10px 12px; border-left: 4px solid var(--blue); background: #f2f7f7; color: var(--muted); }
.empty-state { display: grid; place-items: center; text-align: center; min-height: 220px; padding: 24px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); background: #fff; }
.empty-state h2 { margin-bottom: 0; color: var(--ink); }

.report { max-width: 980px; margin: 0 auto; background: #fff; color: #111; padding: 28px; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.report-toolbar { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 18px; }
.report-head { display: grid; grid-template-columns: 180px 1fr 110px; gap: 18px; align-items: center; border-bottom: 3px solid var(--blue); padding-bottom: 18px; }
.report-head img { width: 180px; }
.report-head h1 { margin: 0; }
.report-head strong { font-size: 42px; color: var(--blue); text-align: right; }
.report-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.report-meta span { display: grid; gap: 3px; padding: 10px; background: #f5f8f7; border-radius: 8px; }
.report-section { break-inside: avoid; margin-top: 20px; }
.report-section h2 { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.note { background: #fff8e8; padding: 10px; border-radius: 8px; }

@media (max-width: 1080px) {
    .app-shell { grid-template-columns: 1fr; }
    .side { position: static; height: auto; border-radius: 0 0 8px 8px; }
    .side-nav { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
    .main { padding: 18px; }
    .filter-bar, .kpi-grid, .summary-grid, .dashboard-grid, .split-grid, .audit-grid, .form-grid, .settings-grid { grid-template-columns: 1fr; }
    .panel.wide { grid-column: auto; }
    .audit-nav { position: static; }
    [data-section-select] { display: block; }
    .section-list { display: none; }
    .response-grid { grid-template-columns: 1fr; }
    .page-head, .audit-topline { flex-direction: column; }
    .report-meta, .report-head { grid-template-columns: 1fr; }
    .report-head strong { text-align: left; }
}

@media (max-width: 720px) {
    .main { padding: 10px; }
    .side { padding: 12px; gap: 10px; }
    .brand { min-height: 54px; padding: 6px; }
    .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
    .side-nav a { min-height: 44px; padding: 8px; font-size: 13px; }
    .side-user, .side-actions { font-size: 13px; }
    .page-head h1, .audit-topline h1 { font-size: 28px; }
    .audit-topline {
        position: sticky;
        top: 0;
        padding: 8px 0 10px;
        margin-bottom: 10px;
    }
    .audit-top-actions { width: 100%; display: grid; grid-template-columns: 1fr auto; }
    .audit-top-actions .button { grid-column: 1 / -1; width: 100%; }
    .audit-nav {
        position: sticky;
        top: 118px;
        z-index: 9;
        padding: 8px 0;
        background: rgba(245,248,247,.96);
        backdrop-filter: blur(8px);
    }
    .section-heading { padding: 14px; }
    .section-heading h2 { font-size: 22px; }
    .question-card { padding: 12px; }
    .question-head { grid-template-columns: 30px 1fr 30px; }
    .question-head h3 { font-size: 17px; line-height: 1.25; }
    .question-index, .answer-mark { width: 28px; height: 28px; }
    .response-button {
        min-height: 54px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        padding: 12px;
        font-size: 16px;
    }
    .response-button span { width: 28px; height: 28px; }
    .icon-button { width: 100%; min-height: 44px; }
    .comment-panel textarea, .section-note textarea { min-height: 92px; }
    .next-audit-panel { display: grid; }
    .simple-kpis { grid-template-columns: 1fr; }
    .simple-audit-list a { align-items: flex-start; }
    th, td { padding: 10px 8px; }
}

@media print {
    body { background: #fff; }
    .app-shell { display: block; }
    .side, .no-print, .flash-stack { display: none !important; }
    .main { padding: 0; }
    .report { border: 0; box-shadow: none; padding: 0; }
    a { text-decoration: none; color: inherit; }
}
