/* SPI Deep Warmth, semantic tokens.
 * Two themes off one token set: dark is the default on :root, light is applied
 * via [data-theme="light"]. Components read the semantic variables only; the dark
 * values below are byte-identical to the previous palette, so dark renders
 * unchanged. Fonts are the same in both themes (Cormorant Garamond plus Inter).
 *   Dark  background #0C0C0E, text #F2F0EB, accent gold #C9A84C.
 *   Light background #F6F1E9, text #1A1714, accent gold #9E7A28.
 */

:root {
  /* Type and shape, theme independent. */
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 2px;

  /* SPI dark, the default theme. */
  --bg: #0c0c0e;
  --surface: #15151a;
  --surface-2: #1d1d22;
  --text: #f2f0eb;
  --text-muted: #c8c5bd;
  --text-dim: #a8a4a0;
  --text-faint: #8a8780;
  --border: #2a2a30;

  --accent: #c9a84c;
  --accent-rgb: 201, 168, 76;
  --accent-soft: #a48733;

  --success: #7fb98a;
  --success-rgb: 127, 185, 138;

  --danger: #d97a6c;
  --danger-rgb: 217, 122, 108;
  --danger-strong: #d68466;
  --danger-strong-rgb: 181, 103, 74;

  --tier-c: #8a8780;

  /* Dashboard signal palette (spec: spi-os-dashboard-DESKTOP.html). Additive,
     used only by the dashboard centre; other surfaces are unaffected. */
  --panel: #121215;
  --panel-2: #17171b;
  --line-2: #2c2c34;
  --dimmer: #56565e;
  --sig-green: #5fa86a;
  --sig-amber: #d6973e;
  --sig-amber-rgb: 214, 151, 62;
  --sig-red: #c2553e;
  --sig-blue: #5b7fa8;

  --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 16px 40px rgba(0, 0, 0, 0.55);

  /* Back-compat aliases. Existing components read these colour-literal names;
     they resolve through the semantic tokens above, so they theme-switch too. */
  --black: var(--bg);
  --black-2: var(--surface);
  --black-3: var(--surface-2);
  --gold: var(--accent);
  --gold-soft: var(--accent-soft);
  --cream: var(--text);
  --cream-dim: var(--text-muted);
  --line: var(--border);
}

/* SPI light. Same token names, light values; the accent gold is darkened so it
   reads on the cream background, and every gold/success/alert tint follows via its
   channel token. */
[data-theme="light"] {
  --bg: #f6f1e9;
  --surface: #efe8dc;
  --surface-2: #e7ddca;
  --text: #1a1714;
  --text-muted: #5c554c;
  --text-dim: #6f675c;
  --text-faint: #8a8073;
  --border: #d9cfbe;

  --accent: #9e7a28;
  --accent-rgb: 158, 122, 40;
  --accent-soft: #876818;

  --success: #3f7a4d;
  --success-rgb: 63, 122, 77;

  --danger: #a6432f;
  --danger-rgb: 166, 67, 47;
  --danger-strong: #9a3c28;
  --danger-strong-rgb: 154, 60, 40;

  --tier-c: #8a8073;

  --panel: #ffffff;
  --panel-2: #ffffff;
  --line-2: #dad0bd;
  --dimmer: #aba191;
  --sig-green: #3f7048;
  --sig-amber: #9a6420;
  --sig-amber-rgb: 154, 100, 32;
  --sig-red: #a03a26;
  --sig-blue: #365677;

  --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 16px 40px rgba(26, 23, 20, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--black);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--cream);
  margin: 0 0 0.5rem 0;
}

a {
  color: var(--gold);
  text-decoration: none;
}

p {
  margin: 0 0 0.75rem 0;
}

.muted {
  color: var(--cream-dim);
}

/* ===================================================================
 * Login page
 * =================================================================== */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background:
    radial-gradient(
      circle at 30% 20%,
      rgba(var(--accent-rgb), 0.06) 0%,
      transparent 60%
    ),
    var(--black);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 2.5rem 2rem 2rem;
  background: var(--black-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
}

.login-mark {
  text-align: left;
  margin-bottom: 1.75rem;
}

.brand-line {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 0.5rem 0;
}

.brand-title {
  font-size: 1.75rem;
  margin: 0 0 0.25rem 0;
}

