/* ─────────────────────────────────────────────────────────────
   editor.css — Premavista Hub UI (v2 — editorial modern).

   Strategy: re-map a handful of CSS variables ONLY inside `body.editor`,
   so every existing template inherits the new look without edits.
   PDFs (which never get body.editor) keep their original look.

   Reference feel: Aesop / Cabana / Linear — generous whitespace, large
   editorial Fraunces headlines, paper-white surfaces with near-invisible
   borders, a single confident gold accent moment per section, finger-
   friendly touch targets, sticky glass nav.
   ───────────────────────────────────────────────────────────── */

/* ── DEFAULT THEME: Editorial (light) ────────────────────────── */
body.editor {
  /* Re-map template-inlined tokens (--text-light, --navy-500, --gold,
     --bronze, --text-muted). Keep the names; flip the values. */
  --navy-700:   #ffffff;
  --navy-500:   rgba(15, 23, 42, 0.08);
  --text-light: #0f172a;
  --text-muted: #64748b;
  --gold:       #9a7d4e;                /* darkened for AA on white text */
  --gold-bright:#c9a876;                /* decorative gold (rules, gradients) */
  --bronze:     #7a6643;

  --ink:        #0f172a;
  --ink-2:      #1e293b;
  --ink-3:      #475569;
  --ink-4:      #94a3b8;
  --paper:      #ffffff;
  --paper-2:    #f8f7f3;
  --paper-3:    #f1efe8;
  --line:       rgba(15, 23, 42, 0.07);
  --line-strong:rgba(15, 23, 42, 0.14);

  --bg-wash:    radial-gradient(1200px 380px at 50% -100px,
                                rgba(184, 153, 104, 0.10),
                                transparent 70%);

  background: var(--paper);
  color: var(--ink-2);
  min-height: 100dvh;
  min-height: 100vh;
}
html:has(body.editor) { background: var(--paper); color-scheme: light; }

body.editor::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 480px;
  background: var(--bg-wash);
  pointer-events: none;
  z-index: 0;
}
.editor .container, .editor .nav { position: relative; z-index: 1; }
.editor .nav { z-index: 100; }

.editor .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px 28px 96px;
}

/* ─── Top navigation — translucent glass with editorial brand ─── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(140%) blur(18px);
  -webkit-backdrop-filter: saturate(140%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.nav .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-brand);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.nav .brand span span { color: var(--ink-3); font-weight: 400; }

.nav ul {
  list-style: none;
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 4px;
  background: var(--paper-2);
  border-radius: 999px;
  border: 1px solid var(--line);
}
.nav ul a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  text-transform: none;
  letter-spacing: 0;
  transition: background 160ms ease, color 160ms ease;
}
.nav ul a:hover { color: var(--ink); background: rgba(15, 23, 42, 0.04); }
.nav ul a.active {
  background: var(--ink);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}
.nav ul a.active .icon { opacity: 1; }

.nav-right { display: flex; align-items: center; gap: 10px; }
.nav-right .eyebrow {
  font-size: 13px;
  color: var(--ink-3);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  padding: 0;
}
.nav-toggle:hover { background: var(--paper-2); }

/* ─── Headings ─────────────────────────────────────────────── */
h1.display {
  font-size: clamp(34px, 5.2vw, 52px);
  line-height: 1.04;
  letter-spacing: -0.028em;
  color: var(--ink);
  font-weight: 400;
}
h2.display {
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.12;
  letter-spacing: -0.022em;
  color: var(--ink);
  font-weight: 500;
}
.display { color: var(--ink); }

