/* ===========================================================================
   Communio Parish Admin Console
   ---------------------------------------------------------------------------
   Every colour in this file is a variable, declared once for light and once
   for dark. That is what lets fourteen existing views inherit a redesign
   without any of them being edited: they already speak in class names
   (.card, .btn, .badge, .table-wrap), and this is the only file that decides
   what those look like.

   Two rules worth keeping if you extend it:

   1. NEVER write a raw hex in a rule. A hardcoded light-mode colour has no
      dark counterpart, so it survives review and then the text disappears on
      a dark card. The exceptions are marked and are all colours sitting on
      the dark rail, which is dark in BOTH themes.

   2. Brand green is a FILL colour, not a foreground one. --primary is a few
      points off a dark card, so green text or a small green control vanishes
      there. Use --primary-lift for anything small or textual; keep --primary
      for large fills carrying white text. (Same trap the mobile app hit —
      see PROJECT-HANDOFF §4.)
   =========================================================================== */

/* Tokens read off ZeroTier Central: a light rail rather than a dark one, a
   #f8f9fa canvas, hairline borders, 8px corners and controls around 48px
   tall at 15px. Work Sans is their typeface; it degrades to the system stack
   when the font cannot be fetched. */
:root {
  /* Parish brand — the green the mobile app is built on. */
  --primary: #0d5c46;
  --primary-dark: #08402f;
  --primary-lift: #0d5c46;        /* lifted in dark, see [data-theme="dark"] */
  --primary-wash: #e9f2ef;

  /* Gold, from the Communio mark itself. Central uses amber for its primary
     call to action and a soft tint for the active nav; here the gold plays
     the same part, which happens to be the logo's own second colour. */
  --accent: #d98416;
  --accent-strong: #f0a02a;
  --accent-soft: #fdf3e3;

  --ink: #333333;
  --ink-strong: #1a1d21;
  --subtext: #6b7280;
  --faint: #9aa3ad;

  --bg: #f8f9fa;
  --card: #ffffff;
  --surface: #f4f5f7;
  --border: #e6e8eb;
  --border-strong: #c4c4c4;

  --danger: #c62b2b;
  --danger-bg: #fdeaea;
  --success: #12805a;
  --success-bg: #e3f6ec;
  --pending: #a96608;
  --pending-bg: #fdf1de;
  --info: #1f5f9e;
  --info-bg: #e8f1fa;

  /* The rail. Light in light mode — Central's is white with a hairline, and
     a dark slab beside a white canvas is the thing that made this console
     look like a different product from the one it is modelled on. */
  --rail: #ffffff;
  --rail-deep: #ffffff;
  --rail-ink: #333333;
  --rail-muted: #6b7280;
  --rail-line: #e6e8eb;
  --rail-active-bg: var(--primary-wash);
  --rail-active-ink: var(--primary);
  --rail-hover: #f4f5f7;

  --radius: 8px;
  --radius-lg: 12px;
  /* Central is nearly flat — structure comes from hairlines, not shadow. */
  --shadow-sm: none;
  --shadow-md: 0 2px 8px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.14);

  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  --sans: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

[data-theme="dark"] {
  /* In dark, --surface is LIGHTER than --card — the reverse of light mode.
     Anything built as card-on-surface inverts and reads as a hole if this is
     forgotten. */
  --primary-lift: #16a67c;
  --primary-wash: #10251f;

  --accent: #f0a94a;
  --accent-strong: #f5b95f;
  --accent-soft: #2a2114;

  --ink: #e6edf3;
  --ink-strong: #ffffff;
  --subtext: #96a3b1;
  --faint: #6a7885;

  --bg: #0b0f14;
  --card: #141a21;
  --surface: #1b232c;
  --border: #242d38;
  --border-strong: #33404e;

  --danger: #f0736f;
  --danger-bg: #2b1618;
  --success: #45c79a;
  --success-bg: #10251f;
  --pending: #e0a44a;
  --pending-bg: #2a2114;
  --info: #6cb0ec;
  --info-bg: #14202c;

  /* The rail follows the theme now rather than staying dark in both. Its
     tokens are aliases so every rule written against them keeps working. */
  --rail: #10161d;
  --rail-deep: #0d1218;
  --rail-ink: #e6edf3;
  --rail-muted: #96a3b1;
  --rail-line: #242d38;
  --rail-active-bg: #10251f;
  --rail-active-ink: #16a67c;
  --rail-hover: rgba(255, 255, 255, 0.05);

  --shadow-sm: none;
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.6);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