.brand-sub {
  color: var(--cream-dim);
  font-size: 0.85rem;
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

.field-input {
  background: var(--black);
  color: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  transition: border-color 120ms ease;
}

.field-input:focus {
  outline: none;
  border-color: var(--gold);
}

.btn-primary {
  background: var(--gold);
  color: var(--black);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.btn-primary:hover {
  background: var(--gold-soft);
  border-color: var(--gold-soft);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--cream-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.45rem 0.85rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}

.btn-ghost:hover {
  color: var(--cream);
  border-color: var(--gold);
}

.form-error {
  min-height: 1.2em;
  margin: 0;
  font-size: 0.85rem;
  color: var(--danger);
}

.login-footer {
  margin-top: 2rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  font-size: 0.75rem;
  color: var(--cream-dim);
}

.login-footer p {
  margin: 0;
}

/* ===================================================================
 * App shell
 * =================================================================== */

.app-body {
  min-height: 100vh;
}

/* Global shell: single left rail (the only nav) plus the scrolling content. */
.app-shell {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  min-height: 100vh;
}

/* Left rail (spec). */
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 0;
  background: var(--panel);
  border-right: 1px solid var(--line-2);
}
.rbrand {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 0 20px 22px;
  color: var(--text);
}
.rbrand span { color: var(--accent); }
.rnav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; flex: 1; }
.rn {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}
.rn:hover { background: var(--panel-2); color: var(--text); }
.rn.is-active { background: var(--panel-2); color: var(--accent); }

/* Collapsed "More" group: native details, the same rail visual. */
.rmore { margin-top: 2px; }
.rmore-toggle {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}
.rmore-toggle::-webkit-details-marker { display: none; }
.rmore-toggle::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
.rmore[open] > .rmore-toggle { color: var(--text); }
.rmore[open] > .rmore-toggle::after { transform: rotate(45deg); }
.rmore-toggle:hover { background: var(--panel-2); color: var(--text); }
.rmore-list { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 0; }
.rmore-list .rn { padding-left: 24px; font-size: 12px; }
.rfoot {
  padding: 14px 8px 0;
  border-top: 1px solid var(--line-2);
  margin: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rfoot-actions { display: flex; flex-direction: column; gap: 8px; }
.who { display: flex; align-items: center; gap: 10px; }
.av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 14px;
  flex: 0 0 auto;
}
.nm { font-size: 12px; font-weight: 600; color: var(--text); }
.rl { font-family: var(--mono); font-size: 9px; color: var(--text-dim); }

.app-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1rem 2rem;
  background: var(--black-2);
  border-bottom: 1px solid var(--line);
}

.app-brand {
  min-width: 8rem;
}

.app-brand .brand-line {
  margin: 0;
}

.app-brand .brand-sub {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.app-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  justify-content: center;
}

.nav-link {
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius);
  color: var(--cream-dim);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid transparent;
  transition: color 120ms ease, border-color 120ms ease,
    background 120ms ease;
}

.nav-link:hover {
  color: var(--cream);
  border-color: var(--line);
}

.nav-link.is-active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(var(--accent-rgb), 0.05);
}

.app-actions {
  display: flex;
  gap: 0.5rem;
}

.app-content {
  overflow-y: auto;
  height: 100vh;
  padding: 24px 28px;
}

.placeholder-card {
  background: var(--black-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
}

.placeholder-card h1 {
  font-size: 1.6rem;
}

/* ===================================================================
 * Contacts page
 * =================================================================== */

.page-contacts {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.page-header-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.page-title {
  font-size: 1.7rem;
  margin: 0;
}

.page-subtitle {
  margin: 0;
  font-size: 0.85rem;
}

.page-header-actions {
  display: flex;
  gap: 0.5rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--black-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 11rem;
}

.filter-field-grow {
  flex: 1;
  min-width: 16rem;
}

.filter-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

.filter-select,
.filter-input {
  background: var(--black);
  color: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  transition: border-color 120ms ease;
}

.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: var(--gold);
}

.table-card {
  background: var(--black-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table thead th {
  text-align: left;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream-dim);
  font-weight: 600;
  padding: 0.85rem 1rem;
  background: var(--black-3);
  border-bottom: 1px solid var(--line);
}

.data-table tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--cream);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: rgba(var(--accent-rgb), 0.04);
}

.row-empty td {
  text-align: center;
  padding: 1.5rem 1rem;
}

.table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--black-3);
}

.table-footer p {
  margin: 0;
  font-size: 0.8rem;
}

/* ===================================================================
 * Modal
 * =================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  background: var(--black-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  margin: 0;
  font-size: 1.35rem;
}

.modal-form {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0;
}

.form-fieldset legend {
  padding: 0 0.4rem;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.radio-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--cream-dim);
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.radio-chip:hover {
  color: var(--cream);
  border-color: var(--gold);
}

.radio-chip input {
  accent-color: var(--gold);
}

.radio-chip:has(input:checked) {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(var(--accent-rgb), 0.06);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem 1rem;
}

.field-wide {
  grid-column: span 2;
}

.field-hint {
  font-size: 0.72rem;
  margin-top: 0.25rem;
}

textarea.field-input {
  resize: vertical;
  min-height: 4.5rem;
  font-family: var(--sans);
}

/* Typeahead picker (linked-record selection in add-new forms).
 * Used for partner contact (required), property owner and building (optional).
 */
