/* stouwe.net components. Plain CSS classes, prefix st-. Values come from tokens.css. */

/* ---------- density ----------
   Compact is the default. Put .st-density-balanced on a container (auth pages, touch-heavy screens) for roomier spacing. */
:root, .st-density-compact {
  --st-control-h: 28px; --st-control-h-sm: 24px;
  --st-pad: 12px; --st-gap: var(--space-4);
  --st-cell-y: 5px; --st-cell-x: 8px; --st-table-text: 13px;
  --st-metric-text: 22px; --st-sidebar-w: 200px; --st-bar-h: 44px;
  --st-icon: 16px;
}
.st-density-balanced {
  --st-control-h: 36px; --st-control-h-sm: 28px;
  --st-pad: var(--space-4); --st-gap: var(--space-6);
  --st-cell-y: 10px; --st-cell-x: 12px; --st-table-text: 14px;
  --st-metric-text: 28px; --st-sidebar-w: 232px; --st-bar-h: 56px;
  --st-icon: 18px;
}

/* ---------- base ---------- */
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
}
.st-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.st-muted { color: var(--ink-muted); }
.st-link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.st-link:hover { text-decoration-thickness: 2px; }
/* A link that leaves stouwe.net ends in the external-link icon, sized to its text. */
.st-link > .st-icon { width: 1em; height: 1em; margin-left: 2px; vertical-align: -0.125em; }
.st-link:focus-visible,
.st-btn:focus-visible,
.st-input:focus-visible,
.st-check input:focus-visible,
.st-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Button ---------- */
.st-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--st-control-h); padding: 0 var(--st-pad);
  border: 1px solid transparent; border-radius: var(--radius-md);
  font: 500 14px/1 var(--font-sans); white-space: nowrap;
  cursor: pointer; text-decoration: none;
  background: transparent; color: var(--ink);
}
.st-btn--primary { background: var(--accent); color: var(--accent-ink); }
.st-btn--primary:hover { filter: brightness(1.08); }
.st-btn--secondary { border-color: var(--border-strong); }
.st-btn--secondary:hover,
.st-btn--ghost:hover { background: var(--surface-2); }
.st-btn--ghost { color: var(--ink-muted); }
.st-btn--ghost:hover { color: var(--ink); }
.st-btn--danger { border-color: var(--danger); color: var(--danger); }
.st-btn--danger:hover { background: var(--surface-2); }
.st-btn--sm { height: var(--st-control-h-sm); padding: 0 var(--space-2); font-size: 13px; }
.st-btn--block { display: flex; width: 100%; }
.st-btn:disabled, .st-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; filter: none; }
.st-kbd {
  font: 400 11px/1 var(--font-mono); padding: 2px 4px;
  border: 1px solid currentColor; border-radius: var(--radius-sm); opacity: .7;
}

/* ---------- TextField ---------- */
.st-field { display: grid; gap: 6px; }
.st-label {
  font: 500 12px/16px var(--font-sans); letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-muted);
}
.st-label-row { display: flex; justify-content: space-between; align-items: baseline; }
.st-input {
  box-sizing: border-box; width: 100%; height: var(--st-control-h);
  padding: 0 calc(var(--space-2) + var(--space-1));
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  font: 400 15px/22px var(--font-sans);
}
.st-input::placeholder { color: var(--ink-muted); opacity: 1; }
.st-input:focus-visible { border-color: var(--accent); }
.st-input--mono { font-family: var(--font-mono); font-size: 14px; letter-spacing: .02em; }
.st-input[aria-invalid="true"] { border-color: var(--danger); }
.st-input:disabled { opacity: .5; cursor: not-allowed; }
.st-hint { margin: 0; font: 400 13px/18px var(--font-sans); color: var(--ink-muted); }
.st-hint--error { color: var(--danger); }

/* ---------- Checkbox ---------- */
.st-check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 14px; cursor: pointer; }
.st-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }

