/* CNBC V2 — refined design system
   Tokens, typography, layout, components.
   Modern light theme with dark navy sidebar. */

:root {
  /* Surfaces — LIGHT */
  --bg:            #f4f6fa;
  --surface:       #ffffff;
  --surface-2:     #f9fafb;
  --surface-3:     #f3f4f6;
  --border:        #e5e7eb;
  --border-strong: #d1d5db;

  /* Text */
  --text:          #111827;
  --text-2:        #374151;
  --text-muted:    #6b7280;
  --text-faint:    #9ca3af;

  /* Brand */
  --primary:       #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft:  #dbeafe;

  /* Semantic */
  --success:       #059669;
  --success-soft:  #d1fae5;
  --danger:        #dc2626;
  --danger-soft:   #fee2e2;
  --warning:       #d97706;
  --warning-soft:  #fef3c7;
  --info:          #0891b2;
  --info-soft:     #cffafe;
  --purple:        #7c3aed;
  --purple-soft:   #ede9fe;

  /* Sidebar (same in both modes) */
  --sidebar-bg:    #0b1220;
  --sidebar-bg-2:  #111a2e;
  --sidebar-text:  #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-active-bg: rgba(37,99,235,.18);

  /* Geometry */
  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  --shadow-1:  0 1px 2px rgba(15,23,42,.05);
  --shadow-2:  0 1px 3px rgba(15,23,42,.07), 0 1px 2px rgba(15,23,42,.04);
  --shadow-3:  0 4px 12px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);

  --sidebar-width: 232px;
  --topbar-height: 56px;
}

[data-theme="dark"] {
  --bg:            #0a0f1c;
  --surface:       #0f172a;
  --surface-2:     #131b2d;
  --surface-3:     #1c2540;
  --border:        #1f2a44;
  --border-strong: #2a3656;

  --text:          #e5e9f2;
  --text-2:        #c7cde0;
  --text-muted:    #8a93ab;
  --text-faint:    #5a6481;

  --primary:       #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft:  rgba(59,130,246,.18);

  --success:       #22c55e;
  --success-soft:  rgba(34,197,94,.14);
  --danger:        #f87171;
  --danger-soft:   rgba(239,68,68,.14);
  --warning:       #fbbf24;
  --warning-soft:  rgba(245,158,11,.14);
  --info:          #22d3ee;
  --info-soft:     rgba(6,182,212,.14);
  --purple:        #a78bfa;
  --purple-soft:   rgba(139,92,246,.14);

  --sidebar-bg:    #060b18;
  --sidebar-bg-2:  #0a1126;

  --shadow-1:  0 1px 2px rgba(0,0,0,.4);
  --shadow-2:  0 2px 6px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.3);
  --shadow-3:  0 8px 24px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; transition: color .12s; }
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4 { margin: 0; letter-spacing: -0.015em; }

