/* Demo palette. Dark is the default and html[data-theme=dark]. Light is html[data-theme=light].
   Border and ring fall back to a solid color, then color-mix where the browser supports it. */
:root,
html[data-theme=dark] {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-raised: #131c31;
  --bg-subtle: #172033;
  --surface: #162033c7;
  --surface-solid: #1a2740;
  --surface-hover: #203049;
  --fg: #e8eef7;
  --fg-muted: #94a3b8;
  --fg-subtle: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-fg: #f8fafc;
  --accent-soft: #3b82f624;
  --ok: #10b981;
  --ok-soft: #10b98124;
  --warn: #f59e0b;
  --warn-soft: #f59e0b24;
  --danger: #ef4444;
  --danger-soft: #ef444424;
  --info: #38bdf8;
  --info-soft: #38bdf824;
  --border: var(--fg);
  --border-strong: var(--fg);
  --shadow-border: 0 0 0 1px #ffffff14;
  --shadow-border-hover: 0 0 0 1px #ffffff24;
  --shadow-lg: 0 24px 60px -24px #0000008c;
  --glass: blur(16px) saturate(1.2);
  --sidebar: 260px;
  --sidebar-sm: 76px;
  --topbar: 60px;
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --motion-micro: 80ms;
  --motion-quick: .15s;
  --motion-fast: .25s;
  --motion-slow: .4s;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ring: 0 0 0 3px var(--accent);
}

@supports (color: color-mix(in lab, red, red)) {
  :root,
  html[data-theme=dark] {
    --border: color-mix(in oklab, var(--fg) 12%, transparent);
    --border-strong: color-mix(in oklab, var(--fg) 22%, transparent);
    --ring: 0 0 0 3px color-mix(in oklab, var(--accent) 45%, transparent);
  }
}

html[data-theme=light],
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f7;
  --bg-raised: #f7f9fc;
  --bg-subtle: #e8eef6;
  --surface: #ffffffc7;
  --surface-solid: #fff;
  --surface-hover: #f1f5f9;
  --fg: #0f172a;
  --fg-muted: #475569;
  --fg-subtle: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-fg: #fff;
  --accent-soft: #2563eb1a;
  --border: var(--fg);
  --border-strong: var(--fg);
  --shadow-border: 0 0 0 1px #0f172a0f, 0 1px 2px -1px #0f172a0f, 0 2px 8px 0 #0f172a0a;
  --shadow-border-hover: 0 0 0 1px #0f172a1a, 0 8px 24px -12px #0f172a2e;
  --shadow-lg: 0 24px 50px -20px #0f172a38;
  --glass: blur(18px) saturate(1.4);
}

@supports (color: color-mix(in lab, red, red)) {
  html[data-theme=light],
  :root[data-theme="light"] {
    --border: color-mix(in oklab, var(--fg) 10%, transparent);
    --border-strong: color-mix(in oklab, var(--fg) 18%, transparent);
  }
}

/* Chrome sizes stay on the --nx-* names. Color names point at the demo tokens. */
:root {
  --nx-bg: var(--bg);
  --nx-bg-raised: var(--surface-solid);
  --nx-sidebar: var(--bg-raised);
  --nx-border: var(--border);
  --nx-text: var(--fg);
  --nx-muted: var(--fg-muted);
  --nx-accent: var(--accent);
  --nx-accent-soft: var(--accent-soft);
  --nx-hover: var(--surface-hover);
  --nx-shadow: var(--shadow-lg);
  --nx-danger: var(--danger);
  --nx-font: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --nx-mono: "IBM Plex Mono", ui-monospace, monospace;
  --nx-sidebar-w: 16.5rem;
  --nx-topbar-h: 3.5rem;
  --nx-radius: 10px;
  --nx-icon: 1.125rem;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--nx-bg);
  color: var(--nx-text);
  font-family: var(--nx-font);
  font-size: 0.9375rem;
  line-height: 1.45;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--nx-accent);
  outline-offset: 2px;
}

