/* ==========================================================================
   Fotoboom — Rediseño 2026
   Sistema de diseño: Linear/Vercel inspired, minimalista, denso pero claro.
   ========================================================================== */

:root {
  /* Brand */
  --fb-yellow: #FFB800;
  --fb-yellow-soft: #FFF4D1;
  --fb-yellow-ink: #0A0A0A;

  /* Theme A — Linear (cool grayscale) */
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --bg-subtle: #f4f4f5;
  --bg-hover: #f4f4f5;
  --bg-active: #ececef;
  --border: #e5e7eb;
  --border-strong: #d4d4d8;
  --border-subtle: #f0f0f2;

  --text: #0a0a0a;
  --text-2: #404040;
  --text-3: #737373;
  --text-4: #a3a3a3;
  --text-5: #d4d4d8;

  --accent: #18181b;        /* neutral graphite as primary action */
  --accent-hover: #27272a;
  --accent-fg: #fafafa;

  --success: #15803d;
  --success-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --info: #1e40af;
  --info-bg: #dbeafe;

  /* Sizing */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --row-h: 36px;
  --row-h-compact: 32px;
  --row-h-cozy: 44px;

  --sidebar-w: 232px;
  --topbar-h: 48px;

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.04);
  --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.06), 0 1px 2px rgb(0 0 0 / 0.04);
  --shadow-md: 0 4px 12px -2px rgb(0 0 0 / 0.08), 0 2px 4px -1px rgb(0 0 0 / 0.04);
  --shadow-lg: 0 12px 32px -8px rgb(0 0 0 / 0.12), 0 4px 8px -2px rgb(0 0 0 / 0.06);
  --shadow-pop: 0 24px 48px -12px rgb(0 0 0 / 0.18);
}

/* Theme B — warmer Stripe-like */
[data-theme="b"] {
  --bg: #fbfaf7;
  --bg-elev: #ffffff;
  --bg-subtle: #f5f3ed;
  --bg-hover: #f3f0e8;
  --bg-active: #ebe7da;
  --border: #e8e3d3;
  --border-strong: #d6cfba;
  --border-subtle: #efebe0;
  --text: #1a1714;
  --text-2: #46413a;
  --text-3: #78706a;
  --text-4: #aaa39a;
  --text-5: #d8d2c5;
  --accent: #1a1714;
  --accent-hover: #2e2924;
  --accent-fg: #fbfaf7;
}

/* Dark mode */
[data-mode="dark"] {
  --bg: #09090b;
  --bg-elev: #0f0f11;
  --bg-subtle: #18181b;
  --bg-hover: #1c1c1f;
  --bg-active: #232327;
  --border: #232327;
  --border-strong: #2e2e33;
  --border-subtle: #1a1a1d;
  --text: #fafafa;
  --text-2: #d4d4d8;
  --text-3: #a1a1aa;
  --text-4: #71717a;
  --text-5: #3f3f46;
  --accent: #fafafa;
  --accent-hover: #e4e4e7;
  --accent-fg: #09090b;
  --success-bg: rgba(22, 163, 74, 0.15);
  --warn-bg: rgba(180, 83, 9, 0.18);
  --danger-bg: rgba(185, 28, 28, 0.18);
  --info-bg: rgba(30, 64, 175, 0.20);
}

[data-mode="dark"][data-theme="b"] {
  --bg: #14110d;
  --bg-elev: #1a1611;
  --bg-subtle: #221d16;
  --bg-hover: #2a241c;
  --border: #2e2820;
  --border-strong: #3a3328;
  --text: #faf6ec;
  --text-2: #d4cdb9;
  --text-3: #a8a08b;
}

/* ==========================================================================
   Base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01", "ss03";
}

#root { min-height: 100vh; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

a { color: inherit; text-decoration: none; }

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

/* ==========================================================================
   Layout
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.app[data-no-sidebar="true"] {
  grid-template-columns: 1fr;
}

/* Sidebar */
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  height: var(--topbar-h);
}

