/* portal-ui.css - the shared components ({% load ui %}, templates/ui/).

   Loaded on every page. Components take their colours from the --ui-*
   variables, which have one set of values for the classic dark look and one
   for the v2 look, so a page built from components is right in both. */

:root {
  --ui-bg: #0f1117;
  --ui-surface: #151b28;
  --ui-surface-2: #1b2232;
  --ui-surface-3: #242d40;
  --ui-line: #2a3447;
  --ui-line-2: #3a465c;
  --ui-ink: #ffffff;
  --ui-ink-2: #d1d5db;
  --ui-muted: #9ca3af;
  --ui-brand: #60a5fa;
  --ui-btn-bg: #2563eb;
  --ui-btn-bg-hover: #1d4ed8;
  --ui-btn-fg: #ffffff;
  --ui-panel: #0b1220;
  --ui-good: #4ade80;
  --ui-warn: #fbbf24;
  --ui-bad: #f87171;
  --ui-radius: 6px;
  --ui-radius-lg: 8px;
  --ui-radius-pill: 6px;
  --ui-title-weight: 400;
}

html.v2 {
  --ui-bg: #f4f4f2;
  --ui-surface: #ffffff;
  --ui-surface-2: #f7f7f5;
  --ui-surface-3: #ebebe8;
  --ui-line: #e3e3de;
  --ui-line-2: #d2d2cc;
  --ui-ink: #0b0b0b;
  --ui-ink-2: #3d3d3a;
  --ui-muted: #6f6f69;
  --ui-brand: #1d54e2;
  --ui-btn-bg: #0b0b0b;
  --ui-btn-bg-hover: #2b2b29;
  --ui-btn-fg: #ffffff;
  --ui-panel: #0b0d12;
  --ui-good: #17663a;
  --ui-warn: #8a5a00;
  --ui-bad: #a3261c;
  --ui-radius: 12px;
  --ui-radius-lg: 20px;
  --ui-radius-pill: 9999px;
}

/* Page header: what the page is, and its main actions. */
.ui-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 28px; }
.ui-page-header-text { min-width: 0; }
.ui-page-header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ui-eyebrow { margin: 0 0 6px; font-size: 14px; color: var(--ui-muted); }
.ui-title { margin: 0; font-size: clamp(28px, 3.4vw, 40px); font-weight: var(--ui-title-weight); line-height: 1.1; letter-spacing: -0.035em; color: var(--ui-ink); }
.ui-subtitle { margin: 10px 0 0; max-width: 60ch; font-size: 16px; line-height: 1.5; color: var(--ui-ink-2); }

/* Buttons: primary (one per view), outline, quiet, danger. */
.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--ui-radius-pill); cursor: pointer;
  font: inherit; font-size: 15px; line-height: 1; text-decoration: none; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.ui-btn-primary { background: var(--ui-btn-bg); border-color: var(--ui-btn-bg); color: var(--ui-btn-fg); }
.ui-btn-primary:hover { background: var(--ui-btn-bg-hover); border-color: var(--ui-btn-bg-hover); color: var(--ui-btn-fg); }
.ui-btn-outline { background: transparent; border-color: var(--ui-line-2); color: var(--ui-ink); }
.ui-btn-outline:hover { border-color: var(--ui-ink); }
.ui-btn-quiet { background: var(--ui-surface-3); color: var(--ui-ink); }
.ui-btn-quiet:hover { background: var(--ui-line); }
.ui-btn-danger { background: transparent; border-color: color-mix(in srgb, var(--ui-bad) 40%, transparent); color: var(--ui-bad); }
.ui-btn-danger:hover { background: color-mix(in srgb, var(--ui-bad) 10%, transparent); }
.ui-btn-sm { height: 34px; padding: 0 14px; font-size: 14px; }

/* Surfaces. */
.ui-card { background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg); padding: 24px; }
.ui-card-flush { padding: 0; overflow: hidden; }
.ui-card-title { margin: 0 0 16px; font-size: 17px; font-weight: 500; letter-spacing: -0.015em; color: var(--ui-ink); }
.ui-card + .ui-card, .ui-card + .ui-table-wrap, .ui-toolbar + .ui-table-wrap, .ui-toolbar + .ui-card, .ui-table-wrap + .ui-card { margin-top: 16px; }
.ui-panel { background: var(--ui-panel); border-radius: var(--ui-radius-lg); padding: 32px; color: #fff; }
.ui-panel .ui-eyebrow { color: #a5a8b0; }
.ui-panel-title { margin: 0 0 8px; font-size: 26px; font-weight: 400; letter-spacing: -0.03em; }

/* Filters above a list. */
.ui-toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 16px 20px;
  background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg);
}
.ui-toolbar .ui-field { flex: 1 1 180px; }
.ui-toolbar-actions { display: flex; gap: 8px; margin-left: auto; }

/* Form fields. */
.ui-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ui-label { font-size: 13.5px; color: var(--ui-ink-2); }
.ui-hint { font-size: 12.5px; color: var(--ui-muted); }
.ui-input, .ui-field > input:not([type='checkbox']):not([type='radio']), .ui-field > select, .ui-field > textarea {
  width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--ui-line-2); border-radius: var(--ui-radius);
  background: var(--ui-surface); font: inherit; font-size: 15px; color: var(--ui-ink); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ui-field > textarea { height: auto; min-height: 96px; padding: 10px 14px; }
.ui-input:focus, .ui-field > input:focus, .ui-field > select:focus, .ui-field > textarea:focus {
  border-color: var(--ui-brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ui-brand) 16%, transparent);
}

/* Tables. */
.ui-table-wrap { overflow-x: auto; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg); }
.ui-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.ui-table th {
  padding: 13px 20px; text-align: left; font-size: 12.5px; font-weight: 400; letter-spacing: 0.02em;
  color: var(--ui-muted); border-bottom: 1px solid var(--ui-line); white-space: nowrap;
}
.ui-table td { padding: 15px 20px; vertical-align: middle; color: var(--ui-ink-2); border-bottom: 1px solid var(--ui-line); }
.ui-table tbody tr:last-child td { border-bottom: 0; }
.ui-table tbody tr:hover td { background: var(--ui-surface-2); }
.ui-table .ui-cell-main { color: var(--ui-ink); font-weight: 500; }
.ui-table .ui-cell-sub { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; color: var(--ui-muted); }
.ui-table .ui-cell-actions { text-align: right; white-space: nowrap; }
.ui-row-actions { display: inline-flex; align-items: center; gap: 14px; }
.ui-link { color: var(--ui-ink); text-decoration: underline; text-decoration-color: var(--ui-line-2); text-underline-offset: 3px; }
.ui-link:hover { text-decoration-color: var(--ui-ink); }
.ui-link-danger { color: var(--ui-bad); text-decoration-color: color-mix(in srgb, var(--ui-bad) 35%, transparent); }

/* Status badges: one tone per meaning, everywhere. */
.ui-badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 9999px;
  background: var(--ui-surface-3); font-size: 12.5px; color: var(--ui-ink-2); white-space: nowrap;
}
.ui-badge::before { content: ''; width: 6px; height: 6px; border-radius: 9999px; background: currentColor; opacity: 0.6; }
.ui-badge-good { background: color-mix(in srgb, var(--ui-good) 13%, transparent); color: var(--ui-good); }
.ui-badge-warn { background: color-mix(in srgb, var(--ui-warn) 15%, transparent); color: var(--ui-warn); }
.ui-badge-bad { background: color-mix(in srgb, var(--ui-bad) 12%, transparent); color: var(--ui-bad); }
.ui-badge-brand { background: color-mix(in srgb, var(--ui-brand) 12%, transparent); color: var(--ui-brand); }

/* Numbers at the top of a page. */
.ui-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.ui-stat { background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg); padding: 20px 22px; }
.ui-stat-label { margin: 0; font-size: 13.5px; color: var(--ui-muted); }
.ui-stat-value { margin: 6px 0 0; font-size: 30px; line-height: 1.1; letter-spacing: -0.03em; color: var(--ui-ink); font-variant-numeric: tabular-nums; }
.ui-stat-good { color: var(--ui-good); } .ui-stat-warn { color: var(--ui-warn); } .ui-stat-bad { color: var(--ui-bad); }
.ui-stat-note { margin: 6px 0 0; font-size: 13px; color: var(--ui-muted); }

/* Nothing to show. */
.ui-empty { padding: 56px 24px; text-align: center; }
.ui-empty-title { margin: 0; font-size: 17px; font-weight: 500; color: var(--ui-ink); }
.ui-empty-body { margin-top: 8px; font-size: 15px; color: var(--ui-muted); }

/* Paging under a list. */
.ui-pager { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; font-size: 14px; color: var(--ui-muted); }
.ui-pager-links { display: flex; gap: 8px; }

