/* =============================================================================
   STAYREEL DESIGN SYSTEM
   -----------------------------------------------------------------------------
   Extends dashboard/server.ts's PAGE_STYLES — does not replace it. Every
   existing color token (--bg/--surface/--red/--accent/--good/--warn/--bad/
   --text*), font (Barlow / Instrument Serif italic / Space Grotesk), and the
   flow/galley-descended layout idiom (.app-layout/.sidebar/.main-content)
   keep their current values untouched.

   INTEGRATION: append this file's contents to the end of the PAGE_STYLES
   template string (or `<link>` it in <head> AFTER the inline <style> block).
   It intentionally re-declares a handful of existing selectors — .card,
   .pill, `button, .btn`, inputs/textarea, .timeline-item, .placeholder-note
   — at the same specificity PAGE_STYLES uses, so *source order* is what
   makes these rules win. Load order matters; nothing else does.

   Naming convention: single-hyphen modifier classes (.btn-primary,
   .pill-blocked, .card-interactive), matching the convention already
   established in dashboard/server.ts itself — not galley's later `--`
   BEM-modifier fork. This is a deliberate divergence from galley for one
   reason only: it keeps the integration diff in server.ts minimal, since
   every existing class name in that file (.btn-primary, .card-title,
   .card-meta, .card-actions, .pill-pending, etc.) already uses this
   pattern and stays valid as-is.

   See dashboard/DESIGN_SYSTEM.md for the usage guide (spacing/type scale,
   which button/card/pill variant for which situation, a11y notes).
   ============================================================================= */


/* -----------------------------------------------------------------------
   1. TOKENS — additive. Spacing scale, type scale, radius/shadow/motion.
   ----------------------------------------------------------------------- */
:root {
  /* radius scale — --radius (10px) / --radius-lg (12px) already existed */
  --radius-sm: 6px;
  --radius-pill: 999px;

  /* spacing scale — 4px base unit. Use these instead of ad-hoc px margins. */
  --space-1: 4px;   /* hairline gaps: icon-to-label, pill internal rhythm  */
  --space-2: 8px;   /* tight: form field gaps, inline button clusters      */
  --space-3: 12px;  /* card internal rhythm, gaps between related controls */
  --space-4: 16px;  /* default block gap, card padding (dense/admin)       */
  --space-5: 20px;  /* card padding (public/storefront), section sub-gaps */
  --space-6: 24px;  /* between distinct form sections                     */
  --space-7: 32px;  /* between major page sections (h2 blocks)             */
  --space-8: 40px;  /* page-level top padding, hero spacing                */
  --space-9: 56px;  /* rare — hero/footer breathing room on public pages   */

  /* type scale — html{font-size:15px}, so 1rem = 15px here */
  --text-xs: 0.72rem;        /* pills, eyebrows/.label, timestamps, hints   */
  --text-sm: 0.83rem;        /* meta text, dense table/list copy            */
  --text-base: 0.92rem;      /* buttons, default UI body copy               */
  --text-md: 1rem;           /* form inputs, standard paragraph copy        */
  --text-lg: 1.15rem;        /* card titles, sub-headings                   */
  --text-xl: 1.4rem;         /* h2 — section headers                        */
  --text-2xl: 1.7rem;        /* h1 — legal pages, lead-detail title         */
  --text-3xl: 2.1rem;        /* h1 — dashboard list page, public sub-hero   */
  --text-display: 2.75rem;   /* serif hero display — public homepage only   */

  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;

  /* elevation — --shadow (0 2px 12px/.4) already existed, kept as the
     default card shadow; these add a step below and above it. */
  --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.3);
  --shadow-lg: 0 10px 32px oklch(0 0 0 / 0.5);

  /* motion + focus */
  --transition-fast: 120ms ease;
  --transition: 180ms ease;
  --focus-ring: 0 0 0 3px color-mix(in oklch, var(--accent) 45%, transparent);
}


