/*
 * Lesengi UI — restrained, gazette-grade design system.
 *
 * Intent: a serious civic/GIS tool, not a startup landing page. Deep ink
 * on warm parchment, thin rules, quiet surfaces, classical typography.
 * Accents are used sparingly — emerald/teal for live/go, umber for
 * value/money, plum for process, claret only for destructive. No neon,
 * no heavy shadows, no "tech green" ambient glow.
 */

:root {
  /* Core palette — warm paper + deep ink */
  --lx-bg:         #F6F2EA;     /* parchment */
  --lx-bg-2:       #EFE9DD;
  --lx-surface:    #FBF9F4;     /* card paper */
  --lx-surface-2:  #F1ECE1;
  --lx-ink:        #1C1A17;     /* near-black ink */
  --lx-ink-soft:   #3A342C;
  --lx-muted:      #6B6355;
  --lx-faint:      #9C9280;
  --lx-hairline:   #D9D1C1;
  --lx-hairline-2: #B8AE99;

  /* Accents — all muted, not saturated */
  --lx-accent:     #1F3D34;     /* deep boreal, replaces bright emerald */
  --lx-accent-2:   #2A5448;
  --lx-accent-50:  #E6ECE9;
  --lx-umber:      #8C5A2B;     /* warm umber — money/value */
  --lx-umber-2:    #6F4620;
  --lx-umber-50:   #F3E9DA;
  --lx-plum:       #533848;     /* muted plum — process */
  --lx-plum-50:    #EDE5EA;
  --lx-teal:       #35616B;
  --lx-teal-50:    #E2E9EB;
  --lx-claret:     #8A2B2B;     /* muted claret — destructive only */
  --lx-claret-50:  #F1E3E3;
  --lx-ochre:      #A37B17;
  --lx-ochre-50:   #F3EAD0;

  --lx-radius:     4px;
  --lx-radius-sm:  3px;
  --lx-radius-lg:  6px;

  --lx-shadow-1: 0 1px 0 rgba(28,26,23,0.04);
  --lx-shadow-2: 0 1px 2px rgba(28,26,23,0.06), 0 1px 1px rgba(28,26,23,0.04);
  --lx-shadow-3: 0 8px 24px rgba(28,26,23,0.10);

  --lx-sans:  'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --lx-serif: var(--lx-sans);  /* Unified on Outfit — no decorative/cursive faces anywhere */
  --lx-mono:  ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

/* ─── Base corrections ──────────────────────────────── */
html, body { background: var(--lx-bg); color: var(--lx-ink); }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-family: var(--lx-sans); }

/* ─── Dark theme — same restraint, deep slate-ink palette ──── */
html[data-theme="dark"] {
  --lx-bg:         #14110D;
  --lx-bg-2:       #1B1714;
  --lx-surface:    #221E19;
  --lx-surface-2:  #2B2620;
  --lx-ink:        #F1ECE1;
  --lx-ink-soft:   #D6CDB9;
  --lx-muted:      #9C9280;
  --lx-faint:      #6B6355;
  --lx-hairline:   #2E2922;
  --lx-hairline-2: #3D372E;

  --lx-accent:     #6B9B7E;     /* boreal, lifted for dark legibility */
  --lx-accent-2:   #84B596;
  --lx-accent-50:  #1F2C26;
  --lx-umber:      #C99563;
  --lx-umber-2:    #B27A45;
  --lx-umber-50:   #2A2117;
  --lx-plum:       #C19BAA;
  --lx-plum-50:    #2A1F26;
  --lx-teal:       #88B4BC;
  --lx-teal-50:    #1B2629;
  --lx-claret:     #C26A6A;
  --lx-claret-50:  #2A1818;
  --lx-ochre:      #D9B25C;
  --lx-ochre-50:   #2A2415;
}

/* In dark mode the Tailwind retints in the legacy section below would
   otherwise force light surfaces. Re-point them at our dark variables
   so existing templates honour the active theme without per-element
   edits. Same set as light mode but mapped to the dark palette. */
