:root {
  color-scheme: dark;
  --bg: #0f1113;
  --surface: #181b1f;
  --surface-2: #22262b;
  --line: #2c3137;
  --text: #f2f4f5;
  --muted: #9aa3ab;
  --accent: #c8f04a;
  --accent-ink: #13180a;
  --warn: #ffb547;
  --danger: #ff6b5e;
  --ok: #5fd38d;
  --radius: 16px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

main.wide { max-width: 1180px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); text-decoration: none; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

h1 { font-size: 30px; line-height: 1.1; margin: 0 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.sub { color: var(--muted); margin: 0 0 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip {
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.banner {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  background: rgba(255, 181, 71, 0.12);
  border: 1px solid rgba(255, 181, 71, 0.4);
  color: var(--warn);
  font-size: 15px;
}

.row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.big { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.big small { font-size: 16px; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }

.target { border-color: rgba(200, 240, 74, 0.45); }
.target .reason { color: var(--accent); font-size: 14px; margin-top: 4px; }

.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.stepper {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 10px;
  text-align: center;
}
.stepper label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.stepper .controls { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.stepper .btn.round { background: var(--line); width: 40px; height: 40px; }
.stepper input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--text);
  font: 700 24px var(--font);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.stepper input:focus { outline: none; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font: 600 16px var(--font);
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); width: 100%; padding: 18px; font-size: 19px; }
.btn.round { width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 22px; flex: none; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }

.set-list { list-style: none; margin: 0; padding: 0; }
.set-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.set-list li:first-child { border-top: 0; }

.rest {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px 14px;
  margin-top: 12px;
}
.rest .time { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rest .bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.rest .bar span { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }

.links { display: flex; gap: 10px; margin-top: 18px; }
.links .btn { flex: 1; }

.footer-note { margin-top: 22px; text-align: center; color: var(--muted); font-size: 12px; }

/* overlay dialogs */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
  padding: 16px;
}
.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
}
.sheet h3 { margin: 0 0 6px; font-size: 20px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 14px; }
.sheet .actions .btn { flex: 1; }

input.field, select.field, textarea.field {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font: 16px var(--font);
  margin-top: 8px;
}
textarea.field { min-height: 80px; resize: vertical; }

.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  z-index: 20;
}

/* progress page */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .delta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.caption { font-size: 13px; }
p.caption { margin: -4px 0 12px; }
.streak { font-size: 13px; color: var(--accent); font-weight: 600; }
.banner.neutral { background: var(--surface); border-color: var(--line); color: var(--muted); }

/* charts: single accent, recessive grid and axes */
.chart { position: relative; margin-top: 8px; touch-action: pan-y; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 11px var(--font); }
.chart .value { fill: var(--text); font: 600 12px var(--font); font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--accent); }
.chart .bar.dim { fill-opacity: 0.45; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); fill-opacity: 0.08; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .marker { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .cell { stroke: none; }
.l0 { fill: var(--surface-2); background: var(--surface-2); }
.l1 { fill: rgba(200, 240, 74, 0.28); background: rgba(200, 240, 74, 0.28); }
.l2 { fill: rgba(200, 240, 74, 0.5); background: rgba(200, 240, 74, 0.5); }
.l3 { fill: rgba(200, 240, 74, 0.75); background: rgba(200, 240, 74, 0.75); }
.l4 { fill: var(--accent); background: var(--accent); }
.legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.cell-key { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--text);
  color: var(--bg);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.tip div { color: #3b4249; }

.hbar { display: grid; grid-template-columns: 84px 1fr 32px; align-items: center; gap: 10px; padding: 5px 0; }
.hbar-label { font-size: 14px; }
.hbar-track { height: 10px; background: var(--surface-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar-track span { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar-value { font-size: 13px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.seg { display: flex; gap: 6px; overflow-x: auto; margin: 10px -16px 0; padding: 0 16px 4px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg .chip { border: 1px solid var(--line); background: transparent; font: 13px var(--font); white-space: nowrap; cursor: pointer; padding: 6px 12px; }
.seg .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.machine-row { cursor: pointer; }
.saved-note { margin-left: 8px; font-size: 13px; color: var(--accent); }
.error-note { color: var(--danger); font-size: 14px; margin: 8px 0 0; }
.error-note:empty { display: none; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi .v { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi .k { color: var(--muted); font-size: 14px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 13px; padding: 0 8px 8px; }
td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
.usage { display: flex; align-items: center; gap: 8px; }
.usage .track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; min-width: 60px; }
.usage .track span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: rgba(95, 211, 141, 0.14); color: var(--ok); }
.pill.reported { background: rgba(255, 181, 71, 0.14); color: var(--warn); }
.pill.maintenance { background: rgba(255, 107, 94, 0.14); color: var(--danger); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 10px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
.feed li:first-child { border-top: 0; }
.feed .when { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.feed li.fresh { animation: flash 2s ease-out; }
@keyframes flash { from { background: rgba(200, 240, 74, 0.18); } to { background: transparent; } }

.hours { display: flex; align-items: flex-end; gap: 3px; height: 110px; }
.hours div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: 0.85; }
.hours-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }

.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