.picker-wrap {
  position: relative;
}

.picker-results {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  margin-top: 0.25rem;
  max-height: 14rem;
  overflow-y: auto;
  background: var(--black-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
}

.picker-results[hidden] {
  display: none;
}

.picker-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 0.85rem;
  cursor: pointer;
}

.picker-item:last-child {
  border-bottom: 0;
}

.picker-item:hover {
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--gold);
}

.picker-sub {
  color: var(--cream-dim);
  font-size: 0.75rem;
}

.picker-empty {
  padding: 0.5rem 0.75rem;
  color: var(--cream-dim);
  font-size: 0.8rem;
}

.picker-selected {
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--gold);
}

.modal-footer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

body.modal-open {
  overflow: hidden;
}

.btn-close {
  padding: 0.35rem 0.7rem;
}

/* ===================================================================
 * Responsive
 * =================================================================== */

@media (max-width: 720px) {
  .app-header {
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
  }

  .app-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    gap: 0.25rem;
    padding-bottom: 0.25rem;
  }

  .app-content {
    padding: 1.5rem 1rem;
  }

  .filter-field {
    min-width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: span 1;
  }

  .data-table {
    font-size: 0.8rem;
  }

  .data-table thead th,
  .data-table tbody td {
    padding: 0.55rem 0.6rem;
  }

  .modal-overlay {
    padding: 0;
    align-items: stretch;
  }

  .modal-card {
    max-height: 100vh;
    border: none;
    border-radius: 0;
  }
}

/* ===== Sprint 4 Day 1: contact detail drawer ===== */

.row-clickable { cursor: pointer; }
.row-clickable:hover { background: rgba(var(--accent-rgb), 0.04); }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 100%);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid rgba(var(--accent-rgb), 0.18);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.5);
  z-index: 80;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drawer[hidden] { display: none; }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.12);
}
.drawer-title {
  font-family: var(--serif, Georgia, serif);
  font-size: 22px;
  font-weight: 500;
  margin: 0;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 32px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 18px;
  margin: 0 0 28px;
}
.detail-grid dt {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  align-self: start;
  padding-top: 2px;
}
.detail-grid dd {
  margin: 0;
  color: var(--text);
  word-break: break-word;
}

.drawer-section { margin-top: 20px; }
.drawer-subtitle {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 8px;
}

.drawer-form { margin-top: 8px; }
.drawer-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 18px;
}

.drawer-footer {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(var(--accent-rgb), 0.12);
}

.btn-danger {
  background: rgba(var(--danger-strong-rgb), 0.12);
  color: var(--danger-strong);
  border: 1px solid rgba(var(--danger-strong-rgb), 0.35);
  padding: 9px 18px;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  border-radius: 4px;
}
.btn-danger:hover { background: rgba(var(--danger-strong-rgb), 0.2); }

.modal-card-small { max-width: 460px; }

/* Right-align numeric columns in data tables. */
.data-table th.num,
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Compact table variant for in-drawer paid history. */
.data-table-compact thead th {
  font-size: 0.62rem;
  padding: 0.55rem 0.75rem;
}
.data-table-compact tbody td {
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
}

/* Buyer profile JSON preview (Sprint 4 Day 4). */
.json-preview {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: 6px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 0.85rem 1rem;
  margin: 0;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===================================================================
 * Monday Signal brief (Sprint 5 Day 5). Deep Warmth dark, read-only.
 * =================================================================== */

.page-monday {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brief-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 0.85rem 1.1rem;
  background: var(--black-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.brief-meta[hidden] {
  display: none;
}

.meta-item {
  color: var(--cream);
}

.meta-label {
  display: block;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream-dim);
  margin-bottom: 0.2rem;
}

.eval-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

.eval-badge[hidden] {
  display: none;
}

.eval-badge.is-passed {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(var(--accent-rgb), 0.06);
}

.eval-badge.is-flagged {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(var(--danger-rgb), 0.08);
}

.brief-prose-card {
  background: var(--black-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
}

.brief-prose-card[hidden] {
  display: none;
}

.brief-prose {
  white-space: pre-wrap;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--cream);
}

.brief-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.brief-section-heading {
  font-size: 1.2rem;
  margin: 0;
}

.tenant-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--cream-dim);
}

.lead-pill {
  display: inline-block;
  margin-right: 0.4rem;
  padding: 0.08rem 0.4rem;
  background: var(--gold);
  color: var(--black);
  border-radius: var(--radius);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  vertical-align: middle;
}

