:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2563eb;

  /* The bands snap-fit.de uses, so the colours read the same way. */
  --quiet: #16a34a;
  --moderate: #eab308;
  --busy: #dc2626;
  --closed: #eceff3;

  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a21;
    --ink: #e8eaed;
    --muted: #9aa3af;
    --line: #262b34;
    --accent: #60a5fa;
    --closed: #1d222a;
  }
}

* { box-sizing: border-box; }

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

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

/* --- chrome ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.brand span { color: var(--muted); font-weight: 400; }

.topbar nav { display: flex; gap: 16px; }
.topbar nav a { text-decoration: none; color: var(--muted); padding: 4px 0; }
.topbar nav a.active { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }

.logout { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 13px; }

main { max-width: 1180px; margin: 0 auto; padding: 24px; }

footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 40px;
  color: var(--muted);
  font-size: 13px;
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 12px; text-transform: uppercase;
     letter-spacing: .06em; color: var(--muted); }

/* --- layout ------------------------------------------------------------ */

.studios { display: grid; gap: 24px; grid-template-columns: 1fr; }

/* Side by side once there is room: comparing the two studios is half the point. */
@media (min-width: 1100px) {
  .studios { grid-template-columns: 1fr 1fr; }
}

.studio { min-width: 0; }

.studio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  min-width: 0;
}

/* --- live number ------------------------------------------------------- */

.now {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border-left: 4px solid var(--muted);
  background: var(--panel);
  flex-wrap: wrap;
}

.now-count { font-size: 26px; font-weight: 700; }
.now-meta, .now-delta { color: var(--muted); font-size: 13px; }
.now-delta { font-style: italic; }

.now.band-quiet { border-left-color: var(--quiet); }
.now.band-moderate { border-left-color: var(--moderate); }
.now.band-busy { border-left-color: var(--busy); }

/* --- recommendations --------------------------------------------------- */

.recs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.recs li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg);
  border-left: 4px solid var(--muted);
  flex-wrap: wrap;
}

.recs li.band-quiet { border-left-color: var(--quiet); }
.recs li.band-moderate { border-left-color: var(--moderate); }
.recs li.band-busy { border-left-color: var(--busy); }

.rec-when { font-weight: 600; }
.rec-stat { color: var(--muted); font-size: 13px; }
.rec-n { margin-left: auto; color: var(--muted); font-size: 12px; }

/* --- heatmap ----------------------------------------------------------- */

.heatmap-scroll { overflow-x: auto; }

.heatmap { border-collapse: collapse; width: 100%; min-width: 320px; }
.heatmap th { font-weight: 600; font-size: 12px; color: var(--muted); padding: 2px; }
.heatmap .time-col {
  width: 46px;
  text-align: right;
  padding-right: 8px;
  font-variant-numeric: tabular-nums;
}

.cell {
  height: 11px;
  border-radius: 2px;
  border: 1px solid var(--panel);
  background: var(--closed);
}

/* Intensity carries the magnitude, hue carries the band, so the grid stays
   readable for viewers who cannot separate the three hues. */
.cell.band-quiet    { background: color-mix(in srgb, var(--quiet)    calc(35% + var(--intensity) * 65%), transparent); }
.cell.band-moderate { background: color-mix(in srgb, var(--moderate) calc(35% + var(--intensity) * 65%), transparent); }
.cell.band-busy     { background: color-mix(in srgb, var(--busy)     calc(35% + var(--intensity) * 65%), transparent); }

.cell.no-data {
  background: repeating-linear-gradient(45deg,
    var(--closed), var(--closed) 2px, transparent 2px, transparent 4px);
}

/* When a date is being planned for, the rest of the week recedes rather than
   disappearing — the surrounding days are still context. */
.cell.dim { opacity: .22; }
.heatmap th.highlight { color: var(--accent); font-weight: 700; }

.clear-date { font-size: 12px; }

.scale { margin-top: 12px; font-size: 12px; color: var(--muted); }

.key {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 2px;
  margin: 0 4px 0 12px;
  vertical-align: -1px;
}
.scale .key:first-child { margin-left: 0; }
.key.band-quiet { background: var(--quiet); }
.key.band-moderate { background: var(--moderate); }
.key.band-busy { background: var(--busy); }
.key.closed { background: var(--closed); border: 1px solid var(--line); }
.key.no-data {
  border: 1px solid var(--line);
  background: repeating-linear-gradient(45deg,
    var(--closed), var(--closed) 2px, transparent 2px, transparent 4px);
}
.key.actual { background: var(--accent); }
.key.typical { background: var(--muted); }

/* --- charts ------------------------------------------------------------ */

.chart { margin: 0; }
.chart svg { width: 100%; height: auto; overflow: visible; }

.grid { stroke: var(--line); stroke-width: 1; }
.axis { fill: var(--muted); font-size: 10px; }
.xaxis { text-anchor: middle; }

.series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series.actual { stroke: var(--accent); }
.series.typical { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 3; }

.legend { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* --- tables ------------------------------------------------------------ */

.trend-table, .settings-table { width: 100%; border-collapse: collapse; font-size: 14px; }

.trend-table th, .trend-table td,
.settings-table th, .settings-table td {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
}

.trend-table th, .settings-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.trend-table td.band-quiet { color: var(--quiet); font-weight: 600; }
.trend-table td.band-moderate { color: var(--moderate); font-weight: 600; }
.trend-table td.band-busy { color: var(--busy); font-weight: 600; }

tr.disabled { opacity: .55; }

/* An account waiting for a grant is the one row here that wants acting on. */
tr.pending td:first-child { font-weight: 600; }
tr.pending { background: color-mix(in srgb, var(--accent) 7%, transparent); }

/* --- forms ------------------------------------------------------------- */

button {
  font: inherit;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button.danger { background: var(--busy); }
.logout button { background: transparent; color: var(--muted); border-color: var(--line); }

input, select {
  font: inherit;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

input[type="number"] { width: 80px; }

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.window-picker { display: flex; align-items: center; gap: 8px; color: var(--muted); }

/* Two forms stacked in one panel — save, then reset — need the gap a single
   form's own layout would have given them. */
.panel form + form { margin-top: 10px; }

/* --- auth -------------------------------------------------------------- */

.auth-card {
  max-width: 380px;
  margin: 60px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}

.auth-card form { display: grid; gap: 6px; margin-top: 16px; }
.auth-card label { font-size: 13px; color: var(--muted); }
.auth-card button { margin-top: 12px; }
.auth-card small { color: var(--muted); font-size: 12px; }

/* --- messages ---------------------------------------------------------- */

.note, .empty, .muted { color: var(--muted); font-size: 13px; }
.empty { font-style: italic; }
.note { margin: 12px 0 0; }

.error {
  color: var(--busy);
  background: color-mix(in srgb, var(--busy) 10%, transparent);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.callout {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
}

.invite-link { word-break: break-all; font-size: 12px; }