/* -----------------------------------------------------------------------
   2. TYPOGRAPHY SCALE
   ----------------------------------------------------------------------- */
h1 { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.3px; line-height: var(--leading-tight); margin: 0 0 var(--space-1); }
h2 { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.2px; line-height: var(--leading-tight); margin: 0 0 var(--space-2); }
h3 { font-size: var(--text-lg); font-weight: 600; line-height: var(--leading-tight); margin: 0 0 var(--space-1); }
p { line-height: var(--leading-normal); }

/* Utility classes for when a heading needs a different visual weight than
   its semantic tag implies (e.g. an <h2> that should read like a page
   title inside a nested component). Prefer the real tag first. */
.text-display { font-family: 'Manrope', sans-serif; font-style: normal; font-weight: 800; font-size: var(--text-display); line-height: var(--leading-tight); margin: 0 0 var(--space-2); }
.h1 { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.3px; line-height: var(--leading-tight); }
.h2 { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.2px; line-height: var(--leading-tight); }
.h3 { font-size: var(--text-lg); font-weight: 600; line-height: var(--leading-tight); }

.lede { font-size: var(--text-md); line-height: var(--leading-relaxed); color: var(--text-secondary); }
.text-body { font-size: var(--text-md); line-height: var(--leading-relaxed); color: var(--text); }
.text-caption { font-size: var(--text-xs); color: var(--text-muted); } /* was --text-dim: ~2.8:1, fails AA. a11y audit 2026-08-19 */
.subtitle { color: var(--text-secondary); margin: 0 0 var(--space-7); font-size: var(--text-base); }

/* .label already exists in PAGE_STYLES (Space Grotesk, uppercase,
   letter-spaced) and is used for BOTH section eyebrows and form-field
   labels today — kept exactly as-is; .eyebrow is an alias for clarity
   when used purely as a section eyebrow rather than a field label. */
.eyebrow { font-family: 'Manrope', sans-serif; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; font-size: var(--text-xs); color: var(--text-muted); }
.eyebrow-accent { color: var(--accent); }


/* -----------------------------------------------------------------------
   3. BUTTONS
   States covered: default / hover / focus-visible / active / disabled /
   loading. Sizes: default (40px, meets a comfortable tap target for the
   public storefront's single-CTA pages), .btn-sm (32px, dense admin
   rows/forms), .btn-lg (46px, storefront primary "Unlock" CTA).
   ----------------------------------------------------------------------- */
button, .btn {
  font: inherit;
  font-family: 'Manrope', sans-serif;
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 var(--space-4);
  height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast), opacity var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--surface-hover); }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn[aria-disabled="true"], .btn.is-disabled {
  opacity: 0.45; cursor: not-allowed; pointer-events: none; transform: none;
}

/* variants */
.btn-primary { background: var(--red); color: #fff; border-color: transparent; }
.btn-primary:hover { background: var(--red-dim); }

.btn-secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--border-hover); background: var(--surface-hover); }

