/* Planning app. Colors are role tokens; dark mode redefines them. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --warning-ink: #7a5200;
  --critical: #d03b3b;
  --critical-ink: #a32424;
  --danger-bg: #fbeaea;
  --ok-bg: #e7f4e7;
  --warn-bg: #fdf3dc;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06);
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242423;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --good-ink: #0ca30c;
    --warning-ink: #fab219;
    --critical-ink: #e66767;
    --danger-bg: #3a1c1c;
    --ok-bg: #16301a;
    --warn-bg: #3a2f14;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242423; --text: #ffffff; --text-2: #c3c2b7;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --accent: #3987e5;
  --series-1: #3987e5; --series-2: #d95926; --good-ink: #0ca30c; --warning-ink: #fab219; --critical-ink: #e66767;
  --danger-bg: #3a1c1c; --ok-bg: #16301a; --warn-bg: #3a2f14; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 14px; margin: 14px 0 8px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
pre { background: var(--surface-2); padding: 10px 12px; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.muted { color: var(--muted); }
.h-sub { font-weight: 400; font-size: 15px; margin-left: 6px; }
.hint { font-size: 12.5px; margin: 8px 0 0; }
.inline { display: inline; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 52px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 18px; height: 18px; border-radius: 4px;
  background: linear-gradient(90deg, #86CF86 0 33%, #FFE066 33% 66%, #86B4F2 66%); border: 1px solid var(--border); }
.mainnav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.mainnav a { color: var(--text-2); padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.mainnav a:hover { background: var(--surface-2); text-decoration: none; }
.mainnav a[aria-current="page"] { color: var(--text); background: var(--surface-2); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.who-name { color: var(--text); }
.role-badge { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-2); }
.role-admin { border-color: var(--critical); color: var(--critical-ink); }
.role-write { border-color: var(--accent); color: var(--accent); }

/* Layout */
.page { max-width: 1280px; margin: 0 auto; padding: 20px; }
.page-wide { max-width: none; }
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin-right: auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
  margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin-right: auto; }
.card-head.spaced { margin-top: 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.section-title { margin: 8px 0 10px; }
.table-scroll { overflow-x: auto; }
.empty { padding: 12px 0; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid var(--border); }
.flash-ok { background: var(--ok-bg); }
.flash-error { background: var(--danger-bg); }
.flash-warn { background: var(--warn-bg); }

/* Forms */
input, select, button { font: inherit; color: inherit; }
input, select { background: var(--surface); border: 1px solid var(--axis); border-radius: 6px; padding: 6px 8px; min-height: 32px; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, .cell:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: inline-flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--text-2); }
label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label input { width: 100%; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.form-row .wide { flex: 1 1 300px; }
.form-row .wide input { width: 100%; }
.form-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.custom-range { display: inline-flex; gap: 10px; }
fieldset.scopes { border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px 6px; display: flex; gap: 12px; }
fieldset.scopes legend { font-size: 12.5px; color: var(--text-2); padding: 0 4px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 5px 12px;
  border-radius: 6px; border: 1px solid var(--axis); background: var(--surface); color: var(--text); cursor: pointer; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--critical-ink); border-color: var(--critical); }
.btn-small { min-height: 26px; padding: 2px 8px; font-size: 12.5px; }
.btn-link { background: none; border: 0; color: var(--text-2); cursor: pointer; padding: 0; }
.btn-link:hover { color: var(--text); text-decoration: underline; }