html[data-theme="dark"] .bg-white       { background-color: var(--lx-surface) !important; }
html[data-theme="dark"] .bg-stone-50    { background-color: var(--lx-surface) !important; }
html[data-theme="dark"] .bg-stone-100   { background-color: var(--lx-bg-2) !important; }
html[data-theme="dark"] .bg-stone-200   { background-color: var(--lx-hairline) !important; }
html[data-theme="dark"] .text-stone-900 { color: var(--lx-ink) !important; }
html[data-theme="dark"] .text-stone-800 { color: var(--lx-ink) !important; }
html[data-theme="dark"] .text-stone-700 { color: var(--lx-ink-soft) !important; }
html[data-theme="dark"] .text-stone-600 { color: var(--lx-ink-soft) !important; }
html[data-theme="dark"] .text-stone-500 { color: var(--lx-muted) !important; }
html[data-theme="dark"] .text-stone-400 { color: var(--lx-faint) !important; }
html[data-theme="dark"] .text-stone-300 { color: var(--lx-faint) !important; }
html[data-theme="dark"] .border-stone-100,
html[data-theme="dark"] .border-stone-200 { border-color: var(--lx-hairline) !important; }
html[data-theme="dark"] .border-stone-300 { border-color: var(--lx-hairline-2) !important; }

/* Status / chip pastels — flip to dark-tinted variants so badges stay
   readable on dark surfaces instead of glaring as pastel patches. */
html[data-theme="dark"] .bg-emerald-50,
html[data-theme="dark"] .bg-emerald-100  { background-color: var(--lx-accent-50) !important; }
html[data-theme="dark"] .bg-amber-50,
html[data-theme="dark"] .bg-amber-100,
html[data-theme="dark"] .bg-yellow-100   { background-color: var(--lx-umber-50)  !important; }
html[data-theme="dark"] .bg-red-50,
html[data-theme="dark"] .bg-red-100      { background-color: var(--lx-claret-50) !important; }
html[data-theme="dark"] .bg-green-100    { background-color: var(--lx-accent-50) !important; }
html[data-theme="dark"] .bg-blue-100,
html[data-theme="dark"] .bg-indigo-100,
html[data-theme="dark"] .bg-purple-100   { background-color: var(--lx-plum-50)   !important; }
html[data-theme="dark"] .bg-gray-100     { background-color: var(--lx-bg-2)      !important; }
html[data-theme="dark"] .text-emerald-800,
html[data-theme="dark"] .text-emerald-700,
html[data-theme="dark"] .text-green-800,
html[data-theme="dark"] .text-green-700  { color: var(--lx-accent-2) !important; }
html[data-theme="dark"] .text-amber-700,
html[data-theme="dark"] .text-amber-600,
html[data-theme="dark"] .text-yellow-800,
html[data-theme="dark"] .text-yellow-700 { color: var(--lx-umber)    !important; }
html[data-theme="dark"] .text-red-800,
html[data-theme="dark"] .text-red-700,
html[data-theme="dark"] .text-red-600    { color: var(--lx-claret)   !important; }
html[data-theme="dark"] .text-blue-800,
html[data-theme="dark"] .text-blue-700,
html[data-theme="dark"] .text-purple-700,
html[data-theme="dark"] .text-indigo-700 { color: var(--lx-plum)     !important; }

/* DataTables (jQuery DataTables default skin) — retint the chrome so
   filter input + length select don't read as light boxes on dark. */
html[data-theme="dark"] table.dataTable thead th         { background: var(--lx-surface-2) !important; color: var(--lx-ink) !important; border-bottom-color: var(--lx-hairline) !important; }
html[data-theme="dark"] table.dataTable tbody td         { border-bottom-color: var(--lx-hairline) !important; color: var(--lx-ink-soft); }
html[data-theme="dark"] table.dataTable tbody tr:hover   { background: var(--lx-surface-2) !important; }
html[data-theme="dark"] .dataTables_filter input,
html[data-theme="dark"] .dataTables_length select        { background: var(--lx-surface) !important; color: var(--lx-ink) !important; border-color: var(--lx-hairline-2) !important; }
html[data-theme="dark"] .dataTables_info,
html[data-theme="dark"] .dataTables_paginate            { color: var(--lx-muted) !important; }
html[data-theme="dark"] .paginate_button                 { color: var(--lx-ink-soft) !important; }

/* Cadastre tool (home map) keeps its own variables; remap to ours
   when the theme is dark so the cockpit/sidebar/legend follow suit. */
