/* ============================================================================
   TruRadar brand tokens — verbatim suite copy.
   Source of truth: packages/tokens/tru-tokens.css (L1→L2) + truinspect/src/brand.css
   (semantic type/depth). Edit the canonical files, copy across. The system in
   one line: near-black, one cyan accent, warm off-white at four opacities,
   Inter at generous sizes in mid weights, no uppercase.
   Component layer aligned to the CURRENT suite state (TruInspect/TruLens/
   TruFlow 2026): cyan-500 fill sculpted buttons, ink-700 raised secondary,
   glass hairlines, dark native form controls.
   ========================================================================== */

:root, [data-app="truradar"] {
  /* ---------- L1 · PRIMITIVES (packages/tokens/tru-tokens.css) ---------- */
  --tru-ink-900: #06080D;
  --tru-ink-800: #0D1117;
  --tru-ink-700: #161B22;
  --tru-ink-600: #21262D;
  --tru-ink-500: #30363D;
  --tru-ink-300: #6E7681;
  --tru-ink-100: #B1BAC4;
  --tru-paper:      #E8EAE6;
  --tru-paper-pure: #FFFFFF;

  --tru-cyan-300: #7FF0EA;
  --tru-cyan-400: #4FE3DC;
  --tru-cyan-500: #3ECFC8;
  --tru-cyan-600: #06B6D4;
  --tru-cyan-700: #0891B2;
  --tru-cyan-800: #22807C;

  --tru-amber-500: #F59E0B;
  --tru-red-500:   #EF4444;
  --tru-green-500: #10B981;

  --tru-cyan-300-rgb: 127 240 234;
  --tru-cyan-400-rgb: 79 227 220;
  --tru-paper-rgb:    232 234 230;
  --tru-ink-900-rgb:  6 8 13;

  /* ---------- L2 · SEMANTIC (components consume these only) ---------- */
  --bg-base:       var(--tru-ink-900);
  --bg-raised:     var(--tru-ink-800);
  --bg-overlay:    var(--tru-ink-700);
  --bg-inset:      var(--tru-ink-600);
  --border-subtle: var(--tru-ink-500);
  --border-strong: var(--tru-ink-300);

  --text-primary:   var(--tru-paper);
  --text-secondary: var(--tru-ink-100);
  --text-muted:     var(--tru-ink-300);
  --text-on-accent: var(--tru-ink-900);

  --accent:         var(--tru-cyan-400);
  --accent-hover:   var(--tru-cyan-500);
  --accent-rgb:     var(--tru-cyan-400-rgb);
  --accent-surface: rgb(var(--accent-rgb) / 0.10);
  --accent-border:  rgb(var(--accent-rgb) / 0.35);
  --focus-ring:     var(--tru-cyan-400);

  --state-attention: var(--tru-amber-500);
  --state-error:     var(--tru-red-500);
  --state-success:   var(--tru-green-500);

  /* brand.css semantic layer */
  --ink:        var(--tru-ink-900);
  --ink-2:      var(--tru-ink-800);
  --glass:      rgba(232, 234, 230, 0.055);
  --glass-line: rgba(232, 234, 230, 0.14);

  --white:      var(--tru-paper);
  --white-dim:  rgba(232, 234, 230, 0.72);
  --muted:      rgba(232, 234, 230, 0.55);
  --faint:      rgba(232, 234, 230, 0.32);

  --cyan:       var(--tru-cyan-400);
  --cyan-bright:var(--tru-cyan-300);
  --cyan-soft:  rgba(79, 227, 220, 0.35);
  --cyan-faint: rgba(79, 227, 220, 0.08);

  --danger:     #B86A6A;
  --warning:    rgba(232, 234, 230, 0.55);
  --amber:      var(--tru-amber-500);

  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;

  /* Type scale — 12px is the floor. No uppercase in body copy. */
  --t-micro: 12px;
  --t-small: 13px;
  --t-body:  15px;
  --t-lead:  17px;
  --t-h3:    20px;
  --t-h2:    28px;

  --w-regular:  400;
  --w-medium:   500;
  --w-semibold: 600;

  --track-h2: -0.015em;
  --track-h3: -0.01em;

  --shadow-card:  0 1px 0 rgba(232,234,230,0.08) inset, 0 20px 45px -20px rgba(0,0,0,0.85);
  --shadow-lift:  0 1px 0 rgba(79,227,220,0.25) inset, 0 0 25px -5px rgba(79,227,220,0.15), 0 28px 60px -25px rgba(0,0,0,0.95);
  --shadow-modal: 0 0 0 1px rgba(79,227,220,0.2), 0 40px 90px -40px rgba(0,0,0,0.95);

  --r-sm:   10px;
  --r-card: 20px;
  --r-pill: 100px;

  color-scheme: dark;
}