.data-table tbody tr.row-lead td {
  background: rgba(var(--accent-rgb), 0.05);
}

.data-table tbody tr.row-lead td:first-child {
  box-shadow: inset 2px 0 0 var(--gold);
}

/* Narrow breakpoint, toggled by the ResizeObserver on the page root. */
.page-monday.is-narrow .brief-meta {
  flex-direction: column;
  gap: 0.6rem;
}

.page-monday.is-narrow .table-card {
  overflow-x: auto;
}

/* ===================================================================
 * Imports (Sprint 6 Day 4-5)
 * =================================================================== */

.import-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 1.25rem;
  align-items: start;
}

.import-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.import-form input[type="file"] {
  padding: 0.55rem 0.65rem;
  cursor: pointer;
}

.import-columns {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.6;
}

.import-cols-label {
  color: var(--cream-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.68rem;
  margin-right: 0.25rem;
}

.import-col {
  background: var(--black-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.1rem 0.35rem;
  color: var(--cream);
  font-size: 0.72rem;
}

.import-dedupe {
  width: 100%;
  color: var(--cream-dim);
  font-size: 0.76rem;
  margin-top: 0.2rem;
}

.import-summary {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.import-written {
  margin: 0;
  color: var(--gold);
  font-size: 0.9rem;
}

.import-dryrun-note {
  margin: 0;
  font-size: 0.82rem;
}

.import-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.import-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--black-2);
}

.import-stat-num {
  font-family: var(--serif);
  font-size: 1.6rem;
  line-height: 1;
  color: var(--cream);
}

.import-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cream-dim);
}

.import-stat.is-new {
  box-shadow: inset 2px 0 0 var(--gold);
}

.import-stat.is-dupe {
  box-shadow: inset 2px 0 0 var(--gold-soft);
}

.import-stat.is-invalid {
  box-shadow: inset 2px 0 0 var(--danger);
}

.import-stat.is-warn {
  box-shadow: inset 2px 0 0 var(--cream-dim);
}

.import-meta {
  margin: 0;
  font-size: 0.78rem;
}

.import-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.import-list-title {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cream-dim);
}

.import-list-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 16rem;
  overflow-y: auto;
  font-size: 0.8rem;
}

.import-list-rows li {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--black-2);
}

.import-line {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  margin-right: 0.4rem;
}

/* Narrow breakpoint, toggled by the ResizeObserver on the page root. */
.page-imports.is-narrow .import-grid {
  grid-template-columns: 1fr;
}

.page-imports.is-narrow .import-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* =========================================================================
   Leads and matches (RE-MATCH Dashboard, Day 2). Mobile-first card worklist
   with a wide detail drawer for deep work on desktop.
   ========================================================================= */

.leads-layout {
  margin-top: 4px;
}
.leads-list-card {
  background: var(--black-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.leads-list {
  display: flex;
  flex-direction: column;
}
.lead-loading {
  padding: 20px 18px;
  margin: 0;
}

/* A lead row is a full-width tap target (mobile-first). */
.lead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  cursor: pointer;
  color: var(--cream);
  font-family: var(--sans);
}
.lead-row:last-child { border-bottom: none; }
.lead-row:hover { background: var(--black-3); }
.lead-row-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.lead-id { font-weight: 600; font-size: 14px; }
.lead-context { font-size: 12px; }
.lead-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.lead-count { font-size: 11px; }

/* Confidence tier badge. */
.tier-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: var(--radius);
  border: 1px solid currentColor;
  white-space: nowrap;
}
.tier-A { color: var(--gold); }
.tier-B { color: var(--cream-dim); }
.tier-C { color: var(--tier-c); }

/* Status pill. */
.status-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--black-3);
  color: var(--cream-dim);
}
.status-candidate { color: var(--gold); background: rgba(var(--accent-rgb), 0.12); }
.status-introduced { color: var(--success); background: rgba(var(--success-rgb), 0.12); }
.status-dismissed { color: var(--text-faint); }

/* Enrich-to-score cue on thin or unmatched worklist rows. Gold dashed, so it
   reads as an open action and stays distinct from the solid tier badge. */
.enrich-cue {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--gold);
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px dashed var(--gold-soft);
  white-space: nowrap;
}

/* Wider drawer for the lead detail (still full width on mobile). */
.drawer-wide { width: min(720px, 100%); }

/* Requirement summary header. */
.req-summary {
  margin: 0 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.req-id {
  font-family: var(--serif);
  font-size: 20px;
  margin: 0 0 6px;
}
.req-facets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--cream);
}
.req-facets .ready { color: var(--success); }
.req-text { margin: 8px 0 0; font-size: 13px; }
.dot { color: var(--line); padding: 0 2px; }

