/* Nexus Playground · nx-ui Design System Kit (Light + Graphite Dark + Compact Density) */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap");

:root, .light-mode {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Nexus Brand Navy (Penn Blue, #121541 = brand-600) */
  --nx-brand-25: #f8f9fc;
  --nx-brand-50: #f1f2f9;
  --nx-brand-100: #dddfe9;
  --nx-brand-200: #b4b7d4;
  --nx-brand-500: #2a2d78;
  --nx-brand-600: #121541;
  --nx-brand-700: #0e1034;

  /* Nexus Accent Yellow (Aureolin, #F7EC33 = accent-400) */
  --nx-accent-50: #fef8b8;
  --nx-accent-200: #fceb55;
  --nx-accent-300: #fde033;
  --nx-accent-400: #f7ec33;
  --nx-accent-500: #e0d420;
  --nx-accent-700: #8a7f0a;

  /* Untitled UI Cool Gray */
  --nx-gray-25: #fcfcfd;
  --nx-gray-50: #f9fafb;
  --nx-gray-100: #f2f4f7;
  --nx-gray-200: #eaecf0;
  --nx-gray-300: #d0d5dd;
  --nx-gray-400: #98a2b3;
  --nx-gray-500: #667085;
  --nx-gray-600: #475467;
  --nx-gray-700: #344054;
  --nx-gray-800: #1d2939;
  --nx-gray-900: #101828;
  --nx-gray-950: #0c111d;

  /* Semantic Status Ramps (UUI) */
  --nx-green-50: #ecfdf3; --nx-green-200: #abefc6; --nx-green-600: #079455; --nx-green-700: #067647;
  --nx-amber-50: #fffaeb; --nx-amber-200: #fedf89; --nx-amber-600: #dc6803; --nx-amber-700: #b54708;
  --nx-red-50: #fef3f2;   --nx-red-200: #fecdca;   --nx-red-600: #d92d20;   --nx-red-700: #b42318;
  --nx-blue-50: #eff8ff;  --nx-blue-200: #b2ddff;  --nx-blue-600: #1570ef;  --nx-blue-700: #175cd3;

  /* Semantic Surface & Text Tokens (Light Mode) */
  --background: #ffffff;
  --foreground: var(--nx-gray-900);
  --card: #ffffff;
  --card-foreground: var(--nx-gray-900);
  --muted: var(--nx-gray-50);
  --muted-foreground: var(--nx-gray-500);
  --subtle: var(--nx-gray-100);
  --secondary: var(--nx-gray-50);
  --secondary-foreground: var(--nx-gray-700);
  --primary: var(--nx-brand-600);
  --primary-hover: var(--nx-brand-700);
  --primary-foreground: #ffffff;
  --destructive: var(--nx-red-600);
  --destructive-foreground: #ffffff;
  --border: var(--nx-gray-200);
  --border-strong: var(--nx-gray-300);
  --input-border: var(--nx-gray-300);
  --ring: rgba(42, 45, 120, 0.24);
  --sidebar: var(--nx-gray-50);
  --sidebar-foreground: var(--nx-gray-700);
  --sidebar-accent: var(--nx-gray-200);
  --sidebar-accent-foreground: var(--nx-gray-900);
  --sidebar-border: var(--nx-gray-200);
  --emblem-color: var(--nx-brand-600);
  --wordmark-color: var(--nx-brand-600);

  /* Radii & Shadows */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-card: 12px;
  --radius-shell: 16px;
  --pad-page: 24px;
  --pad-card: 18px;
  --ctrl-h: 36px;
  --shadow-xs: 0px 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0px 1px 3px rgba(16, 24, 40, 0.10), 0px 1px 2px -1px rgba(16, 24, 40, 0.10);
  --shadow-md: 0px 4px 8px -2px rgba(16, 24, 40, 0.08), 0px 2px 4px -2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0px 12px 24px -4px rgba(16, 24, 40, 0.10), 0px 4px 6px -2px rgba(16, 24, 40, 0.04);
  --shadow-skeuo: 0px 0px 0px 1px rgba(16, 24, 40, 0.18) inset, 0px -2px 0px 0px rgba(16, 24, 40, 0.06) inset, 0px 1px 2px rgba(16, 24, 40, 0.05);
}

/* Nexus Hub Graphite Dark Mode (.dark-mode) — primary flips Navy -> Aureolin Yellow */
.dark-mode {
  --background: #141415;
  --foreground: #fafafa;
  --card: #1c1c1e;
  --card-foreground: #fafafa;
  --muted: #1c1c1e;
  --muted-foreground: #9d9da3;
  --subtle: #27272a;
  --secondary: #27272a;
  --secondary-foreground: #e2e2e5;
  --primary: var(--nx-accent-400);
  --primary-hover: var(--nx-accent-300);
  --primary-foreground: var(--nx-brand-600);
  --destructive: #f04438;
  --destructive-foreground: #ffffff;
  --border: #27272a;
  --border-strong: #38383c;
  --input-border: #38383c;
  --ring: rgba(247, 236, 51, 0.30);
  --sidebar: #141415;
  --sidebar-foreground: #cdcdd1;
  --sidebar-accent: #27272a;
  --sidebar-accent-foreground: #fafafa;
  --sidebar-border: #27272a;
  --emblem-color: var(--nx-accent-400);
  --wordmark-color: #ffffff;

  --nx-green-50: rgba(23, 178, 106, 0.14); --nx-green-200: rgba(23, 178, 106, 0.35); --nx-green-700: #47cd89;
  --nx-amber-50: rgba(247, 144, 9, 0.14);  --nx-amber-200: rgba(247, 144, 9, 0.35);  --nx-amber-700: #fec84b;
  --nx-red-50: rgba(240, 68, 56, 0.14);    --nx-red-200: rgba(240, 68, 56, 0.35);    --nx-red-700: #fda29b;
  --nx-blue-50: rgba(56, 189, 248, 0.14);  --nx-blue-200: rgba(56, 189, 248, 0.35);  --nx-blue-700: #7dd3fc;
  --nx-brand-50: rgba(247, 236, 51, 0.12); --nx-brand-200: rgba(247, 236, 51, 0.35);
}

/* Orthogonal Compact Density Mode (matches nx-ui §8 data-density="compact") */
[data-density="compact"] {
  --radius: 6px;
  --radius-card: 10px;
  --pad-page: 16px;
  --pad-card: 12px;
  --ctrl-h: 30px;
  font-size: 13px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  min-height: 100%;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
code, pre, .nx-mono { font-family: var(--font-mono); font-feature-settings: "calt" 0; }
.nx-tabular { font-variant-numeric: tabular-nums; font-feature-settings: "calt" 0; }

/* === APP SHELL (256px sidebar + rounded lifted page card — signature nx-ui pattern) === */
.nx-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--sidebar);
}
.nx-sidebar {
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 14px;
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border);
}
.nx-sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 8px;
}
.nx-nav-group { display: flex; flex-direction: column; gap: 2px; }
.nx-nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  padding: 6px 10px 4px;
}
.nx-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sidebar-foreground);
  text-decoration: none;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background-color 120ms ease, color 120ms ease;
}
.nx-nav-item:hover { background: var(--subtle); color: var(--foreground); }
.nx-nav-item.active { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); font-weight: 600; }

