/* Self-hosted fonts (via LibMan — see libman.json) */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/lib/fonts/inter/files/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/lib/fonts/inter/files/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/lib/fonts/inter/files/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/lib/fonts/inter/files/inter-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 800; font-display: swap; src: url('/lib/fonts/inter/files/inter-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/lib/fonts/jetbrains-mono/files/jetbrains-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/lib/fonts/jetbrains-mono/files/jetbrains-mono-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url('/lib/fonts/jetbrains-mono/files/jetbrains-mono-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 700; font-display: swap; src: url('/lib/fonts/jetbrains-mono/files/jetbrains-mono-latin-700-normal.woff2') format('woff2'); }

/* ============================================================
   SafeZone AA1 — Design System v3 "operations-grade"
   Evolved from v2: same deep-teal DNA, warm-neutral surfaces,
   Inter + JetBrains Mono. New: metric strip, toolbar system,
   ops tables, bulk dock, slide-over drawer, queue board,
   method cards, revenue strip, storage pressure widget.
   ============================================================ */

:root {
  /* Surfaces — warm neutral, not cold gray */
  --bg-body: #f5f6f4;
  --bg-surface: #ffffff;
  --bg-sidebar: #fafaf9;
  --bg-elevated: #ffffff;
  --bg-hover: #f1f2ef;
  --bg-active: #eaf7f5;
  --bg-subtle: #fafbfa;

  /* Text (muted darkened vs v2 for >= 4.5:1 on white) */
  --text-primary: #0e1b1a;
  --text-secondary: #3a4a48;
  --text-muted: #5d6b68;
  --text-placeholder: #96a29f;

  /* Borders */
  --border-color: #e4e7e3;
  --border-strong: #d2d7d2;
  --divider: #eef0ec;

  /* Accent — deep teal (restrained) */
  --accent-50: #eaf7f5;
  --accent-100: #d2ede8;
  --accent-200: #a6dbd3;
  --accent-400: #2ba193;
  --accent-600: #0e7c72;
  --accent-700: #0b5f58;
  --accent-800: #094d47;
  --accent-900: #083f3b;

  /* Semantic — tuned to sit beside teal */
  --success-bg: #edf7ef;
  --success-text: #15803d;
  --success-border: #cde8d4;
  --warning-bg: #fdf6ea;
  --warning-text: #b45309;
  --warning-border: #f3e0c2;
  --danger-bg: #fdf2f2;
  --danger-text: #b91c1c;
  --danger-border: #f3cccc;
  --info-bg: #eef5fb;
  --info-text: #1e5f8e;
  --info-border: #cfe2f0;

  /* Channels (customs) */
  --channel-green: #15803d;
  --channel-yellow: #b45309;
  --channel-red: #b91c1c;

  /* v3 — nav active pill */
  --nav-active-bg: var(--accent-600);
  --nav-active-fg: #ffffff;

  /* v3 — frosted bulk dock */
  --dock-bg: rgba(255, 255, 255, 0.86);
  --dock-border: rgba(14, 27, 26, 0.14);

  /* v3 — overlays */
  --overlay: rgba(6, 38, 35, 0.45);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows — reserved for elevated surfaces only */
  --shadow-xs: 0 1px 2px 0 rgba(14, 27, 26, 0.04);
  --shadow-sm: 0 1px 2px 0 rgba(14, 27, 26, 0.05), 0 1px 3px 0 rgba(14, 27, 26, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(14, 27, 26, 0.08), 0 2px 6px -2px rgba(14, 27, 26, 0.05);
  --shadow-lg: 0 12px 32px -4px rgba(14, 27, 26, 0.12), 0 4px 12px -2px rgba(14, 27, 26, 0.06);

  --transition: 140ms cubic-bezier(0.4, 0, 0.2, 1);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
}

html.dark {
  --bg-body: #0c1413;
  --bg-surface: #131d1c;
  --bg-sidebar: #0f1817;
  --bg-elevated: #182322;
  --bg-hover: #1a2524;
  --bg-active: #15302d;
  --bg-subtle: #101a19;

  --text-primary: #ecf2f0;
  --text-secondary: #a8b5b2;
  --text-muted: #7f8f8b;
  --text-placeholder: #52615f;

  --border-color: #23302e;
  --border-strong: #324340;
  --divider: #1c2725;

  --accent-50: #15302d;
  --accent-100: #18403c;
  --accent-200: #1c504a;
  --accent-400: #3cb3a5;
  --accent-600: #2ba193;
  --accent-700: #4fc3b5;
  --accent-800: #7ad4c8;
  --accent-900: #a9e4db;

  --success-bg: rgba(21, 128, 61, 0.16);
  --success-text: #4ade80;
  --success-border: rgba(74, 222, 128, 0.2);
  --warning-bg: rgba(180, 83, 9, 0.16);
  --warning-text: #fbbf24;
  --warning-border: rgba(251, 191, 36, 0.2);
  --danger-bg: rgba(185, 28, 28, 0.16);
  --danger-text: #f87171;
  --danger-border: rgba(248, 113, 113, 0.2);
  --info-bg: rgba(30, 95, 142, 0.2);
  --info-text: #60a5fa;
  --info-border: rgba(96, 165, 250, 0.2);

  --nav-active-bg: var(--accent-600);
  --nav-active-fg: #05231f;

  --dock-bg: rgba(23, 34, 33, 0.88);
  --dock-border: rgba(255, 255, 255, 0.1);

  --overlay: rgba(0, 0, 0, 0.55);

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35), 0 1px 3px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4), 0 2px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.5), 0 4px 12px -2px rgba(0, 0, 0, 0.35);
}