.sb-logo {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--fb-yellow-ink);
}
.sb-logo .dot { color: var(--fb-yellow); }
[data-mode="dark"] .sb-logo { color: var(--text); }

.sb-org {
  font-size: 11px;
  color: var(--text-3);
  margin-left: auto;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-subtle);
}

.sb-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.sb-search-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-3);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.1s;
}
.sb-search-btn:hover {
  background: var(--bg-hover);
  color: var(--text-2);
}
.sb-search-btn .kbd {
  margin-left: auto;
  font-family: var(--font);
  font-size: 10px;
  padding: 1px 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-3);
}

.sb-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sb-group-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-4);
  text-transform: uppercase;
  padding: 0 8px 4px;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: 12.5px;
  color: var(--text-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.08s;
  user-select: none;
}
.sb-item:hover { background: var(--bg-hover); color: var(--text); }
.sb-item.active {
  background: var(--bg-active);
  color: var(--text);
  font-weight: 500;
}
.sb-item .ic { color: var(--text-3); flex-shrink: 0; }
.sb-item.active .ic { color: var(--text); }
.sb-item .count {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}

.sb-footer {
  padding: 8px;
  border-top: 1px solid var(--border-subtle);
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.sb-user:hover { background: var(--bg-hover); }
.sb-user .avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fb-yellow), #ff9500);
  color: #000;
  font-size: 11px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sb-user .name { font-size: 12.5px; color: var(--text); font-weight: 500; }
.sb-user .role { font-size: 10.5px; color: var(--text-4); }

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

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  z-index: 10;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-3);
}
.breadcrumbs .crumb { color: var(--text-3); }
.breadcrumbs .crumb.current { color: var(--text); font-weight: 500; }
.breadcrumbs .sep { color: var(--text-5); }

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tb-icon-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  transition: all 0.1s;
  position: relative;
}
.tb-icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.tb-icon-btn .dot-notif {
  position: absolute;
  top: 6px; right: 7px;
  width: 6px; height: 6px;
  background: var(--fb-yellow);
  border-radius: 50%;
  border: 1.5px solid var(--bg-elev);
}

/* Content */
.content {
  padding: 24px 28px 80px;
  max-width: 100%;
  min-width: 0;
}

.content.compact { padding: 16px 20px 60px; }

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

.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 4px 0;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin: 0;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.1s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-hover); }

.btn.yellow {
  background: var(--fb-yellow);
  color: var(--fb-yellow-ink);
  border-color: var(--fb-yellow);
  font-weight: 600;
}
.btn.yellow:hover { background: #f5a900; }

.btn.danger {
  color: var(--danger);
  border-color: var(--danger-bg);
  background: var(--danger-bg);
}

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

.btn.sm { padding: 4px 8px; font-size: 11.5px; }
.btn.icon { padding: 5px; }

.btn-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  overflow: hidden;
}
.btn-group .btn {
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}
.btn-group .btn:last-child { border-right: none; }
.btn-group .btn.active { background: var(--bg-active); color: var(--text); }

/* ==========================================================================
   Inputs
   ========================================================================== */

.input {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  transition: border-color 0.1s, box-shadow 0.1s;
  min-height: 30px;
}
.input:focus-within {
  border-color: var(--text-3);
  box-shadow: 0 0 0 3px var(--bg-hover);
}
.input input, .input select {
  border: none;
  outline: none;
  background: transparent;
  padding: 4px 0;
  flex: 1;
  width: 100%;
  font-size: 12.5px;
  color: var(--text);
  min-width: 0;
}
.input input::placeholder { color: var(--text-4); }
.input .ic { color: var(--text-4); flex-shrink: 0; }
.input.sm { min-height: 26px; padding: 0 6px; }
.input.sm input { font-size: 11.5px; padding: 2px 0; }

.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
}

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