code, .mono {
  font-family: "SF Mono", "JetBrains Mono", Menlo, monospace;
  font-size: 0.92em;
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ---------- ICONS ---------- */
.ico { width: 18px; height: 18px; flex-shrink: 0; }
.ico-lg { width: 22px; height: 22px; flex-shrink: 0; }
.ico-sm { width: 14px; height: 14px; flex-shrink: 0; }

/* ---------- SHELL ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar-bg);
  background-image: linear-gradient(180deg, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 220px);
  color: var(--sidebar-text);
  padding: 20px 0 16px;
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 22px;
  font-size: 14px; font-weight: 500; color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.sidebar .brand { color: #fff; }
.login-card .brand { padding: 0 0 20px; }
.brand-logo {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.08);
}
.brand-text { display: inline-flex; flex-direction: column; }
.brand-text strong { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }
.brand .ico { width: 22px; height: 22px; color: var(--primary); }

.nav-section {
  padding: 0 20px;
  font-size: 10.5px;
  color: var(--sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin: 16px 0 4px;
}
.nav-section:first-of-type { margin-top: 0; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 20px;
  color: var(--sidebar-text); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .12s ease, color .12s ease, border-color .12s ease, padding-left .12s ease;
  position: relative;
}
.nav a .ico {
  width: 16px; height: 16px; opacity: 0.7;
  transition: opacity .12s ease, transform .12s ease, color .12s ease;
}
.nav a:hover {
  background: rgba(255,255,255,.04);
  color: #fff;
  padding-left: 22px;
}
.nav a:hover .ico { opacity: 1; transform: scale(1.05); }
.nav a.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  border-left-color: #60a5fa;
  font-weight: 600;
}
.nav a.active .ico { color: #93c5fd; opacity: 1; }
.nav a.active::after {
  content: '';
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: #60a5fa;
}

.user-card {
  margin: auto 14px 0; padding: 12px;
  background: rgba(255,255,255,.04);
  border-radius: var(--radius);
  font-size: 12px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}
.user-meta { min-width: 0; flex: 1; }
.user-name {
  color: #fff; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 13px;
}
.user-card a {
  color: var(--sidebar-muted); font-size: 11px;
  display: inline-flex; align-items: center; gap: 4px;
}
.user-card a:hover { color: #fff; }
.user-card .ico { width: 12px; height: 12px; }

/* ---------- MAIN ---------- */
.main { padding: 0 36px 28px; max-width: 1400px; }

/* ---------- TOPBAR (sticky, contextual) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  height: var(--topbar-height);
  margin: 0 -36px 22px;
  padding: 0 36px;
}
.topbar-context {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;
}
.topbar-context .page-name {
  font-size: 14px; font-weight: 600;
  color: var(--text); letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-context .page-sub {
  color: var(--text-muted); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.theme-toggle {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer; color: var(--text-muted);
  transition: background .12s, color .12s, border-color .12s;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.theme-toggle .ico { width: 16px; height: 16px; }
.theme-toggle .ico-moon { display: none; }
[data-theme="dark"] .theme-toggle .ico-sun  { display: none; }
[data-theme="dark"] .theme-toggle .ico-moon { display: block; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px; margin-bottom: 24px;
}
.page-title-block { min-width: 0; flex: 1; }
.breadcrumb {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--text-muted); font-size: 12.5px;
  margin-bottom: 6px; text-decoration: none;
}
.breadcrumb:hover { color: var(--primary); }
.breadcrumb .ico { width: 14px; height: 14px; }
.page-title {
  font-size: 24px; font-weight: 700; margin: 0;
  letter-spacing: -0.02em; color: var(--text);
}
.page-subtitle {
  color: var(--text-muted); font-size: 13.5px; margin-top: 4px;
}
.page-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ---------- CARDS ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
.card.padded { padding: 20px 22px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.card-title {
  font-weight: 600; font-size: 14px; margin: 0; color: var(--text);
  letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 8px;
}
.card-title .ico { color: var(--text-muted); }
.card-body { padding: 0; }
.card-body.padded { padding: 18px 22px; }

/* ---------- STAT TILES ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.stat .stat-icon {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
}
.stat .stat-icon .ico { width: 18px; height: 18px; }
.stat.green .stat-icon { background: var(--success-soft); color: var(--success); }
.stat.purple .stat-icon { background: var(--purple-soft); color: var(--purple); }
.stat.amber  .stat-icon { background: var(--warning-soft); color: var(--warning); }
.stat-label {
  color: var(--text-muted); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600;
}
.stat-value {
  font-size: 26px; font-weight: 700;
  margin-top: 6px; letter-spacing: -0.025em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-sub {
  color: var(--text-muted); font-size: 12px; margin-top: 4px;
  display: flex; align-items: center; gap: 4px;
}

/* ---------- ENTITY CARDS ---------- */
.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.entity {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color .12s, transform .08s, box-shadow .12s;
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column;
  gap: 6px;
}
.entity:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-3);
  transform: translateY(-1px);
}
.entity h3 {
  margin: 0; font-size: 15px; font-weight: 600;
  line-height: 1.35;
}
.entity h3 a { color: var(--text); }
.entity h3 a:hover { color: var(--primary); }
.entity .meta {
  color: var(--text-muted); font-size: 12.5px; line-height: 1.6;
  display: flex; flex-direction: column; gap: 2px;
}
.entity .meta-row {
  display: flex; align-items: center; gap: 6px;
}
.entity .meta-row .ico { color: var(--text-faint); width: 13px; height: 13px; }
.entity .pills { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- PILLS ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; font-size: 11px; font-weight: 600;
  background: var(--success-soft); color: var(--success);
  border-radius: 999px; line-height: 1.6;
  white-space: nowrap;
}
.pill .ico { width: 11px; height: 11px; }
.pill.inactive { background: var(--surface-3); color: var(--text-muted); }
.pill.danger   { background: var(--danger-soft);  color: var(--danger); }
.pill.warning  { background: var(--warning-soft); color: var(--warning); }
.pill.info     { background: var(--info-soft);    color: var(--info); }
.pill.purple   { background: var(--purple-soft);  color: var(--purple); }
.pill.primary  { background: var(--primary-soft); color: var(--primary); }