.btn-danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: color-mix(in oklch, var(--bad) 14%, transparent); }
.btn-danger-solid { background: var(--bad); color: #fff; border-color: transparent; }
.btn-danger-solid:hover { opacity: 0.88; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); padding: 0 var(--space-2); height: 32px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* sizes */
.btn-sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn-lg { height: 46px; padding: 0 var(--space-6); font-size: var(--text-md); border-radius: var(--radius); }

/* loading state — pair with aria-busy="true" and (ideally) a disabled
   native attribute so a double-submit can't happen while it spins. */
.btn.is-loading { color: transparent; pointer-events: none; position: relative; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid color-mix(in oklch, currentColor 30%, transparent);
  border-top-color: #fff; animation: btn-spin .6s linear infinite; color: inherit;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.btn-group { display: inline-flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }


/* -----------------------------------------------------------------------
   4. STATUS PILLS / BADGES
   Two layers: (a) literal status-vocabulary classes mapping 1:1 to the
   `leads.status` / `inbound_messages.draft_status` / `payments.status`
   enum values already used in statusPill() — no server.ts change needed
   beyond loading this CSS; (b) generic tone classes for anything outside
   that vocabulary (contact_status, ad-hoc badges).
   ----------------------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 3px 10px; border-radius: var(--radius-sm);
  font-family: 'Manrope', sans-serif; font-size: var(--text-xs);
  font-weight: 600; text-transform: capitalize; letter-spacing: 0;
  line-height: 1.6; white-space: nowrap;
}
.pill-sm { padding: 2px 8px; font-size: 0.65rem; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* status vocabulary (leads.status) */
.pill-pending          { background: color-mix(in oklch, var(--text-dim) 20%, transparent);  color: var(--text-muted); }
.pill-running          { background: color-mix(in oklch, var(--accent) 20%, transparent);     color: var(--accent); }
.pill-awaiting_approval{ background: color-mix(in oklch, var(--warn) 20%, transparent);       color: var(--warn); }
.pill-blocked          { background: color-mix(in oklch, var(--bad) 20%, transparent);        color: var(--bad); }
.pill-failed           { background: color-mix(in oklch, var(--bad) 20%, transparent);        color: var(--bad); }
.pill-stale            { background: color-mix(in oklch, var(--text-dim) 30%, transparent);   color: var(--text-secondary); }
.pill-complete         { background: color-mix(in oklch, var(--good) 20%, transparent);       color: var(--good); }
.pill-done             { background: color-mix(in oklch, var(--good) 20%, transparent);       color: var(--good); }
.pill-paid             { background: color-mix(in oklch, var(--good) 20%, transparent);       color: var(--good); }
.pill-refunded         { background: color-mix(in oklch, var(--bad) 20%, transparent);        color: var(--bad); }

/* --accent/--bad text at full strength on their own 20%-tinted backgrounds
   measures ~3.5-3.8:1 (fails 4.5:1 AA) — red/crimson hues read visually
   brighter than their WCAG luminance actually supports. Lightened text-only
   overrides for the pills where this matters most (the states an operator
   is scanning the list for): running/blocked/failed/refunded. Background
   and every other --accent/--bad usage (buttons, links, field-error) is
   untouched — those already pass separately. a11y audit 2026-08-19. */
.pill-running  { color: oklch(0.72 0.17 29); }
.pill-blocked, .pill-failed, .pill-refunded { color: oklch(0.74 0.16 25); }

/* running/awaiting_approval pulse — small motion cue for "this needs
   attention or is actively working," respects reduced-motion */
.pill-running::before, .pill-awaiting_approval::before { animation: pill-pulse 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .pill-running::before, .pill-awaiting_approval::before { animation: none; } }
@keyframes pill-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* generic tone pills — for values not in the fixed status vocabulary
   above (e.g. contact_status: found/not_found/pending) */
.pill-tone-good    { background: color-mix(in oklch, var(--good) 20%, transparent);    color: var(--good); }
.pill-tone-warn    { background: color-mix(in oklch, var(--warn) 20%, transparent);    color: var(--warn); }
.pill-tone-bad     { background: color-mix(in oklch, var(--bad) 20%, transparent);     color: var(--bad); }
.pill-tone-neutral { background: var(--surface-2);                                     color: var(--text-muted); }
.pill-tone-info    { background: color-mix(in oklch, var(--accent) 20%, transparent);  color: var(--accent); }


/* -----------------------------------------------------------------------
   5. CARDS
   .card = default static content container (existing). .card-interactive
   = the clickable variant (whole card is a target, e.g. lead list rows) —
   apply to the element that actually wraps the interaction (usually an
   <a>) so keyboard/AT users get one focusable, one hit target rather
   than a div soup. .card-flat = de-emphasized nested content (inside
   another card) with no border/shadow competing with the parent.
   ----------------------------------------------------------------------- */
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-5);
  margin-bottom: var(--space-3); box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.card:hover { border-color: var(--border-hover); }

.card-interactive { cursor: pointer; }
a.card-interactive, .card-interactive a.card-link-overlay { text-decoration: none; color: inherit; display: block; }
.card-interactive:hover { border-color: var(--border-hover); box-shadow: var(--shadow); transform: translateY(-1px); }
.card-interactive:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.card-flat { background: var(--surface-2); border: 1px solid transparent; box-shadow: none; padding: var(--space-4); }
.card-flat:hover { border-color: transparent; }

.card-compact { padding: var(--space-3) var(--space-4); }

/* internal rhythm helpers — use instead of stacking inline margin-top */
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); margin-bottom: var(--space-3); }
.card-body > * + * { margin-top: var(--space-3); }
.card-footer { margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--border); display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