/* data-theme is set on <html> by app.js, so :root and [data-theme] are the
   same element. color-scheme is what makes native controls (scrollbars, date
   pickers, the select dropdown) follow the theme — without it a dark console
   opens a blinding white calendar. */
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }

::selection { background: var(--accent-soft); color: var(--ink-strong); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Scrollbars, so a long table doesn't cut a bright gutter through a dark page. */
* { scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }

/* ---------- Layout ---------- */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: 258px;
  background: var(--rail);
  color: var(--rail-ink);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--rail-line);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-top {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 10px 12px 16px;
  border-bottom: 1px solid var(--rail-line);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.sidebar-toggle {
  width: 28px; height: 28px;
  flex-shrink: 0;
  display: grid; place-items: center;
  border: 1px solid var(--rail-line);
  background: var(--card);
  color: var(--rail-muted);
  border-radius: 7px;
  font-size: 13px;
  line-height: 1;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.sidebar-toggle:hover { background: var(--rail-hover); color: var(--rail-ink); }

/* ---------- Collapsed rail ----------
   Icons only. The labels are hidden rather than removed so the DOM (and the
   tooltips on each link) stays identical — collapsing is a display decision,
   not a different navigation. */
#app.sidebar-collapsed .sidebar { width: 64px; }
/* Stacked, because a 64px rail cannot hold the mark and the toggle side by
   side — and the mark is the thing that stays. A collapsed rail with no logo
   is an anonymous strip of icons. */
#app.sidebar-collapsed .sidebar-top {
  flex-direction: column;
  gap: 10px;
  padding: 12px 8px;
}
#app.sidebar-collapsed .sidebar-brand { justify-content: center; flex: none; }
#app.sidebar-collapsed .sidebar-brand .wordmark { display: none; }
/* Only one mark fits, and it is the SAINT — that is this parish's own face.
   The Communio plate is identical in every parish, so it says nothing about
   where you are. `has-patron` is set by brand.js only once a saint photo has
   actually loaded, so a parish without one keeps the plate instead of
   collapsing to an empty rail. */
#app.sidebar-collapsed .sidebar-brand .logo-row.has-patron .logo-plate { display: none; }
#app.sidebar-collapsed .sidebar-brand .logo-patron {
  /* The overlap offset is inline and only makes sense beside the plate. */
  margin-left: 0 !important;
}
#app.sidebar-collapsed .nav-group { display: none; }
#app.sidebar-collapsed .nav-label { display: none; }
#app.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 10px 0;
  margin: 1px 8px;
}
#app.sidebar-collapsed .nav-icon { width: auto; font-size: 15px; }
#app.sidebar-collapsed .sidebar-footer { padding: 12px 8px; }
#app.sidebar-collapsed .who-text { display: none; }
#app.sidebar-collapsed .who { justify-content: center; margin-bottom: 8px; }
#app.sidebar-collapsed .signout-label { display: none; }
#app.sidebar-collapsed .signout-icon { display: inline; }

/* Expanded: the word carries it, so the glyph would only be noise. */
.signout-icon { display: none; }
.sidebar-footer .signout-btn { display: flex; align-items: center; justify-content: center; gap: 7px; }

/* The rail animates, the content follows. Without a transition on width the
   whole page jumps, which reads as a reload rather than a fold. */
.sidebar { transition: width 0.16s var(--ease); }
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- Brand lockup ----------
   The mark and the patron saint photo overlap so they read as ONE mark
   rather than two images side by side — the same lockup the mobile app
   uses, so the two surfaces are recognisably one product. */