/* Reposition the eyebrow as a refined section tag, not a loud label. */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 1px;
  background: var(--gold);
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn, .btn-secondary, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease,
              transform 160ms ease, box-shadow 160ms ease,
              border-color 160ms ease;
}
.btn {
  background: var(--ink);
  color: #ffffff !important;            /* defeats template-inlined --text-light */
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18), inset 0 1px 0 rgba(255,255,255,0.08);
}
.btn:hover { background: #1e293b; transform: translateY(-1px); box-shadow: 0 8px 22px rgba(15, 23, 42, 0.22); }
.btn:active { transform: translateY(0); }

.btn-secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-secondary:hover { background: var(--paper-2); border-color: var(--ink-3); }

.btn-danger { background: #c1453b; color: #ffffff !important; box-shadow: 0 4px 14px rgba(193, 69, 59, 0.25); }
.btn-danger:hover { background: #a93a31; }

/* Outline-style destructive (Archive / Cancel / Decline buttons). */
.btn-ghost-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  border-radius: 999px;
  border: 1px solid rgba(193, 69, 59, 0.35);
  background: transparent;
  color: #c1453b;
  cursor: pointer;
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.btn-ghost-danger:hover { background: rgba(193, 69, 59, 0.08); border-color: #c1453b; color: #a93a31; }

.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }

/* Active toggle pill (used by filter chips: This week / Next week / …).
   The `.editor` prefix lifts this above the defensive `.editor .btn-secondary`
   rule below — without it the two collide at equal specificity and the later
   one wins, painting the active chip's text the same navy as its fill
   (invisible). */
.editor .btn-secondary.is-active,
.btn-secondary.is-active {
  background: var(--ink) !important;
  color: #ffffff !important;
  border-color: var(--ink) !important;
}

/* Defensive: defeat any leftover dark-mode inline color override on
   secondary buttons (templates used to set color:#d0a0a0 — pale on white). */
.editor .btn-secondary { color: var(--ink) !important; }

/* Inline link-style buttons (table row actions). */
.btn-link, .btn-link-danger {
  background: transparent;
  border: none;
  color: var(--bronze);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 140ms ease, color 140ms ease;
}
.btn-link:hover { color: var(--ink); background: var(--paper-2); }
.btn-link-danger { color: #c1453b; }
.btn-link-danger:hover { color: #8c2e26; background: rgba(193, 69, 59, 0.08); }

/* ─── Form fields ──────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: 8px;
}
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  border-radius: 12px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
  min-height: 46px;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:not([type="checkbox"]):not([type="radio"]):hover,
.field select:hover,
.field textarea:hover { border-color: var(--ink-3); }
.field input:not([type="checkbox"]):not([type="radio"]):focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--ink);
  background: var(--paper);
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.08);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--ink-4); }

/* Form selects: drop the native control and draw our own chevron so they
   match the text inputs and the .filter-select dropdowns exactly (the native
   iOS/Chrome arrow renders inconsistently and looks misaligned on mobile).
   Extra right padding reserves room for the chevron so long option text
   never runs under it. */
.field select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238a8578' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* Inline filter dropdowns (Invoices list, etc.) — themed, auto-width, with a
   custom chevron so they match the field selects without the .field wrapper. */
.filter-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238a8578' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 0 38px 0 14px;
  height: 42px;
  font-family: var(--font-body);
  font-size: 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.filter-select:hover { border-color: var(--ink-3); }
.filter-select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.08);
}

/* Colour-coded cleaning status dropdown. The text + border + tint reflect the
   current status at a glance: red = needs scheduling, blue = scheduled,
   teal = confirmed, green = done, grey = cancelled. The class is set
   server-side on render and updated client-side on change (see
   cleanings/_row.html). */
.status-select { font-weight: 600; }
.status-select.status-needs_scheduling {
  color: #b04545; border-color: rgba(176, 69, 69, 0.55); background-color: rgba(176, 69, 69, 0.07);
}
.status-select.status-scheduled {
  color: #2f5fa8; border-color: rgba(47, 95, 168, 0.55); background-color: rgba(47, 95, 168, 0.07);
}
.status-select.status-confirmed {
  color: #0d7a73; border-color: rgba(13, 122, 115, 0.55); background-color: rgba(13, 122, 115, 0.08);
}
.status-select.status-done {
  color: #3f7a57; border-color: rgba(63, 122, 87, 0.55); background-color: rgba(63, 122, 87, 0.08);
}
.status-select.status-cancelled {
  color: var(--text-soft); border-color: var(--line-strong); background-color: transparent;
}

/* The status-select sets a coloured `color` (red/blue/teal/green) on the
   <select>, which the native <option> list inherits. When the dropdown opens,
   the OS highlights the active option with a solid (often blue) fill — leaving
   coloured text on a same-colour highlight, i.e. unreadable. Force the option
   list back to ink-on-paper so every choice stays legible while open. Applies
   to all themed dropdowns, not just cleanings. */
.status-select option,
.filter-select option {
  color: var(--ink);
  background-color: var(--paper);
}

/* Checkboxes & radios: native control, accent the brand colour. */
.field input[type="checkbox"],
.field input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.card > .eyebrow:first-child { margin-bottom: 18px; }

/* Tabular layout where the card is itself a list/section heading. */
.card-tight { padding: 20px; }

/* ─── Stat cards (dashboard headline) ──────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.stat {
  position: relative;
  display: block;
  padding: 26px 24px 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  transition: transform 220ms cubic-bezier(.2,.7,.2,1),
              border-color 160ms ease,
              box-shadow 220ms ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.stat::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), transparent 70%);
  opacity: 0;
  transition: opacity 220ms ease;
}
.stat:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.06);
  color: var(--ink);
}
.stat:hover::before { opacity: 1; }
.stat .eyebrow { color: var(--ink-3); margin-bottom: 6px; }
.stat .eyebrow::before { display: none; }       /* dot bar is reserved for section labels */
.stat-value {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-variation-settings: "SOFT" 30;
  font-size: clamp(36px, 4vw, 52px);
  color: var(--ink);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

/* Dashboard lower card row. A class (not an inline style) so themes can
   reflow it — editorial/dark keep the original 2-up; Steep makes it bento. */
.dash-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-top: var(--space-6);
}

/* ─── Tables ───────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3);
  padding: 14px 16px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
}
.table td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-2);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 140ms ease; }
.table tbody tr:hover td { background: var(--paper-2); }
.table .num { font-variant-numeric: tabular-nums; }

.card:has(> .table:first-child) { padding: 0; overflow: hidden; }

/* ─── Mode pills (radio group) ─────────────────────────────── */
.mode-pill {
  flex: 1;
  display: block;
  cursor: pointer;
  padding: 18px 20px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.mode-pill input { display: none; }
.mode-pill strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 4px;
}
.mode-pill span {
  display: block;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
}
.mode-pill:hover { border-color: var(--ink-3); background: var(--paper-2); }
.mode-pill.active {
  border-color: var(--ink);
  background: var(--paper);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
}

/* ─── Empty state ──────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 80px 28px;
  color: var(--ink-3);
}
.empty .display {
  color: var(--ink);
  font-size: 32px;
  margin-bottom: 12px;
  font-style: normal;
}

/* ─── Icons ────────────────────────────────────────────────── */
.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  vertical-align: -3px;
  display: inline-block;
}
.nav ul a .icon { opacity: 0.7; transition: opacity 160ms ease; }
.nav ul a:hover .icon { opacity: 1; }
.nav .brand .icon { width: 22px; height: 22px; vertical-align: -5px; }
.btn .icon, .btn-secondary .icon, .btn-danger .icon { width: 15px; height: 15px; vertical-align: -2px; }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  background: var(--ink-4);
}

/* Mute the gold of the brand SVG inside the editor — the bright original gold
   reads as warning yellow against the new editorial palette. */
.editor .nav .brand svg circle[fill="#c9a876"] { fill: var(--gold); }
.editor .nav .brand svg path[fill="#c9a876"] { fill: var(--gold); }

/* ─────────────────────────────────────────────────────────────
   Native-app feel (matters most when installed as a standalone PWA)
   ───────────────────────────────────────────────────────────── */
/* Cross-document page transitions where supported (Safari 18+, Chrome): the
   server-rendered navigations cross-fade instead of flashing white. No-op on
   browsers that don't support it. */
@view-transition { navigation: auto; }

/* Kill the grey tap-highlight flash on every touch. */
* { -webkit-tap-highlight-color: transparent; }

/* App chrome (nav, buttons, labels) shouldn't be text-selectable or pop the
   iOS long-press callout — that's a dead giveaway of "web page". Page content
   (tables, invoice numbers, addresses) stays fully selectable/copyable. */
.nav, .btn, .btn-secondary, .btn-danger, .btn-ghost-danger, .btn-sm,
.theme-switch, .mode-pill, .eyebrow, .nav-toggle, .field label {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* No rubber-band overscroll revealing a white gap behind the app. */
html:has(body.editor) { overscroll-behavior-y: none; }

/* ─────────────────────────────────────────────────────────────
   Mobile (≤ 760px)
   ───────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .editor .container { padding: 24px 18px 80px; }

  /* Standalone PWA: keep the nav and content clear of the notch / Dynamic
     Island / home indicator and the rounded screen corners (landscape). */
  @supports (padding: max(0px)) {
    .nav {
      padding-top: max(12px, env(safe-area-inset-top));
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
    }
    .editor .container {
      padding-left: max(18px, env(safe-area-inset-left));
      padding-right: max(18px, env(safe-area-inset-right));
      padding-bottom: max(80px, calc(env(safe-area-inset-bottom) + 28px));
    }
  }

  /* Generic safety nets: any inline-grid or inline-flex row that lays out
     side-by-side on desktop should stack and wrap on mobile. */
  .editor [style*="display: grid"],
  .editor [style*="display:grid"] { grid-template-columns: 1fr !important; gap: 16px !important; }
  .editor [style*="display: flex"][style*="justify-content: space-between"],
  .editor [style*="display:flex"][style*="justify-content:space-between"] {
    flex-wrap: wrap;
    gap: 12px;
  }
  /* Sticky-nav offset for in-page anchors / focus jumps. */
  html:has(body.editor) { scroll-padding-top: 80px; }

  /* Nav: tighter row with brand + hamburger; menu drops below. */
  .nav {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 10px;
  }
  .nav .brand { font-size: 19px; flex: 1; white-space: nowrap; }

  .nav ul {
    order: 99;
    flex-basis: 100%;
    flex-direction: column;
    gap: 2px;
    display: none;
    padding: 8px;
    border-radius: 16px;
    margin-top: 10px;
    background: var(--paper-2);
  }
  .nav ul a {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 15px;
  }
  .nav ul a.active { box-shadow: none; }
  body.nav-open .nav ul { display: flex; }
  .nav-right .eyebrow { display: none; }
  .dash-cols { grid-template-columns: 1fr; }

  /* iOS Safari: 16px input prevents auto-zoom. */
  .field input, .field select, .field textarea, .filter-select { font-size: 16px; }

  /* iOS gives <input type="date|time"> its own intrinsic size, so they render
     taller and wider than the text fields. Strip the native appearance so they
     inherit the exact same box (height, width, padding) as every other field. */
  .field input[type="date"],
  .field input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
    min-width: 0;
    width: 100%;
  }
  .field input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
  .field input[type="date"]::-webkit-calendar-picker-indicator { margin: 0; }

  .card { padding: 20px; border-radius: 18px; }

  /* Collapse template-inlined grids to single column on mobile. */
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 2fr"],
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 2fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Dense quick-add forms: single column on phones so long option text and
     placeholders never truncate, and every control is a full-width tap target.
     (Overrides the inline `align-items: end`, which staggered fields whose
     labels differed in height.) */
  #service-quick-add > div,
  #booking-quick-add > div {
    grid-template-columns: 1fr !important;
    align-items: stretch !important;
  }
  #service-quick-add .field:last-child .btn,
  #booking-quick-add .field:last-child .btn { width: 100%; }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { padding: 18px 18px 16px; border-radius: 16px; }
  .stat-value { font-size: 30px; }

  h1.display { font-size: 30px !important; line-height: 1.08; }
  h2.display { font-size: 22px !important; }

  /* Let wide tables (Bookings, Services, Invoices…) scroll sideways on a phone.
     The base `.card:has(> .table:first-child)` rule sets `overflow: hidden`
     (to clip the table to the card's rounded corners) and outranks a plain
     `.card:has(table)` — so we override with the same specificity here, later
     in the source, to re-enable horizontal swipe. */
  .card:has(table),
  .card:has(> .table:first-child) {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }
  .table th, .table td { padding: 12px 14px; font-size: 13px; white-space: nowrap; }
  .table td:nth-child(3) { white-space: normal; }

  div[style*="display: flex; gap: var(--space-3)"]:has(.mode-pill) { flex-direction: column; }

  .btn, .btn-secondary, .btn-danger { height: 48px; padding: 0 22px; }

  /* Clear the fixed bottom tab bar so the last content isn't hidden behind it. */
  .editor .container { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
}