.nx-main-gutter {
  padding: 10px 10px 10px 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.nx-page-card {
  flex: 1;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-shell);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.nx-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px var(--pad-page) 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.nx-page-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.nx-page-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted-foreground);
}
.nx-page-body {
  padding: var(--pad-page);
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
  min-width: 0;
}
.nx-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted-foreground);
  margin-bottom: 6px;
}

/* === BUTTONS (Skeuomorphic UUI/Nexus Primary + Secondary/Outline/Ghost/Destructive) === */
.nx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--ctrl-h);
  padding: 0 13px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.nx-btn:hover { background: var(--muted); }
.nx-btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.nx-btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: transparent;
  box-shadow: var(--shadow-skeuo);
}
.nx-btn-primary:hover { background: var(--primary-hover); }
.nx-btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--muted-foreground);
}
.nx-btn-ghost:hover { background: var(--subtle); color: var(--foreground); }
.nx-btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
  border-color: transparent;
  box-shadow: var(--shadow-skeuo);
}
.nx-btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.nx-btn-lg { height: 42px; padding: 0 18px; font-size: 14px; }

/* === CARDS & METRIC CARDS === */
.nx-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--pad-card);
  box-shadow: var(--shadow-xs);
}
.nx-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.nx-card-title { margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.nx-card-desc { margin: 3px 0 0; font-size: 12.5px; color: var(--muted-foreground); }

.nx-metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nx-metric-label { font-size: 12.5px; font-weight: 500; color: var(--muted-foreground); }
.nx-metric-val { font-size: 26px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.nx-metric-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-foreground); }

/* === PILL BADGES & NEXUS DOMAIN TAGS === */
.nx-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  border: 1px solid var(--border);
  background: var(--muted);
  color: var(--secondary-foreground);
  white-space: nowrap;
}
.nx-badge-brand { background: var(--nx-brand-50); border-color: var(--nx-brand-200); color: var(--emblem-color); }
.nx-badge-success { background: var(--nx-green-50); border-color: var(--nx-green-200); color: var(--nx-green-700); }
.nx-badge-warning { background: var(--nx-amber-50); border-color: var(--nx-amber-200); color: var(--nx-amber-700); }
.nx-badge-error { background: var(--nx-red-50); border-color: var(--nx-red-200); color: var(--nx-red-700); }
.nx-badge-info { background: var(--nx-blue-50); border-color: var(--nx-blue-200); color: var(--nx-blue-700); }
.nx-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* Nexus Domain Primitives */
.nx-ewc {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  font-feature-settings: "calt" 0;
  background: var(--muted);
  border: 1px solid var(--border-strong);
  color: var(--foreground);
}
.nx-ref {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  font-feature-settings: "calt" 0;
  color: var(--emblem-color);
}
.nx-gate-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: var(--radius-card);
  border: 1px solid var(--nx-amber-200);
  background: var(--nx-amber-50);
  color: var(--foreground);
}