/* existing .card-top/.card-title/.card-meta/.card-actions kept as-is,
   these are refinements only */
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); }
.card-title { font-weight: 600; font-size: var(--text-lg); margin: 0 0 var(--space-1); }
.card-meta { color: var(--text-muted); font-size: var(--text-sm); }
.card-actions { margin-top: var(--space-3); display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-3); }
.card-grid .card { margin-bottom: 0; }

.card-empty { color: var(--text-muted); text-align: center; padding: var(--space-8) var(--space-4); font-size: var(--text-sm); }


/* -----------------------------------------------------------------------
   6. FORMS
   .field wraps a single control + label + hint/error. Base input styling
   applies to native text/email/number/textarea/select so unstyled bare
   inputs (as used throughout server.ts today) still pick up the system
   automatically without a class.
   ----------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-3); }
.field-label { font-family: 'Manrope', sans-serif; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; font-size: var(--text-xs); color: var(--text-muted); } /* was --text-dim: ~2.8:1, fails AA on every form label. a11y audit 2026-08-19 */
.field-label .optional { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text-muted); opacity: .8; }
.field-hint { font-size: var(--text-xs); color: var(--text-muted); }
.field-error { font-size: var(--text-xs); color: var(--bad); display: flex; align-items: center; gap: var(--space-1); }
.field-error::before { content: "!"; display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: var(--bad); color: var(--bg); font-size: 0.62rem; font-weight: 800; flex-shrink: 0; }

textarea, select,
input[type="text"], input[type="email"], input[type="number"],
input[type="password"], input[type="url"], input[type="search"] {
  font: inherit; font-size: var(--text-md);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; width: 100%; min-height: 40px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
textarea { min-height: unset; line-height: var(--leading-normal); resize: vertical; }
::placeholder { color: var(--text-dim); }

textarea:hover, select:hover,
input[type="text"]:hover, input[type="email"]:hover, input[type="number"]:hover {
  border-color: var(--border-hover);
}
textarea:focus, select:focus,
input[type="text"]:focus, input[type="email"]:focus, input[type="number"]:focus,
input[type="password"]:focus, input[type="url"]:focus, input[type="search"]:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); background: var(--surface-2);
}
input:disabled, textarea:disabled, select:disabled { opacity: .5; cursor: not-allowed; }

/* validation state — pair with aria-invalid="true" on the control */
.field.is-invalid input, .field.is-invalid textarea, .field.is-invalid select,
input[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--bad);
}
.field.is-invalid input:focus, .field.is-invalid textarea:focus {
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--bad) 35%, transparent);
}

/* checkbox/radio — native, just aligned + sized to a real hit target */
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--red); }
.field-inline { display: flex; align-items: center; gap: var(--space-2); flex-direction: row; }
.field-inline .field-label { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: var(--text-sm); color: var(--text-muted); }

.form-row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: flex-end; }
.form-row > .field { flex: 1; min-width: 180px; margin-bottom: 0; }
.form-grid { display: grid; gap: var(--space-3); max-width: 460px; }

