:root {
  --bg: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --line: #d9dee7;
  --accent: #1d4ed8;
  --danger: #b91c1c;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --row: #f8fafc;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f16;
    --fg: #e8edf5;
    --muted: #94a3b8;
    --line: #27303f;
    --accent: #7ea2ff;
    --danger: #f87171;
    --warn: #fbbf24;
    --warn-bg: #1f1a0b;
    --row: #111826;
  }
}

* { box-sizing: border-box; }

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

header {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
}

header .wordmark { font-size: 18px; font-weight: 700; color: var(--fg); text-decoration: none; }
header .setup { margin-left: auto; color: var(--muted); text-decoration: none; font-size: 15px; }
header .setup.active, header .setup:hover { color: var(--fg); }

main { padding: 28px 32px 64px; width: 100%; }

h1 { font-size: 26px; margin: 0 0 6px; }

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

.error {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid currentColor;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 16px;
}

input, select, textarea, button {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
}

button { cursor: pointer; border-color: var(--accent); color: var(--accent); }
button:disabled { color: var(--muted); border-color: var(--line); cursor: not-allowed; }

/* ── portfolio strip ─────────────────────────────────────── */

.summary {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 28px;
  margin-bottom: 26px;
}

.headline { display: flex; align-items: baseline; gap: 14px; }
.headline strong { font-size: 46px; line-height: 1; letter-spacing: -0.03em; }
.headline .muted { font-size: 17px; }

.risk-chip {
  margin-left: auto;
  color: var(--warn);
  border: 1.5px solid currentColor;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 15px;
  font-weight: 600;
}

.distribution {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  gap: 2px;
  margin-top: 18px;
}
.distribution span { display: block; height: 100%; }

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  padding: 0;
  margin: 14px 0 0;
  font-size: 15px;
}
.legend li { display: flex; align-items: center; gap: 2px; }
.legend .muted { margin-left: 6px; font-weight: 600; }

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-right: 9px;
}

.new-status { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.page-actions { margin-bottom: 20px; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 650;
  font-size: 16px;
  padding: 11px 20px;
}

.modal {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--fg);
  padding: 26px 30px 30px;
  width: min(520px, calc(100vw - 48px));
}
.modal::backdrop { background: rgb(15 23 42 / 0.45); }
.modal h2 { margin: 0 0 4px; font-size: 22px; }
.modal .detail { max-width: none; }

.modal-dismiss { float: right; }
.modal-dismiss button {
  border-color: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 2px 8px;
}
.modal-dismiss button:hover { color: var(--fg); }

.project-modal {
  width: min(760px, calc(100vw - 48px));
  max-height: calc(100vh - 80px);
}
.modal-sub { margin: 0 0 22px; font-size: 16px; font-weight: 600; }
.project-modal h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 12px;
}

/* ── the board ───────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; }

th { text-align: left; font-weight: 600; border-bottom: 2px solid var(--line); }
th a { color: var(--muted); text-decoration: none; display: block; padding: 10px 12px; font-size: 15px; }
th.sorted a { color: var(--fg); }

td { padding: 16px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: var(--row); }

/* The pipeline is the point of the page, so it takes the largest share and the rest are
   kept to what their content needs. With table-layout:fixed the header row sets these. */
.board { table-layout: fixed; }
.board th.col-project { width: 26%; }
.board th.col-holder { width: 11%; }
.board th.col-small { width: 7%; }

.board td.holder {
  white-space: nowrap;
  vertical-align: middle;
  font-size: 16px;
}
.board td.project { word-break: break-word; }

/* A button, not a link: it opens the project's modal rather than navigating. */
.project-name {
  font-weight: 650;
  font-size: 17px;
  color: var(--fg);
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.project-name:hover { color: var(--accent); text-decoration: underline; }
.percent {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 15px;
  margin-right: 10px;
}

.chip {
  display: inline-block;
  border: 1.5px solid;
  border-radius: 999px;
  padding: 1px 11px;
  font-size: 13px;
  font-weight: 600;
  margin-left: 10px;
  vertical-align: 2px;
  white-space: nowrap;
}

/* No nowrap: a long stage name has to wrap inside its own column rather than overrun
   into the next one, which is what "Deployed production" did once Pending was added. */
th.step-name {
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  padding: 0;
}
th.step-name .dot { margin-right: 6px; }
th.step-name a {
  color: var(--muted);
  text-align: center;
  padding: 10px 6px;
}
th.step-name.sorted a { color: var(--fg); }

/* The connector runs behind the marks so a row reads as one track, not five cells. */
.board td.step {
  position: relative;
  text-align: center;
  padding: 0;
  width: auto;
  /* The connector sits on the cell's mid-line, so the mark has to as well — the table
     default of top-alignment leaves the line hanging below the circles. */
  vertical-align: middle;
}
.board td.step::before,
.board td.step.done::after,
.board td.step.current::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 3px;
  margin-top: -1.5px;
}
.board td.step::before { background: var(--line); }
.board td.step-first::before { left: 50%; }
.board td.step-last::before { right: 50%; }

/* The coloured overlay stops at the current mark, so the track reads as "done up to
   here" rather than colouring a step the project has not reached. */
.board td.step.done::after, .board td.step.current::after { background: var(--phase); }
.board td.step.done.step-first::after { left: 50%; }
.board td.step.done.step-last::after { right: 50%; }
.board td.step.current::after { right: 50%; }
.board td.step.current.step-first::after { content: none; }

.board td.step button {
  position: relative;
  z-index: 1;
  border: none;
  background: none;
  width: 100%;
  height: 64px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: transparent;
  transition: transform 0.08s ease;
}

