/* Inventory — Metronic-inspired UI
   Theming = [data-theme] (color palette) × [data-mode] (light/dark chrome).
   Mode controls bg/surface/text/borders/sidebar/shadows.
   Theme controls brand colors (primary/info). Status colors stay mode-aware. */

/* ─── Mode: light (default) ─── */
:root, [data-mode="light"] {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-hover: #f5f7fb;
  --surface-2: #eef2f8;
  --surface-3: #e6ebf3;
  --border: #e3e6ee;
  --border-bright: #c7cfdc;
  --text: #1f2937;
  --text-2: #4b5563;
  --muted: #9ca3af;
  --dim: #cbd5e1;
  --success: #10b981; --success-light: #d1fae5;
  --warning: #f59e0b; --warning-light: #fef3c7;
  --danger:  #ef4444; --danger-light:  #fee2e2;
  --cyan:    #0ea5e9; --cyan-light:    #e0f2fe;
  --sb-bg: #ffffff;
  --sb-bg-hover: #f3f6fb;
  --sb-text: #4b5563;
  --sb-text-active: #1f2937;
  --sb-border: #e3e6ee;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:    0 3px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.10);
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px;
}

/* ─── Mode: dark ─── */
[data-mode="dark"] {
  --bg: #0b0f1f;
  --surface: #131830;
  --surface-hover: #1a2042;
  --surface-2: #1a2042;
  --surface-3: #232b4d;
  --border: #232b4d;
  --border-bright: #2e3866;
  --text: #eef0fa;
  --text-2: #b9bfd6;
  --muted: #7e89b3;
  --dim: #5a6488;
  --success: #34d399; --success-light: rgba(52, 211, 153, 0.18);
  --warning: #fbbf24; --warning-light: rgba(251, 191, 36, 0.18);
  --danger:  #fb7185; --danger-light:  rgba(251, 113, 133, 0.20);
  --cyan:    #22d3ee; --cyan-light:    rgba(34, 211, 238, 0.18);
  --sb-bg: #0a0d1a;
  --sb-bg-hover: #14193a;
  --sb-text: #9499b8;
  --sb-text-active: #ffffff;
  --sb-border: #1a2042;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow:    0 3px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* ─── Themes (color palettes). Use html[data-theme] for clear higher specificity. ─── */
/* Fallback when no theme attr is present */
:root { --primary: #2563eb; --primary-hover: #1d4ed8; --primary-fg: #ffffff; --info: #6366f1; }

html[data-theme="default"] { --primary: #2563eb; --primary-hover: #1d4ed8; --primary-fg: #ffffff; --info: #6366f1; }
html[data-theme="emerald"] { --primary: #059669; --primary-hover: #047857; --primary-fg: #ffffff; --info: #0d9488; }
html[data-theme="purple"]  { --primary: #7c3aed; --primary-hover: #6d28d9; --primary-fg: #ffffff; --info: #a855f7; }
html[data-theme="sunset"]  { --primary: #ea580c; --primary-hover: #c2410c; --primary-fg: #ffffff; --info: #db2777; }
html[data-theme="slate"]   { --primary: #475569; --primary-hover: #334155; --primary-fg: #ffffff; --info: #64748b; }
html[data-theme="rose"]    { --primary: #e11d48; --primary-hover: #be123c; --primary-fg: #ffffff; --info: #f43f5e; }

/* Dark-mode brightened variants (higher specificity beats single-attr theme) */
html[data-mode="dark"][data-theme="default"] { --primary: #818cf8; --primary-hover: #a5b1ff; --primary-fg: #0b0f1f; --info: #c084fc; }
html[data-mode="dark"][data-theme="emerald"] { --primary: #34d399; --primary-hover: #6ee7b7; --primary-fg: #052e1e; --info: #2dd4bf; }
html[data-mode="dark"][data-theme="purple"]  { --primary: #a78bfa; --primary-hover: #c4b5fd; --primary-fg: #1a0b3a; --info: #d8b4fe; }
html[data-mode="dark"][data-theme="sunset"]  { --primary: #fb923c; --primary-hover: #fdba74; --primary-fg: #2a0e02; --info: #f472b6; }
html[data-mode="dark"][data-theme="slate"]   { --primary: #94a3b8; --primary-hover: #cbd5e1; --primary-fg: #0f172a; --info: #a8b3c4; }
html[data-mode="dark"][data-theme="rose"]    { --primary: #fb7185; --primary-hover: #fda4af; --primary-fg: #2a0210; --info: #fb7185; }

/* primary-light + info-light + sb-active-bg derived per mode (so all themes apply everywhere) */
html[data-mode="light"], :root {
  --primary-light: color-mix(in srgb, var(--primary) 14%, #ffffff);
  --info-light:    color-mix(in srgb, var(--info) 12%, #ffffff);
  --sb-active-bg:  color-mix(in srgb, var(--primary) 14%, transparent);
  --focus-ring:    color-mix(in srgb, var(--primary) 25%, transparent);
}
html[data-mode="dark"] {
  --primary-light: color-mix(in srgb, var(--primary) 22%, transparent);
  --info-light:    color-mix(in srgb, var(--info) 22%, transparent);
  --sb-active-bg:  color-mix(in srgb, var(--primary) 26%, transparent);
  --focus-ring:    color-mix(in srgb, var(--primary) 35%, transparent);
}

/* Dark-mode overrides for components originally tuned to light backgrounds */
[data-mode="dark"] .toast { color: var(--text); }
[data-mode="dark"] .pill.paid    { color: #34d399; }
[data-mode="dark"] .pill.partial { color: #fbbf24; }
[data-mode="dark"] .pill.unpaid  { color: #fb7185; }
[data-mode="dark"] input, [data-mode="dark"] select, [data-mode="dark"] textarea {
  background: var(--surface-hover); color: var(--text);
}
[data-mode="dark"] table.t { background: var(--surface); }
[data-mode="dark"] table.t tbody tr:hover td { background: var(--surface-hover); }
[data-mode="dark"] code { background: var(--surface-hover); padding: 1px 6px; border-radius: 4px; }

/* ─── Dark-mode contrast: keep buttons & accents legible on dark surfaces ─── */
[data-mode="dark"] .btn.ghost {
  background: color-mix(in srgb, var(--primary) 28%, transparent);
  color: color-mix(in srgb, var(--primary) 80%, white);
  border: 1px solid color-mix(in srgb, var(--primary) 50%, transparent);
}
[data-mode="dark"] .btn.ghost:hover {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}
[data-mode="dark"] .btn.danger {
  background: color-mix(in srgb, var(--danger) 28%, transparent);
  color: #fda4af;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
}
[data-mode="dark"] .btn.danger:hover { background: var(--danger); color: #fff; }
[data-mode="dark"] .icon-btn:hover {
  background: color-mix(in srgb, var(--primary) 30%, transparent);
  color: var(--text);
  border-color: var(--primary);
}
[data-mode="dark"] .icon-btn.danger:hover {
  background: color-mix(in srgb, var(--danger) 30%, transparent);
  color: #fda4af;
  border-color: var(--danger);
}

/* ─── Theme presence: subtle accents across the app so the palette feels global ─── */
/* Page heading accent bar */
h1 {
  position: relative;
  padding-left: 14px;
}
h1::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 4px; border-radius: 3px;
  background: linear-gradient(180deg, var(--primary), var(--info));
}
/* Card-top accent on hover for subtle theme reinforcement */
.card { border-top: 2px solid transparent; transition: border-top-color 0.18s, box-shadow 0.18s, transform 0.18s; }
.card:hover { border-top-color: color-mix(in srgb, var(--primary) 60%, transparent); }
/* Stat card icon already uses --primary-light when no inline accent set; reinforce subtle border for theme */
.stat { border-top: 2px solid color-mix(in srgb, var(--accent, var(--primary)) 50%, transparent); }
/* Sidebar brand text gradient picks up theme */
.brand {
  background: linear-gradient(135deg, var(--primary), var(--info));
  background-clip: text; -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.brand::before {
  /* keep the colored block — gradient sourced from theme */
  background: linear-gradient(135deg, var(--primary), var(--info));
}
/* Modal head subtle accent strip */
.modal-head { border-top: 3px solid var(--primary); }
/* Toolbar search icon picks up primary on focus-within */
.toolbar .search:focus-within::before { color: var(--primary); }
/* Active tab uses primary (already set) — boost the underline thickness */
.tabs button.active { border-bottom-width: 3px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  /* Subtle theme-tinted page background — picks up the active palette so the
     theme is felt globally, not just on accents. */
  background:
    radial-gradient(1200px 600px at 100% -200px, color-mix(in srgb, var(--primary) 8%, transparent), transparent 60%),
    radial-gradient(900px 500px at -200px 100%, color-mix(in srgb, var(--info) 6%, transparent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ─────────────── Sidebar ─────────────── */
.sidebar {
  width: 245px;
  flex-shrink: 0;
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  padding: 22px 24px;
  letter-spacing: 0.2px;
  border-bottom: 1px solid var(--sb-border);
}
.brand::before {
  content: "";
  display: inline-block;
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--primary), var(--info));
  border-radius: 8px;
  flex-shrink: 0;
}
.sidebar nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin: 2px 0;
  color: var(--sb-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  border-radius: 8px;
  transition: all 0.15s ease;
}
.sidebar nav a:hover {
  background: var(--sb-bg-hover);
  color: #fff;
}
.sidebar nav a.active {
  background: var(--sb-active-bg);
  color: var(--sb-text-active);
  font-weight: 600;
}

/* Grouped (collapsible) menu */
.nav-group { margin: 2px 0; }
.nav-group-head {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 11px 14px; margin: 0;
  background: transparent; border: none;
  color: var(--sb-text); cursor: pointer;
  font-weight: 600; font-size: 13px;
  border-radius: 8px; text-align: left;
  transition: all 0.15s; font-family: inherit;
}
.nav-group-head:hover { background: var(--sb-bg-hover); color: #fff; }
.nav-group-head .caret {
  margin-left: auto; opacity: 0.6; font-size: 10px;
  transition: transform 0.18s;
}
.nav-group.expanded > .nav-group-head .caret { transform: rotate(180deg); }
.nav-group-body {
  overflow: hidden; max-height: 0;
  transition: max-height 0.22s ease;
}
.nav-group.expanded > .nav-group-body { max-height: 600px; }
.nav-group-body a {
  padding-left: 36px !important;
  font-size: 12.5px;
}

/* #10 — Boost active state inside expanded submenu (left accent bar) */
.nav-group-body a.active {
  background: var(--sb-active-bg);
  color: var(--sb-text-active);
  font-weight: 700;
  position: relative;
}
.nav-group-body a.active::before {
  content: "";
  position: absolute;
  left: 16px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px;
  background: var(--primary);
}

/* #21 — Pill contrast in dark mode (brighter text + tinted bg) */
[data-mode="dark"] .pill.paid    { background: rgba(52, 211, 153, 0.18);  color: #6ee7b7; }
[data-mode="dark"] .pill.partial { background: rgba(251, 191, 36, 0.18);  color: #fcd34d; }
[data-mode="dark"] .pill.unpaid  { background: rgba(251, 113, 133, 0.20); color: #fda4af; }
[data-mode="dark"] .risk-ok      { background: rgba(52, 211, 153, 0.18);  color: #6ee7b7; }
[data-mode="dark"] .risk-watch   { background: rgba(251, 191, 36, 0.18);  color: #fcd34d; }
[data-mode="dark"] .risk-bad     { background: rgba(251, 113, 133, 0.22); color: #fda4af; }

/* #25 — Horizontal-scroll affordance shadow on overflow tables */
.scroll {
  background:
    linear-gradient(to right, var(--surface), var(--surface)) left center / 16px 100% no-repeat,
    linear-gradient(to right, rgba(0,0,0,0.10), rgba(0,0,0,0)) left center / 12px 100% no-repeat,
    linear-gradient(to left,  var(--surface), var(--surface)) right center / 16px 100% no-repeat,
    linear-gradient(to left,  rgba(0,0,0,0.10), rgba(0,0,0,0)) right center / 12px 100% no-repeat;
  background-attachment: local, scroll, local, scroll;
}
[data-mode="dark"] .scroll {
  background:
    linear-gradient(to right, var(--surface), var(--surface)) left center / 16px 100% no-repeat,
    linear-gradient(to right, rgba(0,0,0,0.45), rgba(0,0,0,0)) left center / 14px 100% no-repeat,
    linear-gradient(to left,  var(--surface), var(--surface)) right center / 16px 100% no-repeat,
    linear-gradient(to left,  rgba(0,0,0,0.45), rgba(0,0,0,0)) right center / 14px 100% no-repeat;
  background-attachment: local, scroll, local, scroll;
}

/* #27 — Visible focus rings (keyboard accessibility) */
.icon-btn:focus-visible,
.btn:focus-visible,
.theme-btn:focus-visible,
.swatch:focus-visible,
.mode-btn:focus-visible,
.tabs button:focus-visible,
.modal-close:focus-visible,
.sidebar nav a:focus-visible,
.nav-group-head:focus-visible,
.row-actions button:focus-visible,
#hamburger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--primary-light);
}

/* Permissions matrix table */
.matrix {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
}
.matrix th, .matrix td {
  padding: 10px 12px; text-align: center;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.matrix th:first-child, .matrix td:first-child { text-align: left; border-right: 2px solid var(--border-bright); }
.matrix th { background: var(--surface-hover); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.matrix .module-row td { background: var(--surface-hover); font-weight: 600; color: var(--text); border-right: 1px solid var(--border); }

/* Filter banner shown above lists when URL contains a filter */
.filter-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
}
.filter-banner .icon { font-size: 16px; }
.filter-banner .label { font-weight: 600; color: var(--text); }
.filter-banner .scope { background: var(--surface); padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.filter-banner .clear {
  margin-left: auto;
  background: var(--surface); border: 1px solid var(--primary);
  color: var(--primary); padding: 5px 12px; border-radius: 6px;
  text-decoration: none; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}
.filter-banner .clear:hover { background: var(--primary); color: var(--primary-fg); }

/* ─────────────── Sticky table headers ─────────────── */
.card .scroll { max-height: calc(100vh - 200px); overflow-y: auto; }
table.t thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
}

/* ─────────────── Table footer totals ─────────────── */
table.t tfoot tr {
  background: var(--surface-hover);
  font-weight: 700;
}
table.t tfoot td {
  border-top: 2px solid var(--border-bright);
  position: sticky; bottom: 0;
  background: var(--surface-hover);
}

/* ─────────────── Color-coded amounts ─────────────── */
.amt-pos { color: var(--success); font-weight: 600; }
.amt-neg { color: var(--danger); font-weight: 600; }
.amt-warn { color: var(--warning); font-weight: 600; }
.amt-muted { color: var(--muted); }
[data-mode="dark"] .amt-pos { color: #34d399; }
[data-mode="dark"] .amt-neg { color: #fb7185; }
[data-mode="dark"] .amt-warn { color: #fbbf24; }

/* ─────────────── Row-add highlight animation ─────────────── */
@keyframes row-flash {
  0%   { background: var(--primary-light); }
  100% { background: transparent; }
}
table.t tbody tr.row-new td { animation: row-flash 1.6s ease-out; }

/* ─────────────── Skeleton rows ─────────────── */
@keyframes skel-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
table.t tr.skel td {
  padding: 14px 12px;
}
table.t tr.skel td > span {
  display: block; height: 12px; border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-hover), var(--border), var(--surface-hover));
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s linear infinite;
}

/* ─────────────── Empty state with CTA ─────────────── */
.empty-state .btn { margin-top: 14px; }

/* ─────────────── Hover lift on cards ─────────────── */
.card { transition: box-shadow 0.18s, transform 0.18s; }
.card:hover { box-shadow: var(--shadow); }

/* Stat cards already lift; ensure hover on table card too */
.card-clickable { cursor: pointer; }
.card-clickable:hover { transform: translateY(-1px); }

/* ─────────────── Larger tap targets on mobile ─────────────── */
@media (pointer: coarse), (max-width: 768px) {
  .icon-btn { width: 40px; height: 40px; font-size: 16px; }
  .row-actions { gap: 8px; }
  .btn { padding: 11px 18px; font-size: 14px; }
  table.t th, table.t td { padding: 14px 10px; }
}

/* ─────────────── Mobile FAB ─────────────── */
.mobile-fab {
  display: none;
  position: fixed;
  right: 18px; bottom: 18px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--info));
  color: #fff;
  border: none;
  box-shadow: var(--shadow-lg);
  font-size: 26px; font-weight: 600;
  cursor: pointer; z-index: 50;
  transition: transform 0.18s;
}
.mobile-fab:hover { transform: scale(1.05); }
.mobile-fab:active { transform: scale(0.95); }
@media (max-width: 768px) {
  .mobile-fab { display: flex; align-items: center; justify-content: center; }
}

/* ─────────────── Bottom sheet on mobile ─────────────── */
@media (max-width: 600px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    border-radius: 16px 16px 0 0;
    max-width: 100%;
    max-height: 92vh;
    transform: translateY(100%);
    padding-top: 14px;  /* room for drag handle */
  }
  .modal::before {
    content: "";
    position: absolute;
    top: 8px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px;
    background: var(--border-bright);
    border-radius: 2px;
    cursor: grab;
    touch-action: none;
  }
  .modal.dragging { transition: none; }
  .modal-backdrop.shown .modal { transform: translateY(0); }
  .modal-foot { border-radius: 0; }
}

/* ─────────────── Mini sparklines ─────────────── */
.spark-host {
  height: 32px; margin-top: 6px;
  position: relative;
}
.spark-host canvas {
  position: absolute; inset: 0; max-width: 100%;
}

/* ─────────────── Comparison badge ─────────────── */
.cmp-up   { color: var(--success); font-size: 11px; font-weight: 600; margin-left: 6px; }
.cmp-down { color: var(--danger); font-size: 11px; font-weight: 600; margin-left: 6px; }
.cmp-flat { color: var(--muted); font-size: 11px; font-weight: 500; margin-left: 6px; }

/* ─────────────── Date quick-buttons inline with date input ─────────────── */
.date-quicks {
  display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap;
}
.date-quicks button {
  background: var(--surface-hover); border: 1px solid var(--border);
  color: var(--text-2); font-size: 11px; padding: 3px 8px;
  border-radius: 4px; cursor: pointer;
}
.date-quicks button:hover { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }

/* ─────────────── Print styles for invoice/report views ─────────────── */
@media print {
  .sidebar, .topbar, .toolbar, .filter-banner, .row-actions, #toast-host, .mobile-fab, #drawer-back, #server-flash {
    display: none !important;
  }
  body, .main { background: #fff; color: #000; padding: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; page-break-inside: avoid; }
  table.t th { background: #eee; color: #000; }
  .pill { border: 1px solid currentColor; }
}
.print-only { display: none; }
@media print { .print-only { display: block; } }

/* ─────────────── Bigger stat numbers on mobile (#30) ─────────────── */
@media (max-width: 768px) {
  .stat .val { font-size: 28px; }
  h1 { font-size: 20px; }
}

/* ─────────────── Midnight scrollbars (#47) ─────────────── */
[data-theme="midnight"] ::-webkit-scrollbar { width: 10px; height: 10px; }
[data-theme="midnight"] ::-webkit-scrollbar-track { background: var(--bg); }
[data-theme="midnight"] ::-webkit-scrollbar-thumb {
  background: var(--surface-3); border-radius: 5px; border: 2px solid var(--bg);
}
[data-theme="midnight"] ::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }
[data-theme="midnight"] * { scrollbar-color: var(--surface-3) var(--bg); }

/* ─────────────── Reduced motion (#50) ─────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─────────────── Empty state with illustration (#49) ─────────────── */
.empty-state { padding: 56px 20px; }
.empty-state .e-icon {
  width: 96px; height: 96px;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px;
  background: linear-gradient(135deg, var(--primary-light), var(--info-light));
  border-radius: 50%;
  border: 2px dashed var(--border-bright);
}
.empty-state .e-title { font-size: 16px; }

/* ─────────────── Vendor risk pill (#11) ─────────────── */
.risk-ok    { background: var(--success-light); color: #1a7a3a; }
.risk-watch { background: var(--warning-light); color: #8a6d00; }
.risk-bad   { background: var(--danger-light); color: #b3092f; }

/* ─────────────── Pull-to-refresh indicator (#29) ─────────────── */
#ptr-host {
  position: fixed; top: 0; left: 50%; transform: translate(-50%, -100%);
  background: var(--primary); color: var(--primary-fg);
  padding: 8px 18px; border-radius: 0 0 12px 12px;
  font-size: 12px; font-weight: 600; z-index: 200;
  transition: transform 0.18s;
  box-shadow: var(--shadow);
}
#ptr-host.shown { transform: translate(-50%, 0); }

/* ─────────────── Number count-up + flash (#48) ─────────────── */
@keyframes num-pop {
  0%   { transform: scale(0.95); opacity: 0; }
  60%  { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); }
}
.stat .val.popped { animation: num-pop 0.45s ease-out; }

/* ─────────────── Per-record audit panel (#18) ─────────────── */
.audit-panel { font-size: 12px; }
.audit-panel .a-row {
  display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border);
}
.audit-panel .a-row:last-child { border-bottom: none; }
.audit-panel .a-when { color: var(--muted); min-width: 100px; }
.audit-panel .a-act { color: var(--primary); font-weight: 600; min-width: 70px; }
.audit-panel .a-user { color: var(--text); font-weight: 500; min-width: 110px; }
.audit-panel .a-detail { color: var(--text-2); flex: 1; word-break: break-word; }

/* ─────────────── Trash badges (#25) ─────────────── */
.archived-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; background: var(--surface-3); color: var(--muted);
  margin-left: 8px; vertical-align: 1px;
  border: 1px solid var(--border);
}

/* ─────────────── Thermal-printer invoice (#35) ─────────────── */
@media print {
  .thermal-print {
    width: 80mm !important; max-width: 80mm !important;
    font-size: 11px !important; line-height: 1.4;
  }
  .thermal-print h1 { font-size: 14px; }
  .thermal-print table.t th, .thermal-print table.t td { padding: 4px; font-size: 11px; }
}
.dep-hint {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  opacity: 0.55;
  cursor: help;
  color: var(--primary);
}
.dep-hint:hover { opacity: 1; }
.matrix input[type="checkbox"] { width: auto; cursor: pointer; transform: scale(1.2); }
.matrix .role-h { writing-mode: horizontal-tb; }

/* Tabs */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tabs button {
  background: transparent; border: none;
  padding: 12px 18px; cursor: pointer;
  color: var(--muted); font-size: 13px; font-weight: 600;
  border-bottom: 2px solid transparent;
  white-space: nowrap; font-family: inherit;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.danger-zone {
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 18px 22px;
  background: var(--danger-light);
  margin-top: 18px;
}
[data-theme="midnight"] .danger-zone { background: rgba(251, 113, 133, 0.08); }
.danger-zone h3 { color: var(--danger); margin: 0 0 8px; font-size: 14px; }
.danger-zone p { margin: 0 0 12px; color: var(--text-2); font-size: 12px; }

.ver {
  color: #5a5d76;
  padding: 16px 24px;
  font-size: 11px;
  border-top: 1px solid var(--sb-border);
}

/* ─────────────── Main ─────────────── */
.main {
  flex: 1;
  padding: 24px 36px 50px;
  min-width: 0;
}
h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--text);
  letter-spacing: -0.2px;
}
.sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 22px 0;
}

/* ─────────────── Cards ─────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  margin: 0 0 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0;
  text-transform: none;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

/* ─────────────── Tables ─────────────── */
table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--surface);
}
table.t th, table.t td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
table.t th {
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
table.t tbody tr { transition: background 0.15s; }
table.t tbody tr:hover td { background: var(--surface-hover); }
table.t .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
table.t th.sortable {
  cursor: pointer; user-select: none;
  padding-right: 24px;
  position: relative;
}
table.t th.sortable:hover { color: var(--primary); background: var(--surface-hover); }
table.t th.sort-asc, table.t th.sort-desc { color: var(--primary); }
table.t th .sort-arrow { font-size: 9px; margin-left: 2px; opacity: 0.8; }
.empty {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

/* ─────────────── Forms ─────────────── */
input, select, textarea {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
input::placeholder { color: var(--dim); }

label {
  display: block;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: none;
  letter-spacing: 0;
}
.row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.row > * { flex: 1; min-width: 180px; }

/* ─────────────── Buttons ─────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-fg);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  transition: all 0.15s;
}
.btn:hover {
  background: var(--primary-hover);
  color: var(--primary-fg);
  box-shadow: var(--shadow);
}
.btn.ghost {
  background: var(--primary-light);
  color: var(--primary);
  border-color: transparent;
}
.btn.ghost:hover {
  background: var(--primary);
  color: var(--primary-fg);
}
.btn.danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: transparent;
}
.btn.danger:hover {
  background: var(--danger);
  color: #fff;
}
.btn.success {
  background: var(--success);
  color: #fff;
}
.btn.success:hover { background: #14a548; }

button { font-family: inherit; }

/* ─────────────── Stat Cards ─────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}
.stat:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.stat .icon {
  float: right;
  width: 40px; height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  font-size: 18px;
  margin-top: -2px;
}
.stat .lbl {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.stat .val {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-top: 6px;
  letter-spacing: -0.3px;
}
/* keep --accent compat from previous theme to color icon backgrounds subtly */
.stat[style*="--accent"] .icon { background: color-mix(in srgb, var(--accent, var(--primary)) 15%, transparent); }

/* ─────────────── Toasts ─────────────── */
.toast {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  background: var(--success-light);
  color: #1a7a3a;
  border: 1px solid #c5f3d2;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast::before {
  content: "✓";
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.toast-error {
  background: var(--danger-light);
  color: #b3092f;
  border-color: #fecdd3;
}
.toast-error::before { content: "✕"; background: var(--danger); }
.toast-info {
  background: var(--info-light);
  color: #4f1ec1;
  border-color: #e0d6ff;
}
.toast-info::before { content: "ⓘ"; background: var(--info); }
.toast-warn {
  background: var(--warning-light);
  color: #8a6d00;
  border-color: #ffe88a;
}
.toast-warn::before { content: "!"; background: var(--warning); color: #2d1b00; }

/* ─────────────── Pills / Badges ─────────────── */
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}
.pill.paid { background: var(--success-light); color: #1a7a3a; }
.pill.partial { background: var(--warning-light); color: #8a6d00; }
.pill.unpaid { background: var(--danger-light); color: #b3092f; }

/* ─────────────── Right column (sticky topbar host) ─────────────── */
.page-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}

/* ─────────────── Topbar (sticky at viewport top, full-width of right column) ─────────────── */
.topbar {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border);
  padding: 10px 36px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  box-shadow: none;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
}
.topbar.scrolled {
  box-shadow: var(--shadow);
  border-bottom-color: var(--border-bright);
}
.tb-date { color: var(--text-2); font-size: 12px; font-weight: 500; }

/* Quick controls in the topbar (mode toggle + theme palette popover) */
.topbar-tools {
  display: inline-flex; align-items: center; gap: 6px;
}
.tb-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  color: var(--text-2);
  transition: all 0.15s;
  position: relative;
}
.tb-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.tb-btn .palette-dot {
  position: absolute; right: 4px; bottom: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 2px var(--surface);
}

/* Theme popover (anchored under palette button) */
.theme-pop {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  z-index: 95;
  min-width: 220px;
  display: none;
}
.theme-pop.shown { display: block; }
.theme-pop .pop-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  font-weight: 700; color: var(--muted);
  padding: 4px 4px 8px;
}
.theme-pop .pop-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
}
.theme-pop .pop-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer; padding: 0;
  transition: transform 0.12s, border-color 0.12s;
  position: relative;
}
.theme-pop .pop-swatch:hover { transform: scale(1.1); }
.theme-pop .pop-swatch.active { border-color: var(--text); border-width: 3px; }
.theme-pop .pop-swatch.active::after {
  content: "✓"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.tb-wrap { position: relative; display: inline-block; }
.topbar .crumbs {
  color: var(--muted);
  font-size: 12px;
}
.topbar .crumbs strong { color: var(--text); font-weight: 600; }
.topbar .user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-2);
  font-size: 13px;
}
.topbar .user .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--info));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.user-menu {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px; z-index: 50;
  min-width: 200px;
  display: none;
}
.user-menu.shown { display: block; }
.user-menu .who { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-menu .who .nm { font-weight: 600; color: var(--text); font-size: 13px; }
.user-menu .who .rl { color: var(--muted); font-size: 11px; }
.user-menu a, .user-menu button {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px;
  background: transparent; border: none;
  color: var(--text-2); font-size: 13px; width: 100%; text-align: left;
  cursor: pointer; text-decoration: none;
}
.user-menu a:hover, .user-menu button:hover { background: var(--surface-hover); color: var(--text); }
.user-menu .divider { height: 1px; background: var(--border); margin: 6px 0; }

.topbar .user-wrap { position: relative; }

/* Theme + mode picker (user menu) */
.um-section {
  padding: 8px 12px 4px; color: var(--muted);
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 1px; font-weight: 600;
}
.theme-swatches {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 6px; padding: 4px 8px 8px;
}
.swatch {
  background: transparent; border: 1px solid transparent;
  padding: 6px 4px; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; color: var(--text-2);
  transition: background 0.12s, border-color 0.12s;
}
.swatch:hover { background: var(--surface-hover); }
.swatch.active { border-color: var(--primary); background: var(--primary-light); }
.swatch .sw-dot {
  width: 22px; height: 22px; border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--surface), 0 0 0 1px var(--border);
}
.swatch.active .sw-dot { box-shadow: inset 0 0 0 2px var(--surface), 0 0 0 2px var(--primary); }
.swatch .sw-lbl { font-size: 9px; font-weight: 600; letter-spacing: 0.2px; }
.mode-toggle {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 4px; padding: 4px 8px 8px;
}
.mode-btn {
  background: var(--surface-hover); border: 1px solid var(--border);
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  transition: all 0.12s;
}
.mode-btn:hover { background: var(--surface-2); }
.mode-btn.active {
  background: var(--primary); color: var(--primary-fg);
  border-color: var(--primary);
}

/* ─────────────── Misc ─────────────── */
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.spacer { flex: 1; }
.right { text-align: right; }
.scroll { overflow-x: auto; border-radius: var(--radius-sm); }
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ─────────── Hamburger + drawer backdrop ─────────── */
#hamburger {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  font-size: 18px;
}
#drawer-back {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 998;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s;
}
#drawer-back.shown { opacity: 1; pointer-events: auto; }

/* ─────────── Modal ─────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
  padding: 16px;
  overflow-y: auto;
}
.modal-backdrop.shown { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.2s ease;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 32px);
}
.modal-wide { max-width: 800px; }
.modal-backdrop.shown .modal { transform: translateY(0) scale(1); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 24px; line-height: 1; color: var(--muted); padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-hover);
  display: flex; justify-content: flex-end; gap: 8px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
body.modal-open { overflow: hidden; }

/* ─────────── Toolbar ─────────── */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar .search {
  flex: 1; min-width: 220px;
  position: relative;
}
.toolbar .search input {
  padding-left: 38px;
  background: var(--surface);
}
.toolbar .search::before {
  content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: var(--muted); pointer-events: none;
}
.toolbar .filters { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar .filters select { width: auto; min-width: 130px; }

/* ─────────── Toast host (top-right floating) ─────────── */
#toast-host {
  position: fixed; top: 18px; right: 18px;
  z-index: 1100;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast.toast-fly {
  margin: 0; pointer-events: auto;
  min-width: 240px; max-width: 380px;
  box-shadow: var(--shadow);
  transform: translateX(0); opacity: 1;
  transition: transform 0.22s, opacity 0.22s;
}
.toast.toast-fly .x {
  margin-left: auto; background: transparent; border: none;
  font-size: 18px; cursor: pointer; color: inherit; opacity: 0.6; padding: 0 4px;
}
.toast.toast-fly .x:hover { opacity: 1; }
.toast.toast-out { transform: translateX(120%); opacity: 0; }

/* ─────────── Sentinel / loader ─────────── */
.sentinel {
  text-align: center; color: var(--muted);
  padding: 14px; font-size: 12px;
}
.sentinel.loading::before {
  content: "";
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px; vertical-align: -2px;
}
.sentinel.done::before { content: ""; display: none; }
.sentinel.done { color: var(--dim); font-style: italic; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────── Empty state with icon ─────────── */
.empty-state {
  text-align: center; padding: 48px 20px;
  color: var(--muted);
}
.empty-state .e-icon {
  font-size: 40px; opacity: 0.4; margin-bottom: 12px;
}
.empty-state .e-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.empty-state .e-sub { font-size: 12px; }

/* ─────────── Action buttons inside table rows ─────────── */
.row-actions {
  display: inline-flex; gap: 6px;
}
.row-actions button, .row-actions a.btn {
  padding: 5px 10px; font-size: 12px;
}
.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.icon-btn.danger:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* Skeleton row */
.skel-row td { padding: 14px; }
.skel-bar {
  display: block;
  background: linear-gradient(90deg, var(--surface-hover), #f0f1f5, var(--surface-hover));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  height: 12px; border-radius: 4px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ─────────── Searchable select (combobox) ─────────── */
.sel-wrap { position: relative; }
.sel-wrap .sel-native { position: absolute; opacity: 0; pointer-events: none; height: 0; width: 100%; }
.sel-input {
  width: 100%; padding-right: 28px;
  cursor: text;
}
.sel-caret {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 11px; pointer-events: auto;
  cursor: pointer; user-select: none;
}
.sel-wrap.open .sel-caret { color: var(--primary); transform: translateY(-50%) rotate(180deg); }
.sel-dropdown {
  display: none;
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  z-index: 1100;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  max-height: 240px; overflow-y: auto;
  padding: 4px;
}
.sel-wrap.open .sel-dropdown { display: block; }
.sel-wrap.open.flip-up .sel-dropdown { top: auto; bottom: calc(100% + 4px); }
.sel-opt {
  padding: 8px 10px; border-radius: 4px; cursor: pointer;
  font-size: 13px; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.sel-opt.active { background: var(--primary-light); color: var(--primary); }
.sel-opt.selected { font-weight: 600; }
.sel-opt:hover { background: var(--surface-hover); }
.sel-empty { padding: 14px; color: var(--muted); font-size: 12px; text-align: center; }

/* ─────────── Form layout helpers ─────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* Smooth page fade */
.main { animation: pgFade 0.18s ease-out; }
@keyframes pgFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ─────────── Responsive ─────────── */
@media (max-width: 992px) {
  body { display: flex; }                     /* keep flex so .page-col still grows */
  #hamburger { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 999;
    transform: translateX(-100%); transition: transform 0.22s ease;
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  #drawer-back { display: block; }
  .page-col { width: 100%; }
  .main { padding: 16px; }
  .topbar { padding: 10px 14px; }
}
@media (max-width: 600px) {
  .topbar { flex-direction: row; flex-wrap: nowrap; }
  .topbar .crumbs { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .tb-date { display: none; }            /* save space */
  .topbar .user { gap: 6px; }
  .topbar-tools { gap: 4px; }
  .tb-btn { width: 34px; height: 34px; font-size: 14px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 16px; }
  .stat .val { font-size: 20px; }
  .row > *, .form-grid > * { min-width: 100% !important; }
  .card { padding: 16px; }
  .modal-foot { flex-direction: column; }
  .modal-foot .btn { width: 100%; justify-content: center; }
  table.t th, table.t td { padding: 10px 8px; font-size: 12px; }
  h1 { font-size: 18px; }
}
@media (max-width: 420px) {
  .topbar .crumbs span { display: none; }        /* hide "Pages ›" on tiny screens */
  .topbar { padding: 8px 10px; gap: 6px; }
  .main { padding: 12px; }
}

@media (max-width: 400px) {
  .stats { grid-template-columns: 1fr; }
}