/* ---- file upload / drop-zone ----
   CSS-only baseline works with a bare <input type=file> wrapped in a
   <label class="dropzone">; the [data-drag="over"] state is optional and
   only lights up if a few lines of vanilla JS toggle it on
   dragenter/dragleave (see DESIGN_SYSTEM.md — not required for the
   dropzone to be functional, only for the "drag a file over it" visual). */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-1); text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border-hover); border-radius: var(--radius);
  background: var(--surface-2); padding: var(--space-6) var(--space-4);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.dropzone:hover, .dropzone:focus-within { border-color: var(--accent); background: color-mix(in oklch, var(--accent) 8%, var(--surface-2)); }
.dropzone[data-drag="over"] { border-color: var(--accent); background: color-mix(in oklch, var(--accent) 14%, var(--surface-2)); border-style: solid; }
.dropzone input[type="file"] {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.dropzone-icon { font-size: 1.6rem; color: var(--text-dim); }
.dropzone-title { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.dropzone-hint { font-size: var(--text-xs); color: var(--text-muted); }
.dropzone-or { display: flex; align-items: center; gap: var(--space-2); color: var(--text-dim); font-size: var(--text-xs); margin: var(--space-3) 0; text-transform: uppercase; letter-spacing: .06em; font-family: 'Manrope', sans-serif; }
.dropzone-or::before, .dropzone-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }


/* -----------------------------------------------------------------------
   7. PHOTO GALLERY
   ----------------------------------------------------------------------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--space-2); margin-bottom: var(--space-3); }
.gallery-item {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-sm);
  overflow: hidden; border: 1px solid var(--border); background: var(--surface-2);
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-item .gallery-remove {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; padding: 0; min-width: 0;
  border-radius: 50%; background: oklch(0.1 0 0 / .65); color: #fff; font-size: .8rem;
  opacity: 0; transition: opacity var(--transition-fast);
}
.gallery-item:hover .gallery-remove, .gallery-item .gallery-remove:focus-visible { opacity: 1; }
.gallery-item .gallery-caption {
  position: absolute; inset: auto 0 0 0; padding: 4px 6px;
  background: linear-gradient(to top, oklch(0.1 0 0 / .7), transparent);
  font-size: 0.62rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gallery-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1);
  padding: var(--space-6); border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--text-dim); font-size: var(--text-sm); text-align: center; margin-bottom: var(--space-3);
}

/* click-to-select-in-order (lead-detail's tour photo picker) — a bare
   .gallery-item wrapped in a <label> so it stays keyboard/AT operable
   without extra markup; the order badge is the whole point (it's the
   sliding-window sequence generateStitchedTour() builds clips from). */
.gallery-item-selectable { cursor: pointer; display: block; transition: box-shadow var(--transition-fast); }
.gallery-item-selectable:hover { box-shadow: 0 0 0 2px var(--border-hover); }
.gallery-item-selectable.is-selected { box-shadow: 0 0 0 2px var(--accent); }
.gallery-item-selectable .gallery-order-badge {
  position: absolute; top: 4px; left: 4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: var(--radius-pill); background: var(--accent); color: #fff;
  font-size: 0.72rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--transition-fast);
}
.gallery-item-selectable.is-selected .gallery-order-badge { opacity: 1; }


/* -----------------------------------------------------------------------
   8. TIMELINE / ACTIVITY FEED
   One marker style per event type — outreach email / reply / payment /
   note / system. Existing .timeline-item selector kept so no class
   rename is required in the render function.
   ----------------------------------------------------------------------- */
.timeline { position: relative; margin-left: 4px; }
.timeline-item {
  position: relative; border-left: 2px solid var(--border);
  padding: var(--space-1) 0 var(--space-4) var(--space-4);
  margin-left: 4px; font-size: var(--text-sm); color: var(--text-muted);
}
.timeline-item:last-child { border-color: transparent; padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: -6.5px; top: 6px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid var(--text-dim);
}
.timeline-item .timeline-time { display: block; font-size: var(--text-xs); color: var(--text-dim); font-family: 'Manrope', sans-serif; letter-spacing: .02em; margin-bottom: 2px; }
.timeline-item .timeline-text { color: var(--text); }

