:root {
    --bg: #f4f1e8;
    --surface: #fffdf8;
    --ink: #18201c;
    --muted: #667169;
    --brand: #173f2d;
    --brand-soft: #d9e9df;
    --accent: #c8812a;
    --line: #dce1dc;
    --shadow: 0 12px 32px rgb(23 63 45 / 10%);
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--bg); }
a { color: inherit; }
.icon { width: 1.2rem; height: 1.2rem; flex: 0 0 auto; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 17rem minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 1.4rem 1rem; color: #fff; background: var(--brand); }
.brand { display: flex; align-items: center; gap: .8rem; color: #fff; font-weight: 750; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border: 1px solid rgb(255 255 255 / 35%); border-radius: .75rem; background: rgb(255 255 255 / 12%); }
.sidebar nav { display: grid; gap: .45rem; margin-top: 2.4rem; }
.nav-link { display: flex; align-items: center; gap: .7rem; padding: .75rem; border-radius: .7rem; color: #fff; text-decoration: none; }
.nav-link.active { background: rgb(255 255 255 / 14%); }
.nav-link.disabled { color: rgb(255 255 255 / 55%); }
.page { min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { min-height: 4.3rem; display: flex; align-items: center; gap: 1rem; padding: .8rem clamp(1rem, 4vw, 3rem); border-bottom: 1px solid var(--line); background: rgb(255 253 248 / 88%); }
.unit-context { margin-left: auto; padding: .45rem .7rem; border-radius: 999px; color: var(--brand); background: var(--brand-soft); font-size: .85rem; font-weight: 700; }
.mobile-menu { display: none; }
.content { width: min(72rem, 100%); margin-inline: auto; padding: clamp(2rem, 6vw, 5rem) clamp(1rem, 4vw, 3rem); flex: 1; }
.hero { max-width: 48rem; }
.eyebrow { color: var(--accent); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: .75rem 0 1rem; font-size: clamp(2.1rem, 5vw, 4.5rem); line-height: 1.02; letter-spacing: -.045em; }
.hero p { max-width: 42rem; color: var(--muted); font-size: 1.08rem; line-height: 1.7; }
.status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 3rem; }
.card { padding: 1.35rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: var(--shadow); }
.card h2 { margin: 1rem 0 .35rem; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); line-height: 1.55; }
.status { display: inline-flex; padding: .3rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.status.ok { color: #125d37; background: #d7f2e2; }
.status.pending { color: #8a500a; background: #fae8c7; }
.button { display: inline-flex; margin-top: 1rem; padding: .75rem 1rem; border-radius: .65rem; color: #fff; background: var(--brand); font-weight: 700; text-decoration: none; }
.pwa-action { padding: .45rem .7rem; border: 1px solid var(--brand); border-radius: .55rem; color: var(--brand); background: transparent; font-weight: 700; cursor: pointer; }
.pwa-action[hidden] { display: none; }
.notification-list { display: grid; gap: .8rem; }
.notification-card { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-left: .35rem solid var(--accent); border-radius: .8rem; background: var(--surface); }
.notification-card.severity-critical { border-left-color: #9e2929; }
.notification-card.is-read { opacity: .7; }
.notification-card h2 { margin: .5rem 0 .3rem; font-size: 1rem; }
.notification-card p { margin: 0 0 .4rem; color: var(--muted); }
.notification-card form button { padding: .5rem .7rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--bg); cursor: pointer; }
.push-status:not(:empty) { margin-bottom: 1rem; padding: .7rem; border-radius: .6rem; background: var(--brand-soft); }
.footer { padding: 1rem 3rem 1.4rem; color: var(--muted); text-align: center; font-size: .82rem; }
.footer a, .footer a:visited { color: var(--brand); text-decoration: none; }
.footer a:hover, .footer a:focus-visible { color: var(--accent); text-decoration: underline; }
.bottom-bar { display: none; }

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { display: none; }
    .mobile-menu { display: inline-flex; }
    .content { padding-bottom: 7rem; }
    .status-grid { grid-template-columns: 1fr; }
    .footer { padding: 1rem 1rem 6rem; }
    .bottom-bar { position: fixed; z-index: 10; inset: auto 0 0; display: flex; justify-content: center; padding: .55rem max(1rem, env(safe-area-inset-right)) calc(.55rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: var(--surface); }
    .bottom-bar a { display: grid; justify-items: center; gap: .18rem; color: var(--brand); font-size: .72rem; font-weight: 750; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
    .sidebar, .topbar, .bottom-bar { display: none !important; }
    .app-shell { display: block; }
    .footer { padding: 1rem 0; }
}

.auth-page { min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(circle at top right, var(--brand-soft), transparent 36%), var(--bg); }
.auth-main { width: min(30rem, calc(100% - 2rem)); margin: auto; padding: 2rem 0; }
.auth-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; color: var(--brand); font-weight: 800; text-decoration: none; }
.auth-brand .brand-mark { color: #fff; background: var(--brand); }
.auth-card { padding: clamp(1.4rem, 5vw, 2.2rem); border: 1px solid var(--line); border-radius: 1.2rem; background: var(--surface); box-shadow: var(--shadow); }
.auth-card h1, .hero.compact h1 { font-size: clamp(2rem, 7vw, 3.2rem); }
.auth-card p { color: var(--muted); line-height: 1.55; }
.auth-card form { display: grid; gap: .55rem; margin-top: 1.5rem; }
.auth-card label { margin-top: .45rem; font-size: .84rem; font-weight: 750; }
.auth-card input { width: 100%; padding: .78rem .85rem; border: 1px solid var(--line); border-radius: .65rem; color: var(--ink); background: #fff; font: inherit; }
.auth-card input:focus-visible { outline: 3px solid rgb(200 129 42 / 25%); border-color: var(--accent); }
.auth-card button, button.button { margin-top: .6rem; padding: .8rem 1rem; border: 0; border-radius: .65rem; color: #fff; background: var(--brand); font: inherit; font-weight: 800; cursor: pointer; }
.alert { padding: .75rem; border: 1px solid #e6a3a3; border-radius: .65rem; color: #7b1f1f; background: #fff0f0; }
.report-heading { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin-bottom: 2rem; }
.report-heading h1 { margin-bottom: .4rem; }
.report-heading p { color: var(--muted); }
.filters { display: flex; align-items: end; gap: .7rem; flex-wrap: wrap; padding: 1rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); }
.filters label { display: grid; gap: .25rem; color: var(--muted); font-size: .75rem; font-weight: 700; }
.filters input, .filters select { min-height: 2.4rem; padding: .45rem; border: 1px solid var(--line); border-radius: .45rem; background: #fff; }
.filters button { min-height: 2.4rem; padding: .5rem .85rem; border: 0; border-radius: .5rem; color: #fff; background: var(--brand); font-weight: 750; }
.metric-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: .8rem; }
.metric { padding: 1rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--surface); }
.metric span { display: block; color: var(--muted); font-size: .78rem; }
.metric strong { display: block; margin-top: .45rem; font-size: clamp(1rem,2vw,1.4rem); }
.report-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; margin-top: 1rem; }
.report-card { margin-top: 1rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: var(--shadow); }
.report-card h2 { margin: 0 0 1rem; font-size: 1.05rem; }
.bar-row { display: grid; grid-template-columns: 6.5rem 1fr 7rem; align-items: center; gap: .7rem; margin: .55rem 0; font-size: .8rem; }
.bar-row meter { width: 100%; accent-color: var(--brand); }
.alert-list { display: grid; gap: .8rem; padding: 0; list-style: none; }
.alert-list li { padding: .7rem; border-radius: .6rem; background: var(--bg); }
.table-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .7rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
.ranking { margin: 0; padding-left: 1.4rem; }
.ranking li { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem; border-bottom: 1px solid var(--line); }
.empty { color: var(--muted); }
@media (max-width: 950px) { .report-heading { align-items: stretch; flex-direction: column; } .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } .report-grid { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .metric-grid { grid-template-columns: 1fr; } .bar-row { grid-template-columns: 5.5rem 1fr; } .bar-row strong { grid-column: 2; } }
@media (max-width: 620px) { .notification-card { align-items: stretch; flex-direction: column; } .pwa-action { font-size: .72rem; } }