/* The confirmation dialog (forms with data-confirm; static/js/portal-ui.js). */
.ui-dialog {
  width: min(92vw, 420px); padding: 24px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg);
  background: var(--ui-surface); color: var(--ui-ink);
}
.ui-dialog::backdrop { background: rgba(11, 11, 11, 0.45); }
.ui-dialog-text { margin: 0 0 20px; font-size: 16px; line-height: 1.5; }
.ui-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.ui-inline-form { display: inline; }
.ui-link-button { padding: 0; border: 0; background: none; cursor: pointer; font: inherit; }

/* Card grids, project cards, small tags. */
.ui-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.ui-project-card { display: flex; flex-direction: column; gap: 12px; transition: border-color 0.15s; }
.ui-project-card:hover { border-color: var(--ui-line-2); }
.ui-project-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ui-project-card-title { margin: 0; font-size: 20px; font-weight: 500; line-height: 1.25; letter-spacing: -0.02em; }
.ui-project-card-title a { color: var(--ui-ink); text-decoration: none; }
.ui-project-card-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.ui-project-card-text {
  margin: 0; flex: 1; font-size: 14.5px; line-height: 1.5; color: var(--ui-muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.ui-project-card-actions { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
.ui-push-right { margin-left: auto; }
.ui-tag { font-size: 12.5px; color: var(--ui-muted); }

/* Dialogs opened with data-ui-open="id"; a searchable pick list inside one. */
.ui-dialog-wide { width: min(94vw, 560px); }
.ui-dialog-title { margin: 0 0 6px; font-size: 22px; font-weight: 400; letter-spacing: -0.03em; color: var(--ui-ink); }
.ui-dialog-note { margin: 0 0 16px; font-size: 14.5px; color: var(--ui-muted); }
.ui-pick-list { list-style: none; margin: 12px 0 18px; padding: 0; max-height: 46vh; overflow-y: auto; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.ui-pick-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--ui-line); }
.ui-pick-list li:last-child { border-bottom: 0; }
.ui-pick-text { min-width: 0; font-size: 14.5px; color: var(--ui-ink); }
.ui-pick-text small { display: block; font-size: 12.5px; color: var(--ui-muted); }
.ui-pick-empty { justify-content: center !important; color: var(--ui-muted); font-size: 14.5px; }
.ui-grid > .ui-card { margin-top: 0; }

/* Section headings inside a page. */
.ui-section { margin-top: 36px; }
.ui-section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
.ui-section-title { margin: 0; font-size: 21px; font-weight: 500; line-height: 1.25; letter-spacing: -0.02em; color: var(--ui-ink); }
.ui-section-note { margin: 4px 0 0; font-size: 14.5px; color: var(--ui-muted); }

/* Tabs: links or buttons, the current one marked is-active. */
.ui-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--ui-line); overflow-x: auto; }
.ui-tab {
  margin-bottom: -1px; padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer;
  font: inherit; font-size: 15px; color: var(--ui-muted); text-decoration: none; white-space: nowrap;
}
.ui-tab:hover { color: var(--ui-ink); }
.ui-tab.is-active { color: var(--ui-ink); border-bottom-color: var(--ui-ink); }

/* Notices: a message inside the page. */
.ui-notice { padding: 14px 16px; border-radius: var(--ui-radius); background: var(--ui-surface-3); font-size: 14.5px; line-height: 1.5; color: var(--ui-ink-2); }
.ui-notice-good { background: color-mix(in srgb, var(--ui-good) 11%, transparent); color: var(--ui-good); }
.ui-notice-warn { background: color-mix(in srgb, var(--ui-warn) 13%, transparent); color: var(--ui-warn); }
.ui-notice-bad { background: color-mix(in srgb, var(--ui-bad) 10%, transparent); color: var(--ui-bad); }

/* Icon-only buttons and the "more actions" menu (a <details class="ui-menu">). */
.ui-icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 9999px; background: none; color: var(--ui-muted); cursor: pointer; text-decoration: none;
}
.ui-icon-btn:hover { background: var(--ui-surface-3); color: var(--ui-ink); }
.ui-icon-btn svg { width: 18px; height: 18px; }
.ui-menu { position: relative; display: inline-block; }
.ui-menu > summary { list-style: none; }
.ui-menu > summary::-webkit-details-marker { display: none; }
.ui-menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 200px; padding: 6px;
  background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius);
  box-shadow: 0 18px 40px -16px rgba(11, 11, 11, 0.3);
}
.ui-menu-item {
  display: block; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  text-align: left; font: inherit; font-size: 14.5px; color: var(--ui-ink); text-decoration: none;
}
.ui-menu-item:hover { background: var(--ui-surface-2); }
.ui-menu-item-danger { color: var(--ui-bad); }

/* Forms: one column of fields, rows of related fields, actions at the end. */
.ui-form { display: grid; gap: 18px; }
.ui-form-narrow { max-width: 640px; }
.ui-form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.ui-form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding-top: 6px; }
.ui-check { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--ui-ink); cursor: pointer; }
.ui-check input { width: 18px; height: 18px; accent-color: var(--ui-btn-bg); }
.ui-error { font-size: 13.5px; color: var(--ui-bad); }

/* Label and value pairs. */
.ui-kv { display: grid; grid-template-columns: minmax(120px, 220px) 1fr; gap: 10px 24px; margin: 0; font-size: 15px; }
.ui-kv dt { color: var(--ui-muted); }
.ui-kv dd { margin: 0; color: var(--ui-ink); }

/* Layout helpers, so pages need no layout classes of their own. */
.ui-stack > * + * { margin-top: 16px; }
.ui-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ui-split { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.ui-cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.ui-cols-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.ui-grow { flex: 1; min-width: 0; }
.ui-muted { color: var(--ui-muted); }
.ui-small { font-size: 13.5px; }
.ui-num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.ui-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-hidden { display: none !important; }

/* Hidden means hidden, also on components that set their own display. */
[hidden] { display: none !important; }
[class*='ui-'].hidden { display: none !important; }

/* A scrim for panels that scripts show and hide with the "hidden" class. */
.ui-overlay {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(11, 11, 11, 0.45); overflow-y: auto;
}

/* Progress, avatars, toasts, inputs with a trailing button, and secrets shown as code. */
.ui-progress { display: block; width: 100%; height: 6px; border: 0; border-radius: 9999px; overflow: hidden; background: var(--ui-surface-3); appearance: none; -webkit-appearance: none; }
.ui-progress::-webkit-progress-bar { background: var(--ui-surface-3); }
.ui-progress::-webkit-progress-value { background: var(--ui-btn-bg); border-radius: 9999px; }
.ui-progress::-moz-progress-bar { background: var(--ui-btn-bg); border-radius: 9999px; }
.ui-avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 9999px; overflow: hidden; background: var(--ui-surface-3); color: var(--ui-ink); font-size: 15px; font-weight: 500;
  object-fit: cover;
}
.ui-avatar-lg { width: 96px; height: 96px; font-size: 32px; }
.ui-toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 10px; width: min(92vw, 360px); }
.ui-toast {
  padding: 12px 16px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-surface);
  box-shadow: 0 18px 40px -16px rgba(11, 11, 11, 0.3); font-size: 14.5px; color: var(--ui-ink);
}
.ui-toast-good { border-color: color-mix(in srgb, var(--ui-good) 40%, transparent); }
.ui-toast-bad { border-color: color-mix(in srgb, var(--ui-bad) 40%, transparent); }
.ui-input-group { display: flex; align-items: center; gap: 8px; }
.ui-input-group > .ui-input, .ui-input-group > input { flex: 1; min-width: 0; }
.ui-code {
  display: block; padding: 12px 14px; border-radius: var(--ui-radius); background: var(--ui-panel); color: #e7e7e4;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; overflow-x: auto; word-break: break-all;
}

/* Suite additions from the first conversions. */
.ui-btn:disabled, .ui-btn[disabled], .ui-btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.ui-table th.ui-num { text-align: right; }
.ui-w-sm { width: 7rem; flex: 0 0 auto; }
.ui-w-md { width: 14rem; flex: 0 0 auto; }
.ui-toolbar-row { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }

/* A coloured status dot, and a card tinted by a status. */
.ui-dot { display: inline-block; width: 10px; height: 10px; border-radius: 9999px; background: var(--ui-line-2); flex-shrink: 0; }
button.ui-dot { width: 16px; height: 16px; padding: 0; border: 0; cursor: pointer; }
.ui-dot-good { background: var(--ui-good); } .ui-dot-warn { background: var(--ui-warn); } .ui-dot-bad { background: var(--ui-bad); }
.ui-dot[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--ui-surface), 0 0 0 4px var(--ui-ink); }
.ui-card[data-card-color='green'] { border-color: color-mix(in srgb, var(--ui-good) 45%, transparent); background: color-mix(in srgb, var(--ui-good) 6%, var(--ui-surface)); }
.ui-card[data-card-color='yellow'] { border-color: color-mix(in srgb, var(--ui-warn) 45%, transparent); background: color-mix(in srgb, var(--ui-warn) 7%, var(--ui-surface)); }
.ui-card[data-card-color='red'] { border-color: color-mix(in srgb, var(--ui-bad) 45%, transparent); background: color-mix(in srgb, var(--ui-bad) 6%, var(--ui-surface)); }