/* event-type modifiers — set the marker color/ring per kind */
.timeline-item-outreach::before { border-color: var(--accent); }
.timeline-item-reply::before    { border-color: var(--warn); background: var(--warn); }
.timeline-item-payment::before  { border-color: var(--good); background: var(--good); }
.timeline-item-note::before     { border-color: var(--text-secondary); }
.timeline-item-system::before   { border-color: var(--text-dim); }

.timeline-empty { color: var(--text-muted); font-size: var(--text-sm); padding: var(--space-3) 0; }


/* -----------------------------------------------------------------------
   9. NAVIGATION
   ----------------------------------------------------------------------- */
/* --- admin sidebar (extends existing .sidebar/.sidebar-logo) --- */
.sidebar-nav { display: flex; flex-direction: column; gap: var(--space-1); margin-top: var(--space-4); }
.nav-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-size: var(--text-sm); font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item-active { background: var(--surface-hover); color: var(--text); font-weight: 600; }
.nav-item-active::before { content: ""; }
.sidebar-section-label { padding: var(--space-4) 2px 4px; font-family: 'Manrope', sans-serif; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.sidebar-footer { margin-top: auto; padding-top: var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-xs); color: var(--text-dim); }

/* --- public site header + nav (replaces the inline-styled legalNav) --- */
.site-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
.site-nav { display: flex; gap: var(--space-5); flex-wrap: wrap; }
.site-nav-link { color: var(--text-muted); text-decoration: none; font-size: var(--text-sm); font-weight: 500; padding-bottom: 2px; border-bottom: 2px solid transparent; transition: color var(--transition-fast), border-color var(--transition-fast); }
.site-nav-link:hover { color: var(--text); }
.site-nav-link-active { color: var(--text); font-weight: 600; border-color: var(--red); }


/* -----------------------------------------------------------------------
   10. ALERTS / NOTICES
   Formalizes the existing "placeholder-note" concept (kept as an alias =
   .notice-info) and adds success/warning/error siblings.
   ----------------------------------------------------------------------- */
.notice {
  display: flex; align-items: flex-start; gap: var(--space-2);
  border-radius: var(--radius); padding: var(--space-4);
  font-size: var(--text-sm); line-height: var(--leading-relaxed);
  border: 1px dashed var(--border-hover); background: var(--surface-2); color: var(--text-muted);
}
.notice::before { flex-shrink: 0; font-family: 'Manrope', sans-serif; font-weight: 700; font-size: var(--text-xs); width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-top: 1px; }

.notice-info { border-style: dashed; border-color: var(--border-hover); background: var(--surface-2); color: var(--text-muted); }
.notice-info::before { content: "i"; background: var(--surface-hover); color: var(--text-secondary); }

.notice-success { border-style: solid; border-color: color-mix(in oklch, var(--good) 40%, transparent); background: color-mix(in oklch, var(--good) 10%, var(--surface)); color: var(--text); }
.notice-success::before { content: "✓"; background: var(--good); color: oklch(0.15 0.02 152); }

.notice-warning { border-style: solid; border-color: color-mix(in oklch, var(--warn) 40%, transparent); background: color-mix(in oklch, var(--warn) 10%, var(--surface)); color: var(--text); }
.notice-warning::before { content: "!"; background: var(--warn); color: oklch(0.18 0.02 75); }