.logo-row { display: flex; align-items: flex-end; flex-shrink: 0; }
.logo-plate {
  /* The Communio plate keeps its own green in every season — it is the
     product's mark, as on the app's icon; the season colours the rest. */
  background: #0d5c46;
  display: grid;
  place-items: center;
  border: 2px solid #08402f;
  box-shadow: 0 3px 8px rgba(7, 51, 39, 0.25);
  flex-shrink: 0;
}
.logo-plate img { object-fit: contain; display: block; }
.logo-patron {
  border: 3px solid #ffffff;          /* the frame is white in both themes */
  background: #f1f5f9;
  object-fit: cover;
  flex-shrink: 0;
}

.wordmark { display: flex; flex-direction: column; min-width: 0; }
.wordmark-name {
  font-weight: 800;
  letter-spacing: 0.3px;
  line-height: 1.05;
  white-space: nowrap;
}
/* Low opacity rather than a fixed grey, so the mark works on the dark rail
   and on a light card without a second colour rule. */
.wordmark-sub { font-weight: 700; opacity: 0.55; line-height: 1; white-space: nowrap; }
.sidebar .wordmark { color: var(--rail-ink); }

.sidebar-nav { flex: 1; padding: 8px 0 18px; overflow-y: auto; }
.nav-icon {
  width: 18px;
  flex-shrink: 0;
  text-align: center;
  font-size: 13px;
  opacity: 0.85;
  filter: grayscale(0.35);
}
.sidebar-link.active .nav-icon { opacity: 1; filter: none; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A group heading, for consoles with more than a handful of sections. */
.nav-group {
  padding: 16px 19px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}
.nav-group:first-child { padding-top: 6px; }

/* Central's active item is a full-width rounded pill, not a left-edge marker.
   The pill reads at a glance in a rail this long; a 3px stripe does not. */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 1px 8px;
  padding: 9px 11px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--rail-muted);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.14s var(--ease), background 0.14s var(--ease);
}
.sidebar-link:hover { background: var(--rail-hover); color: var(--rail-ink); }
.sidebar-link.active {
  background: var(--rail-active-bg);
  color: var(--rail-active-ink);
  font-weight: 600;
}

.sidebar-footer {
  padding: 13px 16px;
  border-top: 1px solid var(--rail-line);
  font-size: 12px;
  background: var(--rail-deep);
}
.sidebar-footer .who {
  color: var(--rail-ink);
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.sidebar-footer .who .avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;                         /* on a green fill in both themes */
  display: grid; place-items: center;
  font-size: 11px; font-weight: 800;
}
.sidebar-footer .who .who-text { min-width: 0; line-height: 1.25; }
.sidebar-footer .who .who-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .who .who-role { color: var(--rail-muted); font-size: 11px; }
/* Central puts Log Out in the rail as an ordinary nav row, not a filled
   button — it is a destination, not a call to action. */
.sidebar-footer button {
  width: 100%;
  background: transparent;
  color: var(--rail-muted);
  border: 1px solid transparent;
  padding: 9px 11px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.sidebar-footer button:hover { background: var(--rail-hover); color: var(--danger); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 58px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 14.5px; margin: 0; font-weight: 500; color: var(--subtext); }
.topbar .sub { font-size: 12px; color: var(--subtext); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
.crumb {
  font-size: 14px;
  color: var(--subtext);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crumb.current { color: var(--ink-strong); font-weight: 600; }
.crumb-sep { color: var(--faint); font-size: 14px; flex-shrink: 0; }

/* ---------- Page heading ---------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

/* ---------- Page heading (tokens) ----------
   Central leads a page with a large bold title and a quiet line under it;
   the topbar carries the breadcrumb. */
.page-title { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink-strong); margin: 0; }
.page-sub { font-size: 14.5px; color: var(--subtext); margin-top: 4px; }

.parish-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--subtext);
  background: var(--surface);
}
.parish-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-bg);
}
.parish-chip .slug { font-family: var(--mono); color: var(--ink); font-size: 11.5px; }
/* The parish name can be long ("St. John the Baptist Catholic Church"), so the
   chip caps it and the tooltip carries the whole thing plus the slug. */
.parish-chip-name {
  color: var(--ink);
  font-weight: 600;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 860px) { .parish-chip-name { max-width: 120px; } }