/* ---------- Base ---------- */
html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

* { box-sizing: border-box; }

::selection { background: var(--accent-100); color: var(--accent-900); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; border: 2px solid var(--bg-body); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* v3 — accessible focus ring on everything interactive */
:focus-visible {
  outline: 2px solid var(--accent-600);
  outline-offset: 2px;
  border-radius: 4px;
}

/* v3 — native controls follow the accent */
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent-600); cursor: pointer; }

.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 256px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
}

.main-area {
  flex: 1;
  margin-left: 256px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.content-area {
  flex: 1;
  padding: 28px 32px 64px;
  max-width: 1600px;
  width: 100%;
}

/* ---------- Brand ---------- */
.brand {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
  color: var(--text-primary);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent-900);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

/* ---------- Nav ---------- */
.nav-section {
  padding: 18px 18px 6px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  margin: 1px 10px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  transition: var(--transition);
  position: relative;
}

.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }

/* v3 — active link is a filled accent pill */
.nav-link.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-fg);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.nav-icon {
  font-size: 17px;
  width: 20px;
  text-align: center;
  color: var(--text-muted);
  transition: var(--transition);
}

.nav-link:hover .nav-icon { color: var(--text-secondary); }
.nav-link.active .nav-icon { color: var(--nav-active-fg); opacity: 0.92; }

.nav-badge {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-variant-numeric: tabular-nums;
}
.nav-badge.live { background: var(--accent-50); color: var(--accent-700); border: 1px solid var(--accent-100); }
.nav-link.active .nav-badge { background: rgba(255, 255, 255, 0.2); color: var(--nav-active-fg); border-color: transparent; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

/* v3 — storage pressure widget (above the user pill) */
.storage-widget {
  margin: 0 2px 10px;
  padding: 11px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}
.sw-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 8px; letter-spacing: 0.2px;
}
.sw-head i { color: var(--accent-600); font-size: 14px; }
.sw-head .sw-val { margin-left: auto; font-family: var(--font-mono); font-weight: 700; font-size: 12px; color: var(--text-primary); }
.sw-sub { font-size: 10.5px; color: var(--text-muted); margin-top: 6px; font-variant-numeric: tabular-nums; }

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  transition: var(--transition);
  cursor: pointer;
}

.user-pill:hover { background: var(--bg-hover); border-color: var(--border-color); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-700);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

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

.eyebrow {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--accent-700);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 6px 0 0;
}

/* ---------- Card ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: var(--transition);
}

.card-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.1px;
}

.card-title i { color: var(--accent-600); font-size: 16px; }

.card-body { padding: 18px; }

.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--divider);
  background: var(--bg-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---------- Stat card (kept from v2 for secondary pages) ---------- */
.stat {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-bottom: 8px;
}

.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.stat-delta.up { color: var(--success-text); }
.stat-delta.down { color: var(--danger-text); }

/* ============================================================
   v3 — METRIC STRIP (replaces KPI card rows above busy tables)
   ============================================================ */
.metric-strip {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.metric-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-xs);
  font-family: inherit;
  text-align: left;
  min-width: 0;
}

.metric-chip:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.metric-chip:active { transform: translateY(0); }
.metric-chip[aria-pressed="true"] {
  background: var(--accent-50);
  border-color: var(--accent-600);
  box-shadow: inset 0 0 0 1px var(--accent-600);
}

.metric-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.metric-dot.accent { background: var(--accent-600); }
.metric-dot.success { background: var(--success-text); }
.metric-dot.warning { background: var(--warning-text); }
.metric-dot.danger { background: var(--danger-text); }
.metric-dot.info { background: var(--info-text); }
.metric-dot.neutral { background: var(--text-placeholder); }

.metric-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.metric-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); line-height: 1.25; white-space: nowrap; }
.metric-chip[aria-pressed="true"] .metric-label { color: var(--accent-800); font-weight: 600; }
.metric-delta { font-size: 10.5px; font-weight: 600; line-height: 1.2; color: var(--text-muted); white-space: nowrap; }
.metric-delta.up { color: var(--success-text); }
.metric-delta.down { color: var(--danger-text); }