html[data-theme="dark"] {
  --ink: var(--lx-ink); --ink-2: var(--lx-ink-soft);
  --muted: var(--lx-muted); --muted-2: var(--lx-faint);
  --rule: var(--lx-hairline); --rule-strong: var(--lx-hairline-2);
  --canvas: var(--lx-bg); --surface: var(--lx-surface);
  --accent: var(--lx-accent); --accent-soft: var(--lx-accent-50);
  --flag: var(--lx-umber);
}

h1, h2, h3, h4, .lx-display {
  font-family: var(--lx-serif); font-weight: 500; letter-spacing: -0.01em;
}

/* ─── Card ──────────────────────────────────────────── */
.lx-card {
  background: var(--lx-surface);
  border: 1px solid var(--lx-hairline);
  border-radius: var(--lx-radius);
  box-shadow: var(--lx-shadow-1);
}
.lx-card--pad { padding: 22px 24px; }
.lx-card--pad-sm { padding: 14px 16px; }
.lx-card--tight { padding: 10px 14px; }
.lx-card--interactive { transition: border-color .18s ease, background .18s ease; }
.lx-card--interactive:hover { border-color: var(--lx-hairline-2); background: var(--lx-surface-2); }

/* ─── Panel heading ─────────────────────────────────── */
.lx-panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--lx-hairline);
}
.lx-panel__title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--lx-serif); font-weight: 500; font-size: 17px; color: var(--lx-ink);
  letter-spacing: -0.01em;
}
.lx-panel__sub { font-size: 12px; color: var(--lx-muted); }

/* ─── Stat tile ─────────────────────────────────────── */
.lx-stat { display: flex; align-items: flex-start; gap: 14px; }
.lx-stat__icon {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 3px;
  display: grid; place-items: center; background: var(--lx-surface-2); color: var(--lx-ink-soft);
  border: 1px solid var(--lx-hairline);
}
.lx-stat__icon--emerald { background: var(--lx-accent-50); color: var(--lx-accent); border-color: transparent; }
.lx-stat__icon--amber   { background: var(--lx-umber-50);  color: var(--lx-umber-2); border-color: transparent; }
.lx-stat__icon--indigo  { background: var(--lx-plum-50);   color: var(--lx-plum); border-color: transparent; }
.lx-stat__icon--violet  { background: var(--lx-plum-50);   color: var(--lx-plum); border-color: transparent; }
.lx-stat__label { font-family: var(--lx-sans); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--lx-muted); font-weight: 600; }
.lx-stat__value { font-family: var(--lx-serif); font-size: 30px; font-weight: 500; color: var(--lx-ink); line-height: 1.05; margin-top: 4px; letter-spacing: -0.02em; }
.lx-stat__delta { font-size: 12px; color: var(--lx-muted); margin-top: 2px; }
.lx-stat__delta--up   { color: var(--lx-accent); }
.lx-stat__delta--down { color: var(--lx-claret); }

/* ─── Buttons (unified) ─────────────────────────────── */
.lx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; border-radius: var(--lx-radius-sm);
  font-family: var(--lx-sans); font-weight: 500; font-size: 13.5px;
  letter-spacing: .01em;
  border: 1px solid transparent; cursor: pointer; transition: all .18s ease;
  text-decoration: none; line-height: 1; white-space: nowrap;
}
.lx-btn--sm { padding: 6px 12px; font-size: 12.5px; }
.lx-btn--primary   { background: var(--lx-accent); color: var(--lx-bg); }
.lx-btn--primary:hover { background: var(--lx-accent-2); }
.lx-btn--amber     { background: var(--lx-umber); color: var(--lx-bg); }
.lx-btn--amber:hover { background: var(--lx-umber-2); }
.lx-btn--ghost     { background: var(--lx-surface); color: var(--lx-ink-soft); border-color: var(--lx-hairline-2); }
.lx-btn--ghost:hover { background: var(--lx-surface-2); }
.lx-btn--outline   { background: transparent; color: var(--lx-accent); border-color: var(--lx-accent); }
.lx-btn--outline:hover { background: var(--lx-accent); color: var(--lx-bg); }
.lx-btn--danger    { background: var(--lx-claret); color: var(--lx-bg); }
.lx-btn--icon      { padding: 7px; width: 34px; height: 34px; }