/* Toggle */
.switch {
  width: 30px; height: 18px;
  background: var(--border-strong);
  border-radius: 999px;
  position: relative;
  transition: background 0.15s;
  cursor: pointer;
  flex-shrink: 0;
  border: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(12px); }

/* Checkbox */
.check {
  width: 14px; height: 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  background: var(--bg-elev);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.1s;
}
.check.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.check:hover { border-color: var(--text-3); }

/* ==========================================================================
   Cards / Panels
   ========================================================================== */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.card-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.card-header .sub {
  font-size: 11.5px;
  color: var(--text-3);
}

.card-body { padding: 14px; }
.card-body.flush { padding: 0; }

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 500;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-2);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.5;
}
.badge.success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge.yellow { background: var(--fb-yellow-soft); color: #806100; border-color: transparent; }
[data-mode="dark"] .badge.yellow { color: var(--fb-yellow); background: rgba(255, 184, 0, 0.12); }

.badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.tbl-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.tbl-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.tbl-toolbar .input { min-height: 28px; max-width: 280px; }

.tbl-scroll {
  overflow: auto;
  max-height: calc(100vh - 240px);
}

.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tbl thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-elev);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-align: left;
  padding: 0 10px;
  height: 32px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.tbl thead th.sortable { cursor: pointer; }
.tbl thead th.sortable:hover { color: var(--text); }
.tbl thead th .sort-ic { opacity: 0; margin-left: 3px; }
.tbl thead th.sortable:hover .sort-ic { opacity: 0.5; }
.tbl thead th.sorted .sort-ic { opacity: 1; }

.tbl tbody td {
  padding: 0 10px;
  height: var(--row-h);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--text-2);
  white-space: nowrap;
}

.tbl[data-density="compact"] tbody td { height: var(--row-h-compact); font-size: 11.5px; }
.tbl[data-density="cozy"] tbody td { height: var(--row-h-cozy); }

.tbl tbody tr { transition: background 0.05s; }
.tbl tbody tr:hover { background: var(--bg-hover); }
.tbl tbody tr.selected { background: var(--bg-active); }
.tbl tbody tr:last-child td { border-bottom: none; }

.tbl td.num, .tbl th.num { text-align: right; }
.tbl td.center, .tbl th.center { text-align: center; }
.tbl td.strong { color: var(--text); font-weight: 500; }
.tbl td.muted { color: var(--text-4); }
.tbl td.mono { font-family: var(--font-mono); font-size: 11px; }

.tbl .row-actions {
  opacity: 0;
  display: inline-flex;
  gap: 2px;
}
.tbl tr:hover .row-actions { opacity: 1; }

.tbl-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11.5px;
  color: var(--text-3);
  gap: 12px;
  flex-wrap: wrap;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 2px;
}
.pagination .pg {
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  font-size: 11.5px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-2);
}
.pagination .pg:hover { background: var(--bg-hover); }
.pagination .pg.active {
  background: var(--bg-active);
  color: var(--text);
  font-weight: 500;
}
.pagination .pg:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .ellipsis { padding: 0 4px; color: var(--text-4); }

/* Trend indicators in tables */
.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
}
.trend.up { color: var(--success); }
.trend.down { color: var(--danger); }
.trend.flat { color: var(--text-4); }

