/* ================================================================
   Numbrfactory Design System — theme.css
   Single source of truth. Import once in base.html.
   ================================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Custom Properties ── */
:root {
  /* Brand */
  --nx-navy:           #0F2340;
  --nx-navy-dark:      #0A182C;
  --nx-navy-light:     #1a3558;
  --nx-copper:         #B0754A;
  --nx-copper-light:   #D8B08C;
  --nx-copper-dark:    #8e5e3b;

  /* Surface */
  --nx-bg:             #F5F7FA;
  --nx-card:           #FFFFFF;
  --nx-border:         #E5E7EB;

  /* Semantic */
  --nx-success:        #16A34A;
  --nx-warning:        #F59E0B;
  --nx-danger:         #DC2626;
  --nx-info:           #2563EB;

  /* Semantic tints */
  --nx-success-bg:     #f0fdf4;
  --nx-warning-bg:     #fffbeb;
  --nx-danger-bg:      #fef2f2;
  --nx-info-bg:        #eff6ff;

  /* Chart palette */
  --nx-chart-1:        #0F2340;
  --nx-chart-2:        #B0754A;
  --nx-chart-3:        #2563EB;
  --nx-chart-4:        #16A34A;
  --nx-chart-5:        #F59E0B;
  --nx-chart-6:        #7C3AED;
  --nx-chart-7:        #DC2626;
  --nx-chart-8:        #0891B2;

  /* Typography */
  --nx-font:           'Inter', system-ui, -apple-system, sans-serif;
  --nx-font-mono:      'JetBrains Mono', 'Courier New', monospace;

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

  /* Shadows */
  --nx-shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --nx-shadow:         0 4px 16px rgba(0,0,0,0.08);
  --nx-shadow-lg:      0 20px 60px rgba(0,0,0,0.15);
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--nx-font);
  background: var(--nx-bg);
  color: #1e293b;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Mono numbers */
.nx-mono { font-family: var(--nx-font-mono); }

/* ────────────────────────────────────────────────
   BUTTONS
───────────────────────────────────────────────── */
.nx-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1.25rem;
  border-radius: var(--nx-radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--nx-font);
  line-height: 1.25;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, border-color 0.15s;
  text-decoration: none;
}
.nx-btn:active:not(:disabled) { transform: translateY(1px); }
.nx-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Primary: navy → copper hover */
.nx-btn-primary {
  background: var(--nx-navy);
  color: #fff;
}
.nx-btn-primary:hover:not(:disabled) {
  background: var(--nx-copper);
  box-shadow: 0 4px 14px rgba(176,117,74,0.35);
}

/* Secondary: white, copper border & text */
.nx-btn-secondary {
  background: #fff;
  color: var(--nx-copper-dark);
  border: 1px solid var(--nx-border);
}
.nx-btn-secondary:hover:not(:disabled) {
  background: #fdf8f5;
  border-color: var(--nx-copper-light);
}