.nx-icon {
  width: var(--nx-icon);
  height: var(--nx-icon);
  display: block;
  flex: none;
}

.nx-app {
  display: flex;
  min-height: 100vh;
  background: radial-gradient(1200px 500px at 10% -10%, var(--accent), transparent 50%), var(--bg);
}

@supports (color: color-mix(in lab, red, red)) {
  .nx-app {
    background: radial-gradient(1200px 500px at 10% -10%, color-mix(in oklab, var(--accent) 16%, transparent), transparent 50%), var(--bg);
  }
}

.nx-scrim {
  position: fixed;
  inset: 0;
  background: #02061773;
  z-index: 30;
}

.nx-scrim[hidden] {
  display: none;
}

.nx-sidebar {
  width: var(--nx-sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  /* Dynamic viewport height, as in the /ui/ demo: 100vh is taller than the
     visible area on phones (URL bar), which hid the end of the nav list. */
  height: 100dvh;
  z-index: 40;
}

@supports (color: color-mix(in lab, red, red)) {
  .nx-sidebar {
    background: color-mix(in oklab, var(--bg-raised) 86%, transparent);
  }
}

.nx-sidebar-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.85rem 0.75rem 0.5rem;
}

.nx-brand {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  column-gap: 10px;
  align-items: center;
  min-width: 0;
  flex: 1;
  text-decoration: none;
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
}

.nx-brand-mark {
  grid-row: 1 / span 2;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #0f172a;
  color: #93c5fd;
  box-shadow: var(--shadow-border);
}

.nx-brand-mark svg {
  display: block;
}

:root[data-theme="light"] .nx-brand-mark {
  background: #1e3a5f;
}

.nx-brand:hover {
  background: var(--nx-hover);
}

.nx-brand-name {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nx-brand-tag {
  color: var(--fg-subtle);
  font-size: 0.75rem;
}

.nx-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.35rem 0.6rem 0.85rem;
}

.nx-nav-link,
.nx-nav-group-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  text-decoration: none;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  /* Higher contrast on the sidebar for small screens. */
  color: var(--fg);
}

.nx-nav-link:hover,
.nx-nav-group-btn:hover {
  background: var(--surface-hover);
  color: var(--fg);
}

.nx-nav-link.is-active {
  background: var(--nx-accent-soft);
  color: var(--nx-accent);
}

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

.nx-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.nx-nav-chevron {
  margin-left: auto;
  display: inline-flex;
  /* Higher contrast on the sidebar for small screens. */
  color: var(--nx-text);
  transition: transform 160ms ease;
}

.nx-nav-group:not(.is-open) > .nx-nav-group-btn .nx-nav-chevron {
  transform: rotate(-90deg);
}

.nx-nav-group.is-current > .nx-nav-group-btn .nx-nav-icon {
  color: var(--nx-accent);
}

.nx-nav-group-items {
  display: none;
  flex-direction: column;
  gap: 0.1rem;
}

.nx-nav-sub .nx-nav-item {
  min-height: 36px;
  padding: 6px 10px 6px 12px;
  font-size: 13px;
}

.nx-nav-group.is-open .nx-nav-group-items {
  display: flex;
}

.nx-side-foot {
  box-shadow: inset 0 1px 0 var(--border);
  padding: 8px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nx-side-foot .nx-btn {
  background: var(--surface-solid);
  height: 40px;
  color: var(--fg);
  box-shadow: var(--shadow-border);
  border: 0;
  border-radius: 10px;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0 14px 0 16px;
  font-weight: 550;
  display: inline-flex;
}

.nx-side-foot .nx-btn:hover {
  box-shadow: var(--shadow-border-hover);
}

.nx-side-foot .nx-btn:active {
  scale: 0.96;
}

.nx-side-foot .nx-btn-ghost {
  box-shadow: none;
  color: var(--fg-muted);
  background: transparent;
}

.nx-side-foot .nx-btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--fg);
  box-shadow: none;
}

.nx-side-foot .nx-collapse {
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  width: 100%;
  display: flex;
}