/* ---------- TOOLBAR ---------- */
.toolbar {
  display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
  align-items: center;
}
.toolbar form {
  display: flex; gap: 8px; align-items: center;
  flex: 1; min-width: 280px; max-width: 480px;
}

.search-wrap {
  position: relative; flex: 1;
}
.search-wrap .ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); width: 16px; height: 16px;
  pointer-events: none;
}
.search {
  width: 100%;
  padding: 9px 14px 9px 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.search::placeholder { color: var(--text-faint); }

.segmented {
  display: inline-flex; background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-1);
}
.segmented a {
  padding: 8px 14px; color: var(--text-muted);
  font-size: 12.5px; font-weight: 500;
  border-right: 1px solid var(--border);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.segmented a:last-child { border-right: none; }
.segmented a.active { background: var(--primary); color: #fff; }
.segmented a:hover:not(.active) { background: var(--surface-2); color: var(--text); }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--primary); color: #fff;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--primary);
  cursor: pointer; transition: background .12s, border-color .12s;
  text-decoration: none;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; text-decoration: none; }
.btn .ico { width: 15px; height: 15px; }

.btn.btn-light {
  background: var(--surface); color: var(--text-2);
  border-color: var(--border-strong);
}
.btn.btn-light:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

.btn.btn-ghost {
  background: transparent; color: var(--text-muted);
  border-color: transparent;
}
.btn.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* ---------- TABLES ---------- */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky;
  top: var(--topbar-height);
  background: var(--surface-2);
  padding: 11px 16px;
  text-align: left;
  font-weight: 600; font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