.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--subtext);
  border-radius: 8px;
  font-size: 15px;
  line-height: 1;
  transition: all 0.14s var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: var(--border-strong); background: var(--card); }

.content { padding: 26px 28px 70px; flex: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}
.card + .card { margin-top: 14px; }
.card-row { display: flex; gap: 14px; flex-wrap: wrap; }
.card-row > .card { flex: 1; min-width: 190px; }

/* Stat tiles read as a row of instruments, so the number leads and the label
   sits under it in the quietest weight on the page. */
.stat-number {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-label {
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 2px;
  font-weight: 600;
}

/* ---------- Dashboard grid ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.dash-card {
  background: var(--card, var(--surface));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.dash-span-wide { grid-column: span 2; }
.dash-span-full { grid-column: 1 / -1; }
@media (max-width: 700px) {
  .dash-span-wide { grid-column: span 1; }
}

/* Stat tile */
.dash-stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--subtext);
  margin-bottom: 8px;
}
.dash-stat-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.dash-stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-strong);
  letter-spacing: -0.02em;
}
.dash-stat-delta {
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
}

/* Chart cards */
.dash-chart-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.dash-chart-sub {
  font-size: 12px;
  color: var(--subtext);
  margin-bottom: 14px;
}

/* Legend */
.dash-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.dash-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--subtext);
}
.dash-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Horizontal stacked bar */
.dash-hbar {
  display: flex;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  margin-top: 10px;
  gap: 2px;
}
.dash-hbar-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  min-width: 0;
  transition: opacity 0.15s;
}
.dash-hbar-seg:hover { opacity: 0.85; }