/* Tables */
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-weight: 600; font-size: 12px; color: var(--text-2); padding: 6px 8px;
  border-bottom: 1px solid var(--axis); white-space: nowrap; }
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data.compact td, table.data.compact th { padding: 4px 8px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th .sort-button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
table.data th .sort-button:hover { color: var(--text); }
table.data th .sort-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
table.data th.num .sort-button { flex-direction: row-reverse; }
table.data th .sort-arrow { font-size: 9px; color: var(--muted); min-width: 8px; }
tr.muted td { color: var(--muted); }
details.detail summary { cursor: pointer; color: var(--muted); font-size: 12px; }
details.detail pre { max-height: 240px; overflow: auto; }

/* KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile-hero { grid-column: span 2; }
@media (min-width: 1100px) {
  .tiles { grid-template-columns: minmax(0, 2fr) repeat(5, minmax(0, 1fr)); }
  .tile-hero { grid-column: auto; }
}
.tile-label { font-size: 12.5px; color: var(--text-2); }
.tile-value { font-size: 28px; font-weight: 650; margin: 2px 0 4px; }
.tile-of { font-size: 18px; font-weight: 500; }
.tile-hero .tile-value { font-size: 48px; line-height: 1.1; }
.tile-foot { font-size: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Status (always icon + label, never color alone) */
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px;
  border-radius: 50%; font-size: 10px; color: #fff; }
.status-good { color: var(--good-ink); } .status-good .status-icon { background: var(--good); }
.status-warning { color: var(--warning-ink); } .status-warning .status-icon { background: var(--warning); color: #0b0b0b; }
.status-critical { color: var(--critical-ink); } .status-critical .status-icon { background: var(--critical); }
.status-none { color: var(--muted); font-weight: 400; }

/* Chart */
.chart { position: relative; width: 100%; min-height: 240px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .ref { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .ref-label { fill: var(--text-2); font-size: 11px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .s1 { stroke: var(--series-1); } .chart .s2 { stroke: var(--series-2); }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot.s1 { fill: var(--series-1); } .chart .dot.s2 { fill: var(--series-2); }
.chart .direct-label { font-size: 11px; font-weight: 600; fill: var(--text); }
.chart .crosshair { stroke: var(--text-2); stroke-width: 1; }
.chart .today-line { stroke: var(--axis); stroke-width: 1; }
.chart .future { fill: var(--surface-2); opacity: 0.6; }
.chart .today-label { fill: var(--muted); font-size: 11px; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); min-width: 130px; z-index: 5; }
.chart-tip .tip-title { color: var(--text-2); margin-bottom: 4px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip .tip-row strong { font-variant-numeric: tabular-nums; min-width: 48px; }
.chart-tip .tip-key { width: 12px; height: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { width: 16px; height: 2px; display: inline-block; }
.legend-line.series-1, .tip-key.series-1 { background: var(--series-1); }
.legend-line.series-2, .tip-key.series-2 { background: var(--series-2); }
.legend-line.ref-line { background: repeating-linear-gradient(90deg, var(--text-2) 0 4px, transparent 4px 8px); }
.table-view { margin-top: 8px; }
.table-view summary { cursor: pointer; color: var(--text-2); font-size: 12.5px; }

/* Status colors - keep in sync with STATUS_COLORS in domain.py */
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px;
  border: 1px solid rgba(0, 0, 0, 0.18); }
.s-on_project { background: #86CF86; }
.s-good_will { background: #2E7D32; }
.s-internal { background: #FFE066; }
.s-available { background: #FFFFFF; }
.s-academy { background: #CFE3FC; }
.s-vacation { background: #86B4F2; }
.s-personal { background: #2F5EC9; }
.s-conference { background: #7E57C2; }
.s-sick { background: #D32F2F; }
.s-unpaid { background: #F4A6B8; }
.s-non_working { background: #ABA69D; }
.s-not_working { background: #E4E2DD; }

/* Plan grid */
.month-nav { display: flex; gap: 6px; align-items: center; }
.month-nav form { display: inline-flex; gap: 6px; }
.month-kpi { font-size: 13px; }
.toolbar { padding: 12px 16px; }
.brush { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; }
.toolbar-label { font-weight: 600; font-size: 12.5px; align-self: center; }
.brush-statuses { display: flex; flex-wrap: wrap; gap: 6px; }
.brush-chip { flex-direction: row; align-items: center; gap: 0; padding: 4px 9px; border: 1px solid var(--axis);
  border-radius: 999px; cursor: pointer; color: var(--text); font-size: 12.5px; background: var(--surface); }
.brush-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.brush-chip:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--surface-2); font-weight: 600; }
.brush-chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.brush-field { min-width: 180px; }
.paint-status { margin: 6px 0 0; font-size: 12.5px; min-height: 1.2em; color: var(--text-2); }
.paint-status.flash { margin-bottom: 0; font-size: 13px; color: var(--text); }
.plan-grid .sort-link { color: inherit; display: inline-flex; gap: 4px; align-items: center; }
.plan-grid .sort-link span { font-size: 9px; color: var(--muted); }
.plan-scroll { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  max-height: calc(100vh - 230px); margin-bottom: 12px; }
table.plan-grid { border-collapse: separate; border-spacing: 0; font-size: 11px; user-select: none; }
.plan-grid th, .plan-grid td { border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); }
.plan-grid thead th { position: sticky; background: var(--surface); z-index: 2; font-weight: 500; color: var(--text-2); }
.plan-grid thead tr.weeks th { top: 0; height: 22px; text-align: left; padding-left: 4px; font-size: 11px; }
.plan-grid thead tr.days th { top: 22px; height: 34px; }
.plan-grid .name-col { position: sticky; left: 0; z-index: 3; background: var(--surface); text-align: left; padding: 0 10px;
  min-width: 190px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; font-size: 12.5px; }
.plan-grid thead .name-col { z-index: 4; }
.plan-grid th.day { width: 30px; min-width: 30px; text-align: center; line-height: 1.15; }
.plan-grid th.day .dow { display: block; color: var(--muted); font-size: 10px; }
.plan-grid th.day .dom { display: block; font-weight: 600; color: var(--text); }
.plan-grid th.today { box-shadow: inset 0 -3px 0 var(--accent); }
.plan-grid .monday { border-left: 2px solid var(--axis); }
.plan-grid td.cell { width: 30px; min-width: 30px; height: 26px; text-align: center; color: #1a1a1a; font-size: 9.5px;
  font-weight: 600; overflow: hidden; white-space: nowrap; letter-spacing: -0.02em; }
.plan-grid td.cell.dark { color: #fff; }
.plan-grid td.cell.today { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }
.plan-grid.editable td.cell { cursor: cell; }
.plan-grid td.cell.selecting { outline: 2px solid var(--accent); outline-offset: -2px; filter: brightness(0.92); }
.plan-grid td.cell.saving { opacity: 0.55; }
.plan-grid tbody tr:hover .name-col { background: var(--surface-2); }
.legend-block { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--text-2); margin-bottom: 16px; }

/* Tokens & secrets */
.new-token { border: 1px solid var(--good); background: var(--ok-bg); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0 16px; }
.new-token h3 { margin-top: 0; }
pre.secret { font-size: 14px; font-weight: 600; }
.service-account { border-top: 1px solid var(--grid); padding-top: 8px; margin-top: 8px; }
.service-account:first-of-type { border-top: 0; margin-top: 0; }
.inline-h { display: inline; }
details > summary { cursor: pointer; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 12px; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-page .flash { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); width: min(360px, calc(100% - 32px)); }
.login-card { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 28px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08); }
.login-brand { font-size: 20px; }
.login-card .muted { margin: 4px 0 18px; }
.error-card { max-width: 560px; margin: 40px auto; }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .tile-hero { grid-column: span 1; }
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 16px; gap: 8px; }
  .mainnav { order: 3; flex-basis: 100%; }
  .page { padding: 16px; }
  .plan-grid .name-col { min-width: 120px; max-width: 140px; }
}
@media (forced-colors: active) {
  .plan-grid td.cell { forced-color-adjust: none; }
}

/* Toasts: drop down from the top, gone after 3 s (app.js). Without JS they stay put. */
.toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex;
  flex-direction: column; gap: 8px; width: min(560px, calc(100% - 32px)); pointer-events: none; }
.toast { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14); font-size: 13.5px; pointer-events: auto;
  margin-bottom: 14px; animation: toast-in 0.25s ease-out; }
.toasts .toast { margin-bottom: 0; }
.toast-ok { background: var(--ok-bg); border-color: var(--good); }
.toast-warn { background: var(--warn-bg); border-color: var(--warning); }
.toast-leaving { animation: toast-out 0.3s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-16px); } }
@media (prefers-reduced-motion: reduce) { .toast, .toast-leaving { animation-duration: 0.01s; } }

/* Yes/No confirmation (native <dialog>, app.js) */
dialog.confirm { border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; max-width: 460px;
  background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); }
dialog.confirm::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog.confirm p { margin: 0 0 16px; line-height: 1.45; }
.confirm-buttons { display: flex; justify-content: flex-end; gap: 8px; }