/* ---------- Base ---------- */
html { background: var(--bg-base); }
body {
  background: radial-gradient(circle at 50% 0%, rgba(79, 227, 220, 0.035) 0%, transparent 45%), var(--bg-base);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  min-height: 100vh;
}
::selection { background: var(--accent); color: var(--text-on-accent); }

/* The grey flash Android/iOS paints on every tap is not ours and lands late. */
* { -webkit-tap-highlight-color: transparent; }

/* Focus is always visible — keyboard users navigate this app. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
  border-color: transparent;
}
/* Skip the ring on a cyan fill — it disappears into the button. */
.btn-primary:focus-visible,
.on-fill:focus-visible {
  outline-color: var(--text-primary);
}

/* Native controls follow the OS, not the page. A <select> styled dark still
   dropped a white popup, so its light option text vanished into it. Declaring
   the scheme makes the browser render the popup, scrollbars, date pickers and
   the rest to match; the option colours are belt and braces for Windows.
   Verbatim from TruFlow — this is the white-on-white fix. */
select option,
select optgroup {
  background-color: var(--bg-raised);
  color: var(--text-primary);
}

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

/* ---------- Scrollbars — match the suite's quiet 6px track ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(232,234,230,0.10); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(232,234,230,0.20); }
* { scrollbar-width: thin; scrollbar-color: rgba(232,234,230,0.14) transparent; }

/* ---------- Type floor — the suite bumps anything below 12px ---------- */
.text-\[11px\] { font-size: 12px; }

/* ---------- Surfaces ---------- */
.tru-panel {
  background: linear-gradient(180deg, rgba(232, 234, 230, 0.03) 0%, rgba(232, 234, 230, 0.015) 100%), var(--bg-raised);
  border: 1px solid var(--glass-line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
}
.tru-card {
  background: linear-gradient(180deg, rgba(232, 234, 230, 0.035) 0%, rgba(232, 234, 230, 0.01) 100%), var(--bg-raised);
  border: 1px solid var(--glass-line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  transition: border-color 200ms ease, transform 200ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 200ms ease;
  position: relative;
  overflow: hidden;
}
.tru-card:hover {
  border-color: var(--cyan-soft);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
}
.glass-nav {
  background: rgba(6, 8, 13, 0.82);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border-bottom: 1px solid var(--glass-line);
}

/* ---------- Buttons — current suite sculpted recipe (TruInspect/TruLens) ----------
   Cyan fill carries ink text (cyan/white fails contrast). Thickness not shine:
   a solid darker side, one 1px top hairline, one ambient shadow — never a
   gradient, no letterpress. Min touch target 44px. */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; min-height: 44px;
  background: var(--tru-cyan-500);
  color: var(--text-on-accent);
  border: none; border-radius: 12px;
  font-family: var(--mono); font-weight: 600; font-size: var(--t-small);
  cursor: pointer; text-shadow: none;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.28),
    0 5px 0 var(--tru-cyan-800),
    0 10px 22px -8px rgba(0,0,0,0.95);
  transition: background 120ms ease, transform 90ms ease, box-shadow 90ms ease;
}
.btn-primary:hover { background: var(--tru-cyan-400); }
.btn-primary:active {
  transform: translateY(4px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.20),
    0 1px 0 var(--tru-cyan-800),
    0 2px 6px -3px rgba(0,0,0,0.9);
}
.btn-primary:disabled { background: rgba(232,234,230,0.08); color: var(--faint); box-shadow: none; transform: none; cursor: not-allowed; }
.btn-primary svg { color: var(--text-on-accent); }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; min-height: 44px;
  background: var(--tru-ink-700);
  color: var(--text-primary);
  border: none; border-radius: 12px;
  font-family: var(--mono); font-weight: 500; font-size: var(--t-small);
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(232,234,230,0.10),
    0 4px 0 var(--tru-ink-900),
    0 8px 18px -8px rgba(0,0,0,0.95);
  transition: background 120ms ease, transform 90ms ease;
}
.btn-secondary:hover { background: var(--tru-ink-600); }
.btn-secondary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--tru-ink-900), 0 2px 6px -3px rgba(0,0,0,0.9); }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; min-height: 44px;
  background: transparent; color: var(--white-dim);
  border: none; border-radius: 12px;
  font-weight: 500; font-size: var(--t-small); cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.btn-ghost:hover { background: rgba(232,234,230,0.06); color: var(--white); }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; min-height: 44px;
  background: rgba(184, 106, 106, 0.12); color: var(--danger);
  border: 1px solid rgba(184, 106, 106, 0.25); border-radius: 12px;
  font-weight: 500; font-size: var(--t-small); cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.btn-danger:hover { background: rgba(184, 106, 106, 0.20); border-color: rgba(184, 106, 106, 0.40); }