.notice-error { border-style: solid; border-color: color-mix(in oklch, var(--bad) 40%, transparent); background: color-mix(in oklch, var(--bad) 10%, var(--surface)); color: var(--text); }
.notice-error::before { content: "×"; background: var(--bad); color: #fff; }

/* legacy alias — .placeholder-note keeps working, unstyled diff */
.placeholder-note { display: flex; align-items: flex-start; gap: var(--space-2); background: var(--surface-2); border: 1px dashed var(--border-hover); border-radius: var(--radius); padding: var(--space-4); color: var(--text-muted); font-size: var(--text-sm); line-height: var(--leading-relaxed); }
.placeholder-note::before { content: "i"; flex-shrink: 0; font-family: 'Manrope', sans-serif; font-weight: 700; font-size: var(--text-xs); width: 20px; height: 20px; border-radius: 50%; background: var(--surface-hover); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; margin-top: 1px; }


/* -----------------------------------------------------------------------
   11. STAGE TRACK (existing — refined, current step now distinguishable
   from merely-done steps, matching the current/done language used
   elsewhere in the pipeline vocabulary)
   ----------------------------------------------------------------------- */
.stage-track { display: flex; gap: 4px; margin: var(--space-3) 0; }
.stage-step { flex: 1; height: 4px; border-radius: 2px; background: var(--border); transition: background var(--transition-fast); }
.stage-step.done { background: var(--good); }
.stage-step.current { background: var(--accent); }


/* -----------------------------------------------------------------------
   12. LAYOUT / SPACING UTILITIES
   A small, deliberately limited set — for the common inline-style cases
   already in server.ts (margin-top before a new section, flex clusters),
   not a general utility-CSS system.
   ----------------------------------------------------------------------- */
.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-6); }

.cluster { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.cluster-sm { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.cluster-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }

.section { margin-top: var(--space-7); }
.section-sm { margin-top: var(--space-5); }

.container-narrow { max-width: 760px; margin: 0 auto; }
.container-page { max-width: 880px; margin: 0 auto; }
.container-wide { max-width: 1280px; margin: 0 auto; }

/* generic margin-top scale, for the rare case a one-off gap is genuinely
   needed and none of the above semantic wrappers fit */
.u-mt-1 { margin-top: var(--space-1); } .u-mt-2 { margin-top: var(--space-2); }
.u-mt-3 { margin-top: var(--space-3); } .u-mt-4 { margin-top: var(--space-4); }
.u-mt-5 { margin-top: var(--space-5); } .u-mt-6 { margin-top: var(--space-6); }
.u-mt-7 { margin-top: var(--space-7); } .u-mt-8 { margin-top: var(--space-8); }


/* -----------------------------------------------------------------------
   13b. TABLES
   For a list of records with the same columns every row — the leads
   list, primarily. Not for anything a card handles better (a single
   record with variable-shaped content, like a lead's detail sections).
   ----------------------------------------------------------------------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; vertical-align: middle; }
.table thead th {
  font-family: 'Manrope', sans-serif; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 600; font-size: var(--text-xs); color: var(--text-muted);
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition-fast); }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-hover); }
.table td a { font-weight: 600; }
.table .table-empty { text-align: center; padding: var(--space-8); color: var(--text-muted); }

/* -----------------------------------------------------------------------
   13c. MODAL (native <dialog>)
   Use the browser's own <dialog> element + .showModal()/.close() — it
   gets focus trapping, Escape-to-close, and ::backdrop for free, no
   framework or hand-rolled overlay JS needed. This block only restyles
   its appearance to match the system; behavior is native.
   ----------------------------------------------------------------------- */
dialog.modal {
  background: var(--card-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: var(--space-6); width: min(520px, calc(100vw - var(--space-6) * 2));
  max-height: calc(100vh - var(--space-8) * 2);
}
dialog.modal::backdrop { background: oklch(0.1 0 0 / 0.6); }
dialog.modal[open] { display: flex; flex-direction: column; gap: var(--space-4); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); }
.modal-close { flex-shrink: 0; }
.modal-body { overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding-top: var(--space-2); }

/* -----------------------------------------------------------------------
   13. ACCESSIBILITY BASELINE
   ----------------------------------------------------------------------- */
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
a:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