/* The lead-conversion lever (meta-action banner). Prominent. */
.meta-actions {
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 18px;
}
.meta-actions-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 6px;
}
.meta-actions ul { margin: 0; padding-left: 18px; }
.meta-actions li { font-size: 13px; margin: 4px 0; }

/* Banded batch section. */
.match-batch { margin: 0 0 24px; }
.batch-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}
.batch-title {
  font-family: var(--serif);
  font-size: 16px;
  margin: 0;
}
.batch-reason { font-size: 12px; }

/* A single match card. */
.match-card {
  background: var(--black-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 14px;
}
.listing-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
}
.ls-price { color: var(--gold); }
.ls-flag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cream-dim);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: var(--radius);
}
/* Under-offer state marker: a distinct flag, shown next to the fit tier badge.
   It signals deprioritised stock without altering the tier badge. */
.ls-flag-under-offer {
  color: var(--gold);
  border-color: var(--gold-soft);
}
.listing-text { margin: 6px 0 0; font-size: 12px; }

/* Score block: the percentage and its breakdown are one indivisible unit. */
.score-block {
  margin: 12px 0;
  padding: 12px;
  background: var(--black-3);
  border-radius: var(--radius);
}
.score-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.score-pct {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  color: var(--cream);
}
.score-breakdown { display: flex; flex-direction: column; gap: 6px; }
.axis-row {
  display: grid;
  grid-template-columns: 80px 64px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.axis-name { color: var(--cream-dim); }
.axis-state { font-variant-numeric: tabular-nums; }
.axis-bar {
  height: 5px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.axis-bar i {
  display: block;
  height: 100%;
  background: var(--gold);
}
.score-note { margin: 4px 0 0; font-size: 11px; }

/* Gaps and derived actions. */
.gap-list {
  list-style: none;
  margin: 10px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gap-action, .gap-flag {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius);
  border-left: 2px solid var(--gold);
  background: var(--black-3);
}
.gap-flag { border-left-color: var(--danger); }

/* Contact to call. */
.contact-block {
  margin: 12px 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.contact-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 2px;
}
.contact-name { margin: 0 0 8px; font-weight: 500; }
.contact-links { display: flex; flex-wrap: wrap; gap: 8px; }
.contact-link {
  display: inline-block;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius);
  text-decoration: none;
  border: 1px solid var(--line);
  color: var(--cream);
}
.contact-call { border-color: var(--gold); color: var(--gold); }
.contact-link:hover { background: var(--black-3); }
.contact-none { margin: 0; font-size: 12px; }

/* Action controls. */
.match-actions { margin-top: 12px; }
.status-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-status {
  font-family: var(--sans);
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--black-3);
  color: var(--cream);
  cursor: pointer;
}
.btn-status:hover { border-color: var(--gold-soft); }
.btn-status.is-active { border-color: var(--gold); color: var(--gold); }
.btn-status:disabled { opacity: 0.5; cursor: default; }
.status-current { margin: 8px 0; font-size: 12px; }
.predicted-price { margin: 4px 0; font-size: 12px; }
.action-line { margin-top: 8px; }
.note-line { display: flex; gap: 8px; }
.action-outcome, .action-note {
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--black);
  color: var(--cream);
}
.action-note { flex: 1; }

/* Jump-to controls (open a thin lead, or a listing's buyers, by id). */
.lead-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 14px;
}
.lead-tool { display: flex; gap: 6px; }
.lead-tool .filter-input { width: 150px; }

/* Run trigger feedback. */
.page-header-actions [data-role="run-status"],
.page-header-actions [data-role="run-meta"] {
  font-size: 12px;
  margin: 0;
}