/* Danger */
.nx-btn-danger {
  background: var(--nx-danger);
  color: #fff;
}
.nx-btn-danger:hover:not(:disabled) { background: #b91c1c; }

/* Ghost */
.nx-btn-ghost {
  background: transparent;
  color: var(--nx-navy);
  border: 1px solid var(--nx-border);
}
.nx-btn-ghost:hover:not(:disabled) { background: #f8fafc; }

/* Sizes */
.nx-btn-sm  { padding: 0.3rem 0.875rem; font-size: 0.8125rem; }
.nx-btn-xs  { padding: 0.2rem 0.625rem; font-size: 0.75rem; border-radius: var(--nx-radius-sm); }
.nx-btn-lg  { padding: 0.75rem 1.75rem; font-size: 1rem; }

/* ── Legacy button aliases (keep existing templates working) ── */
.btn-primary  { background: var(--nx-navy); color: #fff; padding: 0.5rem 1.25rem; border-radius: var(--nx-radius); font-size: 0.875rem; font-weight: 500; border: none; cursor: pointer; transition: background 0.15s; }
.btn-primary:hover { background: var(--nx-copper); }
.btn-copper   { background: var(--nx-copper); color: #fff; padding: 0.5rem 1.25rem; border-radius: var(--nx-radius); font-size: 0.875rem; font-weight: 500; border: none; cursor: pointer; transition: background 0.15s; }
.btn-copper:hover  { background: var(--nx-copper-dark); }
.btn-ghost    { background: transparent; color: var(--nx-navy); padding: 0.5rem 1.25rem; border-radius: var(--nx-radius); font-size: 0.875rem; font-weight: 500; border: 1px solid var(--nx-border); cursor: pointer; transition: all 0.15s; }
.btn-ghost:hover   { background: #f8fafc; }

/* ────────────────────────────────────────────────
   CARDS
───────────────────────────────────────────────── */
.nx-card {
  background: var(--nx-card);
  border-radius: var(--nx-radius-lg);
  box-shadow: var(--nx-shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
}
.nx-card-hover:hover {
  box-shadow: var(--nx-shadow);
  transform: translateY(-2px);
}

/* Legacy alias */
.card { background: var(--nx-card); border-radius: var(--nx-radius-lg); box-shadow: var(--nx-shadow-sm); }

/* ────────────────────────────────────────────────
   STAT CARDS
───────────────────────────────────────────────── */
.nx-stat {
  background: var(--nx-card);
  border-radius: var(--nx-radius-lg);
  box-shadow: var(--nx-shadow-sm);
  padding: 1.25rem;
  border-left: 3px solid transparent;
  transition: box-shadow 0.15s;
}
.nx-stat:hover         { box-shadow: var(--nx-shadow); }
.nx-stat-navy          { border-left-color: var(--nx-navy); }
.nx-stat-copper        { border-left-color: var(--nx-copper); }
.nx-stat-success       { border-left-color: var(--nx-success); }
.nx-stat-warning       { border-left-color: var(--nx-warning); }
.nx-stat-danger        { border-left-color: var(--nx-danger); }
.nx-stat-info          { border-left-color: var(--nx-info); }

.nx-stat-value {
  font-family: var(--nx-font-mono);
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--nx-navy);
  line-height: 1;
}
.nx-stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.375rem;
}
.nx-stat-delta {
  font-size: 0.75rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: 0.25rem;
}
.nx-stat-delta-up   { color: var(--nx-success); }
.nx-stat-delta-down { color: var(--nx-danger); }

/* ────────────────────────────────────────────────
   BADGES
───────────────────────────────────────────────── */
.nx-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.5;
}
.nx-badge-navy    { background: #e8ecf2;                    color: var(--nx-navy); }
.nx-badge-copper  { background: #fdf3ec;                    color: var(--nx-copper-dark); }
.nx-badge-success { background: var(--nx-success-bg);       color: #15803d; }
.nx-badge-warning { background: var(--nx-warning-bg);       color: #b45309; }
.nx-badge-danger  { background: var(--nx-danger-bg);        color: #b91c1c; }
.nx-badge-info    { background: var(--nx-info-bg);          color: #1d4ed8; }
.nx-badge-grey    { background: #f1f5f9;                    color: #64748b; }
.nx-badge-purple  { background: #f3e8ff;                    color: #7c3aed; }

/* Legacy alias */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 500; }

/* ────────────────────────────────────────────────
   TABLES
───────────────────────────────────────────────── */
.nx-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.nx-table thead th {
  padding: 0.625rem 0.875rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f8fafc;
  border-bottom: 1px solid var(--nx-border);
  white-space: nowrap;
}
.nx-table tbody td {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid #f1f5f9;
  color: #374151;
  vertical-align: middle;
}
.nx-table tbody tr:last-child td { border-bottom: none; }
.nx-table tbody tr                { transition: background 0.1s; }
.nx-table tbody tr:hover          { background: #f8fafc; }

/* Legacy alias */
.table-row:hover { background: #f8fafc; }

/* ────────────────────────────────────────────────
   MODALS
───────────────────────────────────────────────── */
.nx-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.nx-modal {
  background: #fff;
  border-radius: var(--nx-radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--nx-shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}
.nx-modal-lg  { max-width: 760px; }
.nx-modal-xl  { max-width: 960px; }
.nx-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--nx-border);
}
.nx-modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--nx-navy);
}

/* Legacy aliases */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal         { background: #fff; border-radius: var(--nx-radius-xl); padding: 2rem; width: 100%; max-width: 560px; box-shadow: var(--nx-shadow-lg); }

/* ────────────────────────────────────────────────
   FORM INPUTS
───────────────────────────────────────────────── */
.form-input {
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: #1e293b;
  background: #fff;
  width: 100%;
  font-family: var(--nx-font);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus {
  border-color: var(--nx-navy);
  box-shadow: 0 0 0 3px rgba(15,35,64,0.08);
}
select.form-input { cursor: pointer; }

/* ── Select option colors — explicit to prevent OS dark-mode white-on-white ──
   Native <option> popups don't reliably inherit the parent <select> colour.
   Setting both colour and background-color here ensures WCAG AA contrast
   regardless of OS colour scheme or data-theme state.                          */
select.form-input option            { color: #1e293b; background-color: #ffffff; }
select.form-input optgroup          { color: #6b7280; background-color: #f9fafb; font-weight: 600; }
html[data-theme="dark"] select.form-input option   { color: #e6edf3; background-color: #1c2128; }
html[data-theme="dark"] select.form-input optgroup { color: #9ca3af; background-color: #161b22; }

/* ────────────────────────────────────────────────
   SIDEBAR  — light theme
   Nav items on white: navy text, copper accents.
   WCAG AA: all text ≥ 4.5:1 contrast.
───────────────────────────────────────────────── */
.sidebar-item {
  border-left: 3px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  color: #374151;                           /* 10.9:1 on white ✓ */
}
.sidebar-item svg  { color: #6B7280; transition: color 0.12s; }
.sidebar-item span { color: #374151; transition: color 0.12s; }

.sidebar-item:hover {
  background: #F3F6FA;                      /* very light blue-grey */
  border-left-color: rgba(176,117,74,0.45);
}
.sidebar-item:hover svg  { color: #0F2340; }
.sidebar-item:hover span { color: #0F2340; }

.sidebar-item.active {
  background: rgba(176,117,74,0.10);        /* light copper wash */
  border-left-color: var(--nx-copper);
}
.sidebar-item.active svg  { color: var(--nx-copper)  !important; opacity: 1 !important; }
.sidebar-item.active span { color: #0F2340            !important; opacity: 1 !important; font-weight: 600; }

/* ────────────────────────────────────────────────
   CHART COLOUR HELPERS
───────────────────────────────────────────────── */
.nx-c1 { color: var(--nx-chart-1); } .nx-f1 { fill: var(--nx-chart-1); }
.nx-c2 { color: var(--nx-chart-2); } .nx-f2 { fill: var(--nx-chart-2); }
.nx-c3 { color: var(--nx-chart-3); } .nx-f3 { fill: var(--nx-chart-3); }
.nx-c4 { color: var(--nx-chart-4); } .nx-f4 { fill: var(--nx-chart-4); }
.nx-c5 { color: var(--nx-chart-5); } .nx-f5 { fill: var(--nx-chart-5); }
.nx-c6 { color: var(--nx-chart-6); } .nx-f6 { fill: var(--nx-chart-6); }
.nx-c7 { color: var(--nx-chart-7); } .nx-f7 { fill: var(--nx-chart-7); }
.nx-c8 { color: var(--nx-chart-8); } .nx-f8 { fill: var(--nx-chart-8); }

/* Expose chart palette as JS-readable CSS vars on :root (no duplication) */

/* ────────────────────────────────────────────────
   NOTIFICATION COLOURS
───────────────────────────────────────────────── */
.nx-notif          { border-radius: var(--nx-radius); padding: 0.75rem 1rem; font-size: 0.875rem; display: flex; align-items: flex-start; gap: 0.625rem; }
.nx-notif-success  { background: var(--nx-success-bg); border-left: 3px solid var(--nx-success); color: #14532d; }
.nx-notif-warning  { background: var(--nx-warning-bg); border-left: 3px solid var(--nx-warning); color: #78350f; }
.nx-notif-danger   { background: var(--nx-danger-bg);  border-left: 3px solid var(--nx-danger);  color: #7f1d1d; }
.nx-notif-info     { background: var(--nx-info-bg);    border-left: 3px solid var(--nx-info);    color: #1e3a8a; }

/* ────────────────────────────────────────────────
   LOADING SCREEN
───────────────────────────────────────────────── */
#nx-loading-screen {
  position: fixed;
  inset: 0;
  background: var(--nx-navy-dark);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  transition: opacity 0.4s ease;
}
#nx-loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}
.nx-loading-bar-track {
  width: 200px;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
  overflow: hidden;
}
.nx-loading-bar-fill {
  height: 100%;
  background: var(--nx-copper);
  border-radius: 99px;
  animation: nx-progress 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes nx-progress {
  0%   { width: 0%; }
  25%  { width: 40%; }
  55%  { width: 68%; }
  80%  { width: 86%; }
  100% { width: 100%; }
}
.nx-loading-label {
  color: rgba(255,255,255,0.38);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: var(--nx-font);
  margin-top: 0.5rem;
  text-align: center;
}

/* ────────────────────────────────────────────────
   UTILITY
───────────────────────────────────────────────── */
.nx-copper   { color: var(--nx-copper); }
.nx-navy     { color: var(--nx-navy); }
.nx-success  { color: var(--nx-success); }
.nx-warning  { color: var(--nx-warning); }
.nx-danger   { color: var(--nx-danger); }
.nx-muted    { color: #64748b; }

/* Scrollbar */
::-webkit-scrollbar          { width: 4px; height: 4px; }
::-webkit-scrollbar-track    { background: transparent; }
::-webkit-scrollbar-thumb    { background: #cbd5e1; border-radius: 99px; }

/* ────────────────────────────────────────────────
   DARK MODE
   Applied via html[data-theme="dark"]
───────────────────────────────────────────────── */
html[data-theme="dark"] {
  --nx-bg:     #0d1117;
  --nx-card:   #161b22;
  --nx-border: #30363d;
  color-scheme: dark;
}
html[data-theme="dark"] body         { background: var(--nx-bg); color: #c9d1d9; }
html[data-theme="dark"] .nx-card,
html[data-theme="dark"] .card        { background: var(--nx-card); box-shadow: 0 1px 6px rgba(0,0,0,0.4); }
html[data-theme="dark"] .nx-stat     { background: var(--nx-card); }
html[data-theme="dark"] .nx-modal    { background: var(--nx-card); }
html[data-theme="dark"] .nx-modal-overlay { background: rgba(0,0,0,0.7); }
html[data-theme="dark"] .nx-table thead th { background: #1c2128; color: #8b949e; border-color: #30363d; }
html[data-theme="dark"] .nx-table tbody td { color: #c9d1d9; border-color: #21262d; }
html[data-theme="dark"] .nx-table tbody tr:hover { background: #1c2128; }
html[data-theme="dark"] .form-input  { background: #1c2128; border-color: #30363d; color: #e6edf3; }
html[data-theme="dark"] .form-input:focus { border-color: var(--nx-copper-light); box-shadow: 0 0 0 3px rgba(176,117,74,0.15); }
html[data-theme="dark"] header       { background: #161b22 !important; border-color: #30363d !important; }
html[data-theme="dark"] .bg-white    { background-color: var(--nx-card) !important; }
html[data-theme="dark"] .bg-gray-50  { background-color: #1c2128 !important; }
html[data-theme="dark"] .bg-gray-100 { background-color: #21262d !important; }
html[data-theme="dark"] .text-gray-900 { color: #e6edf3 !important; }
html[data-theme="dark"] .text-gray-800 { color: #c9d1d9 !important; }
html[data-theme="dark"] .text-gray-700 { color: #c9d1d9 !important; }
html[data-theme="dark"] .text-gray-600 { color: #8b949e !important; }
html[data-theme="dark"] .text-gray-500 { color: #8b949e !important; }
html[data-theme="dark"] .text-gray-400 { color: #6e7681 !important; }
html[data-theme="dark"] .border-gray-100,
html[data-theme="dark"] .border-gray-200,
html[data-theme="dark"] .divide-gray-100 { border-color: #30363d !important; }
html[data-theme="dark"] .shadow-xl   { box-shadow: 0 20px 60px rgba(0,0,0,0.7) !important; }
html[data-theme="dark"] .nx-stat-value { color: #e6edf3; }
html[data-theme="dark"] .nx-btn-secondary { background: #1c2128; color: var(--nx-copper-light); border-color: #30363d; }
html[data-theme="dark"] .nx-btn-ghost { background: transparent; border-color: #30363d; color: #c9d1d9; }
html[data-theme="dark"] .nx-badge-navy { background: #1a2540; color: #93b0d8; }

/* ────────────────────────────────────────────────
   SKELETON LOADERS
───────────────────────────────────────────────── */
@keyframes nx-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.nx-skel {
  display: inline-block;
  height: 0.75rem;
  border-radius: 4px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 800px 100%;
  animation: nx-shimmer 1.4s ease-in-out infinite;
}
html[data-theme="dark"] .nx-skel {
  background: linear-gradient(90deg, #1c2128 25%, #2d333b 50%, #1c2128 75%);
  background-size: 800px 100%;
}
.nx-skel-circle {
  border-radius: 50%;
  width: 2rem; height: 2rem;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 800px 100%;
  animation: nx-shimmer 1.4s ease-in-out infinite;
}
.nx-skel-sm  { height: 0.625rem; }
.nx-skel-lg  { height: 1rem; }
.nx-skel-xl  { height: 1.5rem; }

/* ────────────────────────────────────────────────
   COMMAND PALETTE  (Ctrl+K)
───────────────────────────────────────────────── */
.nx-cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  backdrop-filter: blur(4px);
}
.nx-cmd-modal {
  width: 100%;
  max-width: 620px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.08);
}
html[data-theme="dark"] .nx-cmd-modal {
  background: #161b22;
  border-color: #30363d;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
}
.nx-cmd-search {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
}
html[data-theme="dark"] .nx-cmd-search { border-color: #21262d; }
.nx-cmd-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: var(--nx-font);
  color: #1e293b;
  background: transparent;
}
html[data-theme="dark"] .nx-cmd-input { color: #e6edf3; }
.nx-cmd-esc {
  font-size: 0.625rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #64748b;
  font-family: var(--nx-font);
  cursor: pointer;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
}
html[data-theme="dark"] .nx-cmd-esc { background: #21262d; border-color: #30363d; color: #8b949e; }
.nx-cmd-results { max-height: 360px; overflow-y: auto; padding: 0.5rem; }
.nx-cmd-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.625rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s;
  color: inherit;
}
.nx-cmd-item:hover,
.nx-cmd-item.active { background: #f1f5f9; }
html[data-theme="dark"] .nx-cmd-item:hover,
html[data-theme="dark"] .nx-cmd-item.active { background: #1c2128; }
.nx-cmd-item-icon {
  width: 2rem; height: 2rem;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.nx-cmd-item-text { flex: 1; min-width: 0; }
.nx-cmd-item-title { font-size: 0.875rem; font-weight: 500; color: #1e293b; }
html[data-theme="dark"] .nx-cmd-item-title { color: #e6edf3; }
.nx-cmd-item-sub   { font-size: 0.75rem; color: #64748b; margin-top: 1px; }
.nx-cmd-type-badge {
  font-size: 0.625rem;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.nx-cmd-empty,
.nx-cmd-loading {
  padding: 2.5rem 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  color: #94a3b8;
}
.nx-cmd-footer {
  display: flex;
  gap: 1.25rem;
  padding: 0.625rem 1.25rem;
  border-top: 1px solid #f1f5f9;
  font-size: 0.6875rem;
  color: #94a3b8;
}
html[data-theme="dark"] .nx-cmd-footer { border-color: #21262d; }
.nx-cmd-footer kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  background: #f1f5f9;
  color: #475569;
  font-family: var(--nx-font-mono);
  font-size: 0.625rem;
  border: 1px solid #e2e8f0;
  margin-right: 2px;
}
html[data-theme="dark"] .nx-cmd-footer kbd { background: #21262d; border-color: #30363d; color: #8b949e; }

/* ────────────────────────────────────────────────
   FLOATING ACTION BUTTON
───────────────────────────────────────────────── */
.nx-fab-container {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 0.625rem;
}
.nx-fab-btn {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: var(--nx-copper);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(176,117,74,0.5), 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}
.nx-fab-btn:hover          { background: var(--nx-copper-dark); transform: scale(1.06); }
.nx-fab-btn.open           { transform: rotate(45deg); }
.nx-fab-items {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 0.5rem;
}
.nx-fab-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1rem 0.5rem 0.75rem;
  border-radius: 999px;
  background: #fff;
  color: #1e293b;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  box-shadow: 0 2px 12px rgba(0,0,0,0.14);
  border: 1px solid #f1f5f9;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
  white-space: nowrap;
}
.nx-fab-item:hover         { background: #f8fafc; transform: translateX(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.18); }
.nx-fab-item-icon {
  width: 1.75rem; height: 1.75rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
html[data-theme="dark"] .nx-fab-item { background: var(--nx-card); border-color: #30363d; color: #c9d1d9; }
html[data-theme="dark"] .nx-fab-item:hover { background: #1c2128; }

/* ────────────────────────────────────────────────
   TOOLTIPS  (data-tooltip attribute)
───────────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 0.6875rem;
  font-family: var(--nx-font);
  padding: 4px 8px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ────────────────────────────────────────────────
   TABLE SORT HEADERS
───────────────────────────────────────────────── */
.nx-th-sort {
  cursor: pointer;
  user-select: none;
  transition: color 0.1s;
}
.nx-th-sort:hover { color: var(--nx-navy); }
.nx-th-sort .sort-icon {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
  font-style: normal;
  font-size: 0.65rem;
}
.nx-th-sort.asc  .sort-icon,
.nx-th-sort.desc .sort-icon { opacity: 1; color: var(--nx-copper); }

/* ────────────────────────────────────────────────
   NOTIFICATION CENTRE
───────────────────────────────────────────────── */
.nx-notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
  color: inherit;
}
.nx-notif-item:hover { background: #f8fafc; }
.nx-notif-item.unread { background: #f0f9ff; }
html[data-theme="dark"] .nx-notif-item.unread { background: rgba(37,99,235,0.08); }
.nx-notif-item-icon {
  width: 2rem; height: 2rem;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ────────────────────────────────────────────────
   KEYBOARD SHORTCUTS PANEL
───────────────────────────────────────────────── */
.nx-shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem 1.5rem;
}
.nx-shortcut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: #374151;
}
html[data-theme="dark"] .nx-shortcut { color: #c9d1d9; }
.nx-shortcut kbd {
  font-family: var(--nx-font-mono);
  font-size: 0.6875rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 2px 7px;
  color: #475569;
  white-space: nowrap;
}
html[data-theme="dark"] .nx-shortcut kbd { background: #21262d; border-color: #30363d; color: #8b949e; }

/* ────────────────────────────────────────────────
   USER PROFILE PAGE
───────────────────────────────────────────────── */
.nx-profile-avatar {
  width: 5rem; height: 5rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700;
  color: #fff;
  position: relative;
  overflow: hidden;
  background: var(--nx-navy);
}
.nx-profile-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.nx-profile-avatar-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  cursor: pointer;
}
.nx-profile-avatar:hover .nx-profile-avatar-overlay { opacity: 1; }

/* ────────────────────────────────────────────────
   TAB NAVIGATION
───────────────────────────────────────────────── */
.nx-tabs {
  display: flex;
  border-bottom: 2px solid var(--nx-border);
  gap: 0;
}
.nx-tab {
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.nx-tab:hover { color: var(--nx-navy); }
.nx-tab.active { color: var(--nx-navy); border-bottom-color: var(--nx-copper); }

/* ================================================================
   MOBILE RESPONSIVE
   Breakpoints:
     < 768px  — phone / small tablet  (below Tailwind md:)
     < 480px  — small phone  (Galaxy S24, iPhone SE, 360-430px)
   ================================================================ */

/* ── Desktop: sidebar always in-flow, overlay/hamburger hidden ── */
@media (min-width: 768px) {
  .nx-sidebar         { position: relative !important; transform: none !important; height: auto; }
  .nx-sidebar-overlay { display: none !important; }
  .nx-hamburger       { display: none !important; }
}

/* ── Mobile: sidebar becomes a fixed slide-in drawer ── */
@media (max-width: 767px) {

  /* ── Sidebar drawer ────────────────────────────────────────── */
  .nx-sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100dvh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.28s;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .nx-sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.4);
  }

  /* ── Sidebar overlay backdrop ──────────────────────────────── */
  .nx-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    z-index: 199;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  /* ── Hamburger button: visible on mobile ───────────────────── */
  .nx-hamburger {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* ── Topbar ─────────────────────────────────────────────────── */
  .nx-topbar { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }

  /* ── Page content padding ───────────────────────────────────── */
  #nx-main-content { padding: 0.75rem !important; }

  /* ── Tailwind grid: collapse 3+ columns → 2 columns ─────────── */
  .grid-cols-3,
  .grid-cols-4,
  .grid-cols-5,
  .grid-cols-6,
  .grid-cols-8 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* ── Tables: make containers scrollable ─────────────────────── */
  div:has(> .nx-table),
  div:has(> table),
  .nx-card:has(.nx-table),
  .overflow-hidden:has(.nx-table) {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
  }
  .nx-table { min-width: 540px; }

  /* ── Tabs: horizontal scroll, no wrapping ───────────────────── */
  .nx-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    scrollbar-width: none;
  }
  .nx-tabs::-webkit-scrollbar { display: none; }

  /* ── Notification panel: clamp to viewport ──────────────────── */
  .nx-notif-panel {
    right: -2.5rem !important;
    width: 20rem !important;
    max-height: 80vh;
    overflow-y: auto;
  }

  /* ── Stat cards: slightly smaller value on mobile ───────────── */
  .nx-stat-value { font-size: 1.4rem; }

  /* ── Touch targets: minimum 44px height ─────────────────────── */
  .sidebar-item     { min-height: 2.75rem; }
  .nx-btn           { min-height: 2.5rem;  }
  .nx-tab           { min-height: 2.75rem; padding-left: 0.875rem; padding-right: 0.875rem; }

  /* ── Modals: full-width on mobile ───────────────────────────── */
  .nx-modal     { padding: 1.25rem !important; border-radius: 12px; }
  .nx-modal-lg,
  .nx-modal-xl  { max-width: 100% !important; margin: 0.5rem; }

  /* ── FAB: shift up to avoid nav overlap ────────────────────── */
  .nx-fab-container { bottom: 1rem; right: 1rem; }

  /* ── Filter chips / action rows: allow wrapping ─────────────── */
  .flex.items-center.gap-2 { flex-wrap: wrap; }
  .flex.items-center.gap-3 { flex-wrap: wrap; }

  /* ── Command palette ─────────────────────────────────────────── */
  .nx-cmd-overlay  { padding: 3.5rem 0.5rem 0.5rem; align-items: flex-start; }
  .nx-cmd-modal    { border-radius: 12px; max-height: calc(100dvh - 4rem); }
  .nx-cmd-results  { max-height: 55vh; }
}

/* ── Extra-small phones: 360–479px ── */
@media (max-width: 479px) {

  /* Collapse ALL multi-col grids to single column */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .grid-cols-5,
  .grid-cols-6,
  .grid-cols-8 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }

  /* Notification panel: fixed, full-width */
  .nx-notif-panel {
    position: fixed !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    top: 3.75rem !important;
    width: auto !important;
  }

  /* Page content padding */
  #nx-main-content { padding: 0.625rem !important; }

  /* Topbar title: keep on one line */
  .nx-topbar h1 { font-size: 0.8rem !important; }

  /* Stat value: readable but compact */
  .nx-stat-value  { font-size: 1.25rem; }
  .nx-stat        { padding: 0.875rem; }

  /* Prevent filter chips from overflowing */
  .flex-shrink-0 { flex-shrink: 0 !important; }

  /* Table min-width reduced for narrowest phones */
  .nx-table { min-width: 460px; }
}

/* ── Dark mode + mobile sidebar ── */
html[data-theme="dark"] .nx-sidebar-overlay { background: rgba(0, 0, 0, 0.7); }

/* ── Dark mode: restore dark sidebar for users who prefer it ── */
html[data-theme="dark"] .nx-sidebar {
  background: var(--nx-navy-dark) !important;
  border-right-color: rgba(255,255,255,0.06) !important;
}
html[data-theme="dark"] .nx-sidebar-logo {
  background: var(--nx-navy-dark) !important;
  border-bottom-color: rgba(255,255,255,0.08) !important;
}
html[data-theme="dark"] .sidebar-item {
  color: rgba(255,255,255,0.55);
}
html[data-theme="dark"] .sidebar-item svg  { color: rgba(255,255,255,0.40); }
html[data-theme="dark"] .sidebar-item span { color: rgba(255,255,255,0.55); }
html[data-theme="dark"] .sidebar-item:hover {
  background: rgba(255,255,255,0.07);
  border-left-color: rgba(176,117,74,0.5);
}
html[data-theme="dark"] .sidebar-item:hover svg  { color: rgba(255,255,255,0.85); }
html[data-theme="dark"] .sidebar-item:hover span { color: rgba(255,255,255,0.85); }
html[data-theme="dark"] .sidebar-item.active {
  background: rgba(176,117,74,0.15);
}
html[data-theme="dark"] .sidebar-item.active svg  { color: var(--nx-copper-light) !important; }
html[data-theme="dark"] .sidebar-item.active span { color: #fff !important; font-weight: 600; }
html[data-theme="dark"] .nx-sidebar-user-footer {
  border-top-color: rgba(255,255,255,0.08) !important;
}
html[data-theme="dark"] .nx-sidebar-user-name   { color: rgba(255,255,255,0.85) !important; }
html[data-theme="dark"] .nx-sidebar-user-role   { color: rgba(255,255,255,0.35) !important; }
html[data-theme="dark"] .nx-sidebar-signout     { color: rgba(255,255,255,0.30) !important; }
html[data-theme="dark"] .nx-sidebar-signout:hover { color: rgba(255,255,255,0.80) !important; }