.metric-count {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  padding-left: 4px;
}

/* ============================================================
   v3 — TOOLBAR SYSTEM (saved views + search + filter chips)
   ============================================================ */
.toolbar {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}

.toolbar-main {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--divider);
  flex-wrap: wrap;
}

.view-tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.view-tabs::-webkit-scrollbar { display: none; }

.view-tab {
  position: relative;
  padding: 12px 12px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
  margin-bottom: -1px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.view-tab:hover { color: var(--text-primary); }
.view-tab.active { color: var(--accent-700); border-bottom-color: var(--accent-600); }

.vt-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-placeholder);
  margin-left: 5px;
  font-variant-numeric: tabular-nums;
}
.view-tab.active .vt-count { color: var(--accent-600); }

.toolbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 8px 0; }

/* inline search with keyboard hint */
.search-field { position: relative; width: 264px; }
.search-field input {
  width: 100%;
  padding: 7px 52px 7px 31px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}
.search-field input:focus { background: var(--bg-surface); border-color: var(--accent-600); box-shadow: 0 0 0 3px var(--accent-50); }
.search-field input::placeholder { color: var(--text-placeholder); }
.search-field > i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; pointer-events: none; }

.kbd {
  display: inline-block;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  line-height: 1.5;
}
.search-field .kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }

/* active filter chips row */
.filter-chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  flex-wrap: wrap;
}
.filter-chip-row[hidden] { display: none; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-50);
  border: 1px solid var(--accent-100);
  color: var(--accent-800);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}
.filter-chip .fc-x {
  width: 16px; height: 16px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: inherit;
  font-size: 11px; cursor: pointer; transition: var(--transition);
  padding: 0;
}
.filter-chip .fc-x:hover { background: var(--accent-100); }

.link-btn {
  background: none; border: none;
  color: var(--accent-700);
  font-size: 12px; font-weight: 600;
  cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-family: inherit;
}
.link-btn:hover { background: var(--accent-50); }

/* ============================================================
   v3 — OPS DATA TABLE (dense, sticky head, ghost actions)
   ============================================================ */
.table-scroll { overflow: auto; max-height: calc(100vh - 384px); min-height: 220px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

.table-ops {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table-ops thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-subtle);
  text-align: left;
  padding: 9px 12px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table-ops thead th.num { text-align: right; }
.table-ops td { padding: 10px 12px; border-bottom: 1px solid var(--divider); color: var(--text-primary); vertical-align: middle; }
.table-ops td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-ops tbody tr { transition: background var(--transition); }
.table-ops tbody tr:hover { background: var(--bg-hover); }
.table-ops tbody tr.row-selected { background: var(--accent-50); }
.table-ops tbody tr.row-selected:hover { background: var(--accent-100); }

.cell-main { font-weight: 500; color: var(--text-primary); line-height: 1.35; }
.cell-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; line-height: 1.35; }
.cell-sub .mono { font-size: 11px; }
.cell-sub .sep { opacity: 0.6; }

.table-id { font-family: var(--font-mono); font-weight: 600; color: var(--accent-700); font-size: 12.5px; }
.table-meta { color: var(--text-muted); font-size: 11.5px; margin-top: 2px; }

/* ghost row actions — revealed on hover / keyboard focus */
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; opacity: 0; transition: opacity var(--transition); }
.table-ops tr:hover .row-actions,
.table-ops tr:focus-within .row-actions { opacity: 1; }

.ghost-btn {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-size: 15px;
  padding: 0;
}
.ghost-btn:hover { background: var(--bg-active); color: var(--accent-700); }
.ghost-btn.danger:hover { background: var(--danger-bg); color: var(--danger-text); }

/* aging chip — days in storage color ramp */
.aging {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono);
  font-size: 11.5px; font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.aging i { font-size: 12px; }
.aging.neutral { background: var(--bg-hover); color: var(--text-secondary); border-color: var(--border-color); }
.aging.info { background: var(--info-bg); color: var(--info-text); border-color: var(--info-border); }
.aging.warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.aging.danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }

/* ============================================================
   v3 — FLOATING BULK-ACTION DOCK (frosted pill)
   ============================================================ */
.bulk-dock {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px) scale(0.97);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 10px 8px 18px;
  background: var(--dock-bg);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--dock-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  z-index: 1500;
  opacity: 0;
  pointer-events: none;
  transition: 170ms cubic-bezier(0.4, 0, 0.2, 1);
}
.bulk-dock.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); pointer-events: auto; }

.bd-count { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-right: 8px; white-space: nowrap; }
.bd-count strong { font-family: var(--font-mono); font-weight: 700; color: var(--accent-700); }
.bd-sep { width: 1px; height: 20px; background: var(--border-color); margin: 0 6px; flex-shrink: 0; }

.bd-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: none; background: transparent;
  border-radius: var(--radius-full);
  font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.bd-btn i { font-size: 14px; }
