/* ============================================================================
   Firmify.ai · Design System (app.css)
   Shared tokens + app-shell layout + reusable components.
   "Accounting-grade": calm, professional, trust over flash.

   PREMIUM POLISH PASS:
   - Dual theming via :root (light) + :root[data-theme="dark"] (dark) token
     overrides. EVERY component references tokens, so the whole app re-themes
     automatically. Existing token + class names are PRESERVED (never removed
     or renamed), only added to and enhanced.
   - Glassmorphism on sidebar/topbar, layered card depth + lit edge, ambient
     floating gradient blobs, tasteful micro-interactions, theme-aware styled
     scrollbars. All non-essential motion is gated behind prefers-reduced-motion.
   ========================================================================== */

/* ---- Design tokens (LIGHT, default) ---- */
:root {
  /* Brand */
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;

  /* Brand ramp: the Firmify.ai mark's three stops (violet → indigo → teal).
     --brand-gradient-mark is the logo verbatim (decorative: text, rules, bars).
     --brand-gradient is the same ramp stepped one shade deeper so white text
     on a filled button clears WCAG AA (>=4.5:1) at EVERY point along it,
     the literal logo stops fail that at the cyan end. */
  --brand-g1: #7a45f0;
  --brand-g2: #4f6ad8;
  --brand-g3: #0e8296;
  --brand-gradient: linear-gradient(115deg, var(--brand-g1) 0%, var(--brand-g2) 52%, var(--brand-g3) 100%);
  --brand-gradient-mark: linear-gradient(115deg, #7f4ff5 0%, #5e7de7 48%, #1fd3d6 100%);

  /* Calm indigo accent (the ramp's mid stop) for soft badges/pills that used
     to be flat violet. */
  --accent: #3a52c4;
  --accent-soft: #e8edfd;

  /* Neutrals */
  --ink: #0f172a;
  --muted: #475569;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --surface: #ffffff;

  /* Semantic */
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --info: #0891b2;

  /* Semantic soft backgrounds (for pills/badges) */
  --ok-50: #ecfdf5;
  --warn-50: #fffbeb;
  --danger-50: #fef2f2;
  --info-50: #ecfeff;

  /* Space scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;

  /* Radius */
  --r: 8px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* Elevation */
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 4px 16px rgba(15, 23, 42, .12);

  /* Layout */
  --sidebar-w: 244px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;

  /* ---- NEW: premium-polish tokens (additive) ---- */
  /* Secondary elevated surface (cards-on-surface, hover sheets, rails) */
  --surface-2: #f1f5f9;
  /* Translucent glass fills + borders for floating chrome */
  --glass-bg: rgba(255, 255, 255, .72);
  --glass-border: rgba(15, 23, 42, .08);
  --glass-blur: blur(12px) saturate(140%);
  /* Lit top edge (premium inner highlight on cards in dark mode) */
  --edge-hi: rgba(255, 255, 255, 0);
  /* Layered soft card shadow */
  --shadow-card: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 12px rgba(15, 23, 42, .05);
  --shadow-card-hover: 0 2px 4px rgba(15, 23, 42, .06), 0 12px 28px rgba(15, 23, 42, .10);
  /* Brand glow (focus rings, primary button hover) */
  --brand-glow: rgba(37, 99, 235, .28);
  --brand-ring: rgba(37, 99, 235, .18);
  /* Ambient background blobs */
  --blob-1: rgba(37, 99, 235, .10);
  --blob-2: rgba(8, 145, 178, .08);
  --blob-3: rgba(124, 58, 237, .06);
  --blob-opacity: .55;
  /* Scrollbar */
  --scroll-thumb: rgba(100, 116, 139, .35);
  --scroll-thumb-hover: rgba(100, 116, 139, .55);
  /* Motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ---- Design tokens (DARK) · Firmify.ai brand: near-black navy ground ----
   Redefines color tokens only; geometry/space tokens inherit from :root. */
:root[data-theme="dark"] {
  /* Brand (purple + cyan, matching the Firmify.ai mark) */
  --brand: #8b5cf6;
  --brand-dark: #7c3aed;
  --brand-50: rgba(139, 92, 246, .14);
  --brand-100: rgba(139, 92, 246, .22);
  /* Ramp tokens are theme-independent (white text sits on them in both
     themes); only the soft accent needs a dark-ground variant. */
  --accent: #9db1ff;
  --accent-soft: rgba(94, 125, 231, .20);

  /* Neutrals */
  --ink: #e8edf5;
  --muted: #9aa7bd;
  --faint: #64748b;
  --line: rgba(255, 255, 255, .08);
  --bg: #0b1326;
  --surface: #0f172a;

  /* Semantic (emerald success, purple/cyan brand family) */
  --ok: #10b981;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #06b6d4;

  /* Semantic soft backgrounds (translucent tints over dark surface) */
  --ok-50: rgba(16, 185, 129, .14);
  --warn-50: rgba(251, 191, 36, .14);
  --danger-50: rgba(248, 113, 113, .14);
  --info-50: rgba(6, 182, 212, .14);

  /* Elevation (deeper, softer on dark) */
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, .55);

  /* Premium-polish tokens (dark) */
  --surface-2: #16203a;
  --glass-bg: rgba(11, 19, 38, .70);
  --glass-border: rgba(255, 255, 255, .08);
  --edge-hi: rgba(255, 255, 255, .06);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .45);
  --shadow-card-hover: 0 2px 6px rgba(0, 0, 0, .4), 0 16px 40px rgba(0, 0, 0, .55);
  --brand-glow: rgba(139, 92, 246, .40);
  --brand-ring: rgba(139, 92, 246, .30);
  --blob-1: rgba(139, 92, 246, .20);
  --blob-2: rgba(6, 182, 212, .14);
  --blob-3: rgba(94, 125, 231, .14);
  --blob-opacity: .9;
  --scroll-thumb: rgba(148, 163, 184, .28);
  --scroll-thumb-hover: rgba(148, 163, 184, .48);
}