/* === INPUTS & FIELDS === */
.nx-field { display: flex; flex-direction: column; gap: 5px; }
.nx-label { font-size: 13px; font-weight: 500; color: var(--foreground); }
.nx-hint { font-size: 12px; color: var(--muted-foreground); }
.nx-input, .nx-select, .nx-textarea {
  width: 100%;
  height: var(--ctrl-h);
  padding: 0 11px;
  border-radius: var(--radius);
  border: 1px solid var(--input-border);
  background: var(--background);
  color: var(--foreground);
  font-family: inherit;
  font-size: 13.5px;
  box-shadow: var(--shadow-xs);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.nx-textarea { height: auto; padding: 9px 11px; min-height: 82px; resize: vertical; }
.nx-input:focus, .nx-select:focus, .nx-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}

/* === DATA TABLE (TanStack / UUI idiom) === */
.nx-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--card);
  overflow-x: auto;
  box-shadow: var(--shadow-xs);
}
.nx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}
.nx-table th {
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted-foreground);
  background: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.nx-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.nx-table tr:last-child td { border-bottom: 0; }
.nx-table tbody tr:hover { background: var(--muted); }
.nx-table tbody tr.clickable { cursor: pointer; }
.nx-table tbody tr.selected { background: var(--nx-brand-50); }

/* === TABS === */
.nx-tab-list {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.nx-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.nx-tab:hover { color: var(--foreground); }
.nx-tab.active {
  background: var(--background);
  color: var(--foreground);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* === ALERTS, PROGRESS, TIMELINE, AVATAR === */
.nx-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--muted);
  font-size: 13px;
}
.nx-alert-success { background: var(--nx-green-50); border-color: var(--nx-green-200); }
.nx-alert-warning { background: var(--nx-amber-50); border-color: var(--nx-amber-200); }
.nx-alert-error   { background: var(--nx-red-50);   border-color: var(--nx-red-200); }
.nx-alert-info    { background: var(--nx-blue-50);  border-color: var(--nx-blue-200); }

.nx-progress { height: 7px; border-radius: 9999px; background: var(--subtle); overflow: hidden; }
.nx-progress-fill { height: 100%; border-radius: 9999px; background: var(--primary); transition: width 200ms ease; }

.nx-avatar {
  width: 30px; height: 30px;
  border-radius: 9999px;
  background: var(--subtle);
  border: 1px solid var(--border);
  display: inline-grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--foreground);
  flex-shrink: 0;
}

.nx-timeline { display: flex; flex-direction: column; gap: 12px; }
.nx-timeline-item { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.nx-timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }

/* === DRAWER / SHEET & MODAL === */
.nx-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 17, 29, 0.45);
  z-index: 60;
  display: none;
  align-items: stretch;
  justify-content: flex-end;
}
.nx-backdrop.open { display: flex; }
.nx-backdrop.center { align-items: center; justify-content: center; padding: 20px; }
.nx-drawer {
  width: min(460px, 94vw);
  background: var(--background);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.nx-modal {
  width: min(520px, 94vw);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.nx-modal-head, .nx-drawer-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.nx-modal-body, .nx-drawer-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.nx-modal-foot, .nx-drawer-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* === TOAST === */
#nxToastStack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.nx-toast {
  pointer-events: auto;
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === LAYOUT UTILITIES === */
.nx-stack { display: flex; flex-direction: column; gap: 14px; }
.nx-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nx-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.nx-grid { display: grid; gap: 14px; }
.nx-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.nx-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.nx-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.nx-split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.nx-muted { color: var(--muted-foreground); }
.nx-kbd {
  display: inline-flex; align-items: center; padding: 1px 5px;
  border-radius: 4px; border: 1px solid var(--border-strong);
  background: var(--muted); font-family: var(--font-mono); font-size: 11px; color: var(--muted-foreground);
}

@media (max-width: 820px) {
  .nx-shell { grid-template-columns: 1fr; }
  .nx-sidebar { border-right: 0; border-bottom: 1px solid var(--sidebar-border); padding: 10px 12px; }
  .nx-main-gutter { padding: 8px; }
  .nx-cols-3, .nx-cols-4, .nx-split { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .nx-cols-2 { grid-template-columns: 1fr; }
}
