/* === Theme Variables === */
:root {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-soft: #f1f5f9;
  --bg-sunken: #e2e8f0;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --overlay: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-contrast: #ffffff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .05), 0 1px 2px rgba(15, 23, 42, .03);
  --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, .08), 0 2px 6px -2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 20px 36px -4px rgba(15, 23, 42, .12), 0 8px 16px -4px rgba(15, 23, 42, .06);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --nav-h: 56px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090a10;
  --bg-soft: #0f121d;
  --bg-sunken: #06070a;
  --surface: #121626;
  --surface-2: #181d30;
  --overlay: #141829;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --accent-contrast: #ffffff;
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.14);
  --danger: #f43f5e;
  --danger-soft: rgba(244, 63, 94, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, .7), 0 2px 6px -2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 24px 48px -8px rgba(0, 0, 0, .9), 0 8px 20px -4px rgba(0, 0, 0, .55);
}

[data-theme="dark"] body.brand-dark {
  --bg: #0B0D14;
  --bg-soft: #101522;
  --bg-sunken: #0B0D14;
  --surface: #151A28;
  --surface-2: #101522;
  --overlay: #151A28;
  --border: #252D3D;
  --border-strong: #252D3D;
  --text: #C5CEDB;
  --text-muted: #8B95A7;
  --text-faint: #667085;
}

/* Optional Quick Accent Presets */
:root[data-theme-preset="emerald"] {
  --accent: #059669;
  --accent-hover: #047857;
  --accent-soft: rgba(5, 150, 105, 0.14);
}
:root[data-theme-preset="sky"] {
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-soft: rgba(2, 132, 199, 0.14);
}
:root[data-theme-preset="rose"] {
  --accent: #e11d48;
  --accent-hover: #be123c;
  --accent-soft: rgba(225, 29, 72, 0.14);
}
:root[data-theme-preset="amber"] {
  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-soft: rgba(217, 119, 6, 0.14);
}

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

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* === Exact Navbar Styles === */
.nav {
  position: sticky !important;
  top: 0 !important;
  z-index: 1000 !important;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .nav {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -.02em;
  color: var(--text);
  text-decoration: none;
  flex: 0 0 auto;
}
.nav__brand:hover { text-decoration: none; }

.nav__mark {
  height: 35px;
  width: auto;
  aspect-ratio: 3231 / 976;
  object-fit: contain;
  border-radius: 6px;
  padding: 3px 6px;
  background: transparent;
  flex: 0 0 auto;
  transition: transform .15s ease;
}
.nav__brand:hover .nav__mark { transform: scale(1.02); }
[data-theme="dark"] .nav__mark {
  background: transparent;
  filter: brightness(0) invert(1);
  box-shadow: none;
}

.nav__center {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  min-width: 0;
}

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

.nav__links {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
  max-width: 100%;
  overflow: visible;
}

[data-theme="dark"] .nav__links {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

.nav__link {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-muted);
  white-space: nowrap;
  text-decoration: none;
  transition: color .15s ease, background .15s ease, box-shadow .15s ease;
}
.nav__link:hover {
  color: var(--text);
  background: rgba(15, 23, 42, 0.07);
  text-decoration: none;
}
[data-theme="dark"] .nav__link:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.09);
}
.nav__link[aria-current="page"] {
  color: var(--accent-contrast, #fff);
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--accent);
  padding: 5px 13px;
}
[data-theme="dark"] .nav__link[aria-current="page"] {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.nav__dropdown {
  position: relative;
  display: inline-flex;
}

.nav__dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

.nav__dropdown-chev {
  transition: transform .18s cubic-bezier(0.16, 1, 0.3, 1);
}
.nav__dropdown--open .nav__dropdown-chev {
  transform: rotate(180deg);
}

.nav__dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  min-width: 260px;
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--overlay);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
[data-theme="dark"] .nav__dropdown-menu {
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.nav__dropdown-menu[hidden] { display: none; }

.nav__dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  transition: background .12s;
}
.nav__dropdown-item:hover {
  background: rgba(15, 23, 42, 0.07);
  text-decoration: none;
}
[data-theme="dark"] .nav__dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
}
.nav__dropdown-item[aria-current="page"] {
  background: var(--surface);
  border: 1px solid var(--border);
}

.nav__dropdown-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--accent);
  flex: 0 0 auto;
}
.nav__dropdown-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.nav__dropdown-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}
.nav__dropdown-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--btn-radius, var(--radius-sm));
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 16px; height: 16px; }

.nav-auth { position: relative; display: inline-flex; }
.nav__toggle { display: none; }

/* Theme Toggle Context Dropdown Menu */
.theme-dropdown-menu {
  position: fixed;
  z-index: 10050;
  min-width: 205px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.1);
  font-family: var(--sans);
  user-select: none;
}
.theme-dropdown-menu__header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 6px 10px 4px;
}
.theme-dropdown-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.12s, color 0.12s;
}
.theme-dropdown-menu__item:hover { background: var(--bg-soft); color: var(--accent); }
.theme-dropdown-menu__item.is-active { color: var(--accent); font-weight: 650; background: var(--accent-soft); }
.theme-dropdown-menu__icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; }
.theme-dropdown-menu__icon svg { width: 16px; height: 16px; display: block; }
.theme-dropdown-menu__swatch { width: 12px; height: 12px; border-radius: 999px; display: inline-block; }
.theme-dropdown-menu__label { flex: 1 1 auto; text-align: left; }
.theme-dropdown-menu__divider { height: 1px; background: var(--border); margin: 4px 6px; }