/* Stock bar */
.stock-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.stock-bar .bar {
  width: 32px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.stock-bar .fill {
  height: 100%;
  background: var(--success);
  border-radius: 2px;
}
.stock-bar.low .fill { background: var(--warn); }
.stock-bar.out .fill { background: var(--danger); width: 100% !important; opacity: 0.3; }

/* ==========================================================================
   KPI cards
   ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.kpi:hover { border-color: var(--border-strong); }
.kpi .label {
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.kpi .label .ic { color: var(--text-4); }
.kpi .val {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.kpi .delta { font-size: 11.5px; }
.kpi .spark { position: absolute; bottom: 0; right: 0; opacity: 0.5; pointer-events: none; }

/* ==========================================================================
   Modal
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease-out;
}

.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 100%;
  max-height: 92vh;
  overflow: auto;
  animation: popIn 0.18s ease-out;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-title { font-size: 15px; font-weight: 600; margin: 0 0 2px 0; color: var(--text); }
.modal-sub { font-size: 12px; color: var(--text-3); }
.modal-close {
  background: transparent; border: none; padding: 4px; cursor: pointer;
  color: var(--text-3); border-radius: 4px;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }

.modal-body { padding: 18px 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-subtle);
}

/* Drawer */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 90;
  animation: fadeIn 0.15s;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 460px; max-width: 100vw;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 91;
  display: flex; flex-direction: column;
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* ==========================================================================
   Toast
   ========================================================================== */

.toast-stack {
  position: fixed;
  bottom: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 12.5px;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 8px;
  min-width: 240px;
  pointer-events: auto;
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast.success .ic { color: var(--success); }
.toast.danger .ic { color: var(--danger); }

/* ==========================================================================
   Command Palette
   ========================================================================== */

.cmdk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  animation: fadeIn 0.12s;
}
.cmdk {
  width: 560px; max-width: 92vw;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: popIn 0.15s;
}
.cmdk-input-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.cmdk-input-wrap input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14px; color: var(--text);
}
.cmdk-input-wrap input::placeholder { color: var(--text-4); }
.cmdk-list { max-height: 360px; overflow-y: auto; padding: 6px; }
.cmdk-group { font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em; color: var(--text-4); text-transform: uppercase; padding: 6px 8px; }
.cmdk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.cmdk-item .ic { color: var(--text-3); }
.cmdk-item .kbd { margin-left: auto; font-size: 10px; color: var(--text-4); }
.cmdk-item.active { background: var(--bg-active); }
.cmdk-item.active .ic { color: var(--text); }

/* ==========================================================================
   Login & auth
   ========================================================================== */

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.auth-form-side .inner {
  width: 100%;
  max-width: 340px;
}

.auth-form-side .brand {
  margin-bottom: 32px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.auth-form-side .brand .dot { color: var(--fb-yellow); }

.auth-form-side h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.auth-form-side p.lead {
  font-size: 13px;
  color: var(--text-3);
  margin: 0 0 24px;
}

.auth-aside {
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
  color: #fafafa;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
[data-theme="b"] .auth-aside {
  background: linear-gradient(135deg, #1a1714 0%, #2a241c 100%);
}
.auth-aside::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255, 184, 0, 0.10), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255, 184, 0, 0.06), transparent 50%);
  pointer-events: none;
}
.auth-aside .badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
  background: rgba(255, 184, 0, 0.12);
  color: var(--fb-yellow);
  border: 1px solid rgba(255, 184, 0, 0.25);
  border-radius: 999px;
  width: fit-content;
}
.auth-aside h2 {
  font-size: 36px;
  letter-spacing: -0.03em;
  font-weight: 600;
  line-height: 1.1;
  margin: 16px 0 14px;
  max-width: 460px;
}
.auth-aside p {
  font-size: 14px;
  color: rgba(250, 250, 250, 0.7);
  line-height: 1.55;
  max-width: 480px;
  margin: 0;
}

.brand-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.brand-grid .cell {
  background: rgba(0,0,0,0.3);
  padding: 18px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(250,250,250,0.55);
  min-height: 70px;
  text-align: center;
}

.auth-footer {
  position: relative; z-index: 1;
  font-size: 11.5px;
  color: rgba(250,250,250,0.45);
  display: flex; gap: 12px; align-items: center;
}

/* ==========================================================================
   Sync indicators
   ========================================================================== */