.nx-sidebar.is-collapsed {
  width: 4.25rem;
}

.nx-sidebar.is-collapsed .nx-brand-name,
.nx-sidebar.is-collapsed .nx-brand-tag,
.nx-sidebar.is-collapsed .nx-nav-label,
.nx-sidebar.is-collapsed .nx-nav-chevron {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.nx-sidebar.is-collapsed .nx-sidebar-head {
  flex-direction: column;
}

.nx-sidebar.is-collapsed .nx-nav-link,
.nx-sidebar.is-collapsed .nx-nav-group-btn,
.nx-sidebar.is-collapsed .nx-brand,
.nx-sidebar.is-collapsed .nx-collapse {
  justify-content: center;
  position: relative;
}

.nx-sidebar.is-collapsed .nx-collapse {
  padding-left: 8px;
  padding-right: 8px;
}

.nx-sidebar.is-collapsed .nx-collapse span {
  display: none;
}

.nx-sidebar.is-collapsed .nx-brand {
  grid-template-columns: 28px;
  column-gap: 0;
}

.nx-sidebar.is-collapsed .nx-nav-group.is-current > .nx-nav-group-btn {
  background: var(--nx-accent-soft);
  color: var(--nx-accent);
}

.nx-sidebar.is-collapsed .nx-nav-group.is-current > .nx-nav-group-btn .nx-nav-icon {
  color: var(--nx-accent);
}

.nx-sidebar.is-collapsed .nx-nav-link:hover::after,
.nx-sidebar.is-collapsed .nx-nav-group-btn:hover::after,
.nx-sidebar.is-collapsed .nx-brand:hover::after,
.nx-sidebar.is-collapsed .nx-collapse:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 0.5rem);
  top: 50%;
  transform: translateY(-50%);
  background: var(--nx-bg-raised);
  color: var(--nx-text);
  border: 1px solid var(--nx-border);
  border-radius: 8px;
  padding: 0.25rem 0.5rem;
  white-space: nowrap;
  box-shadow: var(--nx-shadow);
  z-index: 50;
  font-size: 0.8125rem;
}

.nx-shell {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
}

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

@supports (color: color-mix(in lab, red, red)) {
  .nx-topbar {
    background: color-mix(in oklab, var(--bg) 72%, transparent);
  }
}

.nx-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 34rem;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  /* Match the Users table search corner radius. */
  border-radius: 10px;
  padding: 0.35rem 0.8rem;
}

.nx-search-icon {
  color: var(--fg-subtle);
  display: inline-flex;
}

.nx-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.15rem 0;
}

.nx-search input:focus {
  outline: none;
}

.nx-search input::-webkit-search-cancel-button {
  appearance: none;
}

.nx-topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 0;
  gap: 0.35rem;
}

.nx-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--fg-muted);
}

.nx-icon-btn:hover,
.nx-user-btn:hover {
  background: var(--surface-hover);
  color: var(--fg);
}

a.nx-icon-btn {
  text-decoration: none;
  color: inherit;
}

.nx-theme-icon {
  display: none;
}

:root .nx-theme-sun,
:root[data-theme="dark"] .nx-theme-sun {
  display: inline-flex;
}

:root[data-theme="light"] .nx-theme-sun {
  display: none;
}

:root[data-theme="light"] .nx-theme-moon {
  display: inline-flex;
}

/* Theme item in the account menu: icon and label, like the other items. */
.nx-menu .nx-theme-icon {
  align-items: center;
  gap: 0.5rem;
}

.nx-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--nx-border);
  background: transparent;
  border-radius: 999px;
  padding: 0.2rem 0.7rem 0.2rem 0.35rem;
}

.nx-user-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  background: var(--nx-accent-soft);
  color: var(--nx-accent);
}

.nx-account {
  position: relative;
}

.nx-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 12.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.35rem;
  background: var(--nx-bg-raised);
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius);
  box-shadow: var(--nx-shadow);
  z-index: 50;
}