/* ---------- Badge ---------- */
.st-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink-muted);
  font: 500 11px/1 var(--font-mono); letter-spacing: .04em; text-transform: uppercase;
}
.st-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-badge--plain::before { display: none; }
.st-badge--ok { color: var(--accent); background: var(--accent-subtle); border-color: transparent; }
.st-badge--warning { color: var(--warning); }
.st-badge--danger { color: var(--danger); }
/* Something happening now (a Run in progress): ink text, an accent dot that pulses. */
.st-badge--live { color: var(--ink); }
.st-badge--live::before { background: var(--accent); animation: st-pulse 1.6s ease-in-out infinite; }
/* Happening now, but winding down or held up (Stopping): the pulsing dot turns warning. */
.st-badge--live.st-badge--warning { color: var(--ink); }
.st-badge--live.st-badge--warning::before { background: var(--warning); }

/* ---------- Alert ---------- */
.st-alert {
  display: flex; gap: var(--space-2); align-items: baseline;
  padding: var(--space-2) calc(var(--space-2) + var(--space-1));
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  font: 400 14px/20px var(--font-sans); color: var(--ink);
}
.st-alert__tag { flex: none; font: 600 12px/20px var(--font-mono); letter-spacing: .04em; }
.st-alert--ok { border-color: var(--accent); }
.st-alert--ok .st-alert__tag { color: var(--accent); }
.st-alert--warning { border-color: var(--warning); }
.st-alert--warning .st-alert__tag { color: var(--warning); }
.st-alert--danger { border-color: var(--danger); }
.st-alert--danger .st-alert__tag { color: var(--danger); }
.st-alert--info .st-alert__tag { color: var(--ink-muted); }

/* ---------- Panel ---------- */
.st-panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-md); }
.st-panel__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--st-pad); border-bottom: 1px solid var(--border);
}
.st-panel__title { margin: 0; font: 600 18px/26px var(--font-sans); }
.st-panel__body { padding: var(--st-pad); }
.st-panel__footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2);
  padding: var(--space-2) var(--st-pad); border-top: 1px solid var(--border);
  background: var(--bg); border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ---------- AppHeader ---------- */