/* ─── Inputs ────────────────────────────────────────── */
.lx-input, .lx-select, .lx-textarea {
  width: 100%; padding: 9px 13px; font: inherit; color: var(--lx-ink);
  background: var(--lx-surface); border: 1px solid var(--lx-hairline-2);
  border-radius: var(--lx-radius-sm); outline: none; transition: border-color .18s ease, box-shadow .18s ease;
  font-family: var(--lx-sans); font-size: 14px;
}
.lx-input:focus, .lx-select:focus, .lx-textarea:focus {
  border-color: var(--lx-accent); box-shadow: 0 0 0 3px rgba(31,61,52,.10);
}
.lx-textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.lx-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--lx-muted) 50%), linear-gradient(135deg, var(--lx-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 38px;
}

/* ─── Chip ──────────────────────────────────────────── */
.lx-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 2px;
  font-size: 11.5px; font-weight: 500; letter-spacing: .03em;
  background: var(--lx-surface-2); color: var(--lx-ink-soft); border: 1px solid var(--lx-hairline);
  text-transform: uppercase;
}
.lx-chip--solid-emerald { background: var(--lx-accent); color: var(--lx-bg); border-color: transparent; }
.lx-chip--emerald { background: var(--lx-accent-50); color: var(--lx-accent); border-color: transparent; }
.lx-chip--amber   { background: var(--lx-umber-50);  color: var(--lx-umber-2); border-color: transparent; }
.lx-chip--indigo  { background: var(--lx-plum-50);   color: var(--lx-plum); border-color: transparent; }
.lx-chip--rose    { background: var(--lx-claret-50); color: var(--lx-claret); border-color: transparent; }
.lx-chip--violet  { background: var(--lx-plum-50);   color: var(--lx-plum); border-color: transparent; }
.lx-chip__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ─── Status dots ───────────────────────────────────── */
.lx-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--lx-muted); }
.lx-dot--pulse { position: relative; }
.lx-dot--pulse::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; background: currentColor; opacity: .35; animation: lx-pulse 1.8s ease-out infinite; }
@keyframes lx-pulse { 0% { transform: scale(.8); opacity: .5 } 100% { transform: scale(2); opacity: 0 } }

/* ─── Key/value "gazette" display ───────────────────── */
.lx-kv { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px 16px; font-size: 14px; }
.lx-kv dt { color: var(--lx-muted); font-weight: 400; }
.lx-kv dd { color: var(--lx-ink); font-weight: 500; margin: 0; }
.lx-kv--lined dt, .lx-kv--lined dd { padding-bottom: 10px; border-bottom: 1px dotted var(--lx-hairline-2); }
.lx-kv--lined > :nth-last-child(-n+2) { border-bottom: none; padding-bottom: 0; }

/* ─── Reference tag (gazette register) ──────────────── */
.lx-ref {
  font-family: var(--lx-mono); font-size: 11.5px; letter-spacing: .04em;
  background: var(--lx-surface-2); color: var(--lx-ink-soft);
  padding: 2px 8px; border-radius: 2px; border: 1px solid var(--lx-hairline);
  text-transform: uppercase;
}

