:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1c2024;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #1f6feb;
  --go: #16794a;
  --go-hi: #1a8d55;
  --stop: #b3261e;
  --stop-hi: #c9302c;
  --radius: 10px;

  /* Statistics timeline */
  --axis: #1a1a1a;          /* the 24-hour baseline */
  --tick: #9aa1aa;          /* hour ticks */
  --tick-major: #5c636b;    /* 00 / 06 / 12 / 18 / 24 ticks */
  --band-day: #1f6feb;      /* 06:00–16:00 */
  --band-evening: #e8730a;  /* 16:00–20:00 */
  --band-night: #c62828;    /* 20:00–06:00 */
  --rowline: #eef0f3;
  --weekend: #fdf4d4;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171a;
    --panel: #1c2126;
    --ink: #e8eaed;
    --muted: #9aa4b0;
    --line: #2c333a;
    --accent: #4f8ef7;

    /* Dark mode steps are chosen for this surface, not flipped from light. */
    --axis: #c9ced4;
    --tick: #6b7580;
    --tick-major: #98a2ad;
    --band-day: #5a93f0;
    --band-evening: #dd8a12;
    --band-night: #c9333d;
    --rowline: #242a30;
    --weekend: #302a15;
  }
}

* { box-sizing: border-box; }

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

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

.wrap { max-width: 940px; margin: 0 auto; padding: 0 16px 48px; }
.wrap.wide { max-width: 1180px; }

header.top {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
header.top .wrap {
  display: flex; align-items: center; gap: 20px;
  padding-top: 12px; padding-bottom: 12px;
}
header.top .brand { font-weight: 700; font-size: 17px; }
header.top nav { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
header.top nav a { color: var(--muted); }
header.top nav a.active { color: var(--ink); font-weight: 600; }
header.top nav a.navicon { display: inline-flex; align-items: center; padding: 1px 2px; }
header.top nav a.navicon svg { display: block; }
header.top nav a.navicon:hover { color: var(--ink); text-decoration: none; }
header.top nav a.navicon.active { color: var(--accent); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 14px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.status { text-align: center; padding: 28px 20px; }
.status .state { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .08em; }
.status .clock { font-size: 46px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 6px 0 2px; }
.status .meta { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.status .meta strong { color: var(--ink); }

.btn {
  display: inline-block; border: 0; cursor: pointer;
  border-radius: 8px; padding: 11px 18px;
  font-size: 15px; font-weight: 600; color: #fff; background: var(--accent);
  text-decoration: none;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--stop); }
.btn.big { font-size: 20px; padding: 16px 42px; border-radius: 999px; }
.btn.go { background: var(--go); }
.btn.go:hover { background: var(--go-hi); }
.btn.halt { background: var(--stop); }
.btn.halt:hover { background: var(--stop-hi); }

.linkbtn {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent); font: inherit; text-decoration: none;
}
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger-link { color: var(--stop); }
.small.linkbtn, .linkbtn.small { font-size: 13px; }

.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.totals div { text-align: center; padding: 14px 8px; border: 1px solid var(--line); border-radius: 8px; }
.totals span { display: block; }
.totals .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.totals .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.totals .sub { text-transform: none; letter-spacing: 0; }
.totals.four { grid-template-columns: repeat(4, 1fr); }

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

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=datetime-local], input[type=date], input[type=month], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
}
textarea { min-height: 72px; resize: vertical; }
.row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.row > * { flex: 1 1 190px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: rgba(22,121,74,.10); border-color: rgba(22,121,74,.35); }
.flash.err { background: rgba(179,38,30,.10); border-color: rgba(179,38,30,.35); }

.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.live { color: #fff; background: var(--go); border-color: var(--go); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; }
code.inline { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }

.login { max-width: 360px; margin: 10vh auto; }
.login h1 { font-size: 22px; margin: 0 0 18px; }

/* ---------------- Statistics: month timeline ---------------- */

.monthnav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.monthnav .title { font-size: 18px; font-weight: 700; min-width: 190px; }
.monthnav form { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.monthnav input[type=month] { width: auto; }

.chartwrap { overflow-x: auto; }
.timeline { width: 100%; min-width: 640px; height: auto; display: block; }

.timeline .axis      { stroke: var(--axis); stroke-width: 1; }
.timeline .tick      { stroke: var(--tick); stroke-width: 1; }
.timeline .tick.major{ stroke: var(--tick-major); }
.timeline .gridline  { stroke: var(--line); stroke-width: 1; }
.timeline .rowsep    { stroke: var(--rowline); stroke-width: 1; }
.timeline .weekend   { fill: var(--weekend); }
.timeline .today     { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 3 2; }

.timeline text        { fill: var(--muted); font-size: 9px; font-family: inherit; }
.timeline text.daylbl { fill: var(--ink); font-size: 9.5px; }
.timeline text.hours  { fill: var(--ink); font-size: 9.5px; font-variant-numeric: tabular-nums; }
.timeline text.dim    { fill: var(--muted); }

.timeline .seg          { stroke-linecap: butt; }
.timeline .seg-day      { stroke: var(--band-day); }
.timeline .seg-evening  { stroke: var(--band-evening); }
.timeline .seg-night    { stroke: var(--band-night); }
.timeline .seg-running  { opacity: .7; }
.timeline .segcap       { stroke-linecap: round; }

.legend { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin: 0 0 4px; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.legend .swatch { width: 22px; height: 6px; border-radius: 3px; display: inline-block; }
.legend .swatch.day     { background: var(--band-day); }
.legend .swatch.evening { background: var(--band-evening); }
.legend .swatch.night   { background: var(--band-night); }
.legend .swatch.axisline{ background: var(--axis); height: 1px; border-radius: 0; }

@media (max-width: 560px) {
  .status .clock { font-size: 38px; }
  .totals, .totals.four { grid-template-columns: 1fr; }
  .monthnav form { margin-left: 0; }
}

@media print {
  header.top, .monthnav form, .actions { display: none; }
  .card { border: 0; padding: 0; }
  body { background: #fff; }
}