.st-header {
  display: flex; align-items: center; gap: var(--space-6);
  height: var(--st-bar-h); padding: 0 var(--st-gap);
  background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.st-wordmark { font: 600 16px/1 var(--font-sans); letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.st-wordmark__tld { color: var(--ink-muted); }
.st-wordmark__cursor { display: inline-block; width: .5em; height: 2px; margin-left: 2px; background: var(--accent); vertical-align: baseline; }
.st-nav { display: flex; align-self: stretch; gap: var(--space-4); }
.st-nav a {
  display: flex; align-items: center; padding: 0 2px;
  color: var(--ink-muted); text-decoration: none; font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.st-nav a:hover { color: var(--ink); }
.st-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.st-header__end { margin-left: auto; display: flex; align-items: center; gap: var(--space-4); }

/* ---------- AppFooter ---------- */
.st-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2) var(--space-6);
  align-items: center; box-sizing: border-box; min-height: var(--st-bar-h);
  padding: var(--space-2) var(--space-6); border-top: 1px solid var(--border);
  font: 400 12px/18px var(--font-mono); color: var(--ink-muted);
}
.st-footer a { color: inherit; }
.st-footer__meta { display: flex; gap: var(--space-4); }

/* ---------- Auth layout (login, 2FA, reset) ---------- */
.st-auth { min-height: 100vh; display: flex; flex-direction: column; }
.st-auth__main { flex: 1; display: grid; place-items: center; padding: var(--space-10) var(--space-4); }
.st-auth__card { width: 100%; max-width: 380px; }
.st-auth__intro { margin: 0 0 var(--space-6); }
.st-auth__prompt { margin: 0 0 var(--space-1); font: 400 13px/20px var(--font-mono); color: var(--accent); }
.st-auth__title { margin: 0; font: 600 24px/32px var(--font-sans); }
.st-stack { display: grid; gap: var(--space-4); }
.st-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.st-stack--tight { gap: var(--space-2); }
/* Items side by side that wrap: a button group, a title and its badge. */
.st-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* ---------- Table ---------- */
.st-table { width: 100%; border-collapse: collapse; font-size: var(--st-table-text); line-height: 20px; }
.st-table th, .st-table td { padding: var(--st-cell-y) var(--st-cell-x); text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.st-table th {
  font: 500 12px/16px var(--font-sans); letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-muted); background: var(--surface-1);
}
.st-table th[aria-sort] { color: var(--ink); }
.st-table th[aria-sort="descending"]::after { content: " \2193"; color: var(--accent); }
.st-table th[aria-sort="ascending"]::after { content: " \2191"; color: var(--accent); }
.st-table tbody tr:hover td { background: var(--surface-2); }
.st-table tbody tr:last-child td { border-bottom: 0; }
.st-table .st-num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.st-table .st-id { font-family: var(--font-mono); color: var(--ink-muted); }
.st-table .st-wide { width: 100%; white-space: normal; }
/* A second line under a cell's value: why a status is what it is, when it happened. */
.st-table__sub { display: block; margin-top: 2px; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
/* Several row actions: a st-cluster in the right-aligned last cell, kept on one line. */
.st-table .st-num > .st-cluster { justify-content: flex-end; flex-wrap: nowrap; }
.st-neg { color: var(--danger); }
.st-pos { color: var(--accent); }
.st-panel .st-table th:first-child, .st-panel .st-table td:first-child { padding-left: var(--st-pad); }
.st-panel .st-table th:last-child, .st-panel .st-table td:last-child { padding-right: var(--st-pad); }
.st-table tfoot th, .st-table tfoot td { border-top: 1px solid var(--border-strong); border-bottom: 0; }
.st-table tfoot td { font-weight: 500; }

/* ---------- MetricTile ---------- */
.st-metric {
  display: grid; gap: var(--space-1); padding: var(--st-pad);
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.st-metric__label { font: 500 12px/16px var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.st-metric__value { font: 500 var(--st-metric-text)/1.2 var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; color: var(--ink); }
.st-metric__delta { font: 400 12px/18px var(--font-mono); color: var(--ink-muted); }
.st-metric__delta--good { color: var(--accent); }
.st-metric__delta--bad { color: var(--danger); }
.st-metric__delta--warn { color: var(--warning); }

/* ---------- App layout + Sidebar ---------- */
.st-app { display: grid; grid-template-columns: var(--st-sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.st-sidebar { display: flex; flex-direction: column; background: var(--surface-1); border-right: 1px solid var(--border); }
.st-sidebar__brand { display: flex; align-items: center; height: var(--st-bar-h); padding: 0 var(--st-pad); border-bottom: 1px solid var(--border); flex: none; }
.st-sidenav { display: grid; gap: 2px; padding: var(--st-pad) var(--space-2); }
.st-sidenav__group { margin: var(--space-2) var(--space-2) var(--space-1); font: 500 11px/16px var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
.st-sidenav__group:first-child { margin-top: 0; }
.st-sidenav a {
  display: flex; align-items: center; gap: var(--space-2);
  height: var(--st-control-h); padding: 0 var(--space-2); border-radius: var(--radius-md);
  color: var(--ink-muted); text-decoration: none; font-size: 14px;
}
.st-sidenav a:hover { background: var(--surface-2); color: var(--ink); }
.st-sidenav a[aria-current="page"] { background: var(--accent-subtle); color: var(--accent); font-weight: 500; }
.st-sidenav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.st-sidenav__count { margin-left: auto; font: 400 12px/1 var(--font-mono); color: var(--ink-muted); }
.st-sidenav__count--alert { color: var(--danger); }
.st-sidebar__end { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); box-sizing: border-box; min-height: var(--st-bar-h); padding: var(--space-2) var(--st-pad); border-top: 1px solid var(--border); font: 400 13px/20px var(--font-mono); color: var(--ink-muted); }
.st-main { display: flex; flex-direction: column; min-width: 0; }
.st-pagehead { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: var(--st-bar-h); padding: 0 var(--st-gap); border-bottom: 1px solid var(--border); }
.st-pagehead__title { margin: 0; font: 600 18px/26px var(--font-sans); }
.st-pagehead__meta { font: 400 13px/20px var(--font-mono); color: var(--ink-muted); }
.st-content { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: var(--st-gap); padding: var(--st-gap); }
.st-grid { display: grid; gap: var(--st-gap); }
.st-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.st-grid--2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }


/* ---------- Icon (Lucide, inline SVG or sprite <use>) ---------- */
.st-icon {
  width: var(--st-icon); height: var(--st-icon); flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.st-icon--lg { width: 24px; height: 24px; stroke-width: 1.75; }
.st-btn .st-icon { margin: 0 -2px; }
.st-btn--icon { width: var(--st-control-h); padding: 0; }
.st-btn--sm.st-btn--icon { width: var(--st-control-h-sm); }

/* ---------- form controls: Select, Textarea, Date, Radio, Switch, Segmented ---------- */
.st-input { color-scheme: dark; }
[data-theme="light"] .st-input { color-scheme: light; }
.st-select { position: relative; display: block; }
.st-select select.st-input { appearance: none; -webkit-appearance: none; padding-right: calc(var(--st-icon) + var(--space-4)); cursor: pointer; }
.st-select .st-icon { position: absolute; right: var(--space-2); top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink-muted); }
textarea.st-input { height: auto; min-height: calc(var(--st-control-h) * 3); padding-top: 6px; padding-bottom: 6px; resize: vertical; }
.st-input[type="date"], .st-input[type="time"], .st-input[type="datetime-local"] { font-family: var(--font-mono); font-size: 13px; }
.st-input:not(textarea) { line-height: calc(var(--st-control-h) - 2px); }
/* Small input for table cells; right-aligned amounts. */
.st-input--sm { height: var(--st-control-h-sm); padding: 0 var(--space-2); font-size: 13px; }
.st-input--sm:not(textarea) { line-height: calc(var(--st-control-h-sm) - 2px); }
.st-input--num { text-align: right; font-variant-numeric: tabular-nums; }
/* A read-only value in a field, aligned with the inputs beside it. */
.st-field__value { display: flex; align-items: center; min-height: var(--st-control-h); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
/* Two or three fields side by side; a hint in the row spans it. */
.st-form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-4); align-items: start; }
.st-form-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: calc(var(--space-2) + var(--space-1)); }
.st-form-row > .st-hint { grid-column: 1 / -1; }
.st-fieldset { display: grid; gap: var(--space-2); min-width: 0; margin: 0; padding: 0; border: 0; }
.st-fieldset > legend { padding: 0; margin-bottom: var(--space-2); }
.st-choices { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.st-choices--stack { flex-direction: column; }

.st-switch { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 14px; cursor: pointer; }
.st-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.st-switch__track {
  position: relative; flex: none; width: 28px; height: 16px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border-strong); box-sizing: border-box;
}
.st-switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--ink-muted); transition: transform .12s ease;
}
.st-switch input:checked + .st-switch__track { background: var(--accent); border-color: var(--accent); }
.st-switch input:checked + .st-switch__track::after { transform: translateX(12px); background: var(--accent-ink); }
.st-switch input:focus-visible + .st-switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }
.st-switch input:disabled + .st-switch__track { opacity: .45; }