.bd-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.bd-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none; background: transparent;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  margin-left: 4px;
  flex-shrink: 0;
}
.bd-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ============================================================
   v3 — SLIDE-OVER DRAWER (480px, right)
   ============================================================ */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2000;
}
.drawer-backdrop.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 480px;
  max-width: calc(100vw - 24px);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 2100;
  transform: translateX(103%);
  transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.drawer.show { transform: translateX(0); }

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.drawer-title { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; margin: 0; color: var(--text-primary); }
.drawer-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-footer {
  padding: 13px 20px;
  border-top: 1px solid var(--divider);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.drawer-section { margin-bottom: 26px; }
.drawer-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 13px;
}
.drawer-section-title .step {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent-50);
  color: var(--accent-700);
  border: 1px solid var(--accent-100);
  font-size: 10.5px;
  font-family: var(--font-mono);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.drawer-section-title .ds-hint { margin-left: auto; font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 11px; color: var(--text-placeholder); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

/* item line rows inside the drawer */
.line-item {
  display: grid;
  grid-template-columns: 1fr 62px 84px 30px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.line-item .form-control { padding: 7px 9px; font-size: 13px; }

/* live fee preview card */
.fee-preview {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.fee-preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.fee-preview-title {
  font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
}
.fp-note { font-size: 11px; color: var(--text-muted); margin-top: 8px; display: flex; align-items: center; gap: 6px; }

.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success-text);
  animation: livePulse 2.2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--success-bg); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

/* ============================================================
   v3 — QUEUE BOARD (master–detail, pickup operations)
   ============================================================ */
.queue-board {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-card {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px 12px 19px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.queue-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--rail, var(--text-placeholder));
  transition: var(--transition);
}
.queue-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.queue-card:active { transform: translateY(0); }
.queue-card.selected {
  border-color: var(--accent-600);
  background: var(--accent-50);
  box-shadow: inset 0 0 0 1px var(--accent-600);
}

.rail-neutral { --rail: var(--text-placeholder); }
.rail-info { --rail: var(--info-text); }
.rail-warning { --rail: var(--warning-text); }
.rail-danger { --rail: var(--danger-text); }

.qc-main { flex: 1; min-width: 0; }
.qc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.qc-id { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: var(--accent-700); }
.qc-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qc-meta { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.qc-wait { text-align: right; flex-shrink: 0; }
.qw-time { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; justify-content: flex-end; font-variant-numeric: tabular-nums; }
.qw-time i { font-size: 12px; color: var(--text-muted); }
.qw-label { font-size: 9.5px; color: var(--text-placeholder); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* detail panel */
/* detail panel — stays in view while the queue list scrolls with the page */
.detail-panel { min-height: 560px; display: flex; flex-direction: column; position: sticky; top: 84px; }
.dp-header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.dp-id { font-family: var(--font-mono); font-size: 20px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; line-height: 1.2; }
.dp-meta { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dp-meta .sep { opacity: 0.5; }
.dp-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.dp-tabs { padding: 0 20px; border-bottom: 1px solid var(--divider); display: flex; gap: 2px; }
.dp-tabpanes { padding: 18px 20px; flex: 1; }

/* payment state block inside detail */
.pay-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.pay-state .ps-label { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.pay-state .ps-label i { font-size: 17px; }
.pay-state.paid { background: var(--success-bg); border-color: var(--success-border); }
.pay-state.paid .ps-label i { color: var(--success-text); }
.pay-state.unpaid { background: var(--danger-bg); border-color: var(--danger-border); }
.pay-state.unpaid .ps-label i { color: var(--danger-text); }
.pay-state.pending { background: var(--warning-bg); border-color: var(--warning-border); }
.pay-state.pending .ps-label i { color: var(--warning-text); }
.pay-state .ps-sub { font-size: 11.5px; color: var(--text-muted); font-weight: 500; }

/* ============================================================
   v3 — PAYMENT METHOD CARDS (radio behavior)
   ============================================================ */
.method-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.method-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 13px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  text-align: left;
}
.method-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.method-card.selected {
  border-color: var(--accent-600);
  background: var(--accent-50);
  box-shadow: inset 0 0 0 1px var(--accent-600);
}

.method-card .mc-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  transition: var(--transition);
}
.method-card.selected .mc-icon { background: var(--bg-surface); color: var(--accent-700); }
.method-card .mc-name { font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.method-card .mc-sub { font-size: 11px; color: var(--text-muted); line-height: 1.3; }

.method-check {
  position: absolute;
  top: 10px; right: 10px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent-600);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}
.method-card.selected .method-check { display: flex; }

/* ============================================================
   v3 — REVENUE HEADER STRIP (fee payments)
   ============================================================ */
.revenue-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: 16px;
  overflow: hidden;
}
.rs-cell {
  padding: 14px 18px;
  border-right: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.rs-cell:last-child { border-right: none; }
.rs-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.rs-label i { font-size: 13px; }
.rs-value { font-family: var(--font-mono); font-size: 20px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; letter-spacing: -0.3px; white-space: nowrap; }
.rs-value .cur { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-right: 3px; }
.rs-delta { font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 4px; color: var(--text-muted); }
.rs-delta.up { color: var(--success-text); }
.rs-delta.down { color: var(--danger-text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
  font-family: inherit;
}

.btn i { font-size: 15px; }

.btn-primary { background: var(--accent-700); color: white; }
.btn-primary:hover { background: var(--accent-800); }
.btn-primary:active { background: var(--accent-900); }

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

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger { background: var(--danger-text); color: white; }
.btn-danger:hover { background: #991b1b; }

.btn-outline-danger {
  background: var(--bg-surface);
  color: var(--danger-text);
  border-color: var(--danger-border);
}
.btn-outline-danger:hover { background: var(--danger-bg); }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-sm i { font-size: 13px; }
.btn-lg { padding: 10px 18px; font-size: 14px; }

.btn-icon { padding: 0; width: 34px; height: 34px; }
.btn-icon.btn-sm { width: 28px; height: 28px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.1px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge i { font-size: 12px; }
.badge-primary { background: var(--accent-50); color: var(--accent-800); border-color: var(--accent-100); }
.badge-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.badge-info { background: var(--info-bg); color: var(--info-text); border-color: var(--info-border); }
.badge-neutral { background: var(--bg-hover); color: var(--text-muted); border-color: var(--border-color); }

/* Customs channel pills */
.channel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 800;
  color: white;
  letter-spacing: 0;
}
.channel-green { background: var(--channel-green); }
.channel-yellow { background: var(--channel-yellow); }
.channel-red { background: var(--channel-red); }

/* Dot status */
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-dot.success { background: var(--success-text); }
.status-dot.warning { background: var(--warning-text); }
.status-dot.danger { background: var(--danger-text); }
.status-dot.neutral { background: var(--text-placeholder); }
.status-dot.info { background: var(--info-text); }
.status-dot.accent { background: var(--accent-600); }

/* ---------- HS code chip ---------- */
.hs-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-800);
  background: var(--accent-50);
  border: 1px solid var(--accent-100);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* ---------- Data table (base, kept from v2) ---------- */
.table-wrapper { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table th.num { text-align: right; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--divider); color: var(--text-primary); vertical-align: middle; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.mono { font-family: var(--font-mono); font-size: 12.5px; }

.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: var(--bg-subtle); }
.table tbody tr:last-child td { border-bottom: none; }

.table-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--accent-100);
  color: var(--accent-800);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
  margin-right: 10px;
  flex-shrink: 0;
}

/* ---------- Forms ---------- */
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: 0.1px;
}

.form-label .req { color: var(--danger-text); margin-left: 2px; }

.form-control,
.form-select {
  width: 100%;
  padding: 8px 11px;
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent-600);
  box-shadow: 0 0 0 3px var(--accent-50);
}

