/* ==========================================================================
   Collanduni — Analytics & Operations Console
   tokens.css · design tokens, reset, base type, buttons, forms
   Dark-first. Light theme via [data-theme="light"] on <html>.
   ========================================================================== */

:root {
  /* ---- Surface ramp (cool blue-black) ---------------------------------- */
  --canvas:        #0A0D12;   /* app background */
  --surface:       #10141C;   /* panels, sidebar */
  --surface-2:     #151A24;   /* cards */
  --surface-3:     #1B2130;   /* hover / elevated */
  --hairline:      #222A38;   /* borders — quiet chrome */
  --hairline-soft: #1A2028;

  /* ---- Text ramp -------------------------------------------------------- */
  --fg:        #E8EDF6;
  --fg-soft:   #A7B2C4;
  --fg-mute:   #6E7A8D;
  --fg-faint:  #4A5464;

  /* ---- Signature accent: azure ----------------------------------------- */
  --accent:       #1FB6FF;
  --accent-soft:  #63CDFF;
  --accent-deep:  #0A8FD1;
  --accent-wash:  rgba(31, 182, 255, 0.12);
  --accent-line:  rgba(31, 182, 255, 0.30);
  --on-accent:    #04121C;

  /* ---- Functional state colours (meaning only, never decoration) -------- */
  --ok:      #34D399;
  --ok-wash: rgba(52, 211, 153, 0.13);
  --warn:      #FBBF24;
  --warn-wash: rgba(251, 191, 36, 0.13);
  --err:      #F87171;
  --err-wash: rgba(248, 113, 113, 0.13);
  --info:      var(--accent);
  --info-wash: var(--accent-wash);

  /* ---- Type ------------------------------------------------------------- */
  --font-display: "Host Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body:    "Schibsted Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-mono:    "Azeret Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.8125rem;
  --text-base: 0.9375rem;
  --text-md:   1.0625rem;
  --text-lg:   1.375rem;
  --text-xl:   1.75rem;
  --text-2xl:  clamp(1.9rem, 1.5rem + 1.2vw, 2.5rem);
  --text-hero: clamp(2.75rem, 2rem + 3.4vw, 4.25rem);   /* north-star number */

  /* ---- Space ------------------------------------------------------------ */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;

  /* ---- Shape ------------------------------------------------------------ */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* ---- Elevation — deliberately restrained (quiet chrome) --------------- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.70);

  /* ---- Motion ----------------------------------------------------------- */
  --dur-fast: 130ms;
  --dur: 220ms;
  --dur-slow: 520ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* ---- Shell metrics ---------------------------------------------------- */
  --rail-w: 254px;
  --rail-w-collapsed: 68px;
  --topbar-h: 60px;

  --z-drawer: 40;
  --z-modal: 50;
  --z-toast: 60;

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   Light theme — a genuine second surface ramp, not an inversion afterthought
   -------------------------------------------------------------------------- */
[data-theme="light"] {
  --canvas:        #F4F7FB;
  --surface:       #FFFFFF;
  --surface-2:     #FFFFFF;
  --surface-3:     #EEF3F9;
  --hairline:      #DCE4EF;
  --hairline-soft: #E8EEF6;

  --fg:       #0D1520;
  --fg-soft:  #45566C;
  --fg-mute:  #6B7C93;
  --fg-faint: #97A5B8;

  --accent:      #0F8FD6;
  --accent-soft: #2FA8EA;
  --accent-deep: #0A6EA6;
  --accent-wash: rgba(15, 143, 214, 0.10);
  --accent-line: rgba(15, 143, 214, 0.28);
  --on-accent:   #FFFFFF;

  --ok:   #0E9F6E;
  --warn: #B45309;
  --err:  #DC2626;
  --ok-wash:   rgba(14, 159, 110, 0.11);
  --warn-wash: rgba(180, 83, 9, 0.11);
  --err-wash:  rgba(220, 38, 38, 0.10);

  --shadow-sm: 0 1px 2px rgba(16, 32, 56, 0.06);
  --shadow-md: 0 8px 24px -10px rgba(16, 32, 56, 0.16);
  --shadow-lg: 0 24px 60px -22px rgba(16, 32, 56, 0.24);

  color-scheme: light;
}

/* ==========================================================================
   Reset
   ========================================================================== */

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

* { margin: 0; }