.step.done .mark {
  background: var(--phase);
  border-color: var(--phase);
  color: #fff;
}
.step.current .mark {
  background: var(--phase);
  border-color: var(--phase);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--phase) 24%, transparent);
}
.step.todo .mark { border-style: dashed; }

.board td.step button:hover .mark { transform: scale(1.22); }
.step.todo button:hover .mark { border-color: var(--phase); border-style: solid; }

.overdue, .stale { color: var(--warn); font-weight: 600; }
tr.at-risk td:first-child { box-shadow: inset 4px 0 0 var(--warn); }

/* ── statuses page ───────────────────────────────────────── */

.phases { margin: 0 0 34px; padding-left: 22px; font-size: 17px; }
.phases li { padding: 5px 0; }
code { font-size: 14px; background: var(--line); padding: 2px 7px; border-radius: 5px; }

.statuses { list-style: none; padding: 0; margin: 0 0 24px; }
.statuses li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.statuses form { display: flex; gap: 10px; align-items: center; }
.position { width: 76px; }
input[type="color"] { padding: 2px; width: 46px; height: 42px; }

.link-danger { border-color: transparent; color: var(--danger); }

.detail { display: grid; gap: 16px; max-width: 520px; margin: 22px 0; }
.detail label { display: grid; gap: 6px; color: var(--muted); font-size: 15px; }
.detail input, .detail select, .detail textarea { color: var(--fg); font-size: 16px; }
.detail button { justify-self: start; }
.danger button { border-color: var(--danger); color: var(--danger); }

.empty { color: var(--muted); padding: 26px 0; font-size: 16px; }

/* ── in whose hand ───────────────────────────────────────── */

.board td.holder select { border-color: transparent; font-weight: 600; }
.board td.holder select:hover { border-color: var(--line); }
.board td.holder.away select { color: var(--warn); }

.hand {
  display: block;
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
  margin-left: 12px;
}

tr.waiting td.holder { background: var(--warn-bg); }

.hand-chip {
  margin-left: auto;
  color: var(--warn);
  border: 1.5px solid currentColor;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 15px;
  font-weight: 600;
}
.hand-chip + .risk-chip { margin-left: 10px; }

.chip.is-me { border-color: var(--accent); color: var(--accent); }
.person-name { min-width: 220px; font-weight: 600; }

/* ── the checklist inside a project modal ────────────────── */

.checks {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  margin-right: 10px;
}
.checks.all-done { color: #16a34a; border-color: currentColor; }

.checklist-head { margin-bottom: 14px; }
.checklist-head h3 { display: inline-block; margin: 0; }
.checklist-count {
  float: right;
  font-size: 14px;
  font-weight: 650;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.track { border-radius: 999px; background: var(--line); overflow: hidden; }
.track span { display: block; height: 100%; background: #16a34a; }
.checklist-head .track { clear: both; margin: 10px 0 0; height: 6px; }

.sub-list { list-style: none; padding: 0; margin: 0; }

/* One row per item, tinted by its state so the list is readable without reading it. */
.sub-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--state);
  border-radius: 10px;
  background: var(--bg);
}
.sub-item.is-done { background: var(--row); border-left-color: var(--state); }
.sub-item.is-done .sub-label { text-decoration: line-through; color: var(--muted); }

.sub-state select {
  color: var(--state);
  font-weight: 650;
  font-size: 14px;
  border-color: var(--state);
  padding: 5px 8px;
  width: 128px;
}

.sub-label { font-size: 16px; flex: 1; }
.sub-when { font-size: 13px; color: var(--muted); white-space: nowrap; }

.sub-remove {
  border-color: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 2px 8px;
}
.sub-remove:hover { color: var(--danger); }

.new-sub { display: flex; gap: 10px; margin-top: 16px; }
.new-sub input { flex: 1; }

.advance { margin-top: 18px; }
.advance button {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
  font-weight: 650;
  padding: 12px 20px;
  font-size: 16px;
  width: 100%;
}

.history { margin-top: 30px; border-top: 1px solid var(--line); padding-top: 20px; }
.history-phase { margin-bottom: 18px; }
.history-phase h4 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 650;
  color: var(--muted);
  display: flex;
  align-items: center;
}
.history ul { list-style: none; padding: 0 0 0 20px; margin: 0; }
.history li { display: flex; align-items: center; gap: 12px; padding: 4px 0; font-size: 15px; }
.history li.is-done .sub-label { text-decoration: line-through; color: var(--muted); }
.history-mark { width: 16px; color: var(--muted); font-weight: 700; }
.history li.is-done .history-mark { color: #16a34a; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.note-edit { display: flex; gap: 10px; margin: 0 0 24px; }
.note-edit input { flex: 1; font-size: 16px; }


/* Progress, checklist, where it is at and updated — one labelled line each, aligned in a
   two-column grid so the values line up under the project name. */
.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 3px 10px;
  margin: 7px 0 0;
  font-size: 15px;
}
.meta dt {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  align-self: center;
}
.meta dd { margin: 0; color: var(--muted); }
.meta dd.stale { color: var(--warn); font-weight: 600; }
.meta .percent { margin: 0; color: var(--fg); }

/* ── sign-in ─────────────────────────────────────────────── */

header .viewer { color: var(--fg); font-weight: 650; font-size: 15px; }
header .setup { margin-left: auto; }
header .sign-out button {
  border-color: transparent;
  color: var(--muted);
  font-size: 15px;
  padding: 4px 10px;
}
header .sign-out button:hover { color: var(--fg); border-color: var(--line); }

.login-page main { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login {
  display: grid;
  gap: 16px;
  width: min(380px, 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
}
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login label { display: grid; gap: 6px; color: var(--muted); font-size: 15px; }
.login button { width: 100%; }

.statuses.people form { gap: 8px; }
.statuses.people input[type="password"] { width: 200px; }