/* A text input with suggestions under it. */
.ui-autocomplete { position: relative; }
.ui-autocomplete > .ui-menu-panel { left: 0; right: 0; top: calc(100% + 4px); max-height: 280px; overflow-y: auto; }
.ui-pick-list li.is-active { background: var(--ui-surface-2); box-shadow: inset 2px 0 0 var(--ui-ink); }
.ui-required { margin-left: 3px; color: var(--ui-bad); }
.ui-field > input[type='file'], input[type='file'].ui-input { height: auto; padding: 9px 14px; }
.ui-subhead { margin: 0; font-size: 15px; font-weight: 500; letter-spacing: -0.01em; color: var(--ui-ink); }
.ui-menu-note { padding: 10px 12px; font-size: 14px; color: var(--ui-muted); }

/* Signed money, compact inputs inside tables, a wider dialog, a side drawer. */
.ui-pos { color: var(--ui-good); } .ui-neg { color: var(--ui-bad); } .ui-caution { color: var(--ui-warn); }
.ui-input-compact, .ui-table .ui-input-compact { width: auto; max-width: 9rem; height: 32px; padding: 0 8px; font-size: 13.5px; border-radius: 8px; }
.ui-dialog-xl { width: min(94vw, 672px); }
.ui-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70; width: min(94vw, 480px); padding: 24px; overflow-y: auto;
  background: var(--ui-surface); border-left: 1px solid var(--ui-line); box-shadow: -24px 0 48px -32px rgba(11, 11, 11, 0.35);
}

/* Components carry their own text colour, so bare text inside one is right in both looks. */
.ui-card, .ui-toolbar, .ui-table-wrap, .ui-stat, .ui-dialog, .ui-drawer { color: var(--ui-ink-2); }
.ui-ink { color: var(--ui-ink); }
.ui-text-good { color: var(--ui-good); } .ui-text-warn { color: var(--ui-warn); } .ui-text-bad { color: var(--ui-bad); }

/* Disabled controls, selectable chips, dividers. */
.ui-input:disabled, .ui-field > input:disabled, .ui-field > select:disabled, .ui-field > textarea:disabled { opacity: 0.6; cursor: not-allowed; background: var(--ui-surface-2); }
.ui-chip {
  display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border: 1px solid var(--ui-line-2); border-radius: 9999px;
  background: var(--ui-surface); cursor: pointer; font: inherit; font-size: 14px; color: var(--ui-ink-2);
}
.ui-chip.is-active, .ui-chip[aria-pressed='true'] { background: var(--ui-btn-bg); border-color: var(--ui-btn-bg); color: var(--ui-btn-fg); }
.ui-divider { height: 1px; margin: 20px 0; border: 0; background: var(--ui-line); }
.ui-cols-2 > .ui-card, .ui-cols-3 > .ui-card, .ui-stack > .ui-card { margin-top: 0; }
.ui-stack > .ui-card + .ui-card { margin-top: 16px; }
.ui-table-plain tbody tr:hover td { background: transparent; }

/* Second-level tabs (views inside a tab), script-positioned menus, tooltips, bare checkboxes. */
.ui-tabs-sub { border-bottom: 0; gap: 6px; margin-bottom: 16px; }
.ui-tabs-sub .ui-tab { margin: 0; padding: 6px 12px; border: 1px solid transparent; border-radius: 9999px; font-size: 14px; }
.ui-tabs-sub .ui-tab:hover { background: var(--ui-surface-3); }
.ui-tabs-sub .ui-tab.is-active { background: var(--ui-surface); border-color: var(--ui-line-2); color: var(--ui-ink); }
.ui-menu-panel-free { position: fixed; right: auto; top: auto; }
.ui-tooltip {
  position: absolute; z-index: 60; max-width: 280px; padding: 8px 10px; border-radius: 8px; background: var(--ui-panel); color: #e7e7e4;
  font-size: 12.5px; line-height: 1.45; box-shadow: 0 12px 28px -12px rgba(11, 11, 11, 0.4);
}
.ui-checkbox { width: 18px; height: 18px; accent-color: var(--ui-btn-bg); cursor: pointer; }

/* Block components keep a standard gap from each other, wherever they meet. */
:where(.ui-card, .ui-toolbar, .ui-table-wrap, .ui-notice, .ui-grid, .ui-cols-2, .ui-cols-3, .ui-stats, .ui-tabs, .ui-empty, form.ui-form, p.ui-muted)
  + :where(.ui-card, .ui-toolbar, .ui-table-wrap, .ui-notice, .ui-grid, .ui-cols-2, .ui-cols-3, .ui-empty, form.ui-form, p.ui-muted) { margin-top: 16px; }
.ui-grid > *, .ui-cols-2 > *, .ui-cols-3 > *, .ui-row > *, .ui-stats > * { margin-top: 0; }

/* A list of checkboxes: one per line, or in columns when there are many. */
.ui-check-list { display: grid; gap: 10px; }
.ui-check-list-cols { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px 24px; }
.ui-check { align-items: flex-start; line-height: 1.35; }
.ui-check input { margin-top: 1px; flex-shrink: 0; }
.ui-nowrap { white-space: nowrap; }

/* A dialog taller than the screen stays reachable: the overlay scrolls and centres its panel. */
.ui-overlay { align-items: flex-start; }
.ui-overlay > * { margin: auto; }

/* Spinner, warning toast, invalid input, bullet list, clickable. */
@keyframes ui-spin { to { transform: rotate(360deg); } }
.ui-spinner {
  display: inline-block; width: 16px; height: 16px; flex-shrink: 0; border: 2px solid var(--ui-line-2);
  border-top-color: var(--ui-ink); border-radius: 9999px; animation: ui-spin 0.7s linear infinite;
}
.ui-btn-primary .ui-spinner { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }
.ui-toast-warn { border-color: color-mix(in srgb, var(--ui-warn) 45%, transparent); }
.ui-input.is-invalid, .ui-field > .is-invalid { border-color: var(--ui-bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-bad) 14%, transparent); }
.ui-list { margin: 0; padding-left: 1.2em; list-style: disc; }
.ui-list li + li { margin-top: 4px; }
.ui-click { cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .ui-spinner { animation-duration: 2s; } }

/* Classic look: the page body sits under the old header, so lift it while an overlay or drawer is open. */
html:not(.v2) main:has(.ui-overlay:not(.hidden)), html:not(.v2) main:has(.ui-drawer.open) { z-index: 50; }

/* Menu item states. */
.ui-menu-item.is-current { background: var(--ui-surface-3); }
.ui-menu-item.is-sub { padding-left: 26px; }
.ui-menu-item[aria-disabled='true'], .ui-menu-item:disabled { opacity: 0.5; cursor: not-allowed; }

/* The classic look's own light mode (the toggle on project pages). */
html:not(.v2)[data-theme='light'] {
  --ui-bg: #f8f9fa; --ui-surface: #ffffff; --ui-surface-2: #f3f4f6; --ui-surface-3: #e5e7eb;
  --ui-line: #d1d5db; --ui-line-2: #9ca3af; --ui-ink: #111827; --ui-ink-2: #374151; --ui-muted: #6b7280;
  --ui-brand: #2563eb; --ui-panel: #111827; --ui-good: #15803d; --ui-warn: #b45309; --ui-bad: #b91c1c;
}

/* Text helpers also win inside table cells; a tooltip a script places; a textarea outside a field. */
.ui-table td.ui-muted { color: var(--ui-muted); }
.ui-table td.ui-pos, .ui-table .ui-pos { color: var(--ui-good); }
.ui-table td.ui-neg, .ui-table .ui-neg { color: var(--ui-bad); }
.ui-tooltip-free { position: fixed; z-index: 75; }
textarea.ui-input { height: auto; min-height: 96px; padding: 10px 14px; }
.ui-table tr.ui-row-group td { background: var(--ui-surface-2); font-weight: 500; color: var(--ui-ink); }

/* A dialog's title row: the title wraps, the close button stays beside it. */
.ui-dialog .ui-split { flex-wrap: nowrap; align-items: flex-start; }
.ui-dialog .ui-split > :first-child { flex: 1 1 auto; min-width: 0; }
.ui-dialog .ui-split > .ui-dialog-title { margin: 0; }