.form-control::placeholder { color: var(--text-placeholder); }
.form-control:disabled,
.form-control[readonly] { background: var(--bg-subtle); color: var(--text-muted); }

.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }

textarea.form-control { resize: vertical; min-height: 80px; }

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-md) 0 0 var(--radius-md); border-right: none; }
.input-group .btn { border-radius: 0 var(--radius-md) var(--radius-md) 0; }

/* ---------- Global search (topbar) ---------- */
.search-global { position: relative; width: 300px; }
.search-global input {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 7px 12px 7px 34px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}
.search-global input:focus { background: var(--bg-surface); border-color: var(--accent-600); box-shadow: 0 0 0 3px var(--accent-50); }
.search-global input::placeholder { color: var(--text-placeholder); }
.search-global i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 15px; }
.search-global .kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 4px;
  padding: 1px 6px; font-size: 10px; color: var(--text-muted); font-family: var(--font-mono);
}

.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--transition); position: relative;
  font-size: 16px;
  padding: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger-text); border: 2px solid var(--bg-surface); }

/* ---------- Dropdown ---------- */
.dropdown-menu {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 5px;
  min-width: 200px;
  display: none;
  position: absolute;
  z-index: 1000;
  /* a wheel/touch drag hitting the menu's scroll edge must not chain into the
     table or page scroller — that scroll would close the menu mid-read */
  overscroll-behavior: contain;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: var(--radius-md);
  font-size: 13px; color: var(--text-secondary); text-decoration: none; transition: var(--transition);
  cursor: pointer;
  border: none; background: none; width: 100%; text-align: left; font-family: inherit;
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item i { font-size: 14px; color: var(--text-muted); }
.dropdown-item:hover i { color: var(--accent-600); }
.dropdown-item.danger { color: var(--danger-text); }
.dropdown-divider { height: 1px; background: var(--divider); margin: 5px 0; }
.dropdown-header { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); padding: 6px 9px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  z-index: 2000; display: none; align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px; max-height: 90vh; display: flex; flex-direction: column;
  animation: modalIn 160ms cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { padding: 16px 18px; border-bottom: 1px solid var(--divider); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-header h3 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--divider); display: flex; justify-content: flex-end; gap: 8px; background: var(--bg-subtle); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

/* Keep pickup handout actions visible when a collection has many item lines. */
.handout-modal-box { overflow: hidden; }
.handout-modal-box > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
}
.handout-modal-box .modal-header,
.handout-modal-box .modal-footer { flex: 0 0 auto; }
.handout-modal-box .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
}