/* ─────────────────────────────────────────────────────────────
   Laptop & below (≤ 1500px): the 12-link top nav can't fit in one
   row (it only does so on wide desktops / iMac), so the links move
   to the bottom tab bar. The top bar keeps just the brand, theme
   switch, name and sign-out. Wide desktops (≥ 1501px) keep the full
   horizontal nav. This is why a MacBook Air — too wide for the old
   ≤760px phone breakpoint, too narrow for 12 inline links — used to
   overflow instead of adapting.
   ───────────────────────────────────────────────────────────── */
@media (max-width: 1500px) {
  .nav ul { display: none; }
  /* The bottom tab bar replaces the hamburger menu wherever it is shown. */
  .nav-toggle { display: none; }
}

/* ─────────────────────────────────────────────────────────────
   Bottom tab bar — native-style navigation on phones and laptops
   (≤ 1500px). Wide desktops keep the top nav; this is hidden there.
   ───────────────────────────────────────────────────────────── */
.tabbar, .tabbar-sheet, .tabbar-backdrop { display: none; }

@media (max-width: 1500px) {
  .tabbar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 200;
    justify-content: space-around;
    align-items: stretch;
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: saturate(140%) blur(18px);
    -webkit-backdrop-filter: saturate(140%) blur(18px);
    border-top: 1px solid var(--line);
  }
  .tabbar .tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 7px 2px 5px;
    border: none;
    background: transparent;
    color: var(--ink-4);
    font-family: var(--font-body);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-transform: none;
    text-decoration: none;
    border-radius: 12px;
    transition: color 140ms ease;
  }
  .tabbar .tab .icon { width: 23px; height: 23px; opacity: 0.85; vertical-align: 0; }
  .tabbar .tab.active { color: var(--ink); }
  .tabbar .tab.active .icon { opacity: 1; }

  /* "More" sheet — slides up above the bar; backdrop dims the page. */
  .tabbar-sheet {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: fixed;
    left: 8px; right: 8px;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    z-index: 201;
    padding: 8px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    transform: translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 180ms ease, opacity 180ms ease;
  }
  body.more-open .tabbar-sheet { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .tabbar-sheet .sheet-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 12px;
    color: var(--ink-2);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
  }
  .tabbar-sheet .sheet-link .icon { width: 18px; height: 18px; opacity: 0.7; vertical-align: 0; }
  .tabbar-sheet .sheet-link.active { background: var(--paper-2); color: var(--ink); }
  .tabbar-sheet .sheet-link.active .icon { opacity: 1; }

  .tabbar-backdrop { display: none; }
  body.more-open .tabbar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(15, 23, 42, 0.32);
  }
}