/* ─── Notification bell dropdown ────────────────────── */
.lx-bell { position: relative; }
.lx-bell__btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 3px; background: transparent; color: var(--lx-ink-soft); border: 1px solid transparent; transition: all .15s ease; cursor: pointer; }
.lx-bell__btn:hover { background: var(--lx-surface-2); border-color: var(--lx-hairline); }
.lx-bell__count { position: absolute; top: -4px; right: -4px; background: var(--lx-claret); color: var(--lx-bg); font-size: 10px; font-weight: 600; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center; border: 2px solid var(--lx-surface); }
.lx-bell__panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 380px; max-height: 480px;
  background: var(--lx-surface); border: 1px solid var(--lx-hairline); border-radius: var(--lx-radius);
  box-shadow: var(--lx-shadow-3); overflow: hidden; display: none; z-index: 60;
}
.lx-bell__panel.is-open { display: flex; flex-direction: column; }
.lx-bell__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--lx-hairline); background: var(--lx-surface-2); }
.lx-bell__head .font-semibold { font-family: var(--lx-serif); font-weight: 500; font-size: 15px; }
.lx-bell__list { overflow-y: auto; flex: 1; }
.lx-bell__item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--lx-hairline); text-decoration: none; color: inherit; transition: background .15s ease; }
.lx-bell__item:last-child { border-bottom: none; }
.lx-bell__item:hover { background: var(--lx-surface-2); }
.lx-bell__item--unread { background: var(--lx-accent-50); }
.lx-bell__item--unread:hover { background: #D9E1DD; }
.lx-bell__ic { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 2px; display: grid; place-items: center; border: 1px solid var(--lx-hairline); }
.lx-bell__t { font-weight: 600; font-size: 13.5px; color: var(--lx-ink); }
.lx-bell__b { font-size: 12.5px; color: var(--lx-muted); margin-top: 2px; }
.lx-bell__time { font-size: 11px; color: var(--lx-faint); margin-top: 4px; }
.lx-bell__empty { padding: 36px 18px; text-align: center; color: var(--lx-muted); font-size: 13px; }

/* ─── Message thread ────────────────────────────────── */
.lx-thread { display: flex; flex-direction: column; gap: 12px; }
.lx-msg { display: flex; gap: 10px; max-width: 78%; }
.lx-msg--mine { align-self: flex-end; flex-direction: row-reverse; }
.lx-msg__av {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 2px;
  display: grid; place-items: center; font-weight: 600; font-size: 12.5px;
  background: var(--lx-plum-50); color: var(--lx-plum); border: 1px solid var(--lx-hairline);
}
.lx-msg--mine .lx-msg__av { background: var(--lx-accent); color: var(--lx-bg); border-color: transparent; }
.lx-msg__body { background: var(--lx-surface); border: 1px solid var(--lx-hairline); padding: 10px 14px; border-radius: 3px; font-size: 14px; line-height: 1.55; }
.lx-msg--mine .lx-msg__body { background: var(--lx-accent); color: var(--lx-bg); border-color: var(--lx-accent); }
.lx-msg__meta { font-size: 11px; color: var(--lx-faint); margin-top: 4px; }
.lx-msg--mine .lx-msg__meta { text-align: right; }
.lx-composer { display: flex; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--lx-hairline); }
.lx-composer .lx-textarea { min-height: 46px; }

/* ─── Document tiles ────────────────────────────────── */
.lx-docgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.lx-doc { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--lx-hairline); border-radius: var(--lx-radius); background: var(--lx-surface); transition: all .18s ease; text-decoration: none; color: inherit; }
.lx-doc:hover { border-color: var(--lx-hairline-2); background: var(--lx-surface-2); }
.lx-doc__ic { flex: 0 0 auto; width: 36px; height: 44px; border-radius: 2px; display: grid; place-items: center; background: var(--lx-umber-50); color: var(--lx-umber-2); border: 1px solid var(--lx-hairline); }
.lx-doc__name { font-weight: 600; font-size: 13.5px; color: var(--lx-ink); line-height: 1.3; }
.lx-doc__meta { font-size: 11.5px; color: var(--lx-muted); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ─── Review stars ──────────────────────────────────── */
.lx-stars { display: inline-flex; gap: 2px; color: var(--lx-ochre); }
.lx-stars svg { width: 16px; height: 16px; fill: currentColor; }
.lx-stars--lg svg { width: 22px; height: 22px; }
.lx-stars--off { color: var(--lx-hairline-2); }

/* ─── Watchlist row ─────────────────────────────────── */
.lx-watch { display: flex; align-items: center; gap: 14px; padding: 13px 14px; border: 1px solid var(--lx-hairline); border-radius: var(--lx-radius); background: var(--lx-surface); transition: all .18s ease; }
.lx-watch:hover { border-color: var(--lx-hairline-2); }
.lx-watch__ic { width: 36px; height: 36px; border-radius: 3px; background: var(--lx-plum-50); color: var(--lx-plum); display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--lx-hairline); }
.lx-watch__lbl { font-weight: 600; font-size: 14.5px; color: var(--lx-ink); }
.lx-watch__sum { font-size: 12.5px; color: var(--lx-muted); margin-top: 2px; }

/* ─── Mineral badge (compatible) ────────────────────── */
.mineral-badge { padding: 3px 10px; border-radius: 2px; font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; display: inline-block; }

/* ─── Section header above cards ────────────────────── */
.lx-section-title {
  font-family: var(--lx-sans);
  font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; font-weight: 600;
  color: var(--lx-muted); margin-bottom: 8px;
}