/* Smooth, brief theme cross-fade on color-bearing surfaces.
   Disabled during initial load (html.theme-booting) to avoid a flash-sweep. */
:root:not(.theme-booting) body,
:root:not(.theme-booting) .sidebar,
:root:not(.theme-booting) .topbar,
:root:not(.theme-booting) .content,
:root:not(.theme-booting) .card,
:root:not(.theme-booting) .btn,
:root:not(.theme-booting) .input,
:root:not(.theme-booting) .select,
:root:not(.theme-booting) .nav-item {
  transition: background-color .28s var(--ease), border-color .28s var(--ease),
    color .28s var(--ease), box-shadow .28s var(--ease);
}

/* ---- Reset / base ---- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: .9rem;
  line-height: 1.55;
  letter-spacing: -0.006em;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* ---- Theme-aware scrollbars (thin, styled) ---- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; }

/* ---- Icon system (icons.js) --------------------------------------------
   Every icon is one stroked 24x24 SVG that inherits `currentColor`, so an
   icon is always exactly the color of the text beside it, in both themes.
   SIZE is driven by font-size: .icon is 1em square. Set the size on the
   CONTAINER (or use .icon-14/16/18/20/24) rather than on the svg. */
.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  flex: none;
  vertical-align: -0.15em;
  overflow: visible;         /* the seal's lobes ride the viewBox edge */
  color: inherit;
}
/* Named sizes, for when the container font-size is not the icon size. */
.icon-14 { font-size: 14px; }
.icon-16 { font-size: 16px; }
.icon-18 { font-size: 18px; }
.icon-20 { font-size: 20px; }
.icon-24 { font-size: 24px; }
/* Hairline compensation: 1.6 reads heavy below ~16px and thin above ~28px,
   so the extremes are nudged back to one optical weight. */
.icon-14 .icon, .icon-14.icon { stroke-width: 1.75; }
.icon-24 .icon, .icon-24.icon { stroke-width: 1.5; }

/* A node whose contents Icons.label() replaced with "icon + text". The rule
   only bites when the node is already a flex row; inline nodes keep the text
   node's leading space, so both layouts space the pair correctly. */
.has-icon { gap: 6px; }