.st-segmented { display: inline-flex; justify-self: start; margin: 0; padding: 2px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); }
.st-segmented label { position: relative; }
.st-segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.st-segmented span {
  display: inline-flex; align-items: center; gap: 6px; height: calc(var(--st-control-h) - 6px); padding: 0 var(--space-2);
  border-radius: var(--radius-sm); font-size: 13px; color: var(--ink-muted); cursor: pointer;
}
.st-segmented span:hover { color: var(--ink); }
.st-segmented input:checked + span { background: var(--surface-1); color: var(--ink); box-shadow: inset 0 0 0 1px var(--border-strong); }
.st-segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.st-segmented .st-count { font: 400 11px/1 var(--font-mono); color: var(--ink-muted); }

/* ---------- Dialog (native <dialog>, confirmations) ---------- */
.st-dialog {
  width: min(420px, calc(100vw - 32px)); padding: 0;
  background: var(--surface-1); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
}
.st-dialog::backdrop, .st-drawer::backdrop { background: rgba(0, 0, 0, .6); }
.st-dialog__body { padding: var(--space-4); display: grid; gap: var(--space-2); }
.st-dialog__title { margin: 0; font: 600 16px/24px var(--font-sans); }
.st-dialog__text { margin: 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.st-dialog__actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-top: 1px solid var(--border); background: var(--bg); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- Drawer (native <dialog> from the right, editing a record) ---------- */
.st-drawer {
  margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(440px, 100vw); padding: 0;
  display: none; flex-direction: column;
  background: var(--surface-1); color: var(--ink); border: 0; border-left: 1px solid var(--border-strong);
}
.st-drawer[open] { display: flex; }
.st-drawer__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); height: var(--st-bar-h); padding: 0 var(--space-2) 0 var(--st-pad); border-bottom: 1px solid var(--border); flex: none; }
.st-drawer__title { margin: 0; font: 600 16px/24px var(--font-sans); }
.st-drawer__body { flex: 1; overflow: auto; padding: var(--st-pad); align-content: start; }
.st-drawer__footer { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); padding: var(--space-2) var(--st-pad); border-top: 1px solid var(--border); background: var(--bg); flex: none; }
/* Text before the buttons in a footer (a hint, a total) sits on the left. */
.st-panel__footer > :first-child:not(.st-btn), .st-drawer__footer > :first-child:not(.st-btn), .st-dialog__actions > :first-child:not(.st-btn) { margin-right: auto; }