/* Tab bar — dark theme surface. */
html[data-theme="dark"] .tabbar { background: rgba(20, 26, 40, 0.86); border-top-color: var(--line); }

/* Larger screens — fixed 4-up stat grid + slightly more breathing room. */
@media (min-width: 900px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1200px) {
  .editor .container { padding-top: 72px; }
}

/* ─────────────────────────────────────────────────────────────
   THEME: Dark — editorial modern, ink-on-paper inverted.
   Activated via <html data-theme="dark">.
   ───────────────────────────────────────────────────────────── */
html[data-theme="dark"] body.editor {
  --navy-700:   #161b28;
  --navy-500:   rgba(255, 255, 255, 0.10);
  --text-light: #e9ecf2;
  --text-muted: #9ca3af;
  --gold:       #d6b87d;
  --gold-bright:#e2c389;
  --bronze:     #b89968;

  --ink:        #f1f3f7;
  --ink-2:      #d8dce4;
  --ink-3:      #9ca3af;
  --ink-4:      #6b7280;
  --paper:      #0b0f1a;
  --paper-2:    #141a28;
  --paper-3:    #1c2236;
  --line:       rgba(255, 255, 255, 0.06);
  --line-strong:rgba(255, 255, 255, 0.14);

  --bg-wash:    radial-gradient(1200px 380px at 50% -80px,
                                rgba(214, 184, 125, 0.10),
                                transparent 70%);
  background: var(--paper);
  color: var(--ink-2);
}
html[data-theme="dark"] { background: #0b0f1a; color-scheme: dark; }
html[data-theme="dark"] .nav { background: rgba(20, 26, 40, 0.72); border-bottom-color: var(--line); }
html[data-theme="dark"] .nav ul { background: var(--paper-2); border-color: var(--line); }
html[data-theme="dark"] .nav ul a.active { background: var(--ink); color: var(--paper); }
html[data-theme="dark"] .card,
html[data-theme="dark"] .stat,
html[data-theme="dark"] .mode-pill,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea { background-color: var(--paper-2); border-color: var(--line); color: var(--ink); }
html[data-theme="dark"] .field input::placeholder,
html[data-theme="dark"] .field textarea::placeholder { color: var(--ink-4); }
html[data-theme="dark"] .table th { background: var(--paper-3); color: var(--ink-3); }
html[data-theme="dark"] .table td { color: var(--ink-2); border-color: var(--line); }
html[data-theme="dark"] .table tbody tr:hover td { background: rgba(255, 255, 255, 0.03); }
html[data-theme="dark"] .btn { background: var(--ink); color: var(--paper) !important; box-shadow: 0 4px 14px rgba(0,0,0,0.4); }
html[data-theme="dark"] .btn:hover { background: #e9ecf2; }
html[data-theme="dark"] .btn-secondary { background: var(--paper-2); color: var(--ink) !important; border-color: var(--line-strong); }
html[data-theme="dark"] .btn-secondary:hover { background: var(--paper-3); }
html[data-theme="dark"] .btn-secondary.is-active { background: var(--ink) !important; color: var(--paper) !important; border-color: var(--ink) !important; }
html[data-theme="dark"] .nav-toggle { color: var(--ink); border-color: var(--line-strong); }
html[data-theme="dark"] .empty .display { color: var(--ink); }

/* ─────────────────────────────────────────────────────────────
   THEME: Steep — "soft dawn on a marble dashboard".
   A light, premium, hospitality-luxe surface: warm marble page,
   white cards that float on a soft peach→lilac dawn wash, gold
   demoted to a quiet accent. Activated via <html data-theme="steep">.
   Re-maps the same tokens as the editorial default, so every
   template inherits it; only a few surfaces are touched directly.
   ───────────────────────────────────────────────────────────── */
html[data-theme="steep"] body.editor {
  --navy-700:   #fcfaf6;
  --navy-500:   rgba(35, 38, 45, 0.08);
  --text-light: #23262d;
  --text-muted: #6a7180;
  --gold:       #9a7d4e;                /* AA-safe gold on light text */
  --gold-bright:#b8995f;                /* decorative dawn gold */
  --bronze:     #8a7551;

  --ink:        #23262d;                /* graphite, not navy */
  --ink-2:      #33373f;
  --ink-3:      #5d6470;
  --ink-4:      #9aa0ab;
  --paper:      #fcfaf6;                /* floating card / input white */
  --paper-2:    #f3eee4;               /* nav pill, hovers, secondary */
  --paper-3:    #ece6d9;               /* stone: table head, wells */
  --line:       rgba(35, 38, 45, 0.07);
  --line-strong:rgba(35, 38, 45, 0.15);

  /* Soft dawn: a peach sun-up at left, a lilac haze at right. */
  --bg-wash:
    radial-gradient(900px 340px at 16% -130px, rgba(232, 179, 148, 0.22), transparent 70%),
    radial-gradient(900px 340px at 84% -150px, rgba(188, 172, 212, 0.18), transparent 72%);

  /* Marble page, a touch deeper than the cards, so cards lift off it. */
  background: #f4f0e8;
  color: var(--ink-2);
}
html[data-theme="steep"] { background: #f4f0e8; color-scheme: light; }
/* A more present dawn than the default 480px sliver. */
html[data-theme="steep"] body.editor::before { height: 620px; }
/* Warmer glass on the marble. */
html[data-theme="steep"] .nav { background: rgba(252, 250, 246, 0.72); }
/* Cards float with a soft, warm double shadow instead of a hard border. */
html[data-theme="steep"] .card {
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(35, 38, 45, 0.04), 0 10px 30px rgba(35, 38, 45, 0.07);
}
html[data-theme="steep"] .stat {
  box-shadow: 0 1px 2px rgba(35, 38, 45, 0.04), 0 6px 18px rgba(35, 38, 45, 0.06);
}
/* Stat headline numbers carry the quiet gold — the one accent moment. */
html:is([data-theme="steep"], [data-theme="dark"]) .stat-value { color: var(--bronze); }

/* ── Steep — redesigned components (all widths) ──────────────────
   Airier, rounder, more "dashboard" than the editorial surfaces. */
html:is([data-theme="steep"], [data-theme="dark"]) .card {
  border-radius: 24px;
  padding: 30px;
  box-shadow: 0 1px 2px rgba(35, 38, 45, 0.04), 0 12px 34px rgba(35, 38, 45, 0.07);
}
html:is([data-theme="steep"], [data-theme="dark"]) .stat {
  border-radius: 22px;
  padding: 28px 26px 24px;
}
/* The gold accent bar is always on in Steep (the one warm note per tile). */
html:is([data-theme="steep"], [data-theme="dark"]) .stat::before {
  opacity: 1;
  height: 4px;
  background: linear-gradient(90deg, var(--gold-bright), transparent 82%);
}
html:is([data-theme="steep"], [data-theme="dark"]) .stat-value { font-size: clamp(40px, 4.4vw, 56px); }

/* ── Sidebar layout (≥1024px) — shared by Steep, Dark and the default Fintech theme ────────────────────
   The top nav becomes a fixed left rail with the sections stacked
   vertically; the content shifts right; the mobile tab bar is hidden
   (the sidebar replaces it). Phones (<1024px) keep the recolored top
   bar + bottom tab bar untouched. CSS-only on the shared nav DOM. */
@media (min-width: 1024px) {
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: 288px;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    padding: 26px 18px;
    background: #efeae0;                 /* stone rail, distinct from marble page */
    border-right: 1px solid var(--line);
    border-bottom: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overflow-y: auto;
  }
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav .brand {
    padding: 6px 10px 0;
    margin-bottom: 26px;
    font-size: 19px;
    white-space: nowrap;
  }
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav ul {
    display: flex !important;            /* overrides the ≤1500 "ul {display:none}" */
    flex-direction: column;
    gap: 3px;
    width: 100%;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
  }
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav ul li { width: 100%; }
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav ul a {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 11px;
    width: 100%;
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 14px;
    color: var(--ink-3);
  }
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav ul a .icon { opacity: 0.7; }
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav ul a:hover { background: rgba(35, 38, 45, 0.05); color: var(--ink); }
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav ul a.active {
    background: #ffffff;
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(35, 38, 45, 0.10);
  }
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav ul a.active .icon { opacity: 1; }
  /* Gold tab marker on the active row. */
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav ul a.active::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 2px;
    background: var(--gold-bright);
  }
  /* User / theme / sign-out pinned to the rail's bottom, stacked. */
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav-right {
    margin-top: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px 6px 4px;
    border-top: 1px solid var(--line);
  }
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav-right .theme-switch { align-self: flex-start; }
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav-right .eyebrow { padding-left: 4px; }
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav-toggle { display: none; }
  /* The sidebar already lists "Search" as a menu row; drop the round icon duplicate. */
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .nav-right .nav-search-btn { display: none; }

  /* Content area shifts past the rail and goes full-bleed. */
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .editor .container {
    margin: 0 0 0 288px;
    max-width: 1480px;
    padding: 44px 48px 90px;
  }
  /* Keep the dawn wash over the content, not under the rail. */
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) body.editor::before { left: 288px; }

  /* The sidebar replaces the bottom tab bar on desktop. */
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .tabbar,
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .tabbar-sheet,
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .tabbar-backdrop { display: none !important; }

  /* Dashboard reads as a bento: asymmetric lower row + airier stat gaps. */
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .stat-grid { gap: 18px; }
  :is(html[data-theme="steep"], html[data-theme="dark"], html:not([data-theme])) .dash-cols { grid-template-columns: 1.5fr 1fr; gap: 22px; }
}