/* ---------- Rendered markdown (notes, wiki text, document bodies) ---------- */
.ui-prose { color: var(--ui-ink-2); line-height: 1.6; overflow-wrap: anywhere; }
.ui-prose h1 { font-size: 1.375rem; font-weight: 500; margin: 1.5rem 0 0.75rem; color: var(--ui-ink); }
.ui-prose h2 { font-size: 1.2rem; font-weight: 500; margin: 1.25rem 0 0.5rem; color: var(--ui-ink); }
.ui-prose h3 { font-size: 1.05rem; font-weight: 500; margin: 1rem 0 0.5rem; color: var(--ui-ink); }
.ui-prose > :first-child { margin-top: 0; }
.ui-prose p { margin-bottom: 0.75rem; }
.ui-prose ul, .ui-prose ol { margin-left: 1.5rem; margin-bottom: 0.75rem; }
.ui-prose li { margin-bottom: 0.25rem; }
.ui-prose ul { list-style-type: disc; }
.ui-prose ol { list-style-type: decimal; }
.ui-prose strong { color: var(--ui-ink); font-weight: 600; }
.ui-prose em { font-style: italic; }
.ui-prose code { background: var(--ui-surface-3); padding: 0.125rem 0.375rem; border-radius: 0.25rem; font-family: monospace; font-size: 0.875rem; }
.ui-prose pre { background: var(--ui-surface-2); padding: 1rem; border-radius: var(--ui-radius); overflow-x: auto; margin-bottom: 0.75rem; }
.ui-prose pre code { background: transparent; padding: 0; }
.ui-prose blockquote { border-left: 3px solid var(--ui-line-2); padding-left: 1rem; margin: 0 0 0.75rem; font-style: italic; }
.ui-prose a { color: var(--ui-ink); text-decoration: underline; }
.ui-prose hr { border-color: var(--ui-line); margin: 1rem 0; }
.ui-prose table { width: 100%; border-collapse: collapse; margin-bottom: 0.75rem; }
.ui-prose th, .ui-prose td { border: 1px solid var(--ui-line); padding: 0.5rem; text-align: left; }
.ui-prose th { background: var(--ui-surface-2); color: var(--ui-ink); }
.ui-prose > :last-child { margin-bottom: 0; }

/* =====================================================================
   Page shapes. Every page is one of four: a list, a detail page (content
   plus a facts column), a form, or a project tab. These classes are the
   whole layout vocabulary; pages do not invent their own.
   ===================================================================== */
.ui-icon { flex: none; vertical-align: -0.2em; }

/* Type scale: one step down from the first pass; hierarchy from size and space. */
.ui-page-header { align-items: center; margin-bottom: 22px; }
.ui-title { font-size: 28px; line-height: 1.15; letter-spacing: -0.03em; }
.ui-subtitle { margin-top: 6px; font-size: 14.5px; color: var(--ui-muted); }
.ui-eyebrow { margin-bottom: 4px; font-size: 13px; }

/* Breadcrumb: where this page sits. Replaces every "Back" button. */
.ui-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; font-size: 13.5px; color: var(--ui-muted); }
.ui-crumbs a { color: var(--ui-muted); text-decoration: none; }
.ui-crumbs a:hover { color: var(--ui-ink); text-decoration: underline; }
.ui-crumbs > * + *::before { content: '/'; margin-right: 6px; color: var(--ui-line-2); }
.ui-crumbs > :last-child { color: var(--ui-ink-2); }

/* Widths: forms and reading pages are narrow on purpose. */
.ui-page-narrow { max-width: 760px; }
.ui-page-reading { max-width: 880px; margin-inline: auto; }

/* Detail page: content on the left, a column of facts and actions on the right. */
.ui-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.ui-layout-main { min-width: 0; display: grid; gap: 24px; }
.ui-layout-aside { position: sticky; top: 24px; display: grid; gap: 16px; }
.ui-layout-aside .ui-card + .ui-card { margin-top: 0; }
@media (max-width: 1040px) { .ui-layout { grid-template-columns: 1fr; } .ui-layout-aside { position: static; } }

/* Facts: label over value, in the facts column. */
.ui-facts { margin: 0; display: grid; gap: 14px; }
.ui-facts dt { font-size: 12.5px; color: var(--ui-muted); }
.ui-facts dd { margin: 2px 0 0; font-size: 14.5px; color: var(--ui-ink); overflow-wrap: anywhere; }
.ui-card-title-sm { margin: 0 0 14px; font-size: 13px; font-weight: 500; color: var(--ui-muted); }

/* Filters: one quiet row above a list. Changing a control applies it
   (data-ui-autosubmit on the form); there is no Apply button and no card. */
.ui-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 16px; }
.ui-filters select, .ui-filters input { height: 38px; width: auto; min-width: 140px; padding: 0 12px; font: inherit; font-size: 14px;
  color: var(--ui-ink); background: var(--ui-surface); border: 1px solid var(--ui-line-2); border-radius: 10px; }
.ui-filters select:focus, .ui-filters input:focus { outline: 2px solid var(--ui-ink); outline-offset: 1px; }
/* A list page carries up to five selects and a search box; they share one row on a laptop. A select is as
   wide as its longest option (a project title) unless capped, so each is capped and the search box gives way. */
.ui-filters select { flex: 0 1 auto; min-width: 118px; max-width: 176px; text-overflow: ellipsis; }
.ui-filters-search { position: relative; flex: 1 1 200px; min-width: 170px; max-width: 340px; }
.ui-filters-search input { width: 100%; padding-left: 36px; }
.ui-filters-search .ui-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ui-muted); pointer-events: none; }
.ui-filters-end { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ui-count { font-size: 13.5px; color: var(--ui-muted); }

/* Rows: a list where the whole row is the link. For files, updates, queues. */
.ui-rows { list-style: none; margin: 0; padding: 0; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg); overflow: hidden; }
.ui-rows > * + * { border-top: 1px solid var(--ui-line); }
.ui-row-item { display: flex; align-items: center; gap: 14px; padding: 13px 18px; color: inherit; text-decoration: none; }
a.ui-row-item:hover, .ui-row-item.ui-click:hover { background: var(--ui-surface-2); }
.ui-row-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--ui-surface-2); color: var(--ui-ink-2); }
.ui-row-icon-brand { background: color-mix(in srgb, var(--ui-brand) 12%, transparent); color: var(--ui-brand); }
.ui-row-icon-warn { background: color-mix(in srgb, var(--ui-warn) 14%, transparent); color: var(--ui-warn); }
.ui-row-icon-bad { background: color-mix(in srgb, var(--ui-bad) 12%, transparent); color: var(--ui-bad); }
.ui-row-icon-good { background: color-mix(in srgb, var(--ui-good) 12%, transparent); color: var(--ui-good); }
.ui-row-body { min-width: 0; flex: 1; }
.ui-row-title { margin: 0; font-size: 14.5px; font-weight: 500; color: var(--ui-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-row-meta { margin: 2px 0 0; font-size: 13px; color: var(--ui-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-row-end { display: flex; align-items: center; gap: 12px; flex: none; font-size: 13.5px; color: var(--ui-muted); }
.ui-row-end .ui-icon { color: var(--ui-line-2); }
.ui-rows-head { padding: 9px 18px; font-size: 12.5px; color: var(--ui-muted); background: var(--ui-surface-2); }

/* Attention: the things someone has to do, most urgent first. */
.ui-attention { display: grid; gap: 10px; }
.ui-attention-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg); }
.ui-attention-item.is-bad { border-color: color-mix(in srgb, var(--ui-bad) 35%, var(--ui-line)); }

/* Timeline: dated entries down a rail. */
.ui-timeline { list-style: none; margin: 0; padding: 0; }
.ui-timeline-month { margin: 26px 0 10px; font-size: 13px; color: var(--ui-muted); }
.ui-timeline-month:first-child { margin-top: 0; }
.ui-timeline-item { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 16px; }
.ui-timeline-date { padding-top: 16px; text-align: right; font-size: 13px; color: var(--ui-muted); }
.ui-timeline-date b { display: block; font-size: 20px; font-weight: 400; line-height: 1; color: var(--ui-ink); letter-spacing: -0.02em; }
.ui-timeline-body { position: relative; padding: 0 0 12px 22px; border-left: 1px solid var(--ui-line-2); }
.ui-timeline-body::before { content: ''; position: absolute; left: -5px; top: 21px; width: 9px; height: 9px; border-radius: 50%; background: var(--ui-surface); border: 2px solid var(--ui-ink); }
.ui-timeline-item.is-future .ui-timeline-body::before { border-color: var(--ui-line-2); }
.ui-timeline-item:last-child .ui-timeline-body { padding-bottom: 0; }

/* Steps: where a project is, as a row of phases. */
.ui-steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ui-step { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: 9999px; font-size: 13px; color: var(--ui-muted); background: var(--ui-surface-2); }
.ui-step::before { content: ''; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--ui-line-2); }
.ui-step.is-done { color: var(--ui-ink-2); }
.ui-step.is-done::before { background: var(--ui-ink); border-color: var(--ui-ink); }
.ui-step.is-current { color: var(--ui-btn-fg); background: var(--ui-btn-bg); }
.ui-step.is-current::before { background: var(--ui-btn-fg); border-color: var(--ui-btn-fg); }

/* Form pages: one column, grouped, with the actions pinned to the bottom of the window. */
.ui-form-section { padding: 22px 0; border-top: 1px solid var(--ui-line); display: grid; gap: 16px; }
.ui-form-section:first-of-type { border-top: 0; padding-top: 0; }
.ui-form-section-title { margin: 0; font-size: 16px; font-weight: 500; color: var(--ui-ink); }
.ui-form-section-note { margin: 2px 0 0; font-size: 13.5px; color: var(--ui-muted); }
.ui-actionbar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  margin-top: 24px; padding: 14px 0; background: linear-gradient(to top, var(--ui-bg) 70%, transparent); }
.ui-actionbar-note { margin-right: auto; font-size: 13.5px; color: var(--ui-muted); }