/* The <i data-icon> placeholder icons.js hydrates in place. */
.ico-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  font-style: normal;
  /* An inline-flex box baselines on its bottom edge, which would leave the
     icon riding high next to text; drop it the same 0.15em a bare .icon uses.
     Ignored (harmlessly) when the parent is itself a flex row. */
  vertical-align: -0.15em;
}
/* Semantic tints, so a warning icon needs no bespoke rule per page. */
.icon-ok { color: var(--ok); }
.icon-warn { color: var(--warn); }
.icon-danger { color: var(--danger); }
.icon-info { color: var(--info); }
.icon-brand { color: var(--brand); }
.icon-muted { color: var(--muted); }
.icon-faint { color: var(--faint); }

/* ---- Type scale ---- */
.t-xs { font-size: .75rem; }
.t-sm { font-size: .82rem; }
.t-lg { font-size: 1.05rem; }
.h2 { font-size: 1.25rem; font-weight: 650; margin: 0; letter-spacing: -0.018em; }
.h1 { font-size: 1.65rem; font-weight: 680; margin: 0; letter-spacing: -0.022em; line-height: 1.2; }
.w-500 { font-weight: 500; }
.w-600 { font-weight: 600; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* Tasteful brand→ink gradient on the largest heading. */
.h1 {
  background: linear-gradient(120deg, var(--brand), var(--ink) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--ink); /* fallback if background-clip unsupported */
}
/* Dark mode: lean into the full purple → cyan brand gradient (matches mark). */
:root[data-theme="dark"] .h1 {
  background: linear-gradient(120deg, var(--brand), var(--info) 85%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---- Layout helpers ---- */
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.row { display: flex; align-items: center; gap: var(--s-2); }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ============================================================================
   APP SHELL
   .app > (.sidebar + .main > (.topbar + .content[#view]))
   ========================================================================== */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ---- Ambient floating gradient blobs (behind everything) ----
   A fixed, non-interactive layer the shell injects (.cb-ambient). Very subtle
   in light mode, a touch more present in dark. Slowly drifts. */
.cb-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: var(--blob-opacity);
}
.cb-ambient .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  will-change: transform;
}
.cb-ambient .blob.b1 {
  width: 46vw; height: 46vw; top: -12vw; left: -8vw;
  background: var(--blob-1);
  animation: blobDrift1 34s ease-in-out infinite;
}
.cb-ambient .blob.b2 {
  width: 40vw; height: 40vw; bottom: -14vw; right: -6vw;
  background: var(--blob-2);
  animation: blobDrift2 40s ease-in-out infinite;
}
.cb-ambient .blob.b3 {
  width: 32vw; height: 32vw; top: 30%; left: 45%;
  background: var(--blob-3);
  animation: blobDrift3 28s ease-in-out infinite;
}
@keyframes blobDrift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(6vw, 8vh) scale(1.12); }
}
@keyframes blobDrift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-7vw, -6vh) scale(1.08); }
}
@keyframes blobDrift3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-5vw, 7vh) scale(1.15); }
}

/* Keep the actual app chrome above the ambient layer. */
.app > .sidebar, .app > .main { position: relative; z-index: 1; }

/* ---- Sidebar (floating glass) ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width .18s var(--ease);
}
/* Fallback solid bg where backdrop-filter is unsupported. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sidebar { background: var(--surface); }
  .topbar { background: var(--surface); }
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-4);
  font-weight: 650;
  font-size: 1.02rem;
  color: var(--ink);
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.brand .brand-mark { width: 24px; height: 24px; line-height: 1; flex-shrink: 0; display: block; }
.brand .brand-suffix {
  background: var(--brand-gradient-mark);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--brand); /* fallback if background-clip unsupported */
}
.sidebar.collapsed .brand .brand-label { display: none; }

