:root {
  --bg: #0b0f14; --panel: #121821; --line: #233041; --text: #d6dde6; --muted: #8a97a8;
  --accent: #ff5d73; --accent-2: #4cc2ff; --ok: #3fb950; --warn: #d29922; --bad: #f85149;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent-2); }
code { background: #1b2430; padding: 1px 5px; border-radius: 4px; font-size: .92em; }
h1 { font-size: 1.4rem; margin: 0 0 1rem; } h2 { font-size: 1.1rem; margin: 0 0 .8rem; } h3 { font-size: .95rem; margin: 1.2rem 0 .4rem; }
.logo { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .err { color: var(--bad); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; }
.card.danger { border-color: #5a2a2e; }
.stack { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.row { display: flex; gap: 8px; } .row input { flex: 1; min-width: 0; }
input, button { font: inherit; color: inherit; }
input[type=email], input[readonly] { background: #0d1117; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
input[readonly] { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; }
button { background: #1b2430; border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { background: #3a1519; border-color: var(--bad); color: #ffb3b8; }
button.link { background: none; border: none; padding: 0; color: var(--accent-2); text-decoration: underline; }
progress { width: 100%; }
ol { padding-left: 1.2rem; } li { margin: .3rem 0; }

/* sign-in / privacy */
body.narrow { display: grid; place-items: center; padding: 16px; }
body.narrow main { width: 100%; max-width: 460px; }
body.narrow main.prose { max-width: 720px; }
.lede { color: var(--muted); }

/* app */
body.app { display: flex; flex-direction: column; overflow: hidden; }
header { display: flex; align-items: center; gap: 18px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.brand { font-weight: 700; }
nav { display: flex; gap: 4px; flex: 1; }
.tab { background: none; border: 1px solid transparent; }
.tab.active { background: #1b2430; border-color: var(--line); }
.who { color: var(--muted); font-size: .85rem; }
.pane { display: none; flex: 1; min-height: 0; }
.pane.active { display: block; }
.pane.scroll { overflow: auto; padding: 16px; }
/* explore: chart card + terminal */
.explore { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(340px, 1fr); height: 100%; min-height: 0; }
.viz-pane { overflow: auto; padding: 14px 16px 24px; min-width: 0; }
.term-pane { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: #0d1117; }
.term-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: .85rem; font-weight: 600; }
#term { flex: 1; min-height: 0; padding: 6px 0 0 10px; }
@media (max-width: 980px) {
  body.app { overflow: auto; }
  .explore { grid-template-columns: 1fr; height: auto; }
  .term-pane { border-left: 0; border-top: 1px solid var(--line); height: 70vh; }
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar select { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 28px 7px 10px; color: var(--text);
  font: inherit; font-size: .88rem; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; max-width: 240px; }
.toolbar select:hover, .seg button:hover { border-color: #3a4a60; }
[hidden] { display: none !important; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { border: 1px solid transparent; background: none; padding: 5px 10px; border-radius: 6px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.seg button.on { background: #223044; color: var(--text); }

.viz-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px 14px; transition: opacity .15s; }
.viz-card.loading { opacity: .55; }
.viz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.viz-title { margin: 0; font-size: 1.12rem; font-weight: 650; letter-spacing: -.01em; }
.viz-sub { margin: 3px 0 0; color: var(--muted); font-size: .84rem; }
.viz-btn { font-size: .8rem; padding: 5px 11px; border-radius: 7px; }
.viz-btn[aria-pressed=true] { background: #223044; border-color: #3a4a60; }
.viz-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0 6px; }
.viz-stats:empty { display: none; }
.stat { background: var(--raised, #18202b); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.stat-label { color: var(--muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value { font-size: 1.5rem; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; line-height: 1.2; }
.stat-sub { color: var(--muted); font-size: .76rem; margin-top: 2px; }
.stat.tone-good .stat-sub { color: #3fc93f; } .stat.tone-serious .stat-sub { color: #ec835a; }
.viz-body { margin-top: 8px; min-height: 120px; }
.viz-chart { width: 100%; }
.viz-block-label { color: var(--muted); font-size: .8rem; font-weight: 600; margin: 14px 0 -4px; }
.viz-note { color: var(--muted); font-size: .78rem; margin: 8px 0 0; }
.viz-note:empty { display: none; } .viz-note.err { color: var(--bad); }
.viz-history { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: .78rem; padding: 4px 10px; border-radius: 999px; background: var(--panel); color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.active { color: var(--text); border-color: #3a4a60; }
.viz-table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.viz-table { width: 100%; border-collapse: collapse; font-size: .82rem; font-variant-numeric: tabular-nums; }
.viz-table th { position: sticky; top: 0; background: #18202b; color: var(--muted); font-weight: 600; text-align: left; }
.viz-table th, .viz-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.viz-table td:not(:first-child), .viz-table th:not(:first-child) { text-align: right; }

/* panel tiles and score rings */
.kpi-rings { display: flex; gap: 28px; flex-wrap: wrap; margin: 10px 0 6px; }
.ring { position: relative; width: 132px; text-align: center; }
.ring svg { width: 132px; height: 132px; }
.ring-mid { position: absolute; top: 0; left: 0; width: 132px; height: 132px; display: grid; place-content: center; }
.ring-value { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; }
.ring-label { color: var(--muted); font-size: .78rem; }
.ring-status { font-size: .8rem; margin-top: 4px; }
.kpi-group { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 8px; font-weight: 600; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.kpi-tile { background: #18202b; border-radius: 12px; padding: 12px 14px 10px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 1.45rem; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; }
.kpi-unit { font-size: .8rem; color: var(--muted); font-weight: 500; }
.kpi-delta { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.tone-good { color: #3fc93f !important; } .tone-warning { color: #fab219 !important; } .tone-serious { color: #ec835a !important; }
.kpi-spark { width: 100%; height: 28px; margin-top: 6px; display: block; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; max-width: 1400px; margin: 0 auto; }
.step { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; background: var(--accent); color: #fff; font-size: .8em; margin-right: 6px; }
table.jobs { width: 100%; border-collapse: collapse; font-size: .82rem; }
table.jobs td { padding: 5px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.st-done { color: var(--ok); } .st-failed { color: var(--bad); } .st-running, .st-queued { color: var(--warn); }
@media (max-width: 600px) { header { gap: 8px; } .who { width: 100%; } }

/* ask bar + answer card */
.askbar { display: flex; gap: 8px; margin-bottom: 10px; }
.askbar input { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; color: var(--text); font: inherit; }
.askbar input:focus { outline: none; border-color: var(--accent-2); }
.answer { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
  margin-bottom: 12px; max-height: 38vh; overflow: auto; line-height: 1.5; }
.answer p { margin: 0 0 8px; }
.answer ul { margin: 0 0 6px; padding-left: 18px; }
.answer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.answer .tag { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.learned-row { border-top: 1px solid var(--line); padding: 8px 0; }
.learned-row button { float: right; }

/* notes */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips label { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; font-size: 13px; }
.chips input { display: none; }
.chips label:has(input:checked) { border-color: var(--accent-2); color: var(--accent-2); }
#note-form textarea { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text);
  padding: 8px; font: inherit; margin-bottom: 8px; box-sizing: border-box; }
#note-form input[type=date] { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; color: var(--text); padding: 4px 6px; }
.row.wrap { flex-wrap: wrap; gap: 12px; }
.note-row { border-top: 1px solid var(--line); padding: 8px 0; }
.note-row button { float: right; }
.note-row button + button { margin-right: 14px; }
.status-table { border-collapse: collapse; width: 100%; margin-bottom: 10px; }
.status-table td, .status-table th { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }
.row input[type=checkbox] { flex: none; margin-top: 3px; accent-color: var(--accent-2); }
label.row { align-items: flex-start; margin-top: 10px; }

/* Explore: derived / raw data dropdowns and the raw data view */
.toolbar { align-items: flex-end; }
.tsel { display: flex; flex-direction: column; gap: 3px; }
.tsel span { font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding-left: 2px; }
.toolbar:not(.raw-mode):not(.circ-mode) #kind, .toolbar.raw-mode #raw-kind, .toolbar.circ-mode #circ-kind { border-color: var(--accent); }
.rv-chart { width: 100%; min-height: 200px; }
.rv-actions { align-items: center; margin: 4px 0; } .rv-actions button { flex: none; }
.raw-viz h3 { margin: 16px 0 2px; font-size: 1rem; }
.raw-viz details { margin-top: 14px; } .raw-viz summary { cursor: pointer; color: var(--muted); }
.rv-scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; }
.rv-method pre { white-space: pre-wrap; margin: 6px 0 0; }

/* Team: master dashboard for coaches and clinicians; invitation banner */
.team { max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.team > .toolbar { margin-bottom: 0; }
.hscroll { overflow-x: auto; margin-bottom: 14px; }
.team-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.team-head h2 { margin: 0; }
#team-main { display: flex; flex-direction: column; gap: 16px; }
.team input[type=text], .team input[type=email], #leader-form input, .banner input { background: #0d1117; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.team select, #team-create select { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; color: var(--text); font: inherit; font-size: .88rem; }
.roster { border-collapse: collapse; width: 100%; font-size: .85rem; }
.roster th { text-align: right; font-weight: 600; color: var(--muted); font-size: .74rem; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; }
.roster th:first-child, .roster td:first-child, .roster td.flags, .roster th.flags { text-align: left; }
.roster td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.roster td.flags { white-space: normal; min-width: 180px; color: var(--muted); }
.roster td.flags b { color: #ec835a; font-weight: 600; }
.roster tbody tr:hover { background: #18202b; cursor: pointer; }
.roster tr.sel { background: #1b2430; }
.roster .sub { display: block; font-size: .72rem; color: var(--muted); }
.banner { background: #13263a; border-bottom: 1px solid #24476b; padding: 10px 16px; font-size: .9rem; }
.banner .inv { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; max-width: 1400px; margin: 0 auto; }
.banner .inv + .inv { margin-top: 8px; padding-top: 8px; border-top: 1px solid #24476b; }
.banner .inv p { margin: 0; flex: 1 1 420px; }
.share-row { border-top: 1px solid var(--line); padding: 8px 0; }
.share-row button { float: right; }

/* circadian: the list of days that broke the pattern */
.circ-disruptions ul { margin: 10px 0 0; padding-left: 18px; font-size: .85rem; columns: 2 320px; column-gap: 28px; }
.circ-disruptions li { margin: 2px 0; break-inside: avoid; }
.circ-ctl { display: contents; }
.circ-ctl[hidden] { display: none; }
.toolbar input[type=date] { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; color: var(--text); font: inherit; font-size: .85rem; color-scheme: dark; }
.toolbar input[type=date]:focus { outline: none; border-color: var(--accent-2); }

/* Data tab: trimming a big Apple export before upload */
.trim { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #0f151d; }
.trim p { margin: 0 0 8px; }
.trim select, .trim input[type=date] { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; color: var(--text); font: inherit; font-size: .85rem; color-scheme: dark; }

/* Explore → Adjust: outliers, baseline, trend (a small menu, so the toolbar stays short) */
.adjust { position: relative; }
.adjust summary { list-style: none; cursor: pointer; background: #1b2430; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-size: .88rem; }
.adjust summary::-webkit-details-marker { display: none; }
.adjust[open] summary, .adjust summary:hover { border-color: #3a4a60; }
.adjust-n:not(:empty) { margin-left: 6px; background: var(--accent-2); color: #0b0f14; border-radius: 9px; padding: 0 6px; font-size: .75rem; font-weight: 700; }
.adjust-body { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: 290px; display: grid; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.4); }
.adjust-body select { max-width: none; width: 100%; }
.adjust-body .check { display: flex; gap: 8px; align-items: center; font-size: .88rem; }
.adjust-body p { margin: 0; }
@media (max-width: 600px) {   /* phones: the menu opens inline, full width, instead of floating off the edge */
  .adjust[open] { flex-basis: 100%; }
  .adjust-body { position: static; width: auto; margin-top: 6px; box-shadow: none; }
}
.saved { display: inline-flex; align-items: flex-end; gap: 8px; }
.saved .link, .saved .muted { padding-bottom: 8px; }
.toolbar .check { display: inline-flex; gap: 6px; align-items: center; padding-bottom: 8px; }
.share-row .grp { display: inline-flex; gap: 6px; margin-left: 8px; }
.share-row .grp input { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; color: var(--text); font: inherit; font-size: .8rem; color-scheme: dark; }
.share-row .grp input[type=text] { width: 110px; }