.nx-menu[hidden] {
  display: none;
}

.nx-menu a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}

.nx-menu a:hover,
.nx-menu a[aria-current="page"] {
  background: var(--nx-hover);
}

.nx-menu form {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
}

.nx-menu form button,
.nx-menu > button[role="menuitem"] {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  text-decoration: none;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.nx-menu form button:hover,
.nx-menu > button[role="menuitem"]:hover {
  background: var(--nx-hover);
}

/* Page body. It fills the width beside the nav at every viewport.
   Dialogs, the drawer, and the topbar search keep their own widths. */
.nx-main {
  flex: 1;
  width: 100%;
  max-width: none;
  min-width: 0;
  outline: none;
  padding: 1.5rem 1.4rem 1rem;
}

.nx-page-head h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.nx-kicker {
  margin: 0 0 0.3rem;
  color: var(--accent);
  font-family: var(--nx-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nx-sections > .nx-card {
  max-width: none;
}

.nx-sections > .nx-card > .nx-card-title {
  padding-bottom: 0.9rem;
}

.nx-footer {
  padding: 0.35rem 1.4rem 1rem;
  color: var(--nx-muted);
  font-size: 0.8125rem;
}

.nx-footer p {
  margin: 0;
}

.nx-drawer-backdrop {
  position: fixed;
  top: var(--nx-topbar-h);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  background: #0206178c;
}

.nx-drawer-backdrop[hidden] {
  display: none;
}

.nx-drawer {
  position: fixed;
  top: var(--nx-topbar-h);
  right: 0;
  bottom: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: 100vw;
  background: var(--nx-bg-raised);
  color: var(--nx-text);
  border-left: 1px solid var(--nx-border);
  box-shadow: var(--nx-shadow);
}

.nx-drawer[hidden] {
  display: none;
}

.nx-drawer-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: none;
  min-height: var(--nx-topbar-h);
  padding: 0 0.75rem 0 1rem;
  border-bottom: 1px solid var(--nx-border);
}

.nx-drawer-head h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.nx-drawer-body {
  flex: 1;
  min-height: 0;
}

.nx-menu-btn {
  display: none;
}

@media (max-width: 900px) {
  .nx-drawer {
    left: 0;
    width: 100vw;
    max-width: 100vw;
  }

  .nx-menu-btn {
    display: inline-flex;
  }

  .nx-side-foot {
    display: none;
  }

  .nx-sidebar,
  .nx-sidebar.is-collapsed {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(16.5rem, 86vw);
    /* Keep the fixed drawer to the visible viewport so .nx-nav scrolls fully. */
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform 160ms ease;
    box-shadow: var(--nx-shadow);
  }

  .nx-app.is-nav-open .nx-sidebar {
    transform: none;
  }

  .nx-sidebar.is-collapsed .nx-brand-name,
  .nx-sidebar.is-collapsed .nx-brand-tag,
  .nx-sidebar.is-collapsed .nx-nav-label,
  .nx-sidebar.is-collapsed .nx-nav-chevron {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
  }

  .nx-sidebar.is-collapsed .nx-sidebar-head {
    flex-direction: row;
  }

  .nx-sidebar.is-collapsed .nx-brand {
    grid-template-columns: 28px minmax(0, 1fr);
    column-gap: 10px;
  }

  .nx-topbar {
    padding-left: 0.6rem;
  }

  .nx-user-btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
}

@media (min-width: 901px) {
  .nx-scrim {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nx-sidebar,
  .nx-nav-chevron {
    transition: none;
  }
}

.nx-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

#nx-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 80;
  width: 100%;
  height: 2px;
  background: var(--nx-accent);
  pointer-events: none;
}

#nx-progress[hidden] {
  display: none;
}

.nx-page-head h1:focus {
  outline: 2px solid var(--nx-accent);
  outline-offset: 2px;
}

h1[tabindex="-1"],
h1[tabindex="-1"]:focus,
h1[tabindex="-1"]:focus-visible {
  outline: none;
}