/* ─── Horizontal scroll rail ────────────────────────── */
.lx-rail { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.lx-rail::-webkit-scrollbar { display: none; }

/* ─── Grid utilities ────────────────────────────────── */
.lx-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1024px) { .lx-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .lx-grid-4 { grid-template-columns: 1fr; } }
.lx-grid-3-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 22px; }
@media (max-width: 960px)  { .lx-grid-3-2 { grid-template-columns: 1fr; } }

/* ─── Toast ─────────────────────────────────────────── */
.toast { padding: 11px 16px; border-radius: var(--lx-radius-sm); color: var(--lx-bg); font-weight: 500; margin-bottom: 10px; box-shadow: var(--lx-shadow-3); font-size: 13.5px; font-family: var(--lx-sans); }
.toast-success { background: var(--lx-accent); }
.toast-error   { background: var(--lx-claret); }
.toast-info    { background: var(--lx-teal); }
.toast-warning { background: var(--lx-umber); }

/* ─── Watch-this-parcel button ──────────────────────── */
.lx-watch-cta {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: var(--lx-plum-50); color: var(--lx-plum);
  border: 1px solid transparent; border-radius: 3px; font-weight: 500; font-size: 13px;
  cursor: pointer; transition: all .15s ease; text-decoration: none;
}
.lx-watch-cta:hover { background: var(--lx-plum); color: var(--lx-bg); }
.lx-watch-cta.is-watching { background: var(--lx-accent); color: var(--lx-bg); }

/* ─── Header rule & plate title (gazette vibe) ──────── */
.lx-plate {
  border-top: 3px double var(--lx-ink);
  border-bottom: 1px solid var(--lx-hairline-2);
  padding: 16px 0 14px; margin-bottom: 20px;
}
.lx-plate__eyebrow { font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--lx-muted); font-weight: 600; }
.lx-plate__title { font-family: var(--lx-serif); font-weight: 500; font-size: 28px; color: var(--lx-ink); margin-top: 4px; letter-spacing: -0.02em; }
.lx-plate__sub { font-size: 14px; color: var(--lx-muted); margin-top: 6px; }

/* ─── Legacy compatibility overrides ────────────────── */
.btn-primary { background: var(--lx-accent); color: var(--lx-bg); padding: 9px 18px; border-radius: var(--lx-radius-sm); font-weight: 500; font-size: 13.5px; border: 1px solid transparent; }
.btn-primary:hover { background: var(--lx-accent-2); }
.btn-secondary { background: var(--lx-umber); color: var(--lx-bg); padding: 9px 18px; border-radius: var(--lx-radius-sm); font-weight: 500; }
.btn-secondary:hover { background: var(--lx-umber-2); }
.btn-outline { border: 1px solid var(--lx-accent); color: var(--lx-accent); padding: 9px 18px; border-radius: var(--lx-radius-sm); font-weight: 500; background: transparent; }
.btn-outline:hover { background: var(--lx-accent); color: var(--lx-bg); }

/* Tailwind emerald-N → our accent so existing templates stay coherent.
   Kept minimal — we only retint the shades used most often.         */
.text-emerald-900, .text-emerald-800, .text-emerald-700 { color: var(--lx-accent) !important; }
.bg-emerald-900, .bg-emerald-800 { background-color: var(--lx-accent) !important; }
.bg-emerald-50, .bg-emerald-100 { background-color: var(--lx-accent-50) !important; }
.border-emerald-900 { border-color: var(--lx-accent) !important; }
.hover\:bg-emerald-800:hover { background-color: var(--lx-accent-2) !important; }
.hover\:text-emerald-900:hover { color: var(--lx-accent) !important; }
.text-amber-600 { color: var(--lx-umber-2) !important; }
.bg-amber-50 { background-color: var(--lx-umber-50) !important; }
.text-amber-700 { color: var(--lx-umber-2) !important; }
.bg-amber-100 { background-color: var(--lx-umber-50) !important; }
.text-purple-700 { color: var(--lx-plum) !important; }
.bg-purple-100 { background-color: var(--lx-plum-50) !important; }
.bg-stone-50 { background-color: var(--lx-surface) !important; }
.bg-stone-100 { background-color: var(--lx-bg-2) !important; }
.bg-stone-200 { background-color: var(--lx-hairline) !important; }
.border-stone-100, .border-stone-200 { border-color: var(--lx-hairline) !important; }
.border-stone-300 { border-color: var(--lx-hairline-2) !important; }
.text-stone-500 { color: var(--lx-muted) !important; }
.text-stone-600 { color: var(--lx-ink-soft) !important; }
.text-stone-900 { color: var(--lx-ink) !important; }
.text-stone-400 { color: var(--lx-faint) !important; }
.bg-white { background-color: var(--lx-surface) !important; }
.hover\:bg-stone-50:hover { background-color: var(--lx-surface-2) !important; }
.hover\:bg-stone-100:hover { background-color: var(--lx-bg-2) !important; }
.hover\:bg-stone-200:hover { background-color: var(--lx-hairline) !important; }