/* ---------- Inputs ---------- */
.tru-input {
  min-height: 44px;
  background: rgba(232, 234, 230, 0.04);
  border: 1px solid var(--glass-line);
  border-radius: 12px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35);
  color: var(--text-primary);
  font-size: var(--t-small);
  font-family: var(--sans);
  padding: 0 12px;
  outline: none;
  transition: border-color 120ms ease;
}
.tru-input::placeholder { color: var(--faint); }
.tru-input:focus { border-color: var(--accent); }
.tru-input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; border-color: transparent; }
select.tru-input { font-family: var(--mono); color-scheme: dark; }
.tru-label { font-size: var(--t-micro); font-weight: 500; color: var(--muted); display: block; margin-bottom: 6px; }

/* Popup colours belt and braces for Windows — same treatment as the suite. */
select.tru-input option,
select.tru-input optgroup {
  background-color: var(--bg-raised);
  color: var(--text-primary);
}

/* ---------- Chips / status ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: var(--t-micro); font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 10px; border-radius: 8px; border: 1px solid var(--glass-line);
  color: var(--white-dim); background: var(--glass);
}
.chip-accent { color: var(--accent); background: var(--accent-surface); border-color: var(--accent-border); }
.chip-attention { color: var(--state-attention); background: rgba(245,158,11,0.10); border-color: rgba(245,158,11,0.30); }
.chip-danger { color: var(--danger); background: rgba(184,106,106,0.12); border-color: rgba(184,106,106,0.25); }
.chip-claimed { color: var(--accent); background: var(--accent-surface); border-color: var(--accent-border); }

/* ---------- Bottom nav (mobile — current TruInspect .tl-bottomnav recipe) ----------
   Light on its top edge, shadow thrown upward, so the nav reads as sitting
   over the list rather than printed on it. Fixed to the viewport here. */
.tl-bottomnav {
  display: flex; align-items: stretch; gap: 4px;
  padding: 6px 8px max(6px, env(safe-area-inset-bottom, 0px));
  background:
    linear-gradient(0deg,
      rgba(232, 234, 230, 0.05) 0%,
      rgba(232, 234, 230, 0.018) 60%,
      rgba(232, 234, 230, 0) 100%),
    #0B0F17;
  backdrop-filter: blur(14px) saturate(1.05);
  -webkit-backdrop-filter: blur(14px) saturate(1.05);
  border-top: 1px solid rgba(232, 234, 230, 0.10);
  box-shadow:
    inset 0 1px 0 rgba(232, 234, 230, 0.10),
    0 -14px 30px -20px rgba(0, 0, 0, 0.95);
}
.tl-bottomnav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; min-width: 48px;
  background: transparent; border: none; border-radius: 10px;
  color: var(--muted); font-family: var(--mono); font-size: var(--t-micro); cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.tl-bottomnav button:hover { background: var(--glass); }
.tl-bottomnav button[aria-current="page"] { color: var(--accent); background: var(--accent-surface); }

/* ---------- Shells ---------- */
#mBottomNav { display: none; }
.m-only { display: none !important; }

@media (max-width: 1023px) {
  .d-only { display: none !important; }
  .m-only { display: block !important; }
  #mBottomNav { display: flex; }
  body { padding-bottom: 76px; } /* bottom nav never obscures content */
  .tru-card:hover { transform: none; }
}

/* ---------- Misc ---------- */
.radar-pulse { animation: pulse-glow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes pulse-glow { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.9); } }
.font-mono-code { font-family: var(--mono); }
/* Icons are stroke-based Lucide paths — the sprite <symbol>s carry no fill/stroke,
   so the referencing <svg> must declare them or every glyph paints solid black on
   the dark chrome. One rule here covers every icon everywhere. */
.icon, .icon-lg { fill: none; stroke: currentColor; stroke-width: 2; }
.icon { width: 16px; height: 16px; flex-shrink: 0; }
.icon-lg { width: 20px; height: 20px; flex-shrink: 0; }

/* ---------- Toast ---------- */
#toastContainer { pointer-events: none; }
.toast {
  pointer-events: auto;
  background: var(--bg-raised);
  border: 1px solid var(--glass-line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-lift);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: var(--t-small);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 200ms ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast.toast-out { animation: toast-out 180ms ease-in forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
