/* =============================================================================
   NSLABS Visitor Intelligence — Design Tokens
   Importance-driven hierarchy. Min type 13px.
   ============================================================================= */

:root {
  --font-sans:
    "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --fs-xs: 13px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 26px;
  --fs-3xl: 34px;
  --fs-4xl: 44px;
  --fs-hero: 56px;
  --lh-tight: 1.15;
  --lh-normal: 1.45;
  --lh-relaxed: 1.6;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-black: 800;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 56px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --content-max: 1320px;
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
  --dur: 180ms;
  --accent: #3b82f6;
  --accent-2: #06b6d4;
  --positive: #22c55e;
  --negative: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
}

[data-theme="dark"] {
  --bg: #080a0d;
  --bg-elevated: #0d1014;
  --bg-panel: #11151a;
  --bg-soft: #161b21;
  --bg-hover: rgba(255, 255, 255, 0.035);
  --bg-active: rgba(59, 130, 246, 0.12);
  --line: rgba(255, 255, 255, 0.065);
  --line-strong: rgba(255, 255, 255, 0.11);
  --focus: rgba(59, 130, 246, 0.5);
  --text: #edf0f2;
  --text-2: #a4adb8;
  --text-3: #707a86;
  --text-inv: #080a0d;
  --shadow:
    0 1px 0 rgba(255, 255, 255, 0.025) inset, 0 12px 32px rgba(0, 0, 0, 0.4);
  --track: rgba(255, 255, 255, 0.07);
  --fill: linear-gradient(90deg, #3b82f6, #06b6d4);
  --live: #22c7d9;
  --pos-bg: rgba(34, 197, 94, 0.11);
  --neg-bg: rgba(239, 68, 68, 0.11);
  --warn-bg: rgba(245, 158, 11, 0.11);
  --acc-bg: rgba(59, 130, 246, 0.11);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f6f8;
  --bg-elevated: #ffffff;
  --bg-panel: #ffffff;
  --bg-soft: #eef1f4;
  --bg-hover: rgba(15, 23, 42, 0.04);
  --bg-active: rgba(37, 99, 235, 0.08);
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.14);
  --focus: rgba(37, 99, 235, 0.45);
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --text-inv: #ffffff;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --track: rgba(15, 23, 42, 0.08);
  --fill: linear-gradient(90deg, #2563eb, #0891b2);
  --live: #0891b2;
  --pos-bg: rgba(22, 163, 74, 0.1);
  --neg-bg: rgba(220, 38, 38, 0.1);
  --warn-bg: rgba(217, 119, 6, 0.1);
  --acc-bg: rgba(37, 99, 235, 0.1);
  color-scheme: light;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}
input,
button {
  font-size: var(--fs-sm);
}
table {
  border-collapse: collapse;
  width: 100%;
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 99px;
}

/* Shared primitives */
.kicker {
  display: block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-black);
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-3);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-2);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 99px;
  white-space: nowrap;
}

.surface {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.surface-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
}

.surface-head h3 {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
}

.surface-head p {
  margin: 3px 0 0;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.chart-area {
  position: relative;
  width: 100%;
  padding: var(--space-3);
}
.chart-area canvas {
  width: 100% !important;
  height: 100% !important;
}

.track {
  height: 6px;
  background: var(--track);
  border-radius: 99px;
  overflow: hidden;
}
.track > i {
  display: block;
  height: 100%;
  background: var(--fill);
  border-radius: inherit;
  transition: width 0.55s var(--ease);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-2);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 99px;
}

.code-pill {
  display: inline-flex;
  padding: 2px 7px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--accent);
  background: var(--acc-bg);
  border-radius: var(--radius-sm);
}

.pos {
  color: var(--positive) !important;
}
.neg {
  color: var(--negative) !important;
}
.is-positive {
  color: var(--positive);
}
.is-negative {
  color: var(--negative);
}
.is-neutral {
  color: var(--text-3);
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  font-size: var(--fs-sm);
}
.data-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  vertical-align: middle;
}
.data-table tbody tr:last-child td {
  border-bottom: none;
}
.data-table tbody tr:hover td {
  background: var(--bg-hover);
}
.data-table td strong {
  color: var(--text);
  font-weight: var(--fw-semibold);
}

.empty-state {
  padding: var(--space-6);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.4s var(--ease),
    transform 0.4s var(--ease);
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  padding: 11px 18px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition:
    opacity 0.2s,
    transform 0.2s var(--ease);
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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