:root {
  --navy: #1E2761; --red: #E63946; --body: #3A4566; --muted: #6E7794; --label: #002060; --hair: #D5DAE5;
  --bg: #F4F6FA; --surface: #FFFFFF; --surface-2: #F8F9FC; --ink: #1B2140;
  --good: #1E7A4C; --good-bg: #E3F3EA; --warn: #9A6200; --warn-bg: #FCF1DC; --bad: #B4232F; --bad-bg: #FBE4E6; --info-bg: #E6EAF5;
  --series-1: #1E2761; --series-2: #E63946; --series-ref: #8089A3; --band: #E6EAF5;
  --mono: Consolas, "SFMono-Regular", Menlo, monospace;
  --sans: Calibri, "Segoe UI", Carlito, system-ui, -apple-system, sans-serif;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy: #A9B6F0; --red: #F06B75; --body: #C5CBE0; --muted: #8E97B3; --label: #B9C4F2; --hair: #2E3552;
    --bg: #0F1222; --surface: #171B2F; --surface-2: #1D2238; --ink: #ECEEF7;
    --good: #6FD39F; --good-bg: #173226; --warn: #F0BE62; --warn-bg: #34290F; --bad: #F7949B; --bad-bg: #3A1A1F; --info-bg: #222947;
    --series-1: #8E9FEA; --series-2: #F06B75; --series-ref: #6E7794; --band: #222947;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); font-size: 15px; line-height: 1.45; color: var(--body); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--navy); }
h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; }
.mono, .num { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--hair); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; flex-direction: column; gap: 2px; padding: 0 10px 14px; border-bottom: 2px solid var(--red); margin-bottom: 10px; }
.brand img { width: 120px; height: auto; }
.brand span { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.nav-sec { font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--body); font-weight: 600; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--info-bg); color: var(--navy); }
.nav .count { font-family: var(--mono); font-size: 11px; background: var(--red); color: #fff; border-radius: 10px; padding: 1px 7px; }
.side .who { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--hair); font-size: 13px; }
.side .who b { color: var(--ink); display: block; }
.main { padding: 26px 32px 60px; min-width: 0; max-width: 1280px; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--red); margin-bottom: 4px; }

/* ---------- cards & grid ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-title { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--red); }
.sec-title::before { content: "— "; }

.tile { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tile .v { font-size: 28px; font-weight: 700; color: var(--ink); font-family: var(--mono); font-variant-numeric: tabular-nums; margin-top: 2px; line-height: 1.15; }
.tile .d { font-size: 13px; color: var(--muted); }

/* ---------- clock card ---------- */
.clock { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; }
.clock .time { font-family: var(--mono); font-size: 44px; font-weight: 700; color: var(--ink); line-height: 1; }
.clock .facts { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 14px; }
.clock .facts div { min-width: 90px; }
.clock .facts .k { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.clock .facts .v { font-family: var(--mono); font-size: 18px; color: var(--ink); font-weight: 700; }
.clock-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; min-width: 220px; }
.seg { display: inline-flex; border: 1px solid var(--hair); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; font: inherit; font-size: 14px; color: var(--body); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--hair); }
.seg button.on { background: var(--navy); color: var(--surface); }
.progress { height: 8px; border-radius: 4px; background: var(--band); overflow: hidden; margin-top: 16px; }
.progress > i { display: block; height: 100%; background: var(--navy); border-radius: 4px; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--hair); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 6px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--navy); }
.btn.primary { background: var(--navy); color: var(--surface); border-color: var(--navy); }
.btn.danger { color: var(--bad); }
.btn.big { padding: 14px 22px; font-size: 18px; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
label.f > span { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--label); font-weight: 700; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--hair); border-radius: 6px; padding: 8px 10px; min-width: 0; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }
textarea { min-height: 70px; resize: vertical; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form .full { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--body); }
.check input { width: auto; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters label.f { width: auto; }
.filters input, .filters select { width: auto; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--label); font-weight: 700; padding: 8px 8px; border-bottom: 1.5px solid var(--hair); white-space: nowrap; }
td { padding: 9px 8px; border-bottom: 1px solid var(--hair); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
tr.weekend td { background: var(--surface-2); color: var(--muted); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.empty { text-align: center; color: var(--muted); padding: 24px; }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; white-space: nowrap; background: var(--info-bg); color: var(--navy); }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.grey { background: var(--surface-2); color: var(--muted); border: 1px solid var(--hair); }
.meter { display: inline-flex; align-items: center; gap: 8px; }
.meter i { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: var(--band); position: relative; overflow: hidden; }
.meter i b { position: absolute; left: 0; top: 0; bottom: 0; background: var(--navy); border-radius: 3px; }

/* ---------- board ---------- */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.person { border: 1px solid var(--hair); border-radius: var(--radius); padding: 12px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
.person b { color: var(--ink); }
.person:hover { border-color: var(--navy); }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.chart .grid-l { stroke: var(--hair); stroke-width: 1; }
.chart .ref { stroke: var(--series-ref); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .hit { fill: transparent; cursor: default; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
#tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 13px; padding: 6px 9px; border-radius: 6px; max-width: 260px; box-shadow: 0 4px 14px rgba(0,0,0,.18); white-space: pre-line; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 18, 34, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 40; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 10px; width: 100%; max-width: 560px; padding: 22px; box-shadow: 0 16px 40px rgba(0,0,0,.25); }
.modal h2 { margin-bottom: 14px; }
.modal .row.end { margin-top: 18px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
#toast div { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 6px; font-weight: 600; box-shadow: 0 6px 18px rgba(0,0,0,.2); max-width: 90vw; }
#toast div.err { background: var(--bad); color: #fff; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login img { width: 150px; display: block; margin-bottom: 4px; }
.login .tag { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--red); border-bottom: 2px solid var(--red); padding-bottom: 12px; margin-bottom: 18px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.err-box { background: var(--bad-bg); color: var(--bad); padding: 8px 10px; border-radius: 6px; font-size: 14px; }
.note-box { background: var(--info-bg); color: var(--navy); padding: 10px 12px; border-radius: 6px; font-size: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 30; transform: translateX(-105%); transition: transform .2s; height: 100%; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  .shell.open .side { transform: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--surface); border-bottom: 2px solid var(--red); position: sticky; top: 0; z-index: 20; }
  .topbar img { height: 30px; }
  .main { padding: 18px 16px 50px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .clock { grid-template-columns: 1fr; }
  .clock .time { font-size: 36px; }
  h1 { font-size: 21px; }
}
@media print { .side, .topbar, .btn { display: none !important; } .shell { display: block; } .main { padding: 0; } }
.grid > .card, .grid > .tile { margin-top: 0; }