/* Match card head: listing summary plus the inverse-view affordance. */
.match-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.btn-link {
  background: none;
  border: none;
  color: var(--gold);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-link:hover { text-decoration: underline; }

/* Inverse buyer card head. */
.buyer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

/* Inline enrichment form. */
.enrich-form {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.enrich-summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  cursor: pointer;
  padding: 6px 0;
}
.enrich-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.enrich-actions { margin-top: 8px; }

/* Narrow breakpoint: stack the lead row meta under the label. */
.page-leads.is-narrow .lead-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.page-leads.is-narrow .lead-row-meta { justify-content: flex-start; }
.page-leads.is-narrow .axis-row {
  grid-template-columns: 72px 56px 1fr;
}
.page-leads.is-narrow .enrich-grid { grid-template-columns: 1fr; }
.page-leads.is-narrow .lead-tool { flex: 1; }
.page-leads.is-narrow .lead-tool .filter-input { width: auto; flex: 1; }

/* Mobile polish: thumb-reachable tap targets on the action controls and links. */
@media (max-width: 640px) {
  .leads-list-card { border-left: none; border-right: none; border-radius: 0; }
  .btn-status,
  .contact-link,
  .lead-tool .btn-ghost,
  .enrich-actions .btn-primary {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .contact-links { gap: 10px; }
  .contact-link { flex: 1; }
  .status-row { gap: 10px; }
  .btn-status { flex: 1; }
  .note-line { flex-direction: column; }
  .note-line .btn-ghost { min-height: 44px; }
}

/* Theme toggle in the header. Reuses btn-ghost; the active state borrows the
   accent so it reads on both backgrounds. 44px tap target on mobile. */
.theme-toggle[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}
@media (max-width: 640px) {
  .theme-toggle {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* =========================================================================
   Dashboard (Brief landing, dashboard v2). Reconciled to the desktop visual
   spec (spi-os-dashboard-DESKTOP.html): three-column shell, mono figures and
   labels, serif headings, signal palette, hairline grids. Colours read tokens
   only, so both themes work via [data-theme]. Stacks to one column on mobile.
   ========================================================================= */

/* The dashboard occupies the spec's second and third columns (centre + SAGE); the
   global rail is the first column. */
.page-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

/* Centre column. */
.dash-centre { display: flex; flex-direction: column; gap: 18px; min-width: 0; font-size: 13px; }
/* Header, ported from the mock .mhead: a serif greeting with the gold count and a
   mono subline. */
.dash-head { margin: 0 0 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line-2); }
.dash-greeting {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.05;
  margin: 0;
  color: var(--text);
}
.dash-greeting b { color: var(--accent); }
.dash-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 7px 0 0;
}
.dash-loading { padding: 16px 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 20px;
}
.panel-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.1;
  margin: 0 0 14px;
}
/* Basis line: mono, dim, the provenance under every figure. */
.basis {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.3px;
  line-height: 1.5;
  margin: 12px 0 0;
  color: var(--text-dim);
}
.awaiting { font-size: 13px; padding: 6px 0; color: var(--text-muted); }

/* Hero: what needs movement. Gradient card with an amber attention bar. */
.hero-panel {
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-2);
  border-radius: 16px;
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.hero-panel::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--sig-amber);
}
.hero-panel .panel-title { font-size: 22px; }
.hero-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.hero-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.hero-item:last-child { border-bottom: none; }
.hero-n {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--accent);
  min-width: 1.4em;
  text-align: right;
}
.hero-label { font-size: 13px; line-height: 1.4; color: var(--text); }
.hero-cta {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  white-space: nowrap;
  transition: transform 0.15s ease;
}
.hero-cta:hover { transform: translateY(-1px); }
.hero-empty { padding: 6px 0; color: var(--text-muted); }

/* Executive shortlist, ported from the mock. Section header, then the deal cards. */
.shortlist-panel { display: block; }
.sec { display: flex; align-items: center; justify-content: space-between; padding: 2px 0 12px; }
.sec-t { font-family: var(--mono); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); }
.sec-c { font-family: var(--mono); font-size: 10px; color: var(--dimmer); }
.cards { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 17px 19px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 18px;
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--dimmer);
}
.card.follow::before { background: var(--sig-amber); }
.card.intro::before { background: var(--accent); }
.rank { font-family: var(--mono); font-size: 20px; font-weight: 700; color: var(--dimmer); min-width: 26px; text-align: center; }
.cbody { flex: 1; min-width: 0; }
.ctop { display: flex; align-items: center; gap: 9px; }
.ckind {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 5px;
}
.ckind.follow { color: var(--sig-amber); background: rgba(var(--sig-amber-rgb), 0.13); }
.ckind.intro { color: var(--accent); background: rgba(var(--accent-rgb), 0.13); }
.cwhen { font-family: var(--mono); font-size: 9px; color: var(--dimmer); }
.ctitle { font-family: var(--serif); font-size: 19px; font-weight: 600; margin-top: 5px; line-height: 1.12; color: var(--text); }
.cbasis { font-family: var(--mono); font-size: 10px; color: var(--text-dim); margin-top: 6px; }
.cval { text-align: right; min-width: 108px; }
.cval .n { font-family: var(--mono); font-size: 17px; font-weight: 700; color: var(--text); }
.cval .l { font-family: var(--mono); font-size: 8px; color: var(--dimmer); text-transform: uppercase; margin-top: 3px; }
.cact { display: flex; flex-direction: column; gap: 7px; min-width: 118px; }
.cact .btn {
  text-align: center;
  padding: 9px 12px;
  border-radius: 9px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease;
  white-space: nowrap;
}
.cact .btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.cact .btn:hover { transform: translateY(-1px); }
.cact .btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* Leads backlog: the demoted bulk counts, one dashed line that keeps its nav. */
.backlog {
  margin: 6px 0 0;
  border: 1px dashed var(--line-2);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.bl { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.bl b { color: var(--text); }
.blnote { font-family: var(--mono); font-size: 9px; color: var(--dimmer); margin-top: 4px; }
.lnk {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 8px 12px;
  white-space: nowrap;
}

/* Ranking-basis foot: the overall basis, plain and once. */
.dash-foot { font-family: var(--mono); font-size: 9px; color: var(--dimmer); line-height: 1.6; margin: 6px 0 0; }

/* KPI row: hairline-separated cells, mono labels and figures. */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  padding: 1px;
  background: var(--line-2);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  overflow: hidden;
}
.kpi-card {
  background: var(--panel);
  border: none;
  border-radius: 0;
  padding: 18px 20px;
}
.kpi-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--dimmer);
  margin: 0;
}
.kpi-value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
  margin: 8px 0 0;
  color: var(--text);
}
.kpi-sub { font-family: var(--mono); font-size: 11px; color: var(--accent); margin: 7px 0 0; }
.kpi-card .basis { margin-top: 9px; }