/* Big number: one figure that matters, with its label. Use sparingly; a page of
   tiles is a page with no priority. */
.ui-figure { margin: 0; }
.ui-figure-label { font-size: 13px; color: var(--ui-muted); }
.ui-figure-value { margin-top: 2px; font-size: 30px; line-height: 1.1; letter-spacing: -0.03em; color: var(--ui-ink); font-variant-numeric: tabular-nums; }
.ui-figure-note { margin-top: 4px; font-size: 13px; color: var(--ui-muted); }
.ui-summary { display: flex; flex-wrap: wrap; gap: 20px 48px; padding: 20px 22px; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg); }

/* Density: an operations tool, not a landing page. */
.ui-btn { height: 38px; padding: 0 16px; font-size: 14px; }
.ui-btn-sm { height: 32px; padding: 0 12px; font-size: 13.5px; }
.ui-card { padding: 20px 22px; }
.ui-card-flush { padding: 0; }
.ui-table { font-size: 14px; }
.ui-table th { padding-top: 10px; padding-bottom: 10px; }
.ui-table td { padding: 12px 16px; }
.ui-table th { padding-left: 16px; padding-right: 16px; }
.ui-table tr[data-href] { cursor: pointer; }
.ui-section { margin-top: 32px; }
.ui-section-title { font-size: 17px; letter-spacing: -0.015em; }
.ui-section-note { font-size: 13.5px; }
.ui-kv { font-size: 14.5px; }

/* Row menu: the secondary actions of a table row or a page, behind one button. */
.ui-row-menu > .ui-menu-panel { right: 0; left: auto; min-width: 180px; }
.ui-row-menu .ui-menu-item { display: block; width: 100%; text-align: left; border: 0; background: none; cursor: pointer; font: inherit; font-size: 14px; }
.ui-row-menu form { margin: 0; }
td.ui-cell-menu, th.ui-cell-menu { width: 1%; padding-left: 0; text-align: right; white-space: nowrap; }
.ui-filters select { max-width: 240px; }

/* --- Gaps reported by the page rebuilds ---------------------------------- */
/* Cards stacked in a layout column are spaced by the grid, not by margins. */
.ui-layout-main > .ui-card + .ui-card, .ui-layout-main > .ui-card + .ui-table-wrap, .ui-layout-main > .ui-table-wrap + .ui-card,
.ui-layout-main > .ui-section, .ui-stack > .ui-card + .ui-card { margin-top: 0; }
/* Switch: a checkbox that reads as on/off. <label class="ui-switch"><input type="checkbox"><span></span> Label</label> */
.ui-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14.5px; color: var(--ui-ink); }
.ui-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ui-switch > span { position: relative; flex: none; width: 38px; height: 22px; border-radius: 9999px; background: var(--ui-line-2); transition: background-color 0.15s; }
.ui-switch > span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform 0.15s; }
.ui-switch input:checked + span { background: var(--ui-good); }
.ui-switch input:checked + span::after { transform: translateX(16px); }
.ui-switch input:focus-visible + span { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.ui-switch input:disabled + span { opacity: 0.5; }
/* Disclosure: an optional or advanced part of a form or page. <details class="ui-disclosure"><summary>Title</summary>…</details> */
.ui-disclosure { border-top: 1px solid var(--ui-line); }
.ui-disclosure > summary { display: flex; align-items: center; gap: 8px; padding: 16px 0; cursor: pointer; list-style: none; font-size: 15px; font-weight: 500; color: var(--ui-ink); }
.ui-disclosure > summary::-webkit-details-marker { display: none; }
.ui-disclosure > summary::before { content: ''; width: 7px; height: 7px; margin: 0 4px 2px 2px; border-right: 1.5px solid var(--ui-muted); border-bottom: 1.5px solid var(--ui-muted); transform: rotate(-45deg); transition: transform 0.15s; }
.ui-disclosure[open] > summary::before { transform: rotate(45deg); }
.ui-disclosure > summary small { font-size: 13px; font-weight: 400; color: var(--ui-muted); }
.ui-disclosure-body { padding: 0 0 20px; display: grid; gap: 16px; }
/* Controls on a row beside a button share its height. */
.ui-control-sm, select.ui-control-sm, input.ui-control-sm { height: 38px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--ui-ink); background: var(--ui-surface); border: 1px solid var(--ui-line-2); border-radius: 10px; }
/* Phones: lists drop their secondary columns instead of scrolling sideways. */
@media (max-width: 720px) {
  .ui-hide-sm, .ui-table th.ui-hide-sm, .ui-table td.ui-hide-sm { display: none; }
  .ui-attention-item, .ui-row-item { flex-wrap: wrap; }
  .ui-attention-item > *, .ui-row-body { min-width: 0; }
  .ui-row-title, .ui-row-meta { white-space: normal; }
  .ui-table td, .ui-table th { padding-left: 12px; padding-right: 12px; }
  .ui-title { font-size: 24px; }
  .ui-layout { gap: 20px; }
}
@media (min-width: 721px) { .ui-show-sm { display: none; } }


/* --- Third-party widgets on the suite's variables --------------------------
   The markdown editor (EasyMDE: wrap in .ui-editor), the searchable select
   (Choices: wrap in .ui-choices) and the code editor (CodeMirror: .ui-code-editor). */
.ui-editor .editor-toolbar {
    display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 8px; opacity: 1;
    border-color: var(--ui-line-2); border-radius: var(--ui-radius) var(--ui-radius) 0 0; background: var(--ui-surface-2);
}
.ui-editor .editor-toolbar:not(.fullscreen) { position: sticky; top: 0; z-index: 2; }
.ui-editor .editor-toolbar button { color: var(--ui-ink-2); font-size: 14px; }
.ui-editor .editor-toolbar button:hover, .ui-editor .editor-toolbar button.active { background: var(--ui-surface-3); border-color: transparent; color: var(--ui-ink); }
/* The page-wide .active rule (old navigation) paints with !important; the toolbar's pressed state must win. */
.ui-editor .editor-toolbar button.active, .ui-editor .editor-toolbar button.active:hover { background: var(--ui-surface-3) !important; border-color: transparent !important; outline: 0 !important; color: var(--ui-ink) !important; }
.ui-editor .editor-toolbar button.signature-btn { color: var(--ui-brand); }
.ui-editor .editor-toolbar i.separator { margin: 4px 6px; border-left-color: var(--ui-line-2); border-right-color: transparent; }
.ui-editor .EasyMDEContainer .CodeMirror {
    padding: 14px 16px; border-color: var(--ui-line-2); border-radius: 0 0 var(--ui-radius) var(--ui-radius);
    background: var(--ui-surface); color: var(--ui-ink); font-size: 15px; line-height: 1.6;
}
.ui-editor .CodeMirror-cursor { border-left-color: var(--ui-ink); }
.ui-editor .CodeMirror-selected, .ui-editor .EasyMDEContainer .CodeMirror-focused .CodeMirror-selected { background: color-mix(in srgb, var(--ui-brand) 18%, transparent); }
.ui-editor .cm-s-easymde .cm-header-1 { font-size: 1.45rem; }
.ui-editor .cm-s-easymde .cm-header-2 { font-size: 1.25rem; }
.ui-editor .cm-s-easymde .cm-header-3, .ui-editor .cm-s-easymde .cm-header-4, .ui-editor .cm-s-easymde .cm-header-5 { font-size: 1.08rem; }
.ui-editor .cm-s-easymde .cm-link, .ui-editor .cm-s-easymde .cm-url, .ui-editor .cm-s-easymde .cm-quote { color: var(--ui-muted); }
.ui-editor .cm-s-easymde .cm-comment { background: var(--ui-surface-3); }
.ui-editor .editor-statusbar { padding: 6px 2px 0; color: var(--ui-muted); }
.ui-editor .editor-preview, .ui-editor .editor-preview-side { background: var(--ui-surface); color: var(--ui-ink-2); border-color: var(--ui-line-2); }
/* Full screen and side by side sit above the portal's sidebar. */
.ui-editor .editor-toolbar.fullscreen, .ui-editor .EasyMDEContainer .CodeMirror-fullscreen { background: var(--ui-surface); z-index: 65; }
.ui-editor .editor-toolbar.fullscreen::before, .ui-editor .editor-toolbar.fullscreen::after { display: none; }
.ui-editor .editor-preview-side { z-index: 65; }