/* Meter / progress */
.dash-meter {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
}
.dash-meter-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ---------- Reactive dashboard: live indicator + flash ---------- */
.dash-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--subtext);
}
.dash-live-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.dash-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0ca30c;
  display: inline-block;
  animation: dash-breathe 2.4s ease-in-out infinite;
}
.dash-pulse-flash { animation: dash-ping 0.6s ease-out; }
@keyframes dash-breathe {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
@keyframes dash-ping {
  0% { box-shadow: 0 0 0 0 rgba(12,163,12,0.6); }
  100% { box-shadow: 0 0 0 8px rgba(12,163,12,0); }
}
.dash-updated { font-variant-numeric: tabular-nums; }

/* Card change flash */
.dash-card {
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.dash-card-flash {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 1px var(--accent) inset;
}

/* Clickable cards */
.dash-clickable {
  cursor: pointer;
  position: relative;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}
.dash-clickable:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 0 0 1px var(--accent, #2a78d6) inset;
}
.dash-clickable:active {
  transform: translateY(0);
}
.dash-card-arrow {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 14px;
  color: var(--subtext, #898781);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.dash-clickable:hover .dash-card-arrow {
  opacity: 1;
  transform: translateX(2px);
}

/* Stacked-bar segment transition */
.dash-hbar-seg {
  transition: width 0.4s ease;
}
/* The grey rounded square Central puts beside a statistic. */
.stat-icon {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 19px;
}

/* An interactive tile: lifts and picks up the accent on hover, so a grid of
   them reads as clickable without any of them shouting. */
.tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.tile.selected { border-color: var(--primary-lift); box-shadow: 0 0 0 1px var(--primary-lift) inset; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th .sort-caret { color: var(--accent); margin-left: 4px; }
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 14px;
}
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background 0.1s var(--ease); }
tbody tr:hover td { background: var(--surface); }
tbody tr:last-child td { border-bottom: none; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  width: 100%;
}
/* A capped table gets its own scroll box; an uncapped one flows with the
   page. Opt-in, because nesting a vertical scrollbar inside a page that also
   scrolls makes a short list feel trapped — the Database browser wants it
   (hundreds of rows, sticky headers), a twelve-row register does not. */
.table-wrap.capped { overflow-y: auto; max-height: 68vh; }
/* A .card already draws the frame, so a table inside one must not draw a
   second. */
.card > .table-wrap { border: none; border-radius: 0; }

.row-link { cursor: pointer; color: var(--primary-lift); font-weight: 600; }
.row-link:hover { text-decoration: underline; }

.cell-null { color: var(--faint); font-style: italic; font-size: 12px; }
.cell-mono { font-family: var(--mono); font-size: 12px; color: var(--subtext); }
.cell-clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--subtext);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}
.field input, .field select, .field textarea,
input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  transition: border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus,
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-lift);
  box-shadow: 0 0 0 3px var(--primary-wash);
}
.field input[disabled], .field select[disabled] { opacity: 0.55; cursor: not-allowed; }
.field textarea { resize: vertical; min-height: 70px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 170px; }
.hint { font-size: 11.5px; color: var(--faint); margin-top: 4px; line-height: 1.45; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--primary-lift); width: 15px; height: 15px; cursor: pointer; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.14s var(--ease), transform 0.1s var(--ease), border-color 0.14s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }   /* white on a green fill */
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #16110a; }  /* dark ink on amber */
.btn-accent:hover { filter: brightness(1.07); }
.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--card); border-color: var(--faint); }
.btn-ghost { background: transparent; color: var(--subtext); border-color: transparent; }
.btn-ghost:hover { background: var(--surface); color: var(--ink); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { filter: brightness(0.96); }
.btn-success { background: var(--success-bg); color: var(--success); }
.btn-success:hover { filter: brightness(0.96); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar .search { flex: 1; max-width: 360px; }
.search input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14.5px;
  background: var(--card);
  color: var(--ink);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-pending { background: var(--pending-bg); color: var(--pending); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-neutral { background: var(--surface); color: var(--subtext); border: 1px solid var(--border); }
.badge-key {
  background: var(--surface);
  color: var(--subtext);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 5px;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--subtext);
  font-size: 15px;
  font-weight: 500;
  transition: color 0.14s var(--ease), background 0.14s var(--ease);
}
.tab-btn:hover { color: var(--ink); background: var(--surface); }
.tab-btn.active { color: var(--primary-lift); background: var(--primary-wash); font-weight: 600; }

/* Pill variant, where tabs are filters rather than sections. */
.tabs-pill { border-bottom: none; gap: 6px; }
.tabs-pill .tab-btn {
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 0;
  padding: 6px 13px;
  font-size: 12.5px;
}
.tabs-pill .tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Steps (the import wizard) ---------- */
.steps { display: flex; align-items: center; gap: 0; margin-bottom: 22px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 700; color: var(--faint); }
.step + .step::before {
  content: '';
  width: 34px; height: 1px;
  background: var(--border-strong);
  margin: 0 12px;
}
.step .step-num {
  width: 23px; height: 23px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-size: 11px;
  color: var(--subtext);
  transition: all 0.18s var(--ease);
}
.step.active { color: var(--ink-strong); }
.step.active .step-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.done { color: var(--subtext); }
.step.done .step-num { background: var(--success-bg); border-color: var(--success); color: var(--success); }

/* ---------- Drop zone ---------- */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}
.dropzone:hover { border-color: var(--primary-lift); }
.dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-icon { font-size: 30px; line-height: 1; margin-bottom: 10px; }
.dropzone .dz-title { font-weight: 700; font-size: 14.5px; margin-bottom: 4px; color: var(--ink-strong); }
.dropzone .dz-sub { font-size: 12.5px; color: var(--subtext); }

/* ---------- Progress ---------- */
.progress { height: 6px; background: var(--surface); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: var(--primary-lift); transition: width 0.25s var(--ease); }
.progress.accent > span { background: var(--accent); }

/* ---------- Callouts ---------- */
.callout {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--subtext);
}
.callout strong { color: var(--ink); }
.callout-warn   { background: var(--pending-bg); border-color: transparent; color: var(--pending); }
.callout-danger { background: var(--danger-bg);  border-color: transparent; color: var(--danger); }
.callout-info   { background: var(--info-bg);    border-color: transparent; color: var(--info); }
.callout-success{ background: var(--success-bg); border-color: transparent; color: var(--success); }

