:root {
  color-scheme: light dark;
  --bg: #fbfbfa;
  --surface: #ffffff;
  --border: #e3e2df;
  --border-strong: #c9c7c2;
  --text: #1b1b19;
  --muted: #6b6a66;
  --accent: #2f6f4f;
  --accent-text: #ffffff;
  --block: #3d8f66;
  --block-edge: #2c6b4c;
  --override: #9a6a1f;
  --override-edge: #7a5217;
  --gap: #d9d7d2;
  --danger: #a33a2a;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --surface: #1f2123;
    --border: #32353a;
    --border-strong: #474b52;
    --text: #e8e8e6;
    --muted: #9b9ea4;
    --accent: #5fae86;
    --accent-text: #10201a;
    --block: #4f9e76;
    --block-edge: #6fc096;
    --override: #c89240;
    --override-edge: #e0ae5c;
    --gap: #2a2d31;
    --danger: #d9705c;
  }
}

* { box-sizing: border-box; }

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

.top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand strong { font-size: 1.15rem; letter-spacing: 0.06em; }
.brand .expand { color: var(--muted); font-size: 0.85rem; margin-left: 0.6rem; }
.who { display: flex; align-items: baseline; gap: 0.75rem; font-size: 0.9rem; color: var(--muted); }

main { max-width: 74rem; margin: 0 auto; padding: 1.25rem; }
.loading { color: var(--muted); }

.columns {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
}
.card { min-width: 0; }
.card.wide { margin-top: 1rem; }
.card.centre { max-width: 32rem; margin: 3rem auto; }
.card h1 { font-size: 1.25rem; margin: 0 0 0.75rem; }
.card h2 { font-size: 1rem; margin: 0 0 0.35rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.9rem; }

button, .button, select, input {
  font: inherit; color: inherit;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
}
button, .button { cursor: pointer; }
button:hover:not(:disabled), .button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
.primary, .button {
  background: var(--accent); color: var(--accent-text);
  border-color: var(--accent); font-weight: 500;
  text-decoration: none; display: inline-block;
}
button.link {
  background: none; border: none; padding: 0;
  color: var(--accent); text-decoration: underline; font-size: inherit;
}
.group { display: inline-flex; }
.group button { border-radius: 0; margin-left: -1px; }
.group button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.group button:last-child { border-radius: 0 6px 6px 0; }
.group button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.field { display: block; margin: 0 0 0.7rem; }
.field > span:first-child { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.2rem; }
.field.inline { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.field.inline > span { display: inline; font-size: 0.85rem; color: var(--muted); margin: 0; }
.row { display: flex; gap: 0.5rem; align-items: center; }
.row select { flex: 1; min-width: 0; }

.quick { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.8rem; }
.quick button { font-size: 0.85rem; }

/* --- the hours editor: any number of intervals per day ---
   One flexible wrapping row per day. A rigid grid column for the action button
   overflowed the panel, because two time inputs plus a day name already fill a
   20rem card; letting everything wrap keeps it inside at any width. */
.days { font-size: 0.9rem; min-width: 0; }
.day {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.3rem 0.45rem; min-width: 0;
  padding: 0.4rem 0; border-top: 1px solid var(--border);
}
.day:first-child { border-top: none; }
.day.is-off .dname { color: var(--muted); }
.dname { flex: 0 0 2.6rem; white-space: nowrap; }
.ivs {
  display: flex; flex-wrap: wrap; gap: 0.3rem 0.4rem;
  align-items: center; flex: 1 1 auto; min-width: 0;
}
.iv {
  display: inline-flex; align-items: center; flex-wrap: wrap;
  gap: 0.1rem; flex: 0 1 auto; max-width: 100%; min-width: 0;
}
.iv input[type=time] {
  font-family: var(--mono); font-size: 0.85rem;
  width: 6rem; min-width: 0; max-width: 100%; padding: 0.2rem 0.25rem;
}
.iv .dash { color: var(--muted); }
.iv .rm {
  border: none; background: none; color: var(--muted);
  padding: 0 0.1rem; font-size: 1rem; line-height: 1;
}
.iv .rm:hover { color: var(--danger); }
.notworking { color: var(--muted); font-style: italic; }
.dact {
  flex: 0 0 auto; font-size: 0.76rem;
  padding: 0.2rem 0.4rem; white-space: nowrap;
}
.hint.small { font-size: 0.78rem; margin: 0.6rem 0 0; }

/* admin page still uses a plain table */
table.days { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.days td { padding: 0.15rem 0.3rem 0.15rem 0; }

.actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.9rem; }
.status { font-size: 0.85rem; color: var(--muted); min-height: 1.4em; }
.status.bad { color: var(--danger); }
.status.good { color: var(--accent); }
/* Saved, but it will not reach incident.io yet - louder than 'good', calmer
   than 'bad', because nothing has been lost. */
.status.warn {
  color: var(--override);
  border-left: 3px solid var(--override);
  padding-left: 8px;
}
.utc-preview { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); margin: 0.6rem 0 0; white-space: pre-wrap; }

