/* ==========================================================================
   DESIGN SYSTEM — Premium SaaS UI
   Tokens, base, layout, components.
   ========================================================================== */

:root {
  /* ---------- Typography ---------- */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Inter", var(--font-sans);

  /* Type scale (fluid-ish, based on 14px root) */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: 30px;

  /* ---------- Spacing scale (4px base) ---------- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 48px;
  --sp-10: 64px;

  /* ---------- Radius ---------- */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 999px;

  /* ---------- LIGHT THEME (default) ---------- */
  --bg-page: #f7f8fa;
  --bg-elevated: #ffffff;
  --bg-subtle: #f2f4f7;
  --bg-hover: rgba(15, 23, 42, 0.04);
  --bg-active: rgba(15, 23, 42, 0.06);

  --surface-1: #ffffff;
  --surface-2: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.72);

  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --border-focus: rgba(79, 70, 229, 0.45);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  /* Brand: refined indigo + violet */
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;

  --accent-violet: #8b5cf6;

  /* Semantic */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.10);
  --success-border: rgba(16, 185, 129, 0.25);

  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.10);
  --warning-border: rgba(245, 158, 11, 0.25);

  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.10);
  --danger-border: rgba(239, 68, 68, 0.25);

  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.10);
  --info-border: rgba(59, 130, 246, 0.25);

  /* Shadows — layered, soft, realistic */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.10), 0 8px 10px -6px rgba(15, 23, 42, 0.06);

  --ring-focus: 0 0 0 3px rgba(99, 102, 241, 0.18);
  --ring-focus-danger: 0 0 0 3px rgba(239, 68, 68, 0.18);

  /* Layout */
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
  --content-max: 1280px;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 140ms;
  --dur: 200ms;
  --dur-slow: 320ms;
}

/* ---------- DARK THEME ---------- */
html[data-theme="dark"] {
  --bg-page: #0a0b0f;
  --bg-elevated: #13151a;
  --bg-subtle: #1a1c23;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(255, 255, 255, 0.07);

  --surface-1: #13151a;
  --surface-2: #1a1c23;
  --surface-glass: rgba(19, 21, 26, 0.72);

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-focus: rgba(129, 140, 248, 0.50);

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --text-muted: #64748b;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.30);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.30), 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.40), 0 2px 4px -2px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.50), 0 4px 6px -4px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.55), 0 8px 10px -6px rgba(0, 0, 0, 0.40);

  --ring-focus: 0 0 0 3px rgba(129, 140, 248, 0.25);
  --ring-focus-danger: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

/* ==========================================================================
   BASE
   ========================================================================== */

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

html, body { height: 100%; }

html {
  background: var(--bg-page);
  color-scheme: light dark;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* Subtle ambient accent — tasteful, not flashy */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(99, 102, 241, 0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 90%, rgba(139, 92, 246, 0.06), transparent 60%);
}

html[data-theme="dark"] body::before {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(99, 102, 241, 0.15), transparent 60%),
    radial-gradient(900px 500px at -10% 90%, rgba(139, 92, 246, 0.10), transparent 60%);
}

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

button, input, select, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

::selection {
  background: rgba(99, 102, 241, 0.25);
  color: var(--text-primary);
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: padding-box; }

/* Focus */
:focus { outline: none; }
:focus-visible { box-shadow: var(--ring-focus); border-radius: var(--radius-sm); }

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

/* ==========================================================================
   LAYOUT SHELL
   ========================================================================== */

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

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

