:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6b6861;
  --line: #e4e1da;
  --accent: #1f5f4a;
  --accent-text: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #e3f3ea;
  --wait: #8a6100;
  --wait-bg: #fbefce;
  --bad: #a3271f;
  --bad-bg: #fbe4e1;
  --off: #5d5a54;
  --off-bg: #ebe9e4;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1d1c1a;
    --text: #ecebe7;
    --muted: #9c988f;
    --line: #2e2d29;
    --accent: #6fcfa8;
    --accent-text: #0f1f19;
    --ok: #7fdcae;
    --ok-bg: #163426;
    --wait: #f0c560;
    --wait-bg: #3a2f10;
    --bad: #ff9d94;
    --bad-bg: #41191a;
    --off: #b3afa6;
    --off-bg: #2a2926;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 24px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.gap-top { margin-top: 14px; }
.nav-title.spaced { margin-top: 12px; }
.small { font-size: 13px; }

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.side {
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.brand { font-weight: 650; letter-spacing: -0.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: 7px 10px; border-radius: 7px; color: var(--text); }
.nav a:hover { background: var(--off-bg); text-decoration: none; }
.nav a.current { background: var(--off-bg); font-weight: 600; }
.nav-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0 10px 4px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.main { padding: 28px 32px 48px; max-width: 1320px; width: 100%; min-width: 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); margin-bottom: 16px; }
.grid .card { margin: 0; }
.metric { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.metric.compact { font-size: 20px; }
.metric-label { color: var(--muted); font-size: 13px; }

progress { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 6px; border: 0; border-radius: 3px; margin-top: 10px; background: var(--off-bg); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--off-bg); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
progress.full::-webkit-progress-value { background: var(--bad); }
progress.full::-moz-progress-bar { background: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 550; white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.wait { color: var(--wait); background: var(--wait-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.off { color: var(--off); background: var(--off-bg); }

.notice { border-radius: var(--radius); padding: 11px 14px; margin-bottom: 16px; border: 1px solid transparent; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.wait { background: var(--wait-bg); color: var(--wait); }

form.stack { display: flex; flex-direction: column; gap: 14px; max-width: 520px; }
form.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
form.row label { flex: 1 1 160px; min-width: 0; }
form.stack input, form.stack textarea, form.row input { width: 100%; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 550; font-size: 14px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
textarea { min-height: 92px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button, .button {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  display: inline-block;
}
button:hover, .button:hover { filter: brightness(1.08); text-decoration: none; }
button.ghost, .button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.danger { background: transparent; color: var(--bad); border-color: var(--line); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; }

.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 18px; padding: 10px 14px; background: var(--off-bg); border-radius: 8px; display: inline-block; user-select: all; }

.report h1, .report h2 { font-size: 15px; margin: 18px 0 8px; }
.report h1:first-child, .report h2:first-child { margin-top: 0; }
.report table { margin-bottom: 12px; font-size: 14px; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; margin: 0; }
.auth form.stack { max-width: none; }

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; min-width: 0; }
  .side form { min-width: 0; }
  .side select { max-width: 100%; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
  .nav-title { display: none; }
  .side-foot { margin-top: 0; flex-direction: row; align-items: center; margin-left: auto; }
  .main { padding: 20px 16px 40px; }
  .head { align-items: flex-start; }
  th, td { padding: 8px 6px; }
}

.score { display: inline-block; min-width: 44px; text-align: center; padding: 2px 8px; border-radius: 7px; font-weight: 650; font-variant-numeric: tabular-nums; }
.score.ok { color: var(--ok); background: var(--ok-bg); }
.score.wait { color: var(--wait); background: var(--wait-bg); }
.score.bad { color: var(--bad); background: var(--bad-bg); }
.score.off { color: var(--off); background: var(--off-bg); }
.score.big { font-size: 26px; padding: 6px 14px; min-width: 72px; }

.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filters label { flex: 0 1 220px; }
.filters select { width: 100%; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.current { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 12px; }

.quote { margin: 6px 0 0; padding: 6px 10px; border-left: 3px solid var(--line); color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.list { margin: 0; padding-left: 20px; }
.list li { margin-bottom: 6px; }
details { margin-top: 4px; }
summary { cursor: pointer; font-weight: 600; }
.timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 34px 132px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline .text { overflow-wrap: anywhere; }
.head-score { display: flex; gap: 12px; align-items: center; }
@media (max-width: 820px) {
  .timeline li { grid-template-columns: 28px 1fr; }
  .timeline .when { grid-column: 2; }
  .timeline .text { grid-column: 2; }
}

.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar.weekend { fill: var(--muted); opacity: 0.55; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .value { fill: var(--text); font-size: 10px; }
.charts { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); margin-bottom: 16px; }
.charts .card { margin: 0; }
.periods { display: flex; gap: 4px; flex-wrap: wrap; }
.periods a { padding: 5px 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--text); font-size: 14px; }
.periods a.current { background: var(--off-bg); font-weight: 600; }
.periods a:hover { text-decoration: none; }
.pair { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); margin-bottom: 16px; }
.pair .card { margin: 0; }
.few { color: var(--muted); font-size: 13px; white-space: nowrap; }

table.compact th, table.compact td { padding: 8px 6px; }
table.compact th { letter-spacing: 0.02em; font-size: 11.5px; }
table.compact td:first-child { min-width: 170px; }