/* Tables nested in cards shouldn't get sticky (the card scrolls within) */
.card thead th { position: static; }
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .08s; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr td a { color: var(--text); font-weight: 500; }
tbody tr td a:hover { color: var(--primary); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Tighter table density inside cards */
.card table thead th { font-size: 11px; padding: 9px 14px; }
.card table tbody td { padding: 10px 14px; font-size: 13px; }

/* ---------- DETAIL PAGES ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 980px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-row {
  display: grid; grid-template-columns: 150px 1fr; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 13.5px; align-items: baseline;
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  color: var(--text-muted); font-weight: 500;
  font-size: 12.5px;
  display: flex; align-items: center; gap: 6px;
}
.detail-label .ico { width: 13px; height: 13px; color: var(--text-faint); }
.detail-value { color: var(--text); }
.detail-value.empty { color: var(--text-faint); font-style: italic; }

/* ---------- EMPTY STATES ---------- */
.empty {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted); font-size: 13.5px;
}
.empty .ico { width: 32px; height: 32px; opacity: 0.4; margin-bottom: 10px; }
.empty p { margin: 0; }
.empty .empty-hint {
  margin-top: 10px; font-size: 12.5px;
  display: inline-flex; align-items: center; gap: 4px;
}
.empty .empty-hint a {
  color: var(--primary); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.empty .empty-hint a:hover { text-decoration: underline; }

/* ---------- PAGINATION (numbered) ---------- */
.pagination {
  display: flex; gap: 4px; justify-content: center;
  margin-top: 22px; align-items: center; flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; gap: 4px;
  min-width: 32px; height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 500;
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
  transition: background .1s, border-color .1s, color .1s;
  justify-content: center;
}
.pagination a:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.pagination .current {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
  pointer-events: none;
}
.pagination span.disabled {
  color: var(--text-faint); background: transparent;
  border-color: var(--border);
}
.pagination .ellipsis {
  border: none; background: transparent;
  color: var(--text-faint); font-weight: 400;
  min-width: 20px; padding: 0 2px;
}
.pagination .ico { width: 14px; height: 14px; }

/* ---------- DETAIL HERO ---------- */
.detail-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 24px 26px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}
.detail-hero::before {
  content: '';
  position: absolute; top: 0; right: 0; width: 200px; height: 100%;
  background: radial-gradient(circle at top right, var(--primary-soft), transparent 70%);
  opacity: 0.4; pointer-events: none;
}
.detail-hero .hero-title {
  font-size: 26px; font-weight: 700;
  letter-spacing: -0.02em; color: var(--text);
  margin: 0 0 8px;
  position: relative; z-index: 1;
}
.detail-hero .hero-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 14px;
  position: relative; z-index: 1;
}
.detail-hero .hero-stats {
  display: flex; flex-wrap: wrap; gap: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  position: relative; z-index: 1;
}
.detail-hero .hero-stat {
  display: flex; flex-direction: column; gap: 2px;
}
.detail-hero .hero-stat .lbl {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.detail-hero .hero-stat .val {
  font-size: 18px; font-weight: 700; color: var(--text);
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}

/* ---------- FLASH ---------- */
.flash {
  padding: 11px 16px; border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid; font-size: 13.5px;
  display: flex; align-items: center; gap: 10px;
}
.flash.danger  { background: var(--danger-soft);  color: var(--danger);  border-color: #fecaca; }
.flash.success { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }
.flash.message { background: var(--info-soft);    color: var(--info);    border-color: #a5f3fc; }

/* ---------- LOGIN ---------- */
.login-page {
  display: flex; min-height: 100vh; align-items: center; justify-content: center;
  background:
    radial-gradient(60% 50% at 20% 20%, rgba(59,130,246,.18), transparent 60%),
    radial-gradient(50% 40% at 80% 80%, rgba(124,58,237,.15), transparent 60%),
    linear-gradient(135deg, #050912 0%, #0b1220 60%, #11203b 100%);
  padding: 24px;
}
.login-card {
  background: #fff; padding: 36px 32px; border-radius: 14px;
  min-width: 380px; max-width: 420px; width: 100%;
  box-shadow: 0 30px 60px rgba(0,0,0,.25);
}
.login-card .brand {
  padding: 0 0 4px; font-size: 22px;
}
.login-card .brand .ico { color: var(--primary); }
.login-card .sub {
  color: var(--text-muted); margin: 0 0 24px;
  font-size: 13.5px;
}
.field {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px;
}
.field label {
  font-size: 11.5px; color: var(--text-muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
}
.field input {
  padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: inherit; color: var(--text);
}
.field input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.login-card .btn {
  width: 100%; justify-content: center;
  padding: 11px; font-size: 14px;
}
.login-card .hint {
  margin-top: 18px; color: var(--text-muted);
  font-size: 12px; text-align: center; line-height: 1.6;
}

/* ---------- UTILITIES ---------- */
.muted    { color: var(--text-muted); }
.faint    { color: var(--text-faint); }
.flex     { display: flex; }
.flex-1   { flex: 1; }
.gap-2    { gap: 8px; }
.gap-3    { gap: 12px; }
.mt-2     { margin-top: 8px; }
.mt-3     { margin-top: 12px; }
.mt-4     { margin-top: 18px; }
.mb-2     { margin-bottom: 8px; }
.mb-3     { margin-bottom: 12px; }
.mb-4     { margin-bottom: 18px; }
.tabular  { font-variant-numeric: tabular-nums; }
.dash     { color: var(--text-faint); }
.right    { text-align: right; }
.nowrap   { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Smaller font weight for table headers in detail-page cards */
.card .detail-row { padding: 9px 0; }

/* ---------- CHARTS ---------- */
.chart-wrap { position: relative; height: 240px; padding: 8px 4px 0; }
.chart-wrap canvas { max-height: 240px; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  padding: 12px 20px 16px;
  font-size: 12px; color: var(--text-muted);
}
.chart-legend .legend-dot {
  display: inline-flex; align-items: center; gap: 6px;
}
.chart-legend .legend-dot::before {
  content: ''; width: 10px; height: 10px; border-radius: 50%;
  background: var(--swatch, var(--primary));
}

/* ---------- DASHBOARD GRID ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 980px) { .dash-row-2 { grid-template-columns: 1fr; } }

/* Quick actions panel */
.quick-action {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none; color: var(--text);
  transition: background .12s, border-color .12s, transform .08s;
  margin-bottom: 8px;
}
.quick-action:hover {
  background: var(--surface-2);
  border-color: var(--primary);
  transform: translateX(2px);
  text-decoration: none;
  color: var(--text);
}
.quick-action .qa-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.quick-action .qa-icon {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.quick-action .qa-icon.amber { background: var(--warning-soft); color: var(--warning); }
.quick-action .qa-icon.danger { background: var(--danger-soft); color: var(--danger); }
.quick-action .qa-icon.blue { background: var(--primary-soft); color: var(--primary); }
.quick-action .qa-icon.purple { background: var(--purple-soft); color: var(--purple); }
.quick-action .qa-icon.green { background: var(--success-soft); color: var(--success); }
.quick-action .qa-icon .ico { width: 18px; height: 18px; }
.quick-action .qa-title { font-weight: 500; font-size: 13.5px; }
.quick-action .qa-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.quick-action .qa-count {
  font-size: 18px; font-weight: 700; color: var(--text);
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.quick-action.zero .qa-count { color: var(--text-faint); }

/* Activity feed */
.activity-list { padding: 6px 0; }
.activity-item {
  display: flex; gap: 12px; padding: 11px 22px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: var(--text-muted);
}
.activity-icon .ico { width: 14px; height: 14px; }
.activity-icon.dollar { background: var(--success-soft); color: var(--success); }
.activity-icon.mail   { background: var(--info-soft); color: var(--info); }
.activity-icon.event  { background: var(--purple-soft); color: var(--purple); }
.activity-body { flex: 1; min-width: 0; line-height: 1.45; }
.activity-title { font-weight: 500; color: var(--text); }
.activity-meta { color: var(--text-muted); font-size: 11.5px; margin-top: 1px; }
.activity-amount {
  flex-shrink: 0; font-variant-numeric: tabular-nums;
  font-weight: 600; color: var(--text);
  font-size: 13px;
}

/* ---------- COMMAND PALETTE ---------- */
.cmdk-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12.5px; color: var(--text-muted);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.cmdk-trigger:hover { background: var(--surface-2); border-color: var(--border-strong); }
.cmdk-trigger .ico { width: 14px; height: 14px; }
.cmdk-trigger kbd {
  font-family: -apple-system, sans-serif;
  font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 4px;
  background: var(--surface-3); color: var(--text-muted);
  border: 1px solid var(--border);
  margin-left: 4px;
}

.cmdk-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  animation: cmdk-fade-in .15s ease;
}
.cmdk-overlay.open { display: flex; }
@keyframes cmdk-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cmdk-slide-in {
  from { opacity: 0; transform: translateY(-10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cmdk-panel {
  width: 100%; max-width: 600px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px rgba(0,0,0,.3);
  overflow: hidden;
  animation: cmdk-slide-in .18s ease;
}
.cmdk-input-wrap {
  position: relative;
  padding: 14px 18px 14px 50px;
  border-bottom: 1px solid var(--border);
}
.cmdk-input-wrap .ico {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px;
  color: var(--text-muted);
}
.cmdk-input {
  width: 100%; border: none; outline: none;
  font-size: 16px; color: var(--text);
  background: transparent; font-family: inherit;
}
.cmdk-input::placeholder { color: var(--text-faint); }
.cmdk-results {
  max-height: 380px; overflow-y: auto;
}
.cmdk-section-label {
  padding: 12px 18px 6px;
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.cmdk-result {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  cursor: pointer;
  border-left: 3px solid transparent;
  text-decoration: none; color: var(--text);
}
.cmdk-result.active {
  background: var(--surface-2);
  border-left-color: var(--primary);
}
.cmdk-result-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cmdk-result-icon .ico { width: 16px; height: 16px; }
.cmdk-result-icon.users    { background: var(--success-soft); color: var(--success); }
.cmdk-result-icon.building { background: var(--purple-soft);  color: var(--purple); }
.cmdk-result-body { flex: 1; min-width: 0; }
.cmdk-result-title { font-size: 14px; font-weight: 500; }
.cmdk-result-title .inactive-tag { color: var(--text-faint); font-weight: 400; margin-left: 6px; font-size: 11px; }
.cmdk-result-sub { font-size: 12px; color: var(--text-muted); }
.cmdk-result-type {
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600;
  background: var(--surface-3); color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.cmdk-empty {
  padding: 36px 24px; text-align: center;
  color: var(--text-muted); font-size: 13px;
}
.cmdk-empty .ico { width: 30px; height: 30px; margin-bottom: 8px; opacity: 0.4; }
.cmdk-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-muted);
  display: flex; justify-content: space-between; align-items: center;
}
.cmdk-footer kbd {
  font-family: -apple-system, sans-serif;
  font-size: 10.5px; font-weight: 600;
  padding: 1px 6px; border-radius: 4px;
  background: var(--surface-3); color: var(--text-muted);
  border: 1px solid var(--border);
}
.cmdk-shortcut-group { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; }

