:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --line: #e3e7ec;
  --accent: #1f7a5c;
  --accent-text: #ffffff;
  --idle: #e9b949;
  --empty: #eef1f4;
  --danger: #b4232c;
  --warn-bg: #fff6e0;
  --notice-bg: #eaf6f1;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121519;
    --surface: #1a1e23;
    --text: #e6e9ed;
    --muted: #97a1ad;
    --line: #2b3138;
    --accent: #3fb68b;
    --accent-text: #0d1512;
    --idle: #c99a2e;
    --empty: #23282e;
    --danger: #ef6b73;
    --warn-bg: #2e2716;
    --notice-bg: #15271f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
h1 { font-size: 1.5rem; margin: 0; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
code, pre { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85rem; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .6rem .8rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; user-select: all; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.r { text-align: right; }
.err { color: var(--danger); }
.warn { background: var(--warn-bg); padding: .6rem .8rem; border-radius: 6px; }

/* header */
.bar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.25rem; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; letter-spacing: -.01em; }
.bar nav { display: flex; gap: 1rem; flex: 1; }
.bar nav a { text-decoration: none; color: var(--muted); padding: .3rem 0; border-bottom: 2px solid transparent; }
.bar nav a.cur { color: var(--text); border-color: var(--accent); }
main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

/* buttons */
button { font: inherit; cursor: pointer; }
.btn, button.primary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; min-width: 36px; padding: 0 .8rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); text-decoration: none;
}
.btn.off { opacity: .35; }
.primary, button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.link { background: none; border: 0; padding: .25rem .4rem; color: var(--muted); text-decoration: underline; }
button.link.danger { color: var(--danger); }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* layout */
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.sub { margin: .25rem 0 0; color: var(--muted); }
.crumb { margin: 0 0 .5rem; }
.crumb a { color: var(--muted); text-decoration: none; }
.days { display: flex; align-items: center; gap: .4rem; }
.day { font-variant-numeric: tabular-nums; min-width: 6.5rem; text-align: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card.flush { padding: 0; overflow-x: auto; }
.card.notice { background: var(--notice-bg); border-color: var(--accent); }
.empty { text-align: center; padding: 2.5rem 1rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stats > .card { margin-bottom: 0; }
.stat span { display: block; color: var(--muted); font-size: .85rem; }
.stat b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.cols { display: grid; grid-template-columns: 3fr 2fr; gap: 1rem; }
.cols > .card { margin-bottom: 1rem; }

/* tables */
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-weight: 600; font-size: .8rem; color: var(--muted); padding: .7rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: .55rem 1rem; vertical-align: middle; }
.grid tr.main td { padding-top: .8rem; }
.grid tr.tlrow td { padding-top: 0; padding-bottom: .8rem; border-bottom: 1px solid var(--line); }
.grid tr.axisrow td { padding-bottom: 0; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid.compact td { padding: .35rem .25rem; border-bottom: 1px solid var(--line); }
.grid.compact tr:last-child td { border-bottom: 0; }
.name { font-weight: 600; text-decoration: none; }
.name:hover { text-decoration: underline; }
.ellipsis { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis.wide { max-width: 0; width: 100%; }
tr.dim { opacity: .55; }
.actions { white-space: nowrap; }
.actions form { display: inline; }

/* badges */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--empty); color: var(--muted); white-space: nowrap; }
.badge.on { background: var(--accent); color: var(--accent-text); }
.badge.idle { background: var(--idle); color: #2b1f00; }
.badge.lock { background: var(--empty); color: var(--text); }

/* timeline */
svg.tl { display: block; width: 100%; height: 22px; border-radius: 4px; overflow: hidden; }
svg.axis { display: block; width: 100%; height: 16px; overflow: visible; }
svg.axis text { font-size: 10px; fill: var(--muted); text-anchor: middle; }
svg.axis text:first-child { text-anchor: start; }
svg.axis text:last-child { text-anchor: end; }
rect.bg { fill: var(--empty); }
rect.active { fill: var(--accent); }
rect.idle { fill: var(--idle); }
.legend { color: var(--muted); font-size: .8rem; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .9rem; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: -.5rem; }
.sw.active { background: var(--accent); }
.sw.idle { background: var(--idle); }
.sw.bg { background: var(--empty); border: 1px solid var(--line); }

/* app bars */
.barcell { width: 40%; }
svg.bar { display: block; width: 100%; height: 8px; border-radius: 4px; background: var(--empty); }
svg.bar rect { fill: var(--accent); }

/* week */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: .4rem; align-items: end; }
.wd { display: flex; flex-direction: column; align-items: center; gap: .2rem; text-decoration: none; padding: .3rem 0; border-radius: 6px; }
.wd.cur { background: var(--bg); }
.wd b { font-size: .72rem; font-weight: 600; }
.wd span { font-size: .72rem; color: var(--muted); }
svg.wbar { width: 60%; height: 90px; }
svg.wbar rect { fill: var(--accent); }

/* forms */
form.inline { display: flex; gap: .5rem; flex-wrap: wrap; }
input { font: inherit; min-height: 38px; padding: 0 .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); min-width: 0; flex: 1; max-width: 22rem; }
body.center { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: .9rem; padding: 1.6rem; }
.login label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
.login input { max-width: none; color: var(--text); }
.login button { min-height: 40px; }

@media (max-width: 760px) {
  .bar { gap: .8rem; padding: 0 16px; }
  .bar .brand { display: none; }
  svg.axis text:nth-child(even) { display: none; }
  .bar nav a, .bar button.link { white-space: nowrap; }
  main { padding: 1rem 16px 2rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cols { grid-template-columns: 1fr; }
  .ellipsis { max-width: 9rem; }
}