/* Mobile Responsive Navbar */
@media (max-width: 1024px) {
  .nav__toggle {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: var(--text);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: all .15s ease;
  }
  .nav__toggle:hover { color: var(--accent); border-color: var(--accent); }
  .nav__toggle[aria-expanded="true"] { background: var(--bg-soft); border-color: var(--border-strong); color: var(--text); }
  .nav__end { margin-left: auto; }

  .nav__center {
    position: absolute;
    top: calc(100% + 8px);
    right: 12px;
    left: auto;
    width: min(280px, calc(100vw - 24px));
    max-height: calc(100dvh - 64px);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(.97);
    transform-origin: top right;
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
    z-index: 1000;
  }
  .nav__center--up {
    top: auto;
    bottom: calc(100% + 8px);
    transform-origin: bottom right;
    transform: translateY(6px) scale(.97);
  }
  .nav__center--open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

  .nav__links {
    width: 100%;
    max-height: calc(100dvh - 72px);
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 8px;
    border-radius: var(--radius);
    background: var(--surface) !important;
    border: 1px solid var(--border-strong) !important;
    box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.45), var(--shadow-lg) !important;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
  }
  [data-theme="dark"] .nav__links {
    background: #141829 !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
    box-shadow: 0 20px 48px -6px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
  }

  .nav__link { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; }
  .nav__link[aria-current="page"] { padding: 10px 14px; }
  .nav__dropdown { width: 100%; flex-direction: column; }
  .nav__dropdown-btn { width: 100%; justify-content: space-between; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; }
  .nav__dropdown-menu {
    position: static;
    transform: none;
    box-shadow: none;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    margin-top: 4px;
    width: 100%;
    min-width: 0;
    border-radius: var(--radius-sm);
    padding: 6px;
  }
  [data-theme="dark"] .nav__dropdown-menu {
    background: #0d101d;
    border-color: rgba(255, 255, 255, 0.08);
  }
}

/* === Cards, Badges, Inputs, Buttons, Alerts === */
.page-head__eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
}
[data-theme="dark"] .card {
  background: linear-gradient(180deg, #131726 0%, #0e1220 100%);
  border-color: rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.08), 0 6px 24px -4px rgba(0, 0, 0, 0.55);
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  background: var(--bg-soft);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}
[data-theme="dark"] .card__head {
  background: rgba(255, 255, 255, 0.03);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}
.card__title { font-size: 13.5px; font-weight: 650; letter-spacing: -.01em; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.card__step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 750;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  flex: 0 0 auto;
}
.card__body { padding: 18px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.align-center { align-items: center; }
.mt-2 { margin-top: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px;
  border-radius: var(--btn-radius, var(--radius-sm));
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: var(--btn-weight, 550);
  text-decoration: none;
  cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--bg-soft); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn--primary {
  background: var(--btn-bg, linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 82%, #000) 100%));
  border-color: var(--accent); color: var(--accent-contrast);
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.btn--danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn--xs { height: 24px; padding: 0 8px; font-size: 11.5px; }
.btn.is-active { border-color: var(--success); color: var(--success); background: var(--success-soft); }

.label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.hint { font-size: 12px; color: var(--text-faint); }
.input, .select {
  width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; box-sizing: border-box;
}
.input--sm, .select--sm { height: 32px; padding: 4px 10px; font-size: 12.5px; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-faint); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--bg-soft); color: var(--text-muted); border: 1px solid var(--border);
}
.badge--accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.alert { padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12.5px; }
.alert--error { background: var(--danger-soft); color: var(--danger); }
.alert[hidden] { display: none; }

/* MultiSelect Compact */
.ms { position: relative; }
.ms--compact { display: inline-flex; position: relative; vertical-align: middle; z-index: 50; }
.ms__control, .ms--compact .ms__control {
  display: flex; align-items: center; gap: 7px; min-width: 140px; max-width: 260px; height: 32px;
  padding: 4px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 12px; font-weight: 550; cursor: pointer;
}
.ms__value { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); text-align: left; }
.ms__value--filled { color: var(--text); font-weight: 600; }
.ms__count { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.ms__chev { width: 14px; height: 14px; color: var(--text-faint); flex: 0 0 auto; }
.ms__panel {
  position: absolute; right: 0; left: auto; top: calc(100% + 6px); width: 310px;
  max-width: min(310px, calc(100vw - 32px)); border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface);
  box-shadow: var(--shadow-lg); z-index: 200; overflow: hidden; display: none;
}
.ms__panel--open { display: block; }
.ms__search { width: 100%; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: inherit; font-size: 12.5px; box-sizing: border-box; }
.ms__search:focus { outline: none; }
.ms__actions { display: flex; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.ms__actions button { border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 4px; cursor: pointer; }
.ms__actions button:hover { color: var(--text); border-color: var(--border-strong); }
.ms__list { max-height: 290px; overflow-y: auto; padding: 6px; }
.ms__empty { padding: 12px 8px; text-align: center; font-size: 12px; color: var(--text-faint); }
.ms__opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 12.5px; }
.ms__opt:hover, .ms__opt[data-active="true"] { background: var(--bg-soft); }
.ms__opt-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms__opt-meta { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); padding: 1px 5px; border-radius: 4px; background: var(--bg-sunken); }

/* Toast & Offscreen utility */
.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--overlay);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 550;
  box-shadow: var(--shadow-lg);
}
.offscreen {
  position: fixed;
  left: -9999px;
  top: -9999px;
  opacity: 0;
}