.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
  position: relative;
}
.sync-dot.ok { background: #22c55e; }
.sync-dot.err { background: #ef4444; }
.sync-dot.warn { background: #f59e0b; }
.sync-dot.idle { background: var(--text-5); }
.sync-dot.ok::after {
  content: ""; position: absolute; inset: -3px;
  border-radius: 50%; background: #22c55e;
  opacity: 0.25; animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 0.25; } 50% { transform: scale(1.6); opacity: 0; } }

/* ==========================================================================
   Charts (lightweight SVG)
   ========================================================================== */
.chart { width: 100%; height: 100%; display: block; }
.chart .grid-line { stroke: var(--border-subtle); stroke-width: 1; }
.chart .axis-label { fill: var(--text-4); font-size: 10px; }
.chart .area { fill: var(--text); fill-opacity: 0.04; }
.chart .line { fill: none; stroke: var(--text); stroke-width: 1.4; }
.chart .yellow-line { stroke: var(--fb-yellow); }
.chart .yellow-area { fill: var(--fb-yellow); fill-opacity: 0.08; }
.chart .dot { fill: var(--bg-elev); stroke: var(--text); stroke-width: 1.5; }

/* ==========================================================================
   Skeleton
   ========================================================================== */
.sk {
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--bg-hover) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: skLoad 1.4s ease-in-out infinite;
  border-radius: 4px;
}
@keyframes skLoad { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Utility */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.grow { flex: 1; }
.hidden { display: none; }
.muted { color: var(--text-3); }
.strong { color: var(--text); font-weight: 500; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  margin-bottom: 16px;
}
.tab {
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-3);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.1s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }

/* Segmented */
.seg {
  display: inline-flex;
  padding: 2px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.seg button {
  padding: 3px 8px;
  font-size: 11.5px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-3);
  cursor: pointer;
}
.seg button.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

/* Detail page grid */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}
.detail-grid.wide { grid-template-columns: 1fr 380px; }

/* Definition list */
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 16px; font-size: 12.5px; }
.dl dt { color: var(--text-3); font-weight: 500; }
.dl dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; }

/* Hover row peek */
.peek-trigger { position: relative; }
.peek-trigger:hover .peek { display: block; }
.peek {
  display: none;
  position: absolute;
  left: 0; bottom: calc(100% + 4px);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 11px;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  z-index: 5;
}

/* Card list (alternative to table) */
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.list-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: all 0.1s;
}
.list-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.list-card .lc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.list-card .lc-title { font-weight: 600; font-size: 13px; color: var(--text); }
.list-card .lc-sub { font-size: 11.5px; color: var(--text-3); }
.list-card .lc-meta { display: flex; gap: 12px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-subtle); font-size: 11px; color: var(--text-3); }
.list-card .lc-meta .v { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }

/* Avatar */
.avatar-circle {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  background: var(--bg-active);
  color: var(--text);
  flex-shrink: 0;
}
.avatar-circle.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-circle.brand { background: linear-gradient(135deg, var(--fb-yellow), #ff9500); color: #000; }

/* ==========================================================================
   Django integration layer (server-rendered specifics)
   Everything below adapts the React prototype's design system to the
   server-rendered Django app: anchors-as-nav-items, forms, messages,
   dropdowns, responsive sidebar, table column-filter row.
   ========================================================================== */

/* Sidebar items are <a> in Django; reset link styles */
a.sb-item, a.sb-item:hover { text-decoration: none; }
.sb-item.active .count { color: var(--text-2); }

/* Full-page link reset inside shell */
.app a { color: inherit; }

/* Generic form controls (login, modals, filters) reuse .input look */
.fb-field { margin-bottom: 14px; }
.fb-field:last-child { margin-bottom: 0; }
.input input:-webkit-autofill { -webkit-text-fill-color: var(--text); transition: background-color 9999s; }
select.fb-native {
  border: none; outline: none; background: transparent; flex: 1;
  font-size: 12.5px; color: var(--text); min-width: 0; cursor: pointer;
  appearance: none; -webkit-appearance: none;
}
textarea.fb-textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--text); padding: 8px 10px;
  font-family: inherit; font-size: 12.5px; resize: vertical; min-height: 72px;
}
textarea.fb-textarea:focus-within, textarea.fb-textarea:focus {
  outline: none; border-color: var(--text-3); box-shadow: 0 0 0 3px var(--bg-hover);
}
.input.error, .fb-textarea.error { border-color: var(--danger); }
.field-error { font-size: 11.5px; color: var(--danger); margin-top: 5px; }