.ui-choices {
    --choices-bg-color: var(--ui-surface); --choices-bg-color-dropdown: var(--ui-surface); --choices-keyline-color: var(--ui-line-2);
    --choices-border-radius: var(--ui-radius); --choices-text-color: var(--ui-ink); --choices-highlighted-color: var(--ui-surface-2);
    --choices-darken: var(--ui-ink); --choices-input-height: 42px; --choices-inner-padding: 5px 8px 2px; --choices-inner-one-padding: 5px;
    --choices-font-size-lg: 15px; --choices-font-size-md: 15px; --choices-guttering: 0; --choices-z-index: 30;
}
.ui-choices .choices { color: var(--ui-ink); }
.ui-choices .choices__list--dropdown .choices__item { color: var(--ui-ink-2); overflow-wrap: anywhere; word-break: normal; }
.ui-choices .choices[data-type*='select-one'] .choices__input {
    height: auto; border: 0; border-bottom: 1px solid var(--ui-line); border-radius: 0; box-shadow: none; outline: 0; color: var(--ui-ink);
}
.ui-code-editor .CodeMirror { height: 62vh; min-height: 360px; border: 1px solid var(--ui-line-2); border-radius: var(--ui-radius); font-size: 13.5px; }

/* More gaps from the rebuilds. */
.ui-table th:first-child, .ui-table td:first-child { min-width: 14rem; }
.ui-table-plain th:first-child, .ui-table-plain td:first-child, .ui-table th.ui-cell-check, .ui-table td.ui-cell-check { min-width: 0; }
.ui-layout-aside { max-height: calc(100vh - 48px); overflow-y: auto; scrollbar-width: thin; }
@media (max-width: 1040px) { .ui-layout-aside { max-height: none; overflow: visible; } }
.ui-dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.ui-code-inline { padding: 1px 6px; border-radius: 6px; background: var(--ui-surface-3); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; color: var(--ui-ink); }
.ui-signature { font-family: 'Snell Roundhand', 'Brush Script MT', cursive; font-size: 1.5em; color: var(--ui-ink); }

/* Gaps from the Updates rebuild. */
.ui-subtitle-page, .ui-page-title-sm { margin: 0; font-size: 22px; font-weight: var(--ui-title-weight); line-height: 1.2; letter-spacing: -0.025em; color: var(--ui-ink); }
.ui-clamp-2, .ui-clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.ui-clamp-2 { -webkit-line-clamp: 2; } .ui-clamp-3 { -webkit-line-clamp: 3; }
/* A card that is one link: put .ui-stretch on the title link inside a .ui-card-link. */
.ui-card-link { position: relative; transition: border-color 0.12s; }
.ui-card-link:hover { border-color: var(--ui-line-2); }
.ui-stretch::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.ui-card-link .ui-menu, .ui-card-link a:not(.ui-stretch), .ui-card-link button { position: relative; z-index: 1; }
.ui-link-quiet { color: var(--ui-muted); text-decoration: none; }
.ui-link-quiet:hover { color: var(--ui-ink); text-decoration: underline; }
button.ui-row-item { width: 100%; border: 0; background: none; cursor: pointer; text-align: left; font: inherit; }
@media (max-width: 520px) {
  .ui-timeline-item { grid-template-columns: 1fr; gap: 4px; }
  .ui-timeline-date { padding-top: 10px; text-align: left; }
  .ui-timeline-date b { display: inline; font-size: 14px; margin-right: 4px; }
  .ui-timeline-body { padding-left: 0; border-left: 0; }
  .ui-timeline-body::before { display: none; }
}

/* Row menus escape the table's scroll box: the script places the open panel on the window. */
.ui-menu-panel.is-floating { position: fixed; right: auto; bottom: auto; z-index: 80; }
a.ui-attention-item { color: inherit; text-decoration: none; transition: border-color 0.12s, background-color 0.12s; }
a.ui-attention-item:hover { border-color: var(--ui-line-2); background: var(--ui-surface-2); }
.ui-row-title.ui-wrap, .ui-row-meta.ui-wrap { white-space: normal; }
.ui-avatar-sm { width: 20px; height: 20px; font-size: 10.5px; }
.ui-pick-list { background: var(--ui-surface); }

/* Phones: a list table becomes a stack of rows. The name cell takes the first line, the
   other cells follow on one wrapped line, the row menu sits top right, and cells marked
   ui-hide-sm are dropped. Tables of inputs (ui-table-plain) and wide grids (ui-table-wide)
   keep their columns and scroll sideways. */
@media (max-width: 720px) {
  .ui-table:not(.ui-table-plain):not(.ui-table-wide) thead { display: none; }
  .ui-table:not(.ui-table-plain):not(.ui-table-wide), .ui-table:not(.ui-table-plain):not(.ui-table-wide) tbody { display: block; }
  .ui-table:not(.ui-table-plain):not(.ui-table-wide) tr { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 14px; border-bottom: 1px solid var(--ui-line); }
  .ui-table:not(.ui-table-plain):not(.ui-table-wide) tbody tr:last-child { border-bottom: 0; }
  .ui-table:not(.ui-table-plain):not(.ui-table-wide) td { display: block; padding: 0; border: 0; min-width: 0; text-align: left; font-size: 13.5px; }
  .ui-table:not(.ui-table-plain):not(.ui-table-wide) td:first-child { flex: 1 1 100%; padding-right: 36px; font-size: 14.5px; }
  .ui-table:not(.ui-table-plain):not(.ui-table-wide) td.ui-cell-menu { position: absolute; top: 6px; right: 6px; width: auto; }
  .ui-table:not(.ui-table-plain):not(.ui-table-wide) td:empty { display: none; }
  .ui-table:not(.ui-table-plain):not(.ui-table-wide) td.ui-num { margin-left: auto; }
  .ui-table tr:hover td { background: none; }
  .ui-table:not(.ui-table-plain):not(.ui-table-wide) td.ui-hide-sm { display: none; }
}

/* Gaps from the Billing rebuild. */
@media (max-width: 1040px) { .ui-layout-aside-first > .ui-layout-aside { order: -1; } }
.ui-figure-sm .ui-figure-value { font-size: 20px; }
.ui-sep::before { content: '·'; margin: 0 6px; color: var(--ui-line-2); }
.ui-facts.ui-mt, .ui-kv.ui-mt, .ui-list.ui-mt, .ui-section-title.ui-mt, .ui-subhead.ui-mt, .ui-timeline.ui-mt { margin-top: 16px; }

/* Gaps from the workspace rebuild. */
.ui-layout-main > *, .ui-attention-item > .ui-row-body, .ui-attention-item { min-width: 0; }
.ui-clamp-4 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; -webkit-line-clamp: 4; }
.ui-dot-brand { background: var(--ui-brand); }