/* ---------- Modal ---------- */
/* No backdrop-filter here on purpose. It creates a compositing layer, and
   Chromium mis-positions or fails to paint native control popups anchored
   inside one — which is a decorative blur costing a working form control.
   The dim alone reads as "behind a dialog" perfectly well. */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(6, 10, 15, 0.62);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  animation: fade-in 0.14s var(--ease);
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.16s var(--ease);
}
.modal.modal-wide { max-width: 700px; }
.modal.modal-xl { max-width: 980px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.modal-header h2 { font-size: 16.5px; margin: 0; letter-spacing: -0.01em; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--subtext); line-height: 1; padding: 4px; border-radius: 6px; }
.modal-close:hover { color: var(--ink); background: var(--surface); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }

/* ---------- Empty / loading ---------- */
.empty-state { text-align: center; padding: 44px 20px; color: var(--subtext); font-size: 13.5px; }
.empty-state .es-icon { font-size: 26px; margin-bottom: 10px; opacity: 0.7; }
.loading { text-align: center; padding: 40px 20px; color: var(--subtext); font-size: 13.5px; }
.error-box { text-align: center; padding: 30px 20px; color: var(--subtext); }
.error-box button { margin-top: 12px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
  border-radius: 6px;
  height: 12px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 480px at 15% -10%, var(--primary-wash), transparent 65%),
    radial-gradient(700px 420px at 95% 110%, var(--accent-soft), transparent 60%),
    var(--bg);
  padding: 24px;
}
.login-shell { width: 100%; max-width: 400px; }
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  color: var(--ink);
}
.login-parish {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-lift);
  text-align: center;
  min-height: 18px;
  transition: opacity 0.2s var(--ease);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px 24px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 19px; text-align: center; margin: 0 0 4px; letter-spacing: -0.02em; }
.login-card .subtitle {
  text-align: center; color: var(--subtext);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 20px;
}
.login-error { color: var(--danger); font-size: 12.5px; margin-top: 10px; text-align: center; }
.login-foot {
  margin-top: 18px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--faint);
  text-align: center;
}
.login-settings-link {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 14px; font-size: 11.5px; color: var(--faint); cursor: pointer;
}
.login-settings-link:hover { color: var(--primary-lift); }
.dot-idle {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--faint); flex-shrink: 0;
}
.btn-block { width: 100%; justify-content: center; margin-top: 6px; }

/* ---------- Toast ---------- */
#toast-host {
  position: fixed; bottom: 22px; right: 22px; z-index: 200;
  opacity: 0; transform: translateY(10px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  pointer-events: none;
}
#toast-host.visible { opacity: 1; transform: translateY(0); }
.toast {
  background: var(--rail);
  color: var(--rail-ink);
  padding: 11px 17px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--rail-line);
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--faint);
}
.toast-error { border-left-color: var(--danger); }
.toast-success { border-left-color: var(--success); }

/* ---------- Calendar ---------- */
.cal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.cal-title { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px;
}
.cal-weekdays > div {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--subtext); text-align: center; padding-bottom: 4px;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-day {
  min-height: 88px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px;
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease), transform 0.1s var(--ease);
  overflow: hidden;
}
.cal-day:hover { border-color: var(--primary-lift); background: var(--surface); }
.cal-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-day-empty { border: none; background: none; cursor: default; min-height: 0; }
.cal-day-empty:hover { background: none; }
/* Sunday reads differently because in a parish it IS different. */
.cal-day.sunday { background: var(--primary-wash); }
.cal-day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-day-num {
  font-size: 12px; font-weight: 700; color: var(--subtext);
  margin-bottom: 4px; font-variant-numeric: tabular-nums;
}
.cal-day.today .cal-day-num { color: var(--accent); }
.cal-entries { display: flex; flex-direction: column; gap: 3px; }
.cal-entry {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--surface);
  color: var(--subtext);
  border-left: 2px solid var(--border-strong);
}
/* Inherited from the weekly timetable — deliberately the quietest, so a date
   carrying something of its own stands out against the routine. */