.nav { flex: 1; padding: var(--s-2) var(--s-2) var(--s-4); }
.nav-section {
  padding: var(--s-3) var(--s-3) var(--s-1);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--faint);
}
.sidebar.collapsed .nav-section { text-align: center; padding-left: 0; padding-right: 0; font-size: 0; }
.sidebar.collapsed .nav-section::after { content: "•"; font-size: .8rem; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 8px 12px;
  border-radius: var(--r);
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .16s var(--ease), color .16s var(--ease);
}
.nav-item:hover { background: var(--brand-50); text-decoration: none; color: var(--ink); }
.nav-item.active {
  background: var(--brand-50);
  color: var(--brand);
  font-weight: 600;
}
/* Animated left accent bar: slides/scales in on the active item. */
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, var(--brand-g1), var(--brand-g3));
  transform-origin: center;
  animation: navAccentIn .26s var(--ease);
  box-shadow: 0 0 8px var(--brand-glow);
}
@keyframes navAccentIn {
  from { transform: scaleY(0); opacity: 0; }
  to { transform: scaleY(1); opacity: 1; }
}
.nav-item .ico {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 19px;
  line-height: 1;
  /* Inactive icons sit a touch lighter than their label; the active item
     brings them back to full brand weight (see .nav-item.active .ico). */
  color: var(--faint);
  transition: color .16s var(--ease);
}
.nav-item:hover .ico { color: var(--muted); }
.nav-item.active .ico { color: var(--brand); }
.nav-item .nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .nav-item { justify-content: center; }
.sidebar.collapsed .nav-item .nav-label,
.sidebar.collapsed .nav-item .nav-badge { display: none; }

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--brand-100);
  color: var(--brand-dark);
  font-size: .68rem;
  font-weight: 600;
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: var(--s-3) var(--s-4);
  font-size: .8rem;
  color: var(--muted);
}
.sidebar-foot .firm { font-weight: 600; color: var(--ink); display: block; }
.sidebar-foot .email { color: var(--faint); font-size: .74rem; overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .sidebar-foot { display: none; }

/* ---- Main column ---- */
.main { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-5);
  position: relative;
  z-index: 5;
}
.topbar .page-title { font-size: 1.05rem; font-weight: 650; color: var(--ink); letter-spacing: -0.014em; }
.topbar-collapse {
  border: 0; background: transparent; cursor: pointer;
  font-size: 19px; color: var(--muted); padding: 6px; border-radius: var(--r);
  line-height: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .14s var(--ease), color .14s var(--ease);
}
.topbar-collapse:hover { background: var(--bg); color: var(--ink); }

/* ---- Theme toggle (added to topbar by the shell) ---- */
.theme-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  width: 34px; height: 34px;
  border-radius: var(--r);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  flex-shrink: 0;
  transition: background-color .16s var(--ease), border-color .16s var(--ease),
    color .16s var(--ease), transform .16s var(--ease);
}
.theme-toggle:hover { background: var(--brand-50); color: var(--brand); border-color: var(--brand-100); }
.theme-toggle:active { transform: scale(.92); }
.theme-toggle .theme-ico {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 0;
  transition: transform .35s var(--ease);
}
.theme-toggle:hover .theme-ico { transform: rotate(25deg); }

/* ---- Notification bell + panel (added to topbar by the shell) ---- */
.notif { position: relative; flex-shrink: 0; display: inline-flex; }
.notif-btn {
  position: relative;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  width: 34px; height: 34px;
  border-radius: var(--r);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  transition: background-color .16s var(--ease), border-color .16s var(--ease),
    color .16s var(--ease), transform .16s var(--ease);
}
.notif-btn:hover { background: var(--brand-50); color: var(--brand); border-color: var(--brand-100); }
.notif-btn:active { transform: scale(.92); }
.notif-btn .notif-ico {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 0;
  transform-origin: 50% 15%;
}
.notif-btn.has-unread { border-color: var(--brand-100); }
.notif-btn.has-unread .notif-ico { animation: bellRing 4s var(--ease) infinite; }
.notif-badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--danger); color: #fff;
  font-size: .64rem; font-weight: 700; line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}
@keyframes bellRing {
  0%, 86%, 100% { transform: rotate(0deg); }
  88% { transform: rotate(13deg); }
  91% { transform: rotate(-11deg); }
  94% { transform: rotate(7deg); }
  97% { transform: rotate(-3deg); }
}