/* ---------- Signature: Tax / fee breakdown ---------- */
.tax-breakdown { width: 100%; font-size: 13px; }
.tax-breakdown .row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px dashed var(--divider);
}
.tax-breakdown .row:last-child { border-bottom: none; }
.tax-breakdown .row .label { color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.tax-breakdown .row .label .pct { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.tax-breakdown .row .amount { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 500; color: var(--text-primary); }
.tax-breakdown .row.subtotal .label { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.tax-breakdown .row.subtotal .amount { color: var(--text-secondary); font-size: 12.5px; }
.tax-breakdown .row.total { padding: 14px 0 4px; border-top: 1.5px solid var(--border-color); border-bottom: none; margin-top: 6px; }
.tax-breakdown .row.total .label { color: var(--text-primary); font-weight: 700; font-size: 14px; }
.tax-breakdown .row.total .amount { color: var(--accent-800); font-weight: 700; font-size: 18px; }

/* change / balance line under amount received */
.change-line {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  font-size: 13px;
  margin-top: 12px;
}
.change-line .cl-label { color: var(--text-muted); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.change-line .cl-value { font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.change-line.positive { background: var(--success-bg); border-color: var(--success-border); }
.change-line.positive .cl-value { color: var(--success-text); }
.change-line.negative { background: var(--danger-bg); border-color: var(--danger-border); }
.change-line.negative .cl-value { color: var(--danger-text); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 1px; background: var(--border-color); }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ''; position: absolute; left: -19px; top: 3px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg-surface); border: 2px solid var(--accent-600); z-index: 2;
}
.timeline-item.success::before { border-color: var(--success-text); }
.timeline-item.warning::before { border-color: var(--warning-text); }
.timeline-item.danger::before { border-color: var(--danger-text); }
.timeline-item.neutral::before { border-color: var(--text-placeholder); }
.timeline-item.info::before { border-color: var(--info-text); }
.timeline-time { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.timeline-text { font-size: 13px; color: var(--text-primary); }
.timeline-text strong { font-weight: 600; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 3px; list-style: none; padding: 0; margin: 0; }
.page-item a {
  display: flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary); text-decoration: none; transition: var(--transition);
  border: 1px solid transparent;
}
.page-item a:hover { background: var(--bg-hover); color: var(--text-primary); }
.page-item.active a { background: var(--accent-700); color: white; }
.page-item.disabled a { color: var(--text-placeholder); cursor: not-allowed; }

/* ---------- Progress ---------- */
.progress { height: 5px; background: var(--bg-hover); border-radius: var(--radius-full); overflow: hidden; }
.progress > div { height: 100%; border-radius: var(--radius-full); background: var(--accent-600); transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); }
.progress.success > div { background: var(--success-text); }
.progress.warning > div { background: var(--warning-text); }
.progress.danger > div { background: var(--danger-text); }

/* ---------- Segmented control ---------- */
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--bg-subtle); border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.segmented button {
  padding: 5px 12px; border-radius: var(--radius-sm); border: none; background: transparent;
  color: var(--text-muted); font-size: 12.5px; font-weight: 600; cursor: pointer; transition: var(--transition); font-family: inherit;
}
.segmented button:hover { color: var(--text-primary); }
.segmented button.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-xs); }

/* ---------- Toast ---------- */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 4000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-600);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  padding: 12px 14px; display: flex; align-items: center; gap: 11px;
  animation: toastIn 200ms cubic-bezier(0.4, 0, 0.2, 1); min-width: 280px; max-width: 380px;
}
.toast.success { border-left-color: var(--success-text); }
.toast.error { border-left-color: var(--danger-text); }
.toast.warning { border-left-color: var(--warning-text); }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
.toast-icon { font-size: 17px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--success-text); }
.toast.error .toast-icon { color: var(--danger-text); }
.toast.warning .toast-icon { color: var(--warning-text); }
.toast-title { font-weight: 600; font-size: 13px; color: var(--text-primary); }
.toast-text { font-size: 12px; color: var(--text-secondary); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 38px; margin-bottom: 12px; color: var(--border-strong); }
.empty-state h4 { color: var(--text-primary); font-weight: 600; margin: 0 0 4px; font-size: 14px; }
.empty-state p { font-size: 12.5px; margin: 0; }