/* ---------- Toast ---------- */
.st-toasts { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 100; display: grid; gap: var(--space-2); width: min(380px, calc(100vw - 32px)); }
.st-toast {
  display: flex; align-items: center; gap: var(--space-2);
  padding-top: 6px; padding-bottom: 6px; padding-right: 4px;
  padding-left: calc(var(--space-2) + var(--space-1));
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  font-size: 13px; line-height: 20px;
}
.st-toast__tag { flex: none; font: 600 12px/20px var(--font-mono); letter-spacing: .04em; }
.st-toast__msg { flex: 1; }
.st-toast--ok .st-toast__tag { color: var(--accent); }
.st-toast--warning .st-toast__tag { color: var(--warning); }
.st-toast--danger { border-color: var(--danger); }
.st-toast--danger .st-toast__tag { color: var(--danger); }
.st-toast--info .st-toast__tag { color: var(--ink-muted); }
.st-toast__time { font: 400 11px/20px var(--font-mono); color: var(--ink-muted); }

/* ---------- Responsive: phone navigation (popover sidebar) ----------
   <aside class="st-sidebar" id="nav" popover> is a normal column from 900px up
   and a slide-in menu below, opened by <button popovertarget="nav">. No JavaScript. */
.st-table-wrap { overflow-x: auto; }
.st-mobilebar { display: none; }
.st-sidebar__close { display: none; }
.st-sidebar[popover] { color: inherit; }
@media (min-width: 900px) {
  .st-sidebar[popover] {
    display: flex; position: sticky; top: 0; inset: auto; height: 100vh; max-height: none; width: auto;
    margin: 0; padding: 0; border: 0; border-right: 1px solid var(--border); overflow: auto;
    background: var(--surface-1);
  }
}
@media (max-width: 899px) {
  .st-app { grid-template-columns: minmax(0, 1fr); }
  .st-mobilebar {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
    position: sticky; top: 0; z-index: 10;
    height: var(--st-bar-h); padding: 0 var(--space-1) 0 var(--st-pad);
    background: var(--surface-1); border-bottom: 1px solid var(--border);
  }
  .st-mobilebar .st-btn--icon { width: 40px; height: 40px; }
  .st-sidebar[popover] {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 85vw); height: 100%; max-height: none;
    margin: 0; padding: 0; border: 0; border-right: 1px solid var(--border-strong);
    background: var(--surface-1); overflow: auto;
  }
  .st-sidebar[popover]:not(:popover-open) { display: none; }
  .st-sidebar[popover]:popover-open { display: flex; }
  .st-sidebar[popover]::backdrop { background: rgba(0, 0, 0, .6); }
  .st-sidebar__brand { justify-content: space-between; padding-right: var(--space-1); }
  .st-sidebar__close { display: inline-flex; width: 40px; height: 40px; }
  .st-sidenav a { height: 40px; }
  .st-pagehead { flex-wrap: wrap; padding: var(--space-2) var(--st-pad); }
  .st-content { padding: var(--st-pad); gap: var(--st-pad); }
  .st-grid { gap: var(--st-pad); }
  .st-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .st-grid--2-1 { grid-template-columns: minmax(0, 1fr); }
  .st-panel__header { flex-wrap: wrap; }
  .st-hide-sm { display: none; }
  .st-footer { padding: var(--space-2) var(--st-pad); }
  .st-toasts { left: var(--space-2); right: var(--space-2); bottom: var(--space-2); width: auto; }
}