.cal-entry-weekly { background: var(--surface); color: var(--subtext); border-left-color: var(--faint); }
.cal-entry-override { background: var(--primary-wash); color: var(--primary-lift); border-left-color: var(--primary-lift); }
.cal-entry-danger { background: var(--danger-bg); color: var(--danger); border-left-color: var(--danger); }
.cal-entry-info { background: var(--info-bg); color: var(--info); border-left-color: var(--info); }
.cal-entry-pending { background: var(--pending-bg); color: var(--pending); border-left-color: var(--pending); }
.cal-entry-offertory { background: var(--info-bg); color: var(--info); border-left-color: var(--info); }
.cal-entry-bidding { background: var(--success-bg, #e9f7ef); color: var(--success, #1a8a4a); border-left-color: var(--success, #1a8a4a); }
.cal-more { font-size: 10px; color: var(--faint); padding-left: 5px; }
.cal-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.cal-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--subtext); }
.cal-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ---------- Calendar selection mode ---------- */
.cal-selecting .cal-day { cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.cal-selecting .cal-day-disabled { opacity: 0.35; cursor: not-allowed; }
.cal-selected {
  border-color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 15%, transparent) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent) inset;
}
.cal-check { color: var(--accent); font-weight: 700; font-size: 11px; }
.cal-sel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  margin-top: 8px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--accent);
  gap: 12px;
}

@media (max-width: 700px) {
  .cal-day { min-height: 64px; padding: 4px; }
  .cal-entry { font-size: 9.5px; }
}

/* ---------- Weekly strip ---------- */
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.week-day {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 6px;
  text-align: center;
  background: var(--surface);
}
.week-day.sunday { background: var(--primary-wash); border-color: var(--primary-lift); }
.week-day-name {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--subtext); margin-bottom: 6px;
}
.week-time { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.week-none { font-size: 12px; color: var(--faint); }

.day-mass {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

/* ---------- Person picker ---------- */
.pp-wrap { position: relative; }
.pp-wrap input.pp-has-tag { padding-right: 96px; }
.pp-tag {
  position: absolute;
  right: 9px; top: 50%; transform: translateY(-50%);
  font-size: 10.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 5px;
  pointer-events: none;
  display: none;
}
.pp-tag-member { background: var(--success-bg); color: var(--success); }
.pp-tag-outside { background: var(--pending-bg); color: var(--pending); }

.pp-list {
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  max-height: 260px;
  overflow-y: auto;
  z-index: 30;
  display: none;
  padding: 4px;
}
.pp-row {
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  line-height: 1.35;
}
.pp-row:hover, .pp-row.active { background: var(--surface); }
.pp-row-name { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.pp-row-sub { font-size: 11.5px; color: var(--subtext); margin-top: 1px; }
/* The off-register option is set apart so it reads as a deliberate exception
   rather than one more name in the list. */
.pp-row-outside { border-top: 1px solid var(--border); border-radius: 0 0 7px 7px; margin-top: 4px; padding-top: 9px; }
.pp-row-outside .pp-row-name { color: var(--pending); }
.pp-empty { padding: 10px; font-size: 12.5px; color: var(--subtext); }

/* ---------- Clergy picker (dropdown + Other) ---------- */
.cp-wrap select {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23898781' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.cp-wrap select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}
.cp-other-wrap input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
}
.cp-other-wrap input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* ---------- Settings ---------- */
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: none; }
.kv-label {
  font-size: 11px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--subtext); flex-shrink: 0;
}
.kv-value { font-size: 13.5px; text-align: right; min-width: 0; word-break: break-word; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 24px; }

.avatar-lg {
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;                        /* on a green fill in both themes */
  display: grid; place-items: center;
  font-size: 14px; font-weight: 800;
}

.theme-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.theme-choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease);
}
.theme-choice:hover { border-color: var(--faint); }
.theme-choice.active { border-color: var(--primary-lift); background: var(--primary-wash); }
.theme-choice-label { font-size: 13px; font-weight: 700; color: var(--ink); }
.theme-choice-hint { font-size: 11px; color: var(--subtext); line-height: 1.4; }
.theme-swatch {
  width: 100%; height: 26px; border-radius: 6px; margin-bottom: 4px;
  border: 1px solid var(--border-strong);
}
/* Literal colours: these swatches must PREVIEW a theme, so they cannot follow
   the theme currently applied — that is the one thing they are not allowed to
   do. The split swatch is the system option. */