.content {
  flex: 1;
  padding: var(--sp-7) var(--sp-8);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width var(--dur) var(--ease);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--sp-5) var(--sp-4);
  gap: var(--sp-5);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  transition: background var(--dur) var(--ease);
}
.sidebar-brand:hover { background: var(--bg-hover); }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-600), var(--accent-violet));
  flex-shrink: 0;
  object-fit: cover;
  box-shadow: 0 2px 8px -2px rgba(99, 102, 241, 0.45);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.brand-text .title {
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.brand-text .subtitle {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Nav */
.nav {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  flex: 1;
}

.nav-section {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  margin-top: var(--sp-2);
}
.nav-section:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  position: relative;
  min-height: 38px;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}
html[data-theme="dark"] .nav-item.active {
  background: rgba(99, 102, 241, 0.12);
  color: #c7d2fe;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand-600);
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: currentColor;
  flex-shrink: 0;
}
.nav-icon svg { width: 18px; height: 18px; display: block; }

.nav-item .label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar footer */
.sidebar-footer {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
  margin: 0 calc(-1 * var(--sp-4));
  margin-top: auto;
  padding-left: var(--sp-4);
  padding-right: var(--sp-4);
}

/* Collapsed sidebar */
html[data-sidebar="collapsed"] .layout-shell {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}
html[data-sidebar="collapsed"] .brand-text,
html[data-sidebar="collapsed"] .nav-section,
html[data-sidebar="collapsed"] .nav-item .label {
  display: none;
}
html[data-sidebar="collapsed"] .sidebar-brand {
  justify-content: center;
  padding: var(--sp-2);
}
html[data-sidebar="collapsed"] .nav-item {
  justify-content: center;
  padding: var(--sp-3);
}
html[data-sidebar="collapsed"] .sidebar-footer {
  flex-direction: column;
}

/* ==========================================================================
   TOPBAR
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 0 var(--sp-8);
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.topbar-title h1 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.topbar-title p {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  line-height: 1.3;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}

/* ==========================================================================
   PAGE HEADER (inside .content, above grids)
   ========================================================================== */

.page-header {
  margin-bottom: var(--sp-7);
}
.page-header h2 {
  margin: 0;
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.page-header p {
  margin: var(--sp-2) 0 0;
  font-size: var(--fs-md);
  color: var(--text-secondary);
}

/* ==========================================================================
   GRID HELPERS
   ========================================================================== */

.grid {
  display: grid;
  gap: var(--sp-5);
}
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-1 { grid-template-columns: 1fr; }

.row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }

/* ==========================================================================
   CARD
   ========================================================================== */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
  overflow: hidden;
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.card-h {
  padding: var(--sp-5) var(--sp-5) 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
}
.card-h .h-title {
  margin: 0;
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--text-primary);
  letter-spacing: -0.005em;
}
.card-h .h-sub {
  margin: var(--sp-1) 0 0;
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.card-b {
  padding: var(--sp-5);
}

.card-h + .card-b { padding-top: var(--sp-4); }

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}
.btn:active { transform: scale(0.98); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn:focus-visible { box-shadow: var(--ring-focus); }

/* Full-width button in card bodies */
.card-b .btn { width: 100%; justify-content: flex-start; padding: 0 var(--sp-4); }

.btn-primary {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: var(--text-inverse);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-primary:hover {
  background: var(--brand-700);
  border-color: var(--brand-700);
}
.btn-primary:focus-visible { box-shadow: var(--ring-focus), inset 0 1px 0 rgba(255, 255, 255, 0.12); }

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--text-inverse);
}
.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}
.btn-danger:focus-visible { box-shadow: var(--ring-focus-danger); }

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

/* Icon-only button */
.btn.icon-btn {
  width: 40px;
  padding: 0;
}

/* Small icon toggle (used in topbar / sidebar) */
.icon-tech,
.icon-ghost {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-tech:hover,
.icon-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.icon-tech:focus-visible,
.icon-ghost:focus-visible { box-shadow: var(--ring-focus); }

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

.icon-tech.icon-danger { color: var(--danger); border-color: var(--danger-border); }
.icon-tech.icon-success { color: var(--success); border-color: var(--success-border); }
.icon-tech.icon-warning { color: var(--warning); border-color: var(--warning-border); }
.icon-tech.icon-info { color: var(--info); border-color: var(--info-border); }

/* ==========================================================================
   FORM CONTROLS
   ========================================================================== */

.label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}

.input, .select, .textarea {
  width: 100%;
  padding: 0 var(--sp-3);
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.textarea {
  min-height: 120px;
  padding: var(--sp-3);
  resize: vertical;
  line-height: 1.5;
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }

.input:hover, .select:hover, .textarea:hover {
  border-color: var(--text-muted);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--ring-focus);
}

.help { color: var(--text-tertiary); font-size: var(--fs-xs); margin-top: var(--sp-2); }