/* ---------- Divider ---------- */
.hr { height: 1px; background: var(--divider); border: none; margin: 20px 0; }

/* ---------- Utility ---------- */
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-accent { color: var(--accent-700) !important; }
.text-success { color: var(--success-text) !important; }
.text-danger { color: var(--danger-text) !important; }
.text-warning { color: var(--warning-text) !important; }
.right { text-align: right; }
.center { text-align: center; }

.fade-in { animation: fadeIn 220ms cubic-bezier(0.4, 0, 0.2, 1) forwards; opacity: 0; }
@keyframes fadeIn { to { opacity: 1; } }

/* ---------- Command palette (carried forward from v2) ---------- */
.command-palette {
  position: fixed; top: 72px; left: 50%;
  transform: translateX(-50%) scale(0.98);
  width: 560px; max-width: 92vw;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  opacity: 0; pointer-events: none;
  transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.command-palette.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) scale(1); }
.command-palette input {
  width: 100%; border: none; border-bottom: 1px solid var(--divider);
  padding: 14px 16px 14px 42px; font-size: 14px;
  background: transparent; color: var(--text-primary); outline: none;
}
.command-palette input::placeholder { color: var(--text-placeholder); }
.command-palette .results { max-height: 360px; overflow-y: auto; padding: 6px; }
.command-palette .result-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-md);
  color: var(--text-secondary); cursor: pointer; transition: var(--transition);
  font-size: 13px;
}
.command-palette .result-item:hover,
.command-palette .result-item.active { background: var(--bg-hover); color: var(--text-primary); }
.command-palette .result-item > i { font-size: 16px; color: var(--text-muted); }
.command-palette .result-item:hover > i { color: var(--accent-600); }
.command-palette-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 2999; display: none; }
.command-palette-backdrop.show { display: block; }

/* ---------- Notification drawer (carried forward from v2) ---------- */
.notification-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 340px; max-width: 90vw;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 2500;
  transform: translateX(100%);
  transition: var(--transition);
  display: flex; flex-direction: column;
}
.notification-drawer.show { transform: translateX(0); }
.notification-drawer-header {
  padding: 16px 18px; border-bottom: 1px solid var(--divider);
  display: flex; justify-content: space-between; align-items: center;
}
.notification-drawer-header h3 { margin: 0; font-size: 15px; font-weight: 700; }
.notification-drawer-body { flex: 1; overflow-y: auto; padding: 10px; }
.notification-item {
  display: flex; gap: 10px; padding: 10px;
  border-radius: var(--radius-md); transition: var(--transition); margin-bottom: 4px;
}
.notification-item:hover { background: var(--bg-hover); }
.notification-item .icon-wrap {
  width: 32px; height: 32px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0; background: var(--bg-hover);
}
.notification-item .content { flex: 1; }
.notification-item .title { font-weight: 600; font-size: 13px; color: var(--text-primary); margin-bottom: 1px; }
.notification-item .text { font-size: 12px; color: var(--text-secondary); margin-bottom: 3px; line-height: 1.4; }
.notification-item .time { font-size: 11px; color: var(--text-muted); }

/* ---------- Row options dropdown (inside tables) ---------- */
.options-cell { position: relative; }
.options-dropdown {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--bg-elevated); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  padding: 4px; min-width: 170px; display: none; z-index: 80;
}
.options-dropdown.show { display: block; }
.options-dropdown .dropdown-item { padding: 6px 8px; font-size: 12.5px; }

/* ---------- Form section (kept from v2) ---------- */
.form-section {
  border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 18px; margin-bottom: 20px; background: var(--bg-surface);
}
.form-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
}

/* ---------- Category chips (kept from v2) ---------- */
.category-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: var(--radius-full);
  border: 1px solid var(--border-color); background: var(--bg-surface);
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; transition: var(--transition);
}
.category-chip:hover { border-color: var(--border-strong); }
.category-chip.selected { background: var(--accent-50); border-color: var(--accent-600); color: var(--accent-700); }

/* ---------- Toggle switch (kept from v2) ---------- */
.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 40px; height: 22px; background: var(--bg-hover);
  border-radius: var(--radius-full); position: relative; transition: var(--transition);
  border: 1px solid var(--border-color);
}
.toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; background: white; border-radius: 50%;
  transition: var(--transition); box-shadow: var(--shadow-xs);
}
.toggle input:checked + .toggle-track { background: var(--accent-600); border-color: var(--accent-600); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .queue-board { grid-template-columns: 1fr; }
  .revenue-strip { grid-template-columns: repeat(2, 1fr); }
  .rs-cell:nth-child(2) { border-right: none; }
  .rs-cell:nth-child(1), .rs-cell:nth-child(2) { border-bottom: 1px solid var(--divider); }
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-area { margin-left: 0; }
  .search-global { display: none; }
  .content-area { padding: 20px 16px 56px; }
  /* toolbar search stays reachable on touch: drops to its own full-width row under the view tabs */
  .toolbar-actions { flex: 1 1 100%; margin-left: 0; padding: 0 0 12px; }
  .search-field { flex: 1 1 auto; width: auto; min-width: 0; }
}