/* ---------- States: empty, loading, error ---------- */
.st-empty { display: grid; justify-items: center; gap: var(--space-1); padding: var(--space-10) var(--st-pad); text-align: center; color: var(--ink-muted); }
.st-empty .st-icon--lg { margin-bottom: var(--space-1); }
.st-empty__title { margin: 0; font: 600 15px/22px var(--font-sans); color: var(--ink); }
.st-empty__text { margin: 0; max-width: 340px; font-size: 13px; line-height: 19px; }
.st-empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-2); }

.st-skeleton { display: block; height: 10px; border-radius: var(--radius-sm); background: var(--surface-2); animation: st-pulse 1.6s ease-in-out infinite; }
.st-skeleton--text, .st-table .st-skeleton { margin: 5px 0; }
.st-skeleton--value { height: 22px; width: 60%; }
@keyframes st-pulse { 50% { opacity: .45; } }

.st-loading { display: flex; align-items: center; gap: var(--space-2); padding: var(--st-pad); font: 400 13px/20px var(--font-mono); color: var(--ink-muted); }
.st-cursor { display: inline-block; width: .55em; height: 1.1em; background: var(--accent); vertical-align: text-bottom; animation: st-blink 1.1s steps(1) infinite; }
@keyframes st-blink { 50% { opacity: 0; } }

.st-btn[aria-busy="true"], .st-btn.htmx-request { cursor: progress; }
.st-btn[aria-busy="true"]::before, .st-btn.htmx-request::before {
  content: ""; width: 12px; height: 12px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: st-spin .7s linear infinite;
}
@keyframes st-spin { to { transform: rotate(360deg); } }

.st-alert__action { margin-left: auto; align-self: center; }
.st-panel__body > .st-alert:only-child { margin: 0; }

.st-errorpage { display: grid; gap: var(--space-2); }
.st-errorpage__code { margin: 0; font: 500 64px/1 var(--font-mono); letter-spacing: -0.02em; color: var(--ink-muted); }
.st-errorpage__req { margin: 0; font: 400 13px/20px var(--font-mono); color: var(--ink-muted); }
.st-errorpage__req b { font-weight: 500; color: var(--accent); }
.st-errorpage__title { margin: var(--space-2) 0 0; font: 600 24px/32px var(--font-sans); }
.st-errorpage__text { margin: 0; color: var(--ink-muted); }
.st-errorpage__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }

@media (prefers-reduced-motion: reduce) {
  .st-skeleton, .st-cursor, .st-badge--live::before, .st-btn[aria-busy="true"]::before, .st-btn.htmx-request::before { animation: none; }
  .st-switch__track::after { transition: none; }
}