.notif-panel {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: min(380px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 40;
}
.notif-head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
}
.notif-title { font-size: .86rem; font-weight: 650; color: var(--ink); }
.notif-markall {
  margin-left: auto;
  border: 0; background: transparent; cursor: pointer;
  color: var(--brand); font-size: .76rem; font-weight: 600;
  padding: 2px 4px; border-radius: var(--r);
}
.notif-markall:hover { text-decoration: underline; }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
  display: flex; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--line);
  transition: background-color .14s var(--ease);
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--brand-50); }
.notif-item.unread:hover { background: var(--brand-100); }
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: transparent; margin-top: 6px; flex-shrink: 0;
}
.notif-dot.on { background: var(--brand); }
.notif-item-title { font-size: .84rem; font-weight: 600; color: var(--ink); }
.notif-item-detail { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.notif-chip {
  display: inline-block; vertical-align: 1px;
  padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--warn-50); color: var(--warn);
  font-size: .64rem; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase;
}
.notif-empty {
  padding: var(--s-5) var(--s-4);
  text-align: center; color: var(--muted); font-size: .82rem;
}
.notif-foot {
  display: block;
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--line);
  text-align: center; text-decoration: none;
  font-size: .78rem; font-weight: 600; color: var(--brand);
}
.notif-foot:hover { background: var(--bg); }

.tenant-control { display: flex; align-items: center; gap: 6px; }
.tenant-control label { font-size: .72rem; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 8px;
  border-radius: var(--r);
  font-size: .8rem;
  color: var(--muted);
}
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: var(--r-pill);
  background: var(--brand-100); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .78rem; flex-shrink: 0;
}
.user-chip .who { line-height: 1.2; }
.user-chip .who .uf { font-weight: 600; color: var(--ink); display: block; }
.user-chip .who .ue { color: var(--faint); font-size: .72rem; }

.content {
  flex: 1;
  overflow: auto;
  padding: var(--s-5);
  background: transparent;
  position: relative;
  z-index: 1;
}

/* Gentle page entrance: shell adds .cb-reveal to .content on mount. */
.content.cb-reveal { animation: contentReveal .26s var(--ease) both; }
@keyframes contentReveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   COMPONENTS
   ========================================================================== */

/* ---- Card (refined depth + lit edge) ---- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-card);
  transition: box-shadow .18s var(--ease), transform .18s var(--ease), border-color .18s var(--ease);
}
/* Lit top edge, most visible in dark mode (--edge-hi is transparent in light). */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, transparent, var(--edge-hi), transparent);
  pointer-events: none;
}
/* Subtle float on hover (alive without being clickable-implying everywhere). */
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}
/* Opt-in stronger lift for explicitly interactive cards. */
.card-hover { cursor: pointer; }
.card-hover:hover { transform: translateY(-3px); border-color: var(--brand-100); }
.card + .card { margin-top: var(--s-4); }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.card-head .title { font-size: 1.02rem; font-weight: 650; color: var(--ink); margin: 0; letter-spacing: -0.012em; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .14s var(--ease), border-color .14s var(--ease),
    box-shadow .14s var(--ease), transform .1s var(--ease), color .14s var(--ease),
    filter .14s var(--ease);
}
.btn:hover { background: var(--bg); text-decoration: none; border-color: var(--faint); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn:disabled:active { transform: none; }

.btn-primary {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
}
.btn-primary:hover {
  background: var(--brand-gradient);
  border-color: transparent;
  filter: brightness(1.08);
  box-shadow: 0 4px 14px var(--brand-glow);
}
.btn-primary:disabled {
  background: var(--brand-gradient);
  border-color: transparent;
  filter: none;
}

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { background: var(--brand-50); color: var(--brand); border-color: transparent; }

/* Positive action (approve, sync): solid ok fill, disabled inherits .btn opacity. */
.btn-success {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.btn-success:hover { background: var(--ok); border-color: var(--ok); filter: brightness(1.07); }
.btn-success:disabled { background: var(--ok); border-color: var(--ok); }

/* Destructive action (remove, delete): soft danger pill that fills on hover. */
.btn-danger {
  background: var(--danger-50);
  border-color: transparent;
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:disabled { background: var(--danger-50); color: var(--danger); }

.btn-sm { padding: 5px 10px; font-size: .8rem; }
/* Optical sizing: a 1em icon looks small next to text, 1.15em reads level. */
.btn .icon, .btn .ico-slot { font-size: 1.15em; }
.badge .icon, .pill .icon, .chip .icon { font-size: 1.2em; }

/* ---- Badges / pills ---- */
.badge, .pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  font-weight: 600;
  border-radius: var(--r-pill);
  padding: 2px 10px;
  background: var(--bg);
  color: var(--muted);
}
.badge-ok { background: var(--ok-50); color: var(--ok); }
.badge-warn { background: var(--warn-50); color: var(--warn); }
.badge-danger { background: var(--danger-50); color: var(--danger); }
.badge-info { background: var(--info-50); color: var(--info); }

/* ---- Status dots ---- */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
}
.dot-high { background: var(--danger); animation: dotPulse 2.4s var(--ease) infinite; }
.dot-med { background: var(--warn); }
.dot-low { background: var(--faint); }
/* Gentle attention pulse on high-severity dots (not a flash). */
@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .35); }
  50% { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0); }
}