/* phones: 16px stops iOS Safari zooming into the box on focus */
@media (max-width: 640px) {
  .search-field input { font-size: 16px; }
}

/* ============================================================
   SafeZone app extensions — utilities replacing the mockups'
   Tailwind classes (kept to the exact set the ported markup uses)
   ============================================================ */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1 1 0%; min-width: 0; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.hidden { display: none !important; }
.min-w-0 { min-width: 0; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overflow-y-auto { overflow-y: auto; }
.relative { position: relative; }
.text-right { text-align: right; }

/* sidebar scroll region between brand and footer */
.sidebar-nav { flex: 1 1 0%; min-height: 0; overflow-y: auto; padding-bottom: 8px; }

/* anchored menus that open upward (sidebar user pill, row options) */
.menu-anchor { position: relative; }
.menu-anchor .dropdown-menu { bottom: calc(100% + 6px); top: auto; left: 0; right: auto; }
.menu-anchor.drop-right .dropdown-menu { left: auto; right: 0; }

/* mobile-only topbar button */
.sidebar-toggle { display: none; }
@media (max-width: 1024px) {
  .sidebar-toggle { display: flex; }
}

/* table checkbox column */
.row-check { width: 34px; text-align: center; }
.row-check input { width: 15px; height: 15px; vertical-align: middle; }

/* inline progress under days cell */
.cell-progress { height: 4px; background: var(--bg-hover); border-radius: var(--radius-full); overflow: hidden; margin-top: 5px; width: 96px; }
.cell-progress > div { height: 100%; border-radius: var(--radius-full); }
.cell-progress.success > div { background: var(--success-text); }
.cell-progress.warning > div { background: var(--warning-text); }
.cell-progress.danger > div { background: var(--danger-text); }

/* ---------- two-column form layout with sticky side rail (form pages) ---------- */
.form-layout-2col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  align-items: start;
}
.form-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* rail sticks just under the topbar; drops under the form on narrow screens */
.form-rail {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-rail .card { min-width: 0; }
.form-rail .card-body { padding: 16px; }
.form-rail .form-section-title { margin-bottom: 12px; }
@media (max-width: 1100px) {
  .form-layout-2col { grid-template-columns: 1fr; }
  .form-rail { position: static; }
}

/* compact 3-col form grid (collapses to 2 then 1) */
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1280px) {
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .form-grid.cols-3, .form-grid { grid-template-columns: 1fr; }
}

/* chip pill row (Good Category etc.) */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
/* chips carry a visually hidden checkbox — the checked state posts the value,
   the .selected class mirrors it visually (kept in sync by the page script) */
.category-chip input[type="checkbox"] {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.category-chip input[type="checkbox"]:focus-visible + .chip-text { outline: 2px solid var(--accent-600); outline-offset: 2px; border-radius: 4px; }

/* rail content helpers */
.rail-hint { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; margin: 0 0 10px; }
.rail-hint:last-child { margin-bottom: 0; }
.rail-hint strong { color: var(--text-primary); font-weight: 600; }
.rail-list { display: flex; flex-direction: column; gap: 2px; }
.rail-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-md);
  font-size: 12.5px; color: var(--text-secondary); text-decoration: none;
}
.rail-item:hover { background: var(--bg-hover); color: var(--accent-700); }
.rail-item-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.rail-qr { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 0 2px; }
.rail-qr i { font-size: 96px; line-height: 1; color: var(--text-muted); }
.rail-caption { font-size: 12px; color: var(--text-muted); margin: 0; }
.rail-meta { display: flex; flex-direction: column; gap: 10px; }
.rail-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.rail-meta-row .k { color: var(--text-muted); }
.rail-meta-row .v { color: var(--text-primary); font-weight: 600; text-align: right; }
.rail-empty { font-size: 12.5px; color: var(--text-muted); margin: 0; }

/* dropdown stacking fix — `.fade-in` used animation-fill-mode: forwards, which keeps the
   animation applied forever and pins every faded-in element (page headers, table cards) in
   its own stacking context. Dropdown menus anchored inside them (Export menu, row action
   menus) were then painted UNDER later siblings (metric chips) and the sticky topbar.
   Re-declared without fill-mode: the element returns to the root stacking context after
   the 220ms entrance, so .dropdown-menu's z-index works again. */
.fade-in { animation: szFadeIn 220ms cubic-bezier(0.4, 0, 0.2, 1); opacity: 1; }
@keyframes szFadeIn { from { opacity: 0; } to { opacity: 1; } }