/* ---------- Utilities added for platform pages ---------- */
/* One-line form: a field and its button (add a note, search). */
.st-form-inline { display: flex; align-items: end; gap: var(--space-2); }
.st-form-inline .st-field { flex: 1; }
/* Text for screen readers only (icon-only controls, empty column headers). */
.st-visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Small text and the caption under a chart or table. */
.st-small { font-size: 13px; line-height: 18px; }
.st-caption { margin: var(--space-2) 0 0; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.st-panel > .st-caption { margin: 0; padding: var(--space-2) var(--st-pad) var(--st-pad); }

/* ---------- Sections inside a dialog or drawer ---------- */
.st-section { display: grid; gap: var(--space-2); }
.st-section__title { margin: 0; font: 500 12px/16px var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.st-inset { display: grid; gap: var(--st-pad); padding: var(--st-pad); border: 1px solid var(--border); border-radius: var(--radius-md); }

/* ---------- Progress (how far along a term is) ---------- */
.st-progress { display: grid; gap: var(--space-2); }
.st-progress__track { position: relative; box-sizing: border-box; height: 12px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.st-progress__fill { position: absolute; top: 0; bottom: 0; left: 0; background: var(--ink-muted); }
.st-progress__mark { position: absolute; top: -3px; width: 2px; height: 16px; margin-left: -1px; background: var(--ink); }
.st-progress__mark--warning { background: var(--warning); }
.st-progress__scale { display: flex; justify-content: space-between; gap: var(--space-2); font: 400 13px/18px var(--font-mono); color: var(--ink-muted); }

/* ---------- Log (the last lines of a log, as written) ---------- */
.st-log {
  margin: 0; max-height: 360px; overflow: auto; padding: var(--space-2) var(--st-pad);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  font: 400 13px/20px var(--font-mono); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4;
}
.st-log:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- MetaList (dl of label and value) ---------- */
.st-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--st-pad) var(--space-4); margin: 0; }
.st-meta dt { font: 500 12px/16px var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.st-meta dd { margin: 2px 0 0; }
/* A pair whose value is too long for half the width (an object key, a task ID): a full row. */
.st-meta__wide { grid-column: 1 / -1; }

/* ---------- Summary (labels with a large value) ---------- */
.st-summary { display: grid; gap: var(--space-1); margin: 0; padding: var(--st-pad); background: var(--surface-2); border-radius: var(--radius-md); }
.st-summary > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--space-4); align-items: baseline; }
.st-summary dt { font: 500 12px/16px var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.st-summary dd { margin: 0; text-align: right; font: 400 15px/22px var(--font-mono); font-variant-numeric: tabular-nums; }
.st-summary__main dd { font-size: 20px; line-height: 28px; font-weight: 500; }
.st-summary .st-summary__note { grid-column: 1 / -1; text-align: left; font: 400 13px/18px var(--font-sans); color: var(--ink-muted); }

/* ---------- List: action rows and history ---------- */
.st-list, .st-history { list-style: none; margin: 0; padding: 0; }
.st-list__item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--st-pad); align-items: center;
  padding: var(--space-2) var(--st-pad); border-bottom: 1px solid var(--border);
}
.st-list__item:last-child { border-bottom: 0; }
.st-list__title { font-size: 14px; line-height: 20px; }
.st-list__sub { font: 400 12px/16px var(--font-mono); color: var(--ink-muted); }
.st-list__action { grid-column: 2; grid-row: 1 / span 2; }
.st-history { font-size: 13px; line-height: 18px; }
.st-history > li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--space-2); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.st-history > li:last-child { border-bottom: 0; }
.st-history__date { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink-muted); }