/* Dark keeps the Steep layout above but needs its own rail colours
   (the shared rules hardcode Steep's light stone and white pill). */
html[data-theme="dark"] .card { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 34px rgba(0, 0, 0, 0.35); }
html[data-theme="dark"] .stat { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.3); }
@media (min-width: 1024px) {
  html[data-theme="dark"] .nav { background: #0e1320; border-right-color: var(--line); }
  html[data-theme="dark"] .nav ul a { color: var(--ink-3); }
  html[data-theme="dark"] .nav ul a:hover { background: rgba(255, 255, 255, 0.05); color: var(--ink); }
  html[data-theme="dark"] .nav ul a.active {
    background: var(--paper-3);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}


/* ─────────────────────────────────────────────────────────────
   DEFAULT THEME: Fintech — Wealth's "Sky" palette.
   Same colours as the Sky theme in Roderick's Wealth app
   (wealth/static/wealth.css [data-theme="sky"]): pale sky page,
   near-white cards without borders, deep teal-navy ink, ONE sky-blue
   accent (nav, buttons, links, logo) with a hot-pink second highlight
   (stat tabs, bars, logo dot), green/red for money, Inter everywhere
   (no serif), tabular big numbers, pill buttons, white left rail on
   desktop (shared sidebar rules above). Active when <html> has NO
   data-theme attribute; Dark and Steep are untouched because every
   rule is scoped to html:not([data-theme]).
   ───────────────────────────────────────────────────────────── */
html:not([data-theme]) body.editor {
  --navy-700:   #fcffff;
  --navy-500:   rgba(11, 37, 51, 0.08);
  --text-light: #0b2533;
  --text-muted: #5f7884;
  --text-soft:  #7f95a0;
  --text-dark:  #0b2533;
  --gold:       #04739c;                /* Sky blue, deepened for AA as text */
  --gold-bright:#0593c6;                /* Sky primary: fills, markers, logo */
  --gold-soft:  #def2f8;                /* Sky primary-soft on a card */
  --bronze:     #035f81;                /* hover / pressed blue */
  --accent-2:   #d83995;                /* Sky's hot-pink second highlight */
  --row-hover:  #f3f9fc;
  --mode-str:   var(--gold);            /* STR / PM labels (properties list) */
  --mode-pm:    var(--accent-2);
  --success:    #0b9b62;
  --danger:     #e23b54;

  --ink:        #0b2533;
  --ink-2:      #173546;
  --ink-3:      #5f7884;
  --ink-4:      #7f95a0;
  --paper:      #fcffff;
  --paper-2:    #e9f3f8;
  --paper-3:    #dcebf2;
  --line:       #dfecf2;
  --line-strong:#c8dce6;
  /* base.css surface tokens (still used by a few inline pills/tracks). */
  --surface:      #fcffff;
  --surface-2:    #e9f3f8;
  --surface-3:    #dcebf2;
  --border:       #dfecf2;
  --border-strong:#c8dce6;
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius-lg: 20px;
  --sky-shadow: 0 1px 2px rgba(11, 37, 51, 0.04), 0 10px 30px rgba(5, 147, 198, 0.07);

  --bg-wash: radial-gradient(1000px 340px at 30% -180px, rgba(5, 147, 198, 0.12), transparent 70%),
             radial-gradient(700px 300px at 90% -160px, rgba(216, 57, 149, 0.06), transparent 70%);

  background: #eef6fa;
  color: var(--ink-2);
  font-feature-settings: "cv11", "ss01", "tnum";
}
html:not([data-theme]) { background: #eef6fa; color-scheme: light; }
html:not([data-theme]) body.editor::before { height: 420px; }

/* Type: tight, bold, sans. */
html:not([data-theme]) .display,
html:not([data-theme]) h1, html:not([data-theme]) h2, html:not([data-theme]) h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.035em;
}
html:not([data-theme]) .eyebrow {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-4);
}
html:not([data-theme]) .eyebrow::before { display: none; }

/* Surfaces: borderless near-white cards floating on pale sky. */
html:not([data-theme]) .card {
  border: 1px solid transparent;
  border-radius: 20px;
  box-shadow: var(--sky-shadow);
}
html:not([data-theme]) .stat {
  border: 1px solid transparent;
  border-radius: 20px;
  box-shadow: var(--sky-shadow);
}
/* Sky's stat tab: a short bar on the top edge, blue / pink alternating. */
html:not([data-theme]) .stat::before {
  left: 24px; right: auto;
  width: 26px;
  border-radius: 0 0 3px 3px;
  background: var(--gold-bright);
  opacity: 1;
}
html:not([data-theme]) .stat:nth-child(even)::before { background: var(--accent-2); }
html:not([data-theme]) .stat:hover {
  transform: translateY(-2px);
  border-color: transparent;
  box-shadow: 0 2px 4px rgba(11, 37, 51, 0.05), 0 16px 36px rgba(5, 147, 198, 0.14);
}
html:not([data-theme]) .stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* Controls: sky-blue pills, no outlines. */
html:not([data-theme]) .btn {
  border-radius: 999px;
  background: var(--gold-bright);
  font-weight: 600;
  box-shadow: 0 6px 18px -6px var(--gold-bright);
  letter-spacing: -0.01em;
}
html:not([data-theme]) .btn:hover { background: var(--gold); transform: none; box-shadow: 0 8px 20px -6px rgba(5, 147, 198, 0.65); }
html:not([data-theme]) .btn-secondary { background: var(--paper-2); border-color: transparent; color: var(--ink) !important; box-shadow: none; }
html:not([data-theme]) .btn-secondary:hover { background: var(--paper-3); border-color: transparent; box-shadow: none; }
html:not([data-theme]) .btn-secondary.is-active,
html:not([data-theme]) .btn.btn-primary { background: var(--gold-bright) !important; color: #ffffff !important; border-color: transparent !important; }
html:not([data-theme]) .btn.btn-primary:hover { background: var(--gold) !important; }
html:not([data-theme]) .field input:not([type="checkbox"]):not([type="radio"]),
html:not([data-theme]) .field select,
html:not([data-theme]) .field textarea,
html:not([data-theme]) .filter-select {
  background: var(--paper-2);
  border-color: transparent;
  border-radius: 14px;
}
html:not([data-theme]) .field input:not([type="checkbox"]):not([type="radio"]):focus,
html:not([data-theme]) .field select:focus,
html:not([data-theme]) .field textarea:focus,
html:not([data-theme]) .filter-select:focus {
  background: var(--paper);
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 4px rgba(5, 147, 198, 0.16);
}
html:not([data-theme]) .mode-pill.active { border-color: var(--gold-bright); box-shadow: 0 0 0 3px rgba(5, 147, 198, 0.14); }
html:not([data-theme]) .table th {
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-4);
  background: transparent;
}
html:not([data-theme]) .table td { font-variant-numeric: tabular-nums; }
html:not([data-theme]) .table tbody tr:hover td { background: var(--row-hover); }
html:not([data-theme]) .status-badge { border-radius: 999px; font-weight: 600; letter-spacing: 0; text-transform: none; }

/* Top bar (phones / narrow) and theme switch. */
html:not([data-theme]) .nav { background: rgba(252, 255, 255, 0.82); border-bottom-color: var(--line); }
html:not([data-theme]) .nav ul a.active { background: var(--gold-soft); color: var(--gold); box-shadow: none; }
html:not([data-theme]) .theme-switch { background: var(--paper-2); border-color: transparent; }
html:not([data-theme]) .theme-switch button:hover { background: var(--paper-3); }
html:not([data-theme]) .theme-switch button[aria-pressed="true"] { box-shadow: 0 1px 3px rgba(11, 37, 51, 0.10); }
html:not([data-theme]) .tabbar { background: rgba(252, 255, 255, 0.92); border-top-color: var(--line); }
html:not([data-theme]) .tabbar .tab.active { color: var(--gold); }

/* Desktop rail: near-white, sky-soft active pill, sky-blue marker. */
@media (min-width: 1024px) {
  html:not([data-theme]) .nav {
    background: var(--paper);
    border-right: 1px solid var(--line);
  }
  html:not([data-theme]) .nav ul a { border-radius: 10px; font-weight: 500; padding: 7px 12px; font-size: 13.5px; }
  html:not([data-theme]) .nav ul .nav-group-menu { gap: 1px; }
  html:not([data-theme]) .nav .brand { margin-bottom: 18px; }
  html:not([data-theme]) .nav-right { gap: 8px; padding-top: 12px; }
  html:not([data-theme]) .nav ul a:hover { background: var(--paper-2); }
  html:not([data-theme]) .nav ul a.active { background: var(--gold-soft); color: var(--gold); box-shadow: none; }
  html:not([data-theme]) .nav ul a.active .icon { color: var(--gold); }
  html:not([data-theme]) .nav ul a.active::before { background: var(--gold-bright); }
  html:not([data-theme]) .nav-group-btn { color: var(--ink-4); }
  html:not([data-theme]) .editor .container { padding: 40px 44px 90px; }
  html:not([data-theme]) .dash-cols { grid-template-columns: 1.5fr 1fr; gap: 22px; }
}


/* Logo: sky-blue disc, white pin, pink dot (Wealth's brand dot). */
html:not([data-theme]) .nav .brand svg circle[fill="#1a1f2e"] { fill: var(--gold-bright); }
html:not([data-theme]) .nav .brand svg path[fill="#c9a876"] { fill: #ffffff; }
html:not([data-theme]) .nav .brand svg circle[fill="#c9a876"] { fill: var(--accent-2); }
html:not([data-theme]) .card a:not(.btn):not(.stat):not(.btn-link),
html:not([data-theme]) .table a:not(.btn) { color: var(--gold); }
html:not([data-theme]) .money-in, html:not([data-theme]) .amount-positive { color: var(--success); }
html:not([data-theme]) .money-out, html:not([data-theme]) .amount-negative { color: var(--danger); }

/* Bars (CRM reports, owner earnings share): Sky's blue-to-pink fill. */
html:not([data-theme]) .crm-bar__fill,
html:not([data-theme]) .share-bar { background: linear-gradient(90deg, var(--gold-bright), var(--accent-2)); opacity: 1; }

/* CRM: Sky's categorical colours for the pipeline phases, blue primary button. */
html:not([data-theme]) :is(.crm, .sortable-fallback) {
  --p-inbound: #0593c6;
  --p-qualify: #8b7cf6;
  --p-proposal: #d83995;
  --p-contract: #f2a541;
  --p-onboarding: #0b9b62;
  --p-parked: #8aa0aa;
  --crm-shadow: var(--sky-shadow);
}
html:not([data-theme]) .crm .crm-btn--primary { background: var(--gold-bright); border-color: var(--gold-bright); color: #ffffff; }
html:not([data-theme]) .crm .crm-btn--primary:hover { background: var(--gold); border-color: var(--gold); opacity: 1; }

/* ─── Theme switcher control ──────────────────────────────── */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.theme-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  border-radius: 999px;
  font-family: var(--font-body);
  transition: background 140ms ease, color 140ms ease;
  padding: 0;
}
.theme-switch button:hover { color: var(--ink); background: rgba(15, 23, 42, 0.04); }
.theme-switch button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.10);
}
html[data-theme="dark"] .theme-switch button:hover { background: rgba(255, 255, 255, 0.06); }
html[data-theme="dark"] .theme-switch button[aria-pressed="true"] { background: var(--paper-3); }
.theme-switch .icon { width: 15px; height: 15px; vertical-align: 0; }