/* Match pipeline by tier. */
.tier-bar {
  display: flex;
  height: 20px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line-2);
  margin-bottom: 12px;
}
.tier-seg { display: flex; align-items: center; min-width: 2px; overflow: hidden; }
.tier-seg-label {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  padding: 0 7px;
  white-space: nowrap;
  color: var(--bg);
}
.tier-seg.tier-A { background: var(--accent); }
.tier-seg.tier-B { background: var(--sig-blue); }
.tier-seg.tier-C { background: var(--dimmer); }
.tier-counts { font-family: var(--mono); font-size: 11px; margin: 5px 0 0; color: var(--text-muted); }

/* Demand and supply pools (NOT pipeline). */
.pool-flag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px dashed var(--accent-soft);
  border-radius: 999px;
  padding: 4px 9px;
  margin: 0 0 14px;
}
.pool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-2);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  overflow: hidden;
}
.pool-cell { background: var(--panel); padding: 16px 18px; }
.pool-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--dimmer);
  margin: 0 0 6px;
}
.pool-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0;
  color: var(--text);
}
.pool-sub { font-family: var(--mono); font-size: 11px; margin: 4px 0 0; color: var(--text-dim); }

/* Coverage and enrichment backlog. The only percentage, always with its counts. */
.cov-figure { display: flex; align-items: baseline; gap: 14px; }
.cov-pct {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1;
  margin: 0;
  color: var(--text);
}
.cov-breakdown { font-family: var(--mono); font-size: 11px; color: var(--text-muted); margin: 0; line-height: 1.45; }
.cov-backlog { font-size: 13px; margin: 12px 0 0; color: var(--text); }

/* Closed-outcome scoreboard. */
.closed-empty { padding: 6px 0; }
.closed-empty-title { font-family: var(--serif); font-size: 19px; font-weight: 600; margin: 0 0 5px; color: var(--accent); }
.closed-count { font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: -1px; margin: 0; color: var(--text); }

/* Right rail: SAGE shell. */
.dash-sage {
  position: sticky;
  top: 16px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 360px;
}
.sage-head { margin: 0; }
.sage-head .brand-line { font-family: var(--mono); letter-spacing: 0.2em; }
.sage-status { font-family: var(--mono); font-size: 9px; letter-spacing: 0.5px; margin: 3px 0 0; }

/* Conversation. */
.sage-conv { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; min-height: 180px; }
.sage-msg { max-width: 94%; }
.sage-msg.sage-u {
  align-self: flex-end;
  background: var(--accent);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: 12px 12px 3px 12px;
  font-size: 12.5px;
  font-weight: 500;
}
.sage-msg.sage-s { align-self: flex-start; }
.sage-bubble {
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 12px 12px 12px 3px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
}
.sage-lbl { font-family: var(--mono); font-size: 8.5px; letter-spacing: 1px; color: var(--accent); display: block; margin-bottom: 4px; }
.sage-rows { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.sage-row { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.sage-draft {
  font-family: var(--mono);
  font-size: 11px;
  white-space: pre-wrap;
  margin: 8px 0 0;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--text);
}
.sage-note { font-family: var(--mono); font-size: 9px; margin: 8px 0 0; }

/* Confirm card (the gate before any write). */
.sage-pcard { border: 1px solid var(--line-2); border-radius: 12px; padding: 13px; background: var(--bg); }
.sage-ct { font-family: var(--mono); font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: var(--sig-amber); }
.sage-ph { font-family: var(--serif); font-size: 15px; font-weight: 600; margin: 8px 0 10px; color: var(--text); }
.sage-pf { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line-2); font-size: 12px; }
.sage-pk { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); }
.sage-pv { font-weight: 600; text-align: right; color: var(--text); }
.sage-pact { display: flex; gap: 8px; margin-top: 12px; }
.sage-pact .btn-ghost, .sage-pact .sage-confirm { flex: 1; text-align: center; }
.sage-confirm {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 9px;
  padding: 9px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.sage-confirm:disabled { opacity: 0.5; cursor: default; }
.sage-draft-edit {
  width: 100%;
  min-height: 90px;
  margin: 8px 0 0;
  padding: 8px;
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--text);
}