/* ---- Form controls ---- */
.input, .select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font-size: .88rem;
  outline: none;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease), background-color .14s var(--ease);
}
.input:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.input::placeholder { color: var(--faint); }
.input-sm { padding: 5px 8px; font-size: .82rem; }
.tenant-input { width: 120px; }

/* ---- Empty state ---- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: var(--s-6) var(--s-5);
  text-align: center;
  color: var(--muted);
}
.empty .empty-ico {
  font-size: 34px;
  line-height: 0;
  color: var(--faint);
  opacity: .8;
  display: inline-flex;
}
.empty .empty-title { font-weight: 600; color: var(--ink); }
.empty .empty-sub { font-size: .85rem; color: var(--faint); max-width: 380px; }

/* ---- Skeleton shimmer utility (for loading placeholders) ---- */
.shimmer {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
}
.shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--edge-hi), transparent);
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, .18), transparent);
  animation: shimmerSweep 1.4s ease infinite;
}
@keyframes shimmerSweep {
  100% { transform: translateX(100%); }
}

/* ---- Page guide: what a page does, and how to use it -----------------------
   Every feature page opens with a one-paragraph description (.page-intro) and
   a collapsed step list (.page-guide) so a new user can get going without a
   manual. Written in plain language, and short enough to actually be read. */
.page-intro {
  color: var(--muted);
  max-width: 72ch;
  margin: 0 0 var(--s-3);
  line-height: 1.55;
}
.page-guide {
  max-width: 72ch;
  margin: 0 0 var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}
.page-guide > summary {
  cursor: pointer;
  list-style: none;
  padding: 9px var(--s-4);
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.page-guide > summary::-webkit-details-marker { display: none; }
.page-guide > summary:hover { background: var(--surface-2); }
.page-guide > summary .guide-caret {
  color: var(--faint);
  display: inline-flex;
  transition: transform .18s var(--ease);
}
.page-guide[open] > summary .guide-caret { transform: rotate(90deg); }
.page-guide[open] > summary { border-bottom: 1px solid var(--line); }
.page-guide .guide-steps {
  margin: 0;
  padding: var(--s-3) var(--s-4) var(--s-4) calc(var(--s-5) + 1.1em);
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.6;
}
.page-guide .guide-steps li { margin-bottom: 6px; }
.page-guide .guide-steps li:last-child { margin-bottom: 0; }
.page-guide .guide-steps strong { color: var(--ink); font-weight: 600; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--surface);
  padding: 10px 20px; border-radius: var(--r);
  font-size: .88rem; box-shadow: var(--shadow-lg);
  display: none; z-index: 999;
}

/* ============================================================================
   MOTION ACCESSIBILITY
   Gate ALL non-essential animation behind the user's reduced-motion choice.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .cb-ambient .blob { animation: none !important; }
  .card:hover { transform: none; }
  .content.cb-reveal { animation: none; }
}