/* ─── App shell + sidebar rail (shared by user-side and super-admin) ──
   Pulled out of per-template <style> blocks so child templates that
   override {% block extra_css %} can't accidentally drop the layout. */

.app-shell { display: grid; grid-template-columns: 240px 1fr; gap: 0; min-height: calc(100vh - 64px); }
@media (max-width: 880px) { .app-shell { grid-template-columns: 1fr; } .app-rail { display: none; } }

.app-rail {
    border-right: 1px solid var(--lx-hairline);
    background: var(--lx-bg);
    padding: 28px 16px 28px 24px;
    position: sticky; top: 64px; align-self: start;
    height: calc(100vh - 64px); overflow-y: auto;
}
.app-rail__group { margin-bottom: 22px; }
.app-rail__label {
    font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
    color: var(--lx-muted); font-weight: 600;
    padding: 0 8px 8px; margin-bottom: 2px;
}
.app-rail__link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; margin-bottom: 2px;
    border-radius: 4px; text-decoration: none;
    color: var(--lx-ink-soft); font-size: 14px; font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.app-rail__link:hover { background: var(--lx-surface-2); color: var(--lx-ink); }
.app-rail__link.is-active { background: var(--lx-ink); color: var(--lx-bg); }
.app-rail__link.is-active:hover { background: var(--lx-ink); color: var(--lx-bg); }
.app-rail__link i, .app-rail__link svg { width: 16px; height: 16px; flex: 0 0 auto; }
.app-rail__count {
    margin-left: auto;
    font-family: var(--lx-mono); font-size: 11px;
    color: var(--lx-muted); background: var(--lx-surface-2);
    padding: 1px 7px; border-radius: 999px;
}
.app-rail__link.is-active .app-rail__count { background: var(--lx-bg); color: var(--lx-ink); }

.app-main { padding: 36px 32px 80px; }
@media (max-width: 880px) { .app-main { padding: 24px 16px 60px; } }

/* Super-admin pagehead + global search input. */
.dash-pagehead {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin-bottom: 24px; padding-bottom: 18px;
    border-bottom: 1px solid var(--lx-hairline);
}
.dash-pagehead__eyebrow {
    font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
    color: var(--lx-muted); font-weight: 600;
}
.dash-pagehead__title {
    font-size: 22px; color: var(--lx-ink); font-weight: 600;
    letter-spacing: -0.01em; margin-top: 4px;
}
.dash-pagehead__tools { display: flex; gap: 10px; align-items: center; }
.dash-search { position: relative; }
.dash-search__input {
    width: 280px; padding: 8px 12px 8px 32px;
    background: var(--lx-surface); color: var(--lx-ink);
    border: 1px solid var(--lx-hairline-2); border-radius: var(--lx-radius-sm);
    font: inherit; font-size: 13px; outline: none;
    transition: border-color .15s ease;
}
.dash-search__input:focus { border-color: var(--lx-accent); }
.dash-search__icon {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 14px; height: 14px; color: var(--lx-faint);
}
.dash-search__results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--lx-surface); border: 1px solid var(--lx-hairline);
    border-radius: var(--lx-radius); box-shadow: var(--lx-shadow-3);
    overflow: hidden; z-index: 50;
}
.dash-search__results a {
    display: flex; gap: 10px; padding: 10px 14px;
    color: var(--lx-ink-soft); font-size: 13px; text-decoration: none;
    border-bottom: 1px solid var(--lx-hairline);
}
.dash-search__results a:hover { background: var(--lx-surface-2); }
.dash-search__results a:last-child { border-bottom: none; }
@media (max-width: 720px) { .dash-search__input { width: 180px; } }