/* Foot: chips and the input bar. */
.sage-foot { display: flex; flex-direction: column; gap: 10px; }
.sage-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sage-chip {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
}
.sage-chip:hover { border-color: var(--accent); color: var(--accent); }
.sage-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 6px 6px 6px 12px;
}
.sage-input {
  flex: 1;
  background: transparent;
  color: var(--text);
  border: none;
  outline: none;
  font-family: var(--sans);
  font-size: 13px;
}
.sage-send {
  flex: 0 0 auto;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  border-radius: 8px;
  padding: 7px 12px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* Hero priority tones: the introductions read most urgent, Tier A next. */
.hero-red .hero-n { color: var(--sig-red); }
.hero-amber .hero-n { color: var(--sig-amber); }
.also-panel .panel-title { font-size: 18px; }

/* SPHI cells (the spec heat-cell visual, bound to real figures). */
.sphi-cells {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-2);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  overflow: hidden;
}
.sphi-cell { background: var(--panel); padding: 16px 18px; text-align: center; }
.sphi-n { font-family: var(--mono); font-size: 24px; font-weight: 700; letter-spacing: -1px; margin: 0; color: var(--accent); }
.sphi-l { font-family: var(--mono); font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: var(--dimmer); margin: 4px 0 0; }
.sphi-stages { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.sphi-stage {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 5px 9px;
}

/* The SAGE bottom-sheet controls are desktop-hidden; they appear only on mobile,
   where SAGE drops to a sheet behind a toggle. */
.sage-fab,
.sage-close,
.sage-backdrop { display: none; }

/* Tablet: drop the SAGE rail under the centre. */
@media (max-width: 1080px) {
  .page-dashboard { grid-template-columns: minmax(0, 1fr); }
  .dash-sage { grid-column: 1 / -1; }
}

/* Mobile: single column, the rail becomes a horizontal strip, and SAGE drops to a
   bottom sheet behind a floating toggle. Verified down to 380px. */
@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 14px;
    border-right: none;
    border-bottom: 1px solid var(--line-2);
  }
  .rbrand { padding: 0 10px 0 0; }
  .rnav { flex-direction: row; padding: 0; flex: 1; gap: 4px; }
  .rn { white-space: nowrap; }
  .rfoot { display: none; }
  .app-content { height: auto; }
  .page-dashboard { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pool-grid, .sphi-cells { grid-template-columns: 1fr; }
  .hero-item { grid-template-columns: auto 1fr; }
  /* Deal cards stack their parts full-width on a phone. */
  .card { flex-wrap: wrap; gap: 10px 14px; }
  .card .cbody { flex: 1 1 100%; order: 1; }
  .card .rank { order: 0; min-width: 0; }
  .card .cval { order: 2; text-align: left; min-width: 0; }
  .card .cact { order: 3; flex-direction: row; min-width: 0; flex: 1; justify-content: flex-end; }
  .backlog { flex-direction: column; align-items: flex-start; }
  .hero-cta { grid-column: 2; justify-self: start; }

  /* Floating toggle. */
  .sage-fab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 60;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-lift);
    cursor: pointer;
  }
  .sage-backdrop.is-open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 65;
  }
  /* The SAGE panel as a bottom sheet: off-screen until toggled. */
  .dash-sage {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: auto;
    max-height: 85vh;
    min-height: 0;
    border-radius: 16px 16px 0 0;
    border: 1px solid var(--line-2);
    transform: translateY(110%);
    transition: transform 0.22s ease;
    z-index: 70;
  }
  .dash-sage.is-open { transform: translateY(0); }
  .sage-close {
    display: inline-block;
    margin-left: auto;
    background: none;
    border: 1px solid var(--line-2);
    border-radius: 8px;
    color: var(--text-muted);
    font-family: var(--sans);
    font-size: 12px;
    padding: 6px 10px;
    cursor: pointer;
  }
  .sage-head { display: flex; align-items: center; gap: 10px; }
}

/* Phone: KPI cards and deal cards stack full-width. */
@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr; }
}