/* Block button (full width, used in auth/modals) */
.btn.block { width: 100%; justify-content: center; }

/* Form alerts / Django messages */
.alert {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; border: 1px solid var(--border); background: var(--bg-subtle);
  color: var(--text-2); margin-bottom: 14px;
}
.alert .ic { flex-shrink: 0; margin-top: 1px; }
.alert.success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.alert.danger, .alert.error { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.alert.warn, .alert.warning { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.alert.info { background: var(--info-bg); color: var(--info); border-color: transparent; }

/* Dropdown menu (topbar/user/row actions) */
.dropdown { position: relative; }
.dropdown-menu {
  display: none;
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 200px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 50;
}
.dropdown-menu.open { display: block; }
.dropdown-menu.left { right: auto; left: 0; }
.dropdown-menu.up { top: auto; bottom: calc(100% + 6px); }
.dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 8px; font-size: 12.5px; color: var(--text-2);
  border: none; background: transparent; border-radius: var(--radius-sm);
  cursor: pointer; text-align: left; white-space: nowrap;
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item .ic { color: var(--text-3); }
.dropdown-divider { height: 1px; background: var(--border-subtle); margin: 6px 0; }

/* AJAX list swap: dim the table area while the new page is loading */
.tbl-wrap.is-loading .tbl-scroll { opacity: .55; transition: opacity .12s ease; }
.tbl-wrap.is-loading { cursor: progress; }

/* Column filter row inside table header */
.tbl thead tr.filters th { padding: 4px 6px 8px; background: var(--bg-elev); }
.tbl thead tr.filters .input { min-height: 26px; }
.tbl thead tr.filters .input input,
.tbl thead tr.filters .input select { font-size: 11px; }

/* Empty state */
.empty-state {
  padding: 48px 24px; text-align: center; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty-state .ic { color: var(--text-4); }
.empty-state .title { font-size: 13px; font-weight: 500; color: var(--text-2); }

/* Sortable header anchors keep table cell layout */
.tbl thead th a.sort-link {
  display: inline-flex; align-items: center; gap: 3px;
  color: inherit; text-decoration: none;
}

/* Mobile: collapsible sidebar */
.sb-toggle { display: none; }
.sidebar-scrim { display: none; }
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 80;
    width: var(--sidebar-w); transform: translateX(-100%);
    transition: transform 0.2s ease-out;
  }
  .app[data-sidebar-open="true"] .sidebar { transform: translateX(0); }
  .sb-toggle { display: inline-flex; }
  .app[data-sidebar-open="true"] .sidebar-scrim {
    display: block;
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 79;
    animation: fadeIn 0.15s;
  }
}

/* Detail grid responsive */
@media (max-width: 980px) {
  .detail-grid, .detail-grid.wide { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-2col { grid-template-columns: 1fr !important; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* x-cloak for Alpine */
[x-cloak] { display: none !important; }

/* Overlays are server-rendered and always present in the DOM; they must stay
   hidden until opened. The prototype CSS sets `display:flex` on the base class
   (it relied on React conditional mounting), which overrides the [hidden]
   attribute — so gate visibility on the `.open` class instead. */
.cmdk-overlay,
.modal-overlay,
.drawer-overlay { display: none; }
.cmdk-overlay.open,
.modal-overlay.open { display: flex; }
.drawer-overlay.open { display: block; }
.cmdk-overlay[hidden],
.modal-overlay[hidden],
.drawer-overlay[hidden] { display: none; }