.theme-swatch-light { background: linear-gradient(135deg, #ffffff 0%, #f2f5f7 100%); }
.theme-swatch-dark { background: linear-gradient(135deg, #141a21 0%, #0b0f14 100%); }
.theme-swatch-system { background: linear-gradient(135deg, #ffffff 0% 50%, #141a21 50% 100%); }

.conn-status { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; }
.dot-good, .dot-bad, .dot-idle { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-good { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.dot-bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.dot-idle { background: var(--faint); }

/* ---------- Utilities ---------- */
.section-heading { font-size: 19px; font-weight: 700; margin: 0 0 10px; letter-spacing: -0.01em; color: var(--ink-strong); }
.muted { color: var(--subtext); }
.faint { color: var(--faint); }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.scroll-y { overflow-y: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: column; }
  .sidebar-nav { display: flex; overflow-x: auto; padding: 6px 8px; }
  .nav-group { display: none; }
  .sidebar-link { border-left: none; border-bottom: 3px solid transparent; padding: 10px 14px; white-space: nowrap; }
  .sidebar-link.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .content { padding: 18px 14px 50px; }
  .topbar { padding: 0 14px; }
}

/* ---------- Custom dropdowns ----------
   Replaces the native <select> popup, which the browser draws itself and
   which therefore cannot be relied on inside a backdrop-filtered modal or in
   an embedded webview. The native select stays in the DOM (visually hidden)
   as the source of truth; see enhanceSelects() in js/helpers.js. */
.dd-wrap { position: relative; width: 100%; }

/* Hidden but still focusable-by-script and still the value holder. Not
   display:none — that would take it out of form submission and out of
   getComputedStyle checks some views make. */
select.dd-native {
  position: absolute; opacity: 0; pointer-events: none;
  width: 100%; height: 100%; left: 0; top: 0; margin: 0; z-index: -1;
}

.dd-trigger {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 15px; font-family: inherit; text-align: left;
  color: var(--ink); background: var(--card);
  transition: border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}
.dd-trigger:hover:not(:disabled) { border-color: var(--primary-lift); }
.dd-trigger:focus-visible,
.dd-trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--primary-lift);
  box-shadow: 0 0 0 3px var(--primary-wash);
}
.dd-trigger:disabled { opacity: 0.55; cursor: not-allowed; }
.dd-trigger.dd-placeholder .dd-label { color: var(--subtext); }
.dd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-caret {
  flex-shrink: 0; width: 0; height: 0;
  border-left: 4.5px solid transparent; border-right: 4.5px solid transparent;
  border-top: 5.5px solid var(--subtext);
  transition: transform 0.14s var(--ease);
}
.dd-trigger[aria-expanded="true"] .dd-caret { transform: rotate(180deg); }

.dd-menu {
  display: none;
  /* Fixed to the viewport and parented to <body> while open, so no modal,
     card or scroll container can clip it. Left/top/max-height are set by
     place() in helpers.js. Above .modal-backdrop (z 100). */
  position: fixed; left: 0; top: 0;
  z-index: 1000;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  transform-origin: top center;
  animation: dd-in 0.12s var(--ease);
}
.dd-menu.open { display: block; }
.dd-menu.dd-up { transform-origin: bottom center; }
@keyframes dd-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

.dd-option {
  padding: 9px 11px; border-radius: 7px;
  font-size: 14.5px; color: var(--ink); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dd-option:hover { background: var(--surface); }
.dd-group { padding: 10px 12px 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); cursor: default; }
.dd-group ~ .dd-option { padding-left: 20px; }
.dd-option.selected { background: var(--primary-wash); color: var(--primary-lift); font-weight: 650; }
.dd-option.disabled { opacity: 0.45; cursor: not-allowed; }

/* Compact variant: inline selects in table rows and segment builders set
   their own font-size/padding, so the trigger has to follow them down. */
.dd-wrap.dd-sm .dd-trigger { padding: 5px 9px; font-size: 12.5px; border-radius: 6px; }
.dd-wrap.dd-sm .dd-option { padding: 7px 9px; font-size: 12.5px; }