.planned { margin: 0.5rem 0 0.75rem; font-size: 0.9rem; }
.planned summary { cursor: pointer; color: var(--accent); }
.planned > * { margin-top: 0.5rem; }

ul.mutes, ul.teams { list-style: none; margin: 0.5rem 0 0; padding: 0; }
ul.mutes li, ul.teams li {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.4rem 0; border-top: 1px solid var(--border); font-size: 0.88rem;
}
ul.mutes li span.when { font-family: var(--mono); font-size: 0.8rem; }
ul.teams li .tname { font-weight: 500; }
ul.teams li .tmeta { color: var(--muted); font-size: 0.8rem; }

.week-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.week-controls { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* --- the week grid --- */
.week { overflow-x: auto; }
.week-inner { min-width: 46rem; }
.week-dates {
  display: grid; grid-template-columns: 9rem repeat(7, 1fr);
  font-size: 0.75rem; color: var(--muted);
}
.week-dates div { padding: 0 0 0.25rem 0.35rem; border-left: 1px solid var(--border); }
.week-dates div:first-child { border-left: none; }
.week-dates div.today { color: var(--accent); font-weight: 600; }

.week-row { display: grid; grid-template-columns: 9rem 1fr; align-items: stretch; border-top: 1px solid var(--border); }
.week-row .label { padding: 0.45rem 0.5rem 0.45rem 0; font-size: 0.85rem; overflow: hidden; }
.week-row .label .sub { display: block; color: var(--muted); font-size: 0.72rem; font-family: var(--mono); }
.week-row.is-out .label { opacity: 0.55; }

.track { position: relative; height: 2.1rem; background: var(--gap); border-radius: 3px; overflow: hidden; }
.track .daylines { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(7, 1fr); }
.track .daylines i { border-left: 1px solid var(--surface); }
.track .daylines i:first-child { border-left: none; }
.track .now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); }

.blk {
  position: absolute; top: 3px; bottom: 3px;
  background: var(--block); border: 1px solid var(--block-edge);
  border-radius: 3px; min-width: 2px;
  font-size: 0.68rem; line-height: 1.55rem; color: #fff;
  padding: 0 0.25rem; overflow: hidden; white-space: nowrap;
}
.blk.override { background: var(--override); border-color: var(--override-edge); }
.blk.nobody {
  background: repeating-linear-gradient(45deg, var(--gap), var(--gap) 4px, var(--border-strong) 4px, var(--border-strong) 8px);
  border-color: var(--border-strong); color: var(--text);
}

.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.75rem; color: var(--muted); margin-top: 0.7rem; }
.legend span { display: flex; align-items: center; gap: 0.3rem; }
.legend i { width: 0.9rem; height: 0.9rem; border-radius: 2px; display: inline-block; }
.legend i.b { background: var(--block); border: 1px solid var(--block-edge); }
.legend i.o { background: var(--override); border: 1px solid var(--override-edge); }
.legend i.n { background: repeating-linear-gradient(45deg, var(--gap), var(--gap) 3px, var(--border-strong) 3px, var(--border-strong) 6px); border: 1px solid var(--border-strong); }

code { font-family: var(--mono); font-size: 0.9em; }
.empty { color: var(--muted); font-size: 0.88rem; padding: 0.8rem 0; }

/* A past mute is history: present but visibly spent, so it does not read as
   something still shaping the schedule. */
ul.mutes li.past span.when { opacity: 0.55; text-decoration: line-through; }
ul.mutes li.past { opacity: 0.8; }
.muted-note { color: var(--muted); font-size: 0.8rem; }

/* Marking a teammate off call: the controls read as one row on a wide screen
   and stack on a narrow one. */
.cover-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.cover-row .field { flex: 1 1 12rem; margin: 0; }
.by-other { color: var(--accent, inherit); font-weight: 600; }

/* Admin overview: a table you can scan down a column of, not prose. */
table.overview { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.overview th, table.overview td {
  text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border);
}
table.overview th {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); font-weight: 600; border-bottom-width: 2px;
}
table.overview td.num, table.overview th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.overview td.warn { color: var(--danger); font-weight: 600; }
table.overview tr:last-child td { border-bottom: none; }
.attention-head { font-size: 0.95rem; margin: 1.6rem 0 0.2rem; }
#overview-detail details { margin: 0.4rem 0; }
#overview-detail summary { cursor: pointer; padding: 0.35rem 0; font-size: 0.9rem; }