@media (max-width: 760px) {
  /* 44px minimum touch target on phones (was 34px, below the a11y minimum). */
  .theme-switch button { width: 44px; height: 44px; }
}

/* ═══════════════════════════════════════════════════════════════
   Design-system pass (2026-06) — shared utilities + theme-aware
   semantics. Consolidates patterns that were previously inlined per
   page (error/help text, page headers, status badges, archived
   pills, inline row inputs) and makes danger/success/soft semantics
   adapt across the editorial / dark themes.
   ═══════════════════════════════════════════════════════════════ */

/* Semantic colours that adapt per theme. base.css :root holds the light
   (editorial) values; these lighten them so status text/badges stay legible
   on the dark surface (where they were previously too dim). */
html[data-theme="dark"] body.editor {
  --danger:    #e08a8a;
  --success:   #79b894;
  --text-soft: #9aa0b2;
}

/* Form validation + inline help (replaces hardcoded #f0c0c0 and inline greys). */
.field-error { color: var(--danger); font-size: 12px; line-height: 1.4; margin-top: 4px; }
.field-help  { color: var(--text-muted); font-size: 11px; line-height: 1.4; margin-top: 4px; }

/* Form-wide / banner error (e.g. __root__ errors, "email not configured"). */
.alert-error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
}

/* Page header — eyebrow + title + actions, shared by every list/detail page.
   Lets h1.display keep its responsive clamp (pages used to override it with
   an inline font-size:36px). */