/* Any class that sets `display` outranks the hidden attribute's UA rule, which
   silently breaks tab panels, empty states and the bulk bar. Restore it. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--canvas);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

img, svg { display: block; max-width: 100%; }
img { height: auto; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

a { color: inherit; text-decoration: none; }

ul, ol { list-style: none; padding: 0; }

table { border-collapse: collapse; width: 100%; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--accent-wash); color: var(--fg); }

/* ==========================================================================
   Base typography
   ========================================================================== */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.018em;
  line-height: 1.22;          /* display grotesque — never below 1.15 */
  color: var(--fg);
}

h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
h4 { font-size: var(--text-base); }

p { line-height: 1.62; }

/* Numerals: mono + tabular everywhere a figure can change or be compared. */
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.02em;
}

.label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-mute);
  line-height: 1.45;
}

.muted { color: var(--fg-mute); }
.soft  { color: var(--fg-soft); }

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

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 36px;
  padding: 0 var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}

.btn:active { transform: translateY(1px); }

.btn svg { width: 15px; height: 15px; flex: none; }

.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn--primary:hover { background: var(--accent-soft); }

.btn--ghost {
  background: transparent;
  border-color: var(--hairline);
  color: var(--fg-soft);
}
.btn--ghost:hover {
  background: var(--surface-3);
  color: var(--fg);
  border-color: var(--hairline);
}

.btn--quiet {
  background: transparent;
  color: var(--fg-mute);
  padding: 0 var(--s-3);
}
.btn--quiet:hover { color: var(--fg); background: var(--surface-3); }

.btn--danger {
  background: var(--err-wash);
  color: var(--err);
  border-color: transparent;
}
.btn--danger:hover { background: var(--err); color: #fff; }

.btn--sm { height: 30px; padding: 0 var(--s-3); font-size: var(--text-xs); }

.btn--icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--r-md);
  color: var(--fg-mute);
}
.btn--icon:hover { background: var(--surface-3); color: var(--fg); }
.btn--icon svg { width: 17px; height: 17px; }

.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ==========================================================================
   Form controls
   ========================================================================== */

.field { display: grid; gap: var(--s-2); }

.field > label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg-soft);
}

.field .hint { font-size: var(--text-xs); color: var(--fg-mute); }

.input,
.select,
.textarea {
  width: 100%;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 0 var(--s-3);
  height: 38px;
  font-size: var(--text-sm);
  color: var(--fg);
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}

[data-theme="light"] .input,
[data-theme="light"] .select,
[data-theme="light"] .textarea { background: var(--surface); }

.textarea { height: auto; padding: var(--s-3); resize: vertical; min-height: 96px; line-height: 1.6; }

.input::placeholder, .textarea::placeholder { color: var(--fg-faint); }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.select {
  appearance: none;
  padding-right: var(--s-6);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236E7A8D' stroke-width='1.6' stroke-linecap='round'><path d='M4 6.5 8 10.5 12 6.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  background-size: 15px;
  cursor: pointer;
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 40px;
  height: 22px;
  flex: none;
  cursor: pointer;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%; height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch .track {
  width: 100%; height: 100%;
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.switch .thumb {
  position: absolute;
  left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--fg-mute);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch input:checked ~ .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked ~ .thumb { transform: translateX(18px); background: var(--on-accent); }
.switch input:focus-visible ~ .track { box-shadow: 0 0 0 3px var(--accent-wash); }

/* Checkbox */
.check {
  appearance: none;
  width: 16px; height: 16px;
  flex: none;
  border: 1.5px solid var(--fg-faint);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.check::after {
  content: "";
  width: 8px; height: 4px;
  border-left: 2px solid var(--on-accent);
  border-bottom: 2px solid var(--on-accent);
  transform: rotate(-45deg) scale(0);
  transition: transform var(--dur-fast) var(--ease);
  margin-top: -2px;
}
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after { transform: rotate(-45deg) scale(1); }
.check:indeterminate { background: var(--accent); border-color: var(--accent); }
.check:indeterminate::after {
  width: 8px; height: 0;
  border-left: 0;
  border-bottom: 2px solid var(--on-accent);
  transform: none;
  margin-top: 0;
}

/* Radio card — used for plan pickers */
.radio-card {
  position: relative;
  display: grid;
  gap: var(--s-1);
  padding: var(--s-4);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.radio-card:hover { border-color: var(--fg-faint); }
.radio-card input { position: absolute; opacity: 0; }
.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-wash);
}
.radio-card:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-wash); }

/* ==========================================================================
   Motion preferences
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