/* ---------- Charts: legend, MonthGrid, BarChart ---------- */
.st-legend { display: flex; flex-wrap: wrap; gap: 6px var(--space-4); margin: 0; padding: 0; list-style: none; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.st-legend > li { display: inline-flex; align-items: center; gap: 6px; }
.st-legend__key { flex: none; width: 12px; height: 12px; box-sizing: border-box; border: 1px solid transparent; border-radius: var(--radius-sm); }
.st-legend__key--solid { background: var(--ink-muted); }
.st-legend__key--dashed { border: 1px dashed var(--ink-muted); }
.st-legend__key--now { border: 2px solid var(--accent); }
.st-legend__key--gap { border: 1px dashed var(--warning); }
.st-legend__key--multi { border-color: var(--ink); background: var(--surface-2); }
.st-legend__key--term { border: 1px solid var(--ink); }

.st-monthgrid { width: 100%; min-width: 860px; table-layout: fixed; border-collapse: separate; border-spacing: var(--space-1); }
.st-monthgrid tr > :first-child { width: 48px; }
.st-monthgrid th { padding: 0 var(--space-1); text-align: left; font: 500 12px/16px var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.st-monthgrid tbody th { vertical-align: top; padding: var(--space-2) 0 0; font: 400 12px/16px var(--font-mono); letter-spacing: 0; text-transform: none; }
.st-monthgrid tbody td { height: 58px; box-sizing: border-box; padding: 6px 7px; vertical-align: top; border: 1px solid transparent; border-radius: var(--radius-md); }
.st-monthgrid__amount { display: block; font: 500 13px/18px var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.st-monthgrid__sub { display: block; margin-top: 2px; font: 400 11px/14px var(--font-mono); color: var(--ink-muted); }
.st-monthgrid .st-monthgrid__cell--release { background: var(--surface-2); border-color: var(--border); }
.st-monthgrid .st-monthgrid__cell--multi { background: var(--surface-2); border-color: var(--ink); }
.st-monthgrid .st-monthgrid__cell--gap { border: 1px dashed var(--warning); }
.st-monthgrid__cell--gap .st-monthgrid__amount { color: var(--warning); }
.st-monthgrid .st-monthgrid__cell--out { border: 1px dashed var(--border); }
.st-monthgrid__cell--out .st-monthgrid__amount { color: var(--ink-muted); }
.st-monthgrid__term { display: inline-block; margin-top: 2px; padding: 0 4px; box-sizing: border-box; border: 1px solid var(--ink); border-radius: var(--radius-sm); font: 500 11px/14px var(--font-mono); color: var(--ink); }
.st-monthgrid td.st-monthgrid__cell--now { border: 2px solid var(--accent); padding: 5px 6px; }

.st-bars { min-width: 760px; }
.st-bars__max { display: block; margin-bottom: var(--space-1); font: 400 11px/14px var(--font-mono); color: var(--ink-muted); }
.st-bars__list { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin: 0; padding: 0; list-style: none; border-top: 1px dashed var(--border); }
.st-bars__item { position: relative; display: grid; grid-template-rows: 160px auto; }
.st-bars__item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.st-bars__track { display: flex; align-items: flex-end; padding: 0 2px; border-bottom: 1px solid var(--border-strong); }
.st-bars__bar { width: 100%; box-sizing: border-box; background: var(--ink-muted); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.st-bars__item--projected .st-bars__bar { background: transparent; border: 1px dashed var(--ink-muted); border-bottom: 0; }
.st-bars__label { padding: var(--space-1) 2px 0; font: 400 11px/14px var(--font-mono); color: var(--ink-muted); white-space: nowrap; }
.st-bars__year { display: block; }
.st-bars__item--now .st-bars__label { color: var(--accent); }
.st-bars__tip { display: none; position: absolute; z-index: 2; top: var(--space-1); left: 0; width: max-content; min-width: 180px; padding: 6px 8px; box-sizing: border-box; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-md); font: 400 12px/16px var(--font-mono); color: var(--ink); pointer-events: none; }
.st-bars__item--end .st-bars__tip { left: auto; right: 0; }
.st-bars__item:hover .st-bars__tip, .st-bars__item:focus .st-bars__tip { display: block; }
.st-bars__tip-title { display: block; margin-bottom: 2px; font-weight: 500; }
.st-bars__tip-line { display: flex; justify-content: space-between; gap: var(--space-4); color: var(--ink-muted); }
.st-bars__tip-line > :last-child { color: var(--ink); font-variant-numeric: tabular-nums; }