/* Gaps from the Files rebuild. */
.ui-sheet { background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg); padding: clamp(20px, 4vw, 48px); }
.ui-sheet table { display: block; max-width: 100%; overflow-x: auto; }
.ui-row-end .ui-icon-btn .ui-icon, .ui-row-end .ui-btn .ui-icon { color: inherit; }
.ui-row-item[data-href] { cursor: pointer; }
.ui-row-item[data-href]:hover { background: var(--ui-surface-2); }
.ui-stack > :not(.ui-card) + .ui-card { margin-top: 16px; }
@media print {
  .ui-crumbs, .ui-page-header-actions, .ui-actionbar, .ui-filters, .ui-tabs, .ui-row-menu, .ui-layout-aside { display: none !important; }
  .ui-layout { display: block; } .ui-sheet, .ui-card { border: 0; padding: 0; }
  body { background: #fff !important; }
}

/* Gaps from the Invoices rebuild. */
.ui-icon { display: inline-block; }
.ui-form > *, .ui-form-section > * { min-width: 0; }
.ui-actionbar { flex-wrap: wrap; }
.ui-figure-note.ui-text-bad, .ui-row-meta.ui-text-bad, .ui-cell-sub.ui-text-bad, .ui-table .ui-cell-sub.ui-text-bad { color: var(--ui-bad); }
.ui-figure-note.ui-text-warn, .ui-row-meta.ui-text-warn, .ui-cell-sub.ui-text-warn, .ui-table .ui-cell-sub.ui-text-warn { color: var(--ui-warn); }
.ui-figure-note.ui-text-good, .ui-row-meta.ui-text-good, .ui-cell-sub.ui-text-good, .ui-table .ui-cell-sub.ui-text-good { color: var(--ui-good); }

/* The facts column scrolls with the page: a pinned column cut off anything below the fold.
   Add ui-layout-aside-sticky only where the column is short and the content is long. */
.ui-layout-aside { position: static; max-height: none; overflow: visible; }
.ui-layout-aside.ui-layout-aside-sticky { position: sticky; top: 24px; }
@media (max-width: 1040px) { .ui-layout-aside.ui-layout-aside-sticky { position: static; } }

/* Gaps from the Sales rebuild. */
.ui-filters input[type='checkbox'], .ui-filters input[type='radio'] { height: auto; width: auto; min-width: 0; padding: 0; }
.ui-switch > span:not(:first-of-type) { all: unset; }
.ui-stack > .ui-notice + .ui-card { margin-top: 0; }
.ui-stack { gap: 16px; }
@media (max-width: 720px) { .ui-actionbar-note { flex: 1 1 100%; margin-right: 0; } }
.ui-row-icon-violet { background: color-mix(in srgb, #7c3aed 12%, transparent); color: #6d28d9; }
.ui-timeline-plain .ui-timeline-body { padding-bottom: 14px; padding-top: 12px; }

/* Corrections and gaps from the Library and sign-in rebuild. */
.ui-stack > .ui-card + .ui-card, .ui-stack > .ui-notice + .ui-card, .ui-stack > * + .ui-card { margin-top: 16px; }
.ui-btn-block { width: 100%; justify-content: center; }
.ui-btn-lg { height: 44px; font-size: 15px; }
.ui-otp { letter-spacing: 0.4em; text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; height: 52px; }
.ui-disclosure-body { padding-left: 21px; }
.ui-prose table { display: block; max-width: 100%; overflow-x: auto; }
.ui-prose th, .ui-prose td { overflow-wrap: normal; word-break: normal; white-space: normal; min-width: 6rem; }
.ui-prose .codehilite pre, .ui-prose pre { font-size: 13px; line-height: 1.55; }
@media (max-width: 720px) { .ui-row-meta.ui-wrap, .ui-row-meta { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; } }
/* The signed-out pages: one centred card. */
.ui-auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: var(--ui-bg); }
.ui-auth-card { width: 100%; max-width: 400px; }

/* Gaps from the Payments rebuild. */
.ui-summary + .ui-filters, .ui-summary + .ui-table-wrap, .ui-summary + .ui-card, .ui-summary + .ui-section, .ui-tabs + .ui-summary, .ui-notice + .ui-summary, .ui-summary + .ui-notice { margin-top: 16px; }
.ui-summary { margin-bottom: 16px; }
.ui-figure-value.ui-neg, .ui-figure-value.ui-text-bad, .ui-figure-note.ui-neg { color: var(--ui-bad); }
.ui-figure-value.ui-pos, .ui-figure-value.ui-text-good, .ui-figure-note.ui-pos { color: var(--ui-good); }
.ui-chip-static { cursor: default; pointer-events: none; }
@media (max-width: 1100px) { .ui-hide-md, .ui-table th.ui-hide-md, .ui-table td.ui-hide-md { display: none; } }
/* Selects show a chevron. */
.ui-filters select, .ui-field > select, select.ui-input, select.ui-control-sm, select.ui-input-compact {
  appearance: none; -webkit-appearance: none; padding-right: 30px; background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f6f69' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.ui-field > select[multiple], select.ui-input[multiple] { background-image: none; padding-right: 12px; }
/* An editable cell: looks like text until hovered or focused. */
.ui-input-quiet { width: 100%; padding: 4px 6px; margin: -4px -6px; border: 1px solid transparent; border-radius: 6px; background: transparent; font: inherit; color: inherit; }
.ui-input-quiet:hover { border-color: var(--ui-line-2); }
.ui-input-quiet:focus { outline: 0; border-color: var(--ui-ink); background: var(--ui-surface); }

/* Narrow and reading pages start at the page's left edge like everything else;
   they are narrower, never centred. */
.ui-page-reading { margin-inline: 0; }

/* Feed: dated entries, newest first, under month labels. Each entry is a card with its
   date inside, so every card starts at the page edge. (Updates tab.) */
.ui-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ui-feed-label { margin: 18px 0 2px; font-size: 13px; color: var(--ui-muted); }
.ui-feed-label:first-child { margin-top: 0; }
.ui-feed-item > .ui-card { display: flex; flex-direction: row; align-items: flex-start; gap: 18px; padding: 18px 20px; }
.ui-feed-item .ui-feed-body { min-width: 0; flex: 1; display: grid; gap: 8px; }
.ui-feed-item .ui-feed-text { margin: 0; max-width: 78ch; font-size: 14.5px; line-height: 1.5; color: var(--ui-ink-2); }
.ui-date { flex: none; width: 40px; padding-top: 1px; text-align: center; font-size: 12.5px; line-height: 1.2; color: var(--ui-muted); }
.ui-date b { display: block; font-size: 21px; font-weight: 400; line-height: 1.1; letter-spacing: -0.02em; color: var(--ui-ink); }
/* A layout whose aside comes first in the page (and first on a phone) but sits on the right on a wide screen. */
@media (min-width: 1041px) {
  .ui-layout-aside-lead > .ui-layout-aside { grid-column: 2; grid-row: 1; }
  .ui-layout-aside-lead > .ui-layout-main { grid-column: 1; grid-row: 1; }
}

/* Tabs never show a scrollbar. The active tab's underline sits on the row's border
   (margin-bottom: -1px), which made the row overflow by a pixel and grow a bar.
   A row too wide for a phone still scrolls sideways, without the bar. */
.ui-tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -ms-overflow-style: none; }
.ui-tabs::-webkit-scrollbar { display: none; }

/* Breadcrumb: the way back up, nothing more. The current page's name is the title
   right under it, so the last (unlinked) entry is not shown. */
.ui-crumbs > span:last-child { display: none; }
.ui-crumbs > a:first-child::before { content: '←'; margin-right: 6px; color: var(--ui-muted); }
.ui-feed { grid-template-columns: minmax(0, 1fr); }
.ui-feed-row { position: relative; display: flex; align-items: flex-start; gap: 14px; }
.ui-feed-row > :last-child { min-width: 0; flex: 1; }
.ui-feed-row + .ui-feed-row { padding-top: 12px; border-top: 1px solid var(--ui-line); }


/* --- Dark mode (html.v2.dark, see portal-v2.css) --------------------------------
   Components take every colour from these variables, so this block is the whole
   dark version. Primary buttons become light pills with dark text. */
html.v2.dark {
  --ui-bg: #0e0f11; --ui-surface: #17181b; --ui-surface-2: #1c1e22; --ui-surface-3: #26282d;
  --ui-line: #2a2c31; --ui-line-2: #3b3e45;
  --ui-ink: #f4f4f2; --ui-ink-2: #c9c9c4; --ui-muted: #8f8f89;
  --ui-brand: #86a8ff;
  --ui-btn-bg: #f4f4f2; --ui-btn-bg-hover: #dadad5; --ui-btn-fg: #0b0b0b;
  --ui-panel: #000000;
  --ui-good: #5fcf8f; --ui-warn: #e2b455; --ui-bad: #f1887d;
}
html.v2.dark .ui-btn-primary .ui-spinner { border-color: rgba(11, 11, 11, 0.25); border-top-color: #0b0b0b; }
html.v2.dark .ui-menu-panel, html.v2.dark .ui-dialog, html.v2.dark .ui-drawer { box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.8); }
html.v2.dark .ui-overlay, html.v2.dark dialog.ui-dialog::backdrop { background-color: rgba(0, 0, 0, 0.6); }
html.v2.dark .ui-row-icon-violet { color: #b79cff; }
html.v2.dark .ui-filters select, html.v2.dark .ui-field > select, html.v2.dark select.ui-input, html.v2.dark select.ui-control-sm, html.v2.dark select.ui-input-compact {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f8f89' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
/* Paper stays paper: a document body, a contract to sign or an invoice sheet is shown as
   the white page it prints as, with the light palette inside it. */
html.v2.dark .ui-paper, html.v2.dark .ui-sheet {
  --ui-bg: #f4f4f2; --ui-surface: #ffffff; --ui-surface-2: #f7f7f5; --ui-surface-3: #ebebe8;
  --ui-line: #e3e3de; --ui-line-2: #d2d2cc; --ui-ink: #0b0b0b; --ui-ink-2: #3d3d3a; --ui-muted: #6f6f69;
  --ui-brand: #1d54e2; --ui-btn-bg: #0b0b0b; --ui-btn-bg-hover: #2b2b29; --ui-btn-fg: #ffffff;
  --ui-good: #17663a; --ui-warn: #8a5a00; --ui-bad: #a3261c;
  background: #ffffff; color: #3d3d3a; color-scheme: light;
}

/* Gaps from the Marketing rebuild. */
.ui-figure-value.ui-caution, .ui-figure-value.ui-text-warn, .ui-figure-note.ui-caution { color: var(--ui-warn); }
@media (max-width: 720px) { .ui-table .ui-cell-sub.ui-hide-sm, .ui-table td .ui-hide-sm { display: none; } }
.ui-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ui-grid-2 > .ui-card { margin-top: 0; }
@media (max-width: 900px) { .ui-grid-2 { grid-template-columns: minmax(0, 1fr); } }
.ui-table th a.is-sorted { color: var(--ui-ink); }
.ui-check + .ui-hint, .ui-check .ui-hint { display: block; margin-left: 26px; }
.ui-dialog-chart { width: min(1100px, 94vw); max-width: none; }
svg.ui-inline { display: inline-block; vertical-align: middle; }

/* ── Search palette (templates/snippets/universal_search.html, static/js/portal-search.js) ──
   One surface, one line per result; the selected row is the only filled thing. */
.ui-palette-backdrop { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: flex-start; justify-content: center;
  padding: min(14vh, 120px) 16px 16px; background: rgba(11, 11, 11, 0.45); }
.ui-palette-backdrop[hidden] { display: none; }
html.ui-palette-open { overflow: hidden; }
.ui-palette { display: flex; flex-direction: column; width: min(100%, 640px); max-height: min(72vh, 620px); overflow: hidden;
  background: var(--ui-surface); color: var(--ui-ink-2); border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28); font-size: 15px; }
.ui-palette-bar { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--ui-line); color: var(--ui-muted); }
.ui-palette-bar > svg { flex-shrink: 0; }
.ui-palette .ui-palette-input { flex: 1; min-width: 0; height: 54px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  font: inherit; font-size: 17px; color: var(--ui-ink); outline: none; }
.ui-palette .ui-palette-input:focus { outline: none; box-shadow: none; border: 0; }
.ui-palette .ui-palette-input::placeholder { color: var(--ui-muted); opacity: 1; }
.ui-palette kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; margin: 0;
  font: inherit; font-size: 11.5px; line-height: 1; color: var(--ui-muted); background: var(--ui-surface-2); border: 1px solid var(--ui-line); border-radius: 6px; }
.ui-palette-scope { display: inline-flex; align-items: center; gap: 4px; max-width: 45%; height: 28px; padding: 0 4px 0 10px; flex-shrink: 0;
  font-size: 13.5px; color: var(--ui-ink); background: var(--ui-surface-3); border-radius: var(--ui-radius-pill); }
.ui-palette-scope[hidden] { display: none; }
.ui-palette-scope > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-palette-scope > button { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 9999px; background: transparent; color: var(--ui-muted);
  font-size: 16px; line-height: 1; cursor: pointer; }
.ui-palette-scope > button:hover { color: var(--ui-ink); background: var(--ui-line); }
.ui-palette-results { flex: 1; min-height: 120px; overflow-y: auto; padding: 6px; overscroll-behavior: contain; }
.ui-palette-group + .ui-palette-group { margin-top: 6px; }
.ui-palette-label { padding: 8px 10px 4px; font-size: 12.5px; color: var(--ui-muted); }
.ui-palette-item { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 7px 10px; border-radius: calc(var(--ui-radius) - 2px);
  color: var(--ui-ink-2); text-decoration: none; cursor: pointer; }
.ui-palette-item.is-active { background: var(--ui-surface-3); color: var(--ui-ink); }
.ui-palette-icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--ui-muted); }
.ui-palette-item.is-active .ui-palette-icon { color: var(--ui-ink); }
.ui-palette-text { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 1px; }
.ui-palette-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ui-ink); }
.ui-palette-tag { margin-left: 8px; font-size: 13px; color: var(--ui-muted); }
.ui-palette-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--ui-muted); }
.ui-palette-meta { flex-shrink: 0; font-size: 13px; color: var(--ui-muted); white-space: nowrap; }
.ui-palette-mark { padding: 0; background: transparent; color: inherit; font-weight: 600; text-decoration: underline; text-decoration-color: var(--ui-line-2); text-underline-offset: 3px; }
.ui-palette-item .ui-badge { flex-shrink: 0; }
.ui-palette-inside { display: none; flex-shrink: 0; height: 26px; padding: 0 10px; font: inherit; font-size: 12.5px; color: var(--ui-ink);
  background: var(--ui-surface); border: 1px solid var(--ui-line-2); border-radius: var(--ui-radius-pill); cursor: pointer; }
