/* Clinic Tracker — dark ledger shell (shared with the trading tools), EHN green accent. */
:root {
  --bg: #13171a;
  --panel: #1c2225;
  --panel-2: #242c30;
  --line: #2f3a3f;
  --line-soft: #283135;
  --text: #f0f3f1;
  --text-dim: #a5b1ab;
  --text-faint: #6f7d76;
  --brand: #39B54A;
  --brand-soft: #3DBF52;
  --brand-dim: rgba(57, 181, 74, 0.14);
  --brand-ink: #08160b;
  --ret: #7fb8a4;
  --calls: #6fb3e0;
  --up: #39B54A;
  --down: #ff8e5e;
  --down-dim: rgba(255, 142, 94, 0.14);
  --sans: "Archivo", -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Menlo, monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { color-scheme: dark; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  background-image: radial-gradient(1100px 420px at 75% -10%, rgba(57, 181, 74, 0.07), transparent 60%);
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px 80px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 22px 24px;
  margin-top: 18px;
}
.panel h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--brand); font-weight: 600; margin-bottom: 14px; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); font-size: 0.85rem; }
.mono { font-family: var(--mono); }

header { display: flex; align-items: baseline; justify-content: space-between; padding: 24px 4px 6px; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand h1 { font-weight: 800; font-size: 1.35rem; letter-spacing: -0.01em; }
.brand h1 em { color: var(--brand); font-style: normal; }
.tag { font-family: var(--mono); font-size: 0.72rem; color: var(--text-faint); }
header nav { display: flex; gap: 6px; }
header nav a { color: var(--text-dim); font-weight: 600; font-size: 0.9rem; text-decoration: none; padding: 6px 12px; border-radius: 8px; }
header nav a:hover { color: var(--text); background: var(--panel-2); }
header nav a.active { color: var(--brand-ink); background: var(--brand); }

button, .btn {
  font: inherit; font-weight: 600; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 16px; cursor: pointer;
}
button:hover { border-color: var(--brand); }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.primary:hover { background: var(--brand-soft); }
button.ghost { background: transparent; }
button.small { padding: 5px 10px; font-size: 0.85rem; border-radius: 8px; }
button:disabled { opacity: 0.5; cursor: default; }
input, select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--brand); }
input[type="number"] { font-family: var(--mono); text-align: center; }
input[type="date"], input[type="month"] { font-family: var(--mono); }