.page-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-4); flex-wrap: wrap; margin-top: var(--space-6);
}
.page-head .page-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.page-title { color: var(--ink); margin-top: 6px; }

/* Archived pill (was a ~10-declaration inline style duplicated per detail page). */
.badge-archived {
  font-family: var(--font-body); font-size: 11px; vertical-align: middle;
  padding: 3px 8px; border: 1px solid var(--bronze); color: var(--bronze);
  border-radius: var(--radius-pill); letter-spacing: 0.15em; text-transform: uppercase;
  margin-left: var(--space-3);
}

/* Unified status badge — one theme-aware palette, replaces the per-page pastel
   hex maps in invoices / proposals / reports / bookings / services. */
.status-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 5px 11px; border-radius: var(--radius-pill); white-space: nowrap;
}
.status-badge--neutral { background: var(--surface-3); color: var(--text-muted); }
.status-badge--info    { background: color-mix(in srgb, #2f5fa8 14%, var(--paper)); color: #2f5fa8; }
.status-badge--active  { background: var(--gold-soft); color: var(--bronze); }
.status-badge--success { background: color-mix(in srgb, var(--success) 18%, var(--paper)); color: var(--success); }
.status-badge--danger  { background: color-mix(in srgb, var(--danger) 14%, var(--paper)); color: var(--danger); }
html[data-theme="dark"] .status-badge--neutral { background: var(--paper-3); color: var(--ink-3); }

/* Inline-editable text input for htmx row editors (cleanings/operations rows). */
.inline-input {
  min-height: 36px; padding: 7px 11px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 14px; width: 100%;
}

/* Notes are a wrapping textarea, not a one-line input: in a narrow phone table
   cell a single-line <input> scrolls the text out of view as you type (you had
   to drag the caret to read it back). The textarea wraps every word so the
   whole note stays visible, and a comfortable min-width gives room to type
   even inside a sideways-scrolling table. */
textarea.inline-input {
  min-height: 38px; min-width: 200px; line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: anywhere; resize: vertical;
}
@media (max-width: 760px) {
  textarea.inline-input { min-width: 240px; font-size: 16px; }
}

/* A brief "saved" pulse for htmx note fields that swap nothing visible. */
.saved-flash { animation: savedFlash 1.1s ease; }
@keyframes savedFlash {
  0% { border-color: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 25%, transparent); }
  100% { border-color: var(--line-strong); box-shadow: none; }
}

/* Issue report thumbnails (issues/edit.html). */
.issue-media { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-3); }
.issue-media .thumb { position: relative; width: 96px; height: 96px; border-radius: var(--radius-sm); overflow: hidden; background: var(--paper-3); }
.issue-media .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.issue-media .thumb form { margin: 0; }
.issue-media .thumb .del { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(15,23,42,0.72); color: #fff; font-size: 13px; line-height: 1; padding: 0; cursor: pointer; }
.issue-media .vidtag { position: absolute; bottom: 3px; left: 3px; background: rgba(15,23,42,0.72); color: #fff; font-size: 9px; padding: 1px 5px; border-radius: 6px; }
.issue-media .thumb.broken { outline: 1px dashed var(--danger, #b3412f); }
.issue-media .nopreview { display: block; padding: 8px; font-size: 10px; line-height: 1.3; color: var(--danger, #b3412f); }

/* Ghost-danger buttons that also carry .btn (Cancel invoice, Archive,
   Decline): .btn and the theme .btn rules force white text on a dark fill,
   which left white text on the transparent ghost background, unreadable.
   Outranks every theme's .btn rule. */
html body .btn.btn-ghost-danger {
  background: transparent;
  color: var(--danger, #c1453b) !important;
  border: 1px solid color-mix(in srgb, var(--danger, #c1453b) 45%, transparent);
  box-shadow: none;
}
html body .btn.btn-ghost-danger:hover {
  background: color-mix(in srgb, var(--danger, #c1453b) 9%, transparent);
  border-color: var(--danger, #c1453b);
  transform: none;
}
html[data-theme="dark"] body .btn.btn-ghost-danger { color: #f0857e !important; border-color: rgba(240, 133, 126, 0.45); }