.ui-palette-item.is-active .ui-palette-inside { display: inline-flex; align-items: center; }
.ui-palette-inside:hover { border-color: var(--ui-ink); }
.ui-palette-empty { padding: 36px 16px; text-align: center; }
.ui-palette-empty-title { margin: 0; color: var(--ui-ink); }
.ui-palette-empty-note { margin: 4px 0 0; font-size: 13.5px; color: var(--ui-muted); }
.ui-palette-foot { display: flex; align-items: center; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--ui-line); font-size: 12.5px; color: var(--ui-muted); }
.ui-palette-foot > span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.ui-palette-foot > span[hidden] { display: none; }
.ui-palette-count { margin-left: auto; }
@media (max-width: 560px) {
  .ui-palette-backdrop { padding: 12px; }
  .ui-palette { max-height: calc(100vh - 24px); }
  .ui-palette-foot > span:not(.ui-palette-count) { display: none; }
  .ui-palette-item .ui-badge, .ui-palette-meta { display: none; }
}
html.v2.dark .ui-palette-backdrop { background: rgba(0, 0, 0, 0.6); }

/* ── "What's new" walkthrough (templates/snippets/whats_new.html) ── one step at a time, same dialog as everything else. */
.ui-tour { width: min(94vw, 480px); }
.ui-tour-count { margin: 0 0 18px; font-size: 13px; color: var(--ui-muted); }
.ui-tour-step { min-height: 172px; }
.ui-tour-step[hidden] { display: none; }
.ui-tour-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-bottom: 16px;
  border-radius: var(--ui-radius); background: var(--ui-surface-3); color: var(--ui-ink); }
.ui-tour .ui-dialog-title { margin-bottom: 8px; }
.ui-tour-body { margin: 0; font-size: 15.5px; line-height: 1.55; color: var(--ui-ink-2); }
.ui-tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; }
.ui-tour-dots { display: inline-flex; gap: 6px; }
.ui-tour-dots i { width: 6px; height: 6px; border-radius: 9999px; background: var(--ui-line-2); }
.ui-tour-dots i.is-on { background: var(--ui-ink); }
.ui-tour [hidden] { display: none !important; }

/* ── Switch between two or three views of the same thing (List / Board) ────── */
.ui-seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--ui-line-2); border-radius: 999px; background: var(--ui-surface); }
.ui-seg-item { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 13px; line-height: 1.2;
  color: var(--ui-ink-3); text-decoration: none; white-space: nowrap; }
.ui-seg-item:hover { color: var(--ui-ink); }
.ui-seg-item.is-on { background: var(--ui-ink); color: var(--ui-surface); }
.ui-seg-item:focus-visible { outline: 2px solid var(--ui-brand); outline-offset: 2px; }

/* ── Board: columns of cards (projects by phase). Scrolls sideways when the columns do not fit. ── */
.ui-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(232px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; align-items: start; }
.ui-board-column { min-width: 0; border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg, 20px); background: color-mix(in srgb, var(--ui-ink) 2.5%, transparent); }
.ui-board-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; }
.ui-board-cards { display: flex; flex-direction: column; gap: 8px; padding: 4px 10px 12px; min-height: 64px; }
.ui-board-card { display: block; padding: 11px 12px; border: 1px solid var(--ui-line); border-radius: 14px; background: var(--ui-surface); color: var(--ui-ink);
  text-decoration: none; transition: border-color 0.12s ease, box-shadow 0.12s ease; }
.ui-board-card:hover { border-color: var(--ui-line-2); box-shadow: 0 6px 16px -12px rgba(0, 0, 0, 0.45); }
.ui-board-card:focus-visible { outline: 2px solid var(--ui-brand); outline-offset: 2px; }
.ui-board-card[draggable='true'] { cursor: grab; }
.ui-board-card.is-dragging { opacity: 0.45; }
.ui-board-card.is-saving { opacity: 0.6; pointer-events: none; }
.ui-board-card-title { display: block; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.ui-board-card-meta { display: block; margin-top: 4px; font-size: 12.5px; color: var(--ui-ink-3); }
.ui-board-column.is-target { border-color: var(--ui-brand); background: color-mix(in srgb, var(--ui-brand) 7%, transparent); }