/* today page */
.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .today-grid { grid-template-columns: 1fr; } }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row + .row { margin-top: 14px; }
.stepper { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.stepper:last-of-type { border-bottom: 0; }
.stepper .lbl { font-weight: 600; }
.stepper .lbl small { display: block; font-weight: 400; color: var(--text-faint); font-size: 0.8rem; }
.stepper button { width: 46px; height: 46px; font-size: 1.3rem; border-radius: 12px; padding: 0; }
.stepper input { width: 70px; height: 46px; font-size: 1.25rem; }
.stepper.is-off { opacity: 0.35; pointer-events: none; }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { width: 20px; height: 20px; accent-color: var(--brand); }
.status { min-height: 1.4em; font-size: 0.9rem; }
.status.ok { color: var(--brand); }
.status.err { color: var(--down); }
.note { background: var(--brand-dim); border: 1px solid rgba(57,181,74,0.3); border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; margin-top: 12px; }
.note.warn { background: var(--down-dim); border-color: rgba(255,142,94,0.35); }

.list { list-style: none; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.list li:last-child { border-bottom: 0; }
.list .d { font-family: var(--mono); font-size: 0.9rem; }
.list .v { color: var(--text-dim); font-size: 0.9rem; }
.pill { font-family: var(--mono); font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--text-dim); }
.pill.off { color: var(--down); }
.pill.approx { color: #e0c46f; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.card { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 14px 16px; }
.card .k { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }
.card .v { font-family: var(--mono); font-size: 1.5rem; font-weight: 600; margin-top: 4px; }
.card .s { font-size: 0.85rem; color: var(--text-dim); margin-top: 2px; }
.delta { font-family: var(--mono); font-weight: 600; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--text-faint); }

/* trends */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 7px 14px; }
.seg button.active { background: var(--brand); color: var(--brand-ink); }
.chart-wrap { position: relative; height: 300px; margin-top: 8px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-grid .panel { margin-top: 0; }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.compare { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 14px 16px; }
.compare h3 { font-size: 0.9rem; margin-bottom: 8px; }
.compare h3 small { color: var(--text-faint); font-weight: 400; margin-left: 6px; }
.compare table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.compare td { padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.compare td:not(:first-child) { text-align: right; font-family: var(--mono); }
.compare tr:last-child td { border-bottom: 0; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; white-space: nowrap; }
table.tbl th { text-align: right; font-weight: 600; color: var(--text-faint); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }
table.tbl td { text-align: right; font-family: var(--mono); padding: 7px 10px; border-bottom: 1px solid var(--line-soft); }
table.tbl tr.total td { font-weight: 700; border-top: 1px solid var(--line); }

/* history grid */
.hist { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.88rem; }
.hist th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); padding: 6px 4px; text-align: center; }
.hist td { padding: 4px; text-align: center; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.hist td.wk { text-align: left; font-family: var(--mono); color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; }
.hist .day { display: grid; grid-template-columns: 52px 52px 52px auto; gap: 4px; align-items: center; justify-content: center; }
.hist .day input[type="number"] { padding: 6px 4px; width: 52px; }
.hist .day.off input[type="number"] { opacity: 0.3; }
.hist .day.other { opacity: 0.25; pointer-events: none; }
.hist .day .dn { font-family: var(--mono); font-size: 0.72rem; color: var(--text-faint); grid-column: 1 / -1; text-align: left; }
.hist .day.dirty input { border-color: var(--brand); }
.hist .day label { font-size: 0.72rem; color: var(--text-faint); display: flex; align-items: center; gap: 3px; }
.hist .day label input { accent-color: var(--down); }
.hist td.tot { font-family: var(--mono); color: var(--text-dim); }

/* passcode overlay */
.overlay[hidden] { display: none; }
.overlay { position: fixed; inset: 0; background: rgba(10,13,14,0.9); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.overlay .box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: min(380px, 100%); }
.overlay h2 { margin-bottom: 6px; }
.overlay p { color: var(--text-dim); margin-bottom: 16px; font-size: 0.92rem; }
.overlay input { width: 100%; font-size: 1.1rem; margin-bottom: 12px; font-family: var(--mono); }

/* comparison cards: current period bright, previous period lighter */
.compare td:nth-child(2) { color: var(--text); font-weight: 600; }
.compare td:nth-child(3) { color: var(--text-faint); }
.compare thead th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); font-weight: 600; text-align: right; padding-bottom: 4px; }
.compare thead th:first-child { text-align: left; }
.compare td:not(:first-child), .compare th:not(:first-child) { padding-left: 14px; }
.compare td:last-child, .compare th:last-child { padding-left: 22px; }

/* history on narrow screens: one block per week, days stacked */
.hist .day .dn b { color: var(--text-dim); font-weight: 600; }
@media (max-width: 700px) {
  .hist thead { display: none; }
  .hist, .hist tbody { display: block; }
  .hist tr { display: block; border-top: 1px solid var(--line); padding: 8px 0 4px; }
  .hist td { display: block; border-top: 0; padding: 3px 0; text-align: left; }
  .hist td.wk { font-size: 0.85rem; color: var(--text); padding-bottom: 6px; }
  .hist td.wk::before { content: "Week of "; color: var(--text-faint); }
  .hist .day { justify-content: start; grid-template-columns: 60px 60px 60px auto; }
  .hist .day .dn { text-align: left; }
  .hist td.tot { padding-top: 6px; }
  .hist td.tot::before { content: "Week total: "; color: var(--text-faint); font-family: var(--sans); }
  .hist td.tot br { display: none; }
  .hist td.tot .faint::before { content: " · "; }
  .history-top { flex-wrap: nowrap; }
}

/* history inputs: typed numbers in brand green, placeholders stay faint */
.hist .day input[type="number"] { color: var(--brand); font-weight: 600; }
.hist .day input[type="number"]::placeholder { color: var(--text-faint); font-weight: 400; opacity: 0.6; }
.hist .day.off input[type="number"] { color: var(--text-faint); }
.stepper input { color: var(--brand); font-weight: 600; }