/* ==========================================================================
   CHIPS / BADGES
   ========================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px var(--sp-2);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.4;
}
.chip.dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.chip.success { color: var(--success); border-color: var(--success-border); background: var(--success-bg); }
.chip.success.dot::before { background: var(--success); }
.chip.warn { color: var(--warning); border-color: var(--warning-border); background: var(--warning-bg); }
.chip.warn.dot::before { background: var(--warning); }
.chip.danger { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.chip.danger.dot::before { background: var(--danger); }
.chip.info { color: var(--info); border-color: var(--info-border); background: var(--info-bg); }
.chip.info.dot::before { background: var(--info); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-2);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-1);
}
.badge.success { color: var(--success); border-color: var(--success-border); background: var(--success-bg); }
.badge.danger { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.badge.warn { color: var(--warning); border-color: var(--warning-border); background: var(--warning-bg); }
.badge.info { color: var(--info); border-color: var(--info-border); background: var(--info-bg); }

.badge-count {
  min-width: 22px;
  padding: 2px 8px;
  margin-left: var(--sp-2);
  justify-content: center;
}

/* ==========================================================================
   TABLE
   ========================================================================== */

.table-wrap {
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-1);
  box-shadow: var(--shadow-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
thead th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  position: sticky;
  top: 0;
}
tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--dur-fast) var(--ease); }
tbody tr:hover { background: var(--bg-hover); }

.verified-icon { margin-left: var(--sp-2); color: var(--success); }

/* ==========================================================================
   TOP LOADER
   ========================================================================== */

.top-loader {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--brand-500), var(--accent-violet));
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.45);
  z-index: 1000;
  transition: width 220ms var(--ease-out);
}

/* ==========================================================================
   TOASTS
   ========================================================================== */

.toast-wrap {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-width: 380px;
}
.toast {
  min-width: 280px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  animation: toastIn 420ms var(--ease-out) both;
}
.toast .t-title {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-primary);
}
.toast .t-msg {
  margin: var(--sp-1) 0 0;
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  line-height: 1.4;
}
.toast.is-leaving { animation: toastOut 240ms var(--ease) both; }

@keyframes toastIn {
  0% { opacity: 0; transform: translate3d(0, 12px, 0) scale(0.96); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes toastOut {
  0% { opacity: 1; transform: translate3d(0, 0, 0); }
  100% { opacity: 0; transform: translate3d(0, 8px, 0) scale(0.98); }
}

/* ==========================================================================
   LOGIN PAGE
   ========================================================================== */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: var(--sp-7);
}
.login-card .brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin: 0 auto var(--sp-4);
}
.login-card h1 {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 600;
  text-align: center;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.login-card .login-sub {
  margin: var(--sp-2) 0 var(--sp-6);
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
}
.login-error {
  margin-bottom: var(--sp-4);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: var(--fs-sm);
  text-align: center;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 1024px) {
  .layout-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(88vw, var(--sidebar-w));
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 39;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
  }
  .sidebar-backdrop.open { opacity: 1; visibility: visible; }

  .topbar { padding: 0 var(--sp-5); }
  .content { padding: var(--sp-5); }

  .grid.cols-3 { grid-template-columns: 1fr; }
  .grid.cols-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .content { padding: var(--sp-4); }
  .topbar { padding: 0 var(--sp-4); }
  .topbar-title p { display: none; }
  .page-header h2 { font-size: var(--fs-xl); }
}

@media (min-width: 1025px) {
  #sidebarOpenMobile { display: none !important; }
}

/* Login dark modern override */
.login-wrap { background: #0a0b0f !important; min-height: 100vh !important; display: flex !important; align-items: center !important; justify-content: center !important; }
.login-card { color: #f1f5f9 !important; }
.login-card .label { color: rgba(255,255,255,.4) !important; }
.login-card .input { background: rgba(255,255,255,.05) !important; border-color: rgba(255,255,255,.08) !important; color: #f1f5f9 !important; }
.login-card .input:focus { border-color: #4f46e5 !important; box-shadow: 0 0 0 3px rgba(79,70,229,.15) !important; }
.login-card .input::placeholder { color: rgba(255,255,255,.2) !important; }
.login-card .btn-primary { background: linear-gradient(135deg,#4f46e5,#6366f1) !important; border: none !important; box-shadow: 0 4px 12px rgba(79,70,229,.3) !important; }
.login-card .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79,70,229,.4) !important; }
.login-error { background: rgba(239,68,68,.1) !important; border: 1px solid rgba(239,68,68,.2) !important; color: #fca5a5 !important; }
