/* =========================================================
   TrustSift — data verification API platform
   Dark, code-forward infra aesthetic. Single electric-blue accent.
   ========================================================= */

:root {
  /* Surfaces — near-black with a faint blue cast */
  --bg-0: #07090f;          /* page */
  --bg-1: #0b0e16;          /* panels */
  --bg-2: #10141f;          /* raised cards */
  --bg-3: #161b29;          /* inputs / hover */
  --bg-4: #1d2435;          /* borders strong */

  --line: #1a2030;          /* hairline */
  --line-2: #232b3e;

  /* Text */
  --tx-0: #f3f6fd;          /* headings */
  --tx-1: #c2cbdd;          /* body */
  --tx-2: #8b96ad;          /* muted */
  --tx-3: #7d89a2;          /* faint, still WCAG AA on dark surfaces */

  /* Accent — electric blue → cyan */
  --acc: #4d8dff;
  --acc-bright: #6aa3ff;
  --acc-cyan: #34e1d5;
  --acc-soft: rgba(77, 141, 255, 0.14);
  --acc-glow: rgba(77, 141, 255, 0.45);

  /* Semantic */
  --ok: #36d399;
  --ok-soft: rgba(54, 211, 153, 0.13);
  --warn: #f7b955;
  --warn-soft: rgba(247, 185, 85, 0.13);
  --err: #ff6b6b;
  --err-soft: rgba(255, 107, 107, 0.13);
  --violet: #a78bfa;

  /* Syntax highlight */
  --syn-key: #6aa3ff;
  --syn-str: #5fd0a7;
  --syn-num: #f7b955;
  --syn-bool: #c792ea;
  --syn-null: #ff6b6b;
  --syn-punc: #6c7793;

  --r-sm: 7px;
  --r-md: 11px;
  --r-lg: 16px;
  --r-xl: 22px;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Spline Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --sidebar-w: 252px;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.02) inset, 0 18px 40px -24px rgba(0,0,0,0.8);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-0);
  color: var(--tx-1);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  min-height: 100vh;
}

/* Ambient atmosphere */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 78% -10%, rgba(77,141,255,0.10), transparent 60%),
    radial-gradient(700px 500px at 8% 8%, rgba(52,225,213,0.06), transparent 55%);
}
/* faint grid texture */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(1100px 700px at 70% 0%, #000 0%, transparent 75%);
  mask-image: radial-gradient(1100px 700px at 70% 0%, #000 0%, transparent 75%);
  opacity: 0.18;
}

::selection { background: var(--acc-glow); color: #fff; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--acc-bright);
  outline-offset: 3px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 20px; border: 3px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: #2a3450; }

/* =========================================================
   App shell
   ========================================================= */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #090c14 0%, #07090f 100%);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 22px;
}
.brand .mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0 8px 22px -8px var(--acc-glow);
  flex-shrink: 0;
  overflow: hidden;
}
.brand .mark svg { width: 19px; height: 19px; color: #061018; }
.brand .mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand .name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--tx-0);
}
.brand .name b { color: var(--acc-bright); font-weight: 600; }
.brand .env-tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--ok);
  background: var(--ok-soft);
  padding: 3px 6px;
  border-radius: 5px;
}

.nav-group { margin-top: 10px; }
.nav-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--tx-3);
  padding: 12px 10px 7px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  color: var(--tx-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .14s, color .14s;
  position: relative;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.nav-item:hover { background: var(--bg-2); color: var(--tx-0); }
.nav-item.active { background: var(--acc-soft); color: var(--acc-bright); }
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--acc);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px var(--acc-glow);
}
.nav-item .badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-3);
  color: var(--tx-2);
  padding: 2px 6px;
  border-radius: 20px;
}

.sidebar-foot { margin-top: auto; padding-top: 16px; }
.usage-mini {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px;
}
.usage-mini .row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--tx-2); }
.usage-mini .row b { color: var(--tx-0); font-family: var(--font-mono); }
.bar { height: 6px; background: var(--bg-3); border-radius: 20px; margin-top: 9px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--acc), var(--acc-cyan)); }
.usage-mini .plan { display: flex; align-items: center; gap: 7px; margin-top: 11px; font-size: 11.5px; color: var(--tx-2); }
.usage-mini .plan b { color: var(--acc-bright); }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 9px; margin-top: 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-1);
}
.user-chip .av {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, #2a3450, #161b29);
  display: grid; place-items: center;
  color: var(--acc-bright); font-weight: 600; font-size: 13px;
  font-family: var(--font-display);
}
.user-chip .meta { line-height: 1.25; overflow: hidden; }
.user-chip .meta b { display: block; font-size: 12.5px; color: var(--tx-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta span { font-size: 11px; color: var(--tx-3); }

/* ---------- Main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(7,9,15,0.78);
  backdrop-filter: blur(14px);
}
.topbar .crumbs { font-size: 13px; color: var(--tx-2); display: flex; align-items: center; gap: 8px; }
.topbar .crumbs b { color: var(--tx-0); font-weight: 500; }
.topbar .crumbs .sep { opacity: .4; }
.topbar .spacer { flex: 1; }

.searchbar {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  width: 280px;
  color: var(--tx-2);
  font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
.searchbar:focus-within { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.searchbar svg { width: 15px; height: 15px; opacity: .7; }
.searchbar input { background: none; border: none; outline: none; color: var(--tx-0); width: 100%; }
.searchbar input::placeholder { color: var(--tx-3); }
.searchbar kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--tx-3);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 5px;
}
.searchbar { position: relative; }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--r-md); padding: 6px;
  box-shadow: 0 18px 44px -16px rgba(0,0,0,.8), 0 0 0 1px rgba(255,255,255,.02) inset;
  display: none; z-index: 60; max-height: 60vh; overflow-y: auto;
  min-width: 340px;
}
.search-results.open { display: block; }
.sr-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: none; border: none; cursor: pointer; text-align: left;
  padding: 9px 10px; border-radius: var(--r-sm); color: var(--tx-1);
}
.sr-item.on { background: var(--acc-soft); }
.sr-item .sr-ic { display: inline-flex; width: 18px; height: 18px; color: var(--acc); flex: 0 0 18px; }
.sr-item .sr-ic svg { width: 18px; height: 18px; }
.sr-item .sr-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.sr-item .sr-txt b { color: var(--tx-0); font-size: 13px; font-weight: 500; }
.sr-item .sr-txt span { color: var(--tx-2); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-item .sr-txt mark { background: transparent; color: var(--acc-bright); }
.sr-item .sr-kind {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .03em;
  color: var(--tx-3); border: 1px solid var(--line-2); border-radius: 4px;
  padding: 2px 6px; flex: 0 0 auto;
}
.sr-empty { padding: 14px 12px; color: var(--tx-2); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.sr-empty svg { width: 15px; height: 15px; opacity: .6; }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--tx-2);
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 20px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px var(--ok-soft); } 50% { box-shadow: 0 0 0 6px transparent; } }

.content { padding: 30px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* Page heads */
.page-head { margin-bottom: 26px; display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.page-head h1 {
  font-family: var(--font-display);
  font-size: 27px; font-weight: 600; letter-spacing: -0.025em;
  color: var(--tx-0);
}
.page-head p { color: var(--tx-2); font-size: 14px; margin-top: 5px; max-width: 60ch; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 13.5px; font-weight: 500;
  padding: 9px 15px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--tx-0);
  transition: background .14s, border-color .14s, transform .08s, box-shadow .14s;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: var(--bg-3); border-color: var(--bg-4); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--acc-bright), var(--acc));
  border-color: transparent; color: #fff;
  box-shadow: 0 8px 22px -10px var(--acc-glow), 0 0 0 1px rgba(255,255,255,.07) inset;
}
.btn.primary:hover { box-shadow: 0 10px 28px -8px var(--acc-glow), 0 0 0 1px rgba(255,255,255,.12) inset; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--tx-2); }
.btn.ghost:hover { background: var(--bg-2); color: var(--tx-0); }
.btn.danger { color: var(--err); border-color: rgba(255,107,107,.25); background: var(--err-soft); }
.btn.danger:hover { background: rgba(255,107,107,.2); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.icon { padding: 8px; }

/* =========================================================
   Cards / panels
   ========================================================= */
.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 22px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.card-head > svg { width: 17px; height: 17px; color: var(--acc-bright); flex-shrink: 0; }
.card-head h3 { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--tx-0); letter-spacing: -0.01em; }
.card-head p { font-size: 12px; color: var(--tx-3); }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.grid { display: grid; gap: 18px; }

/* =========================================================
   Stat cards
   ========================================================= */
.stat {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.stat::after {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, var(--acc-soft), transparent 70%);
  opacity: .8;
}
.stat .lbl { font-size: 12px; color: var(--tx-2); display: flex; align-items: center; gap: 8px; }
.stat .lbl svg { width: 15px; height: 15px; color: var(--acc-bright); }
.stat .val { font-family: var(--font-display); font-size: 30px; font-weight: 600; color: var(--tx-0); letter-spacing: -0.03em; margin-top: 10px; }
.stat .val small { font-size: 16px; color: var(--tx-2); font-weight: 500; }
.stat .delta { font-size: 12px; margin-top: 7px; display: inline-flex; align-items: center; gap: 5px; }
.stat .delta.up { color: var(--ok); }
.stat .delta.down { color: var(--err); }
.stat .delta svg { width: 13px; height: 13px; }
.stat .spark { position: absolute; right: 16px; bottom: 14px; width: 90px; height: 34px; opacity: .9; }

/* =========================================================
   Badges
   ========================================================= */
.badge-st {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  padding: 3px 9px; border-radius: 20px; letter-spacing: 0.01em;
}
.badge-st.ok { color: var(--ok); background: var(--ok-soft); }
.badge-st.warn { color: var(--warn); background: var(--warn-soft); }
.badge-st.err { color: var(--err); background: var(--err-soft); }
.badge-st.info { color: var(--acc-bright); background: var(--acc-soft); }
.badge-st.neutral { color: var(--tx-2); background: var(--bg-3); }
.badge-st .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.method {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 5px; letter-spacing: 0.03em;
}
.method.get { color: var(--ok); background: var(--ok-soft); }
.method.post { color: var(--acc-bright); background: var(--acc-soft); }

/* =========================================================
   Tables
   ========================================================= */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-weight: 500; color: var(--tx-3);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  padding: 11px 20px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td { padding: 13px 20px; border-bottom: 1px solid var(--line); color: var(--tx-1); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover { background: var(--bg-2); }
table.tbl .mono { font-family: var(--font-mono); font-size: 12px; color: var(--tx-1); }
table.tbl .muted { color: var(--tx-3); }

/* =========================================================
   Forms
   ========================================================= */
.field { margin-bottom: 16px; }
.field label, .field .field-label { display: block; font-size: 12.5px; color: var(--tx-1); margin-bottom: 7px; font-weight: 500; }
.field .hint { font-size: 11.5px; color: var(--tx-3); margin-top: 6px; }
.input, .select, textarea.input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  color: var(--tx-0);
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input.mono { font-family: var(--font-mono); font-size: 13px; }
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); background: var(--bg-1);
}
.input::placeholder { color: var(--tx-3); }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%238b96ad' stroke-width='2' viewBox='0 0 24 24'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 34px;
}

/* segmented control */
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button {
  border: none; background: none; color: var(--tx-2);
  font-size: 12.5px; font-weight: 500; padding: 6px 13px; border-radius: 5px;
  transition: background .14s, color .14s; white-space: nowrap;
}
.seg button:hover { color: var(--tx-0); }
.seg button.on { background: var(--bg-4); color: var(--tx-0); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset; }

/* =========================================================
   Code / JSON viewer
   ========================================================= */
.code {
  font-family: var(--font-mono);
  font-size: 12.5px; line-height: 1.7;
  background: #060810;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  overflow-x: auto;
  color: var(--tx-1);
  white-space: pre;
  tab-size: 2;
}
.code .ln { color: #303a52; display: inline-block; width: 2em; user-select: none; text-align: right; margin-right: 16px; }
.tok-key { color: var(--syn-key); }
.tok-str { color: var(--syn-str); }
.tok-num { color: var(--syn-num); }
.tok-bool { color: var(--syn-bool); }
.tok-null { color: var(--syn-null); }
.tok-punc { color: var(--syn-punc); }

.code-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--r-md) var(--r-md) 0 0;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--tx-2);
}
.code-head .dots { display: flex; gap: 6px; }
.code-head .dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--bg-4); }
.code-head .dots i:nth-child(1) { background: #ff5f57; opacity: .7; }
.code-head .dots i:nth-child(2) { background: #febc2e; opacity: .7; }
.code-head .dots i:nth-child(3) { background: #28c840; opacity: .7; }
.code-head .right { margin-left: auto; }
.code-head + .code { border-radius: 0 0 var(--r-md) var(--r-md); }

.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-3); border: 1px solid var(--line-2);
  color: var(--tx-2); font-size: 11.5px; padding: 4px 9px; border-radius: 6px;
  transition: all .14s;
}
.copy-btn:hover { color: var(--tx-0); border-color: var(--bg-4); }
.copy-btn svg { width: 13px; height: 13px; }
.copy-btn.done { color: var(--ok); border-color: var(--ok-soft); }

/* =========================================================
   Toast
   ========================================================= */
.toast-wrap { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 11px;
  background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--r-md); padding: 12px 15px;
  color: var(--tx-0); font-size: 13px;
  box-shadow: 0 18px 40px -14px rgba(0,0,0,.7);
  min-width: 240px;
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1);
}
.toast .ic { width: 18px; height: 18px; flex-shrink: 0; }
.toast.ok .ic { color: var(--ok); }
.toast.info .ic { color: var(--acc-bright); }
.toast.err .ic { color: var(--err); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut .25s forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* =========================================================
   Modal
   ========================================================= */
.modal-bg {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(4,6,11,0.72); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 24px;
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 460px;
  background: var(--bg-1); border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8);
  animation: modalIn .28s cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.modal-head { padding: 20px 22px 0; }
.modal-head h3 { font-family: var(--font-display); font-size: 18px; color: var(--tx-0); font-weight: 600; }
.modal-head p { color: var(--tx-2); font-size: 13px; margin-top: 5px; }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 16px 22px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); background: var(--bg-0); }

/* =========================================================
   Misc
   ========================================================= */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.split-3070 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }

.legend { display: flex; flex-direction: column; gap: 11px; }
.legend .li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend .li .sw { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.legend .li .nm { color: var(--tx-1); }
.legend .li .vl { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--tx-2); }

.empty {
  text-align: center; padding: 50px 20px; color: var(--tx-3);
}
.empty svg { width: 38px; height: 38px; opacity: .4; margin-bottom: 12px; }

.skel { background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.divider { height: 1px; background: var(--line); margin: 20px 0; }

.tag { font-family: var(--font-mono); font-size: 11px; color: var(--tx-2); background: var(--bg-3); border: 1px solid var(--line); padding: 2px 8px; border-radius: 6px; }

.flag { width: 20px; height: 14px; border-radius: 3px; display: inline-block; vertical-align: -2px; box-shadow: 0 0 0 1px rgba(255,255,255,.08); object-fit: cover; }

/* reveal on load */
.reveal { opacity: 0; transform: translateY(10px); animation: reveal .5s forwards; }
@keyframes reveal { to { opacity: 1; transform: none; } }

.mono { font-family: var(--font-mono); }
.acc { color: var(--acc-bright); }
.muted { color: var(--tx-2); }
.faint { color: var(--tx-3); }
.nowrap { white-space: nowrap; }

/* =========================================================
   Responsive
   ========================================================= */
.menu-btn { display: none; }
.sidebar-backdrop { display: none; }
.sidebar-backdrop { border: 0; padding: 0; }

@media (max-width: 1080px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .split-3070, .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 120;
    width: 264px; transform: translateX(-104%);
    transition: transform .28s cubic-bezier(.2,.8,.2,1);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 110;
    background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
  }
  .menu-btn { display: inline-flex; }
  .searchbar { display: none; }
  .content { padding: 20px 16px; }
  .topbar { padding: 12px 16px; }
}

@media (max-width: 560px) {
  .kpi-row { grid-template-columns: 1fr; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head h1 { font-size: 23px; }
  /* Let card headers wrap their controls (e.g. filter segmented control)
     onto a second line, and let an overflowing segmented control scroll
     instead of forcing the whole page wider. */
  .card-head { flex-wrap: wrap; }
  .card-head .right { margin-left: 0; width: 100%; }
  .card-head .seg { max-width: 100%; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
  .dot.pulse { box-shadow: none; }
}

/* =========================================================
   AI components — shared by playground (Explain) + docs (Assistant)
   ========================================================= */
.ai-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--acc-bright); background: var(--acc-soft);
  border: 1px solid rgba(77,141,255,.28); border-radius: 999px;
  padding: 3px 9px; line-height: 1;
}
.ai-pill svg { width: 13px; height: 13px; }

/* Spinner used inside buttons */
.ai-spin {
  display: inline-block; width: 13px; height: 13px; vertical-align: -2px;
  border: 2px solid rgba(255,255,255,.25); border-top-color: var(--acc-bright);
  border-radius: 50%; animation: ai-spin .7s linear infinite; margin-right: 4px;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* Animated thinking dots */
.ai-loading {
  display: flex; align-items: center; gap: 4px;
  color: var(--tx-2); font-size: 13px; padding: 4px 0;
}
.ai-loading .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--acc);
  margin-right: 2px; animation: ai-bounce 1.1s ease-in-out infinite;
}
.ai-loading .dot:nth-child(2) { animation-delay: .15s; }
.ai-loading .dot:nth-child(3) { animation-delay: .3s; margin-right: 8px; }
@keyframes ai-bounce { 0%,80%,100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

/* Answer blocks */
.ai-answer { display: flex; gap: 10px; align-items: flex-start; }
.ai-answer svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 2px; color: var(--acc-bright); }
.ai-answer p { margin: 0; color: var(--tx-1); font-size: 13.5px; line-height: 1.6; }
.ai-answer code { background: var(--bg-3); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.ai-answer.err svg { color: var(--err); }
.ai-answer.err p { color: var(--tx-2); }

/* Playground "Explain with AI" block (lives in response panel) */
.ai-explain {
  margin: 0 20px 18px; padding: 14px 16px;
  background: linear-gradient(140deg, rgba(77,141,255,.06), rgba(52,225,213,.04));
  border: 1px solid var(--line-2); border-radius: var(--r-md);
}
.ai-explain-head { display: flex; align-items: center; gap: 10px; }
.ai-explain-title { font-size: 13px; color: var(--tx-2); font-weight: 600; }
.ai-explain-head .btn { margin-left: auto; }
.ai-explain-body:not(:empty) { margin-top: 12px; }

/* Docs assistant box */
.docs-assistant {
  background: linear-gradient(140deg, rgba(77,141,255,.07), rgba(52,225,213,.04));
  border: 1px solid var(--line-2); border-radius: var(--r-lg);
  padding: 20px 22px; margin-bottom: 30px;
}
.docs-assistant .da-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.docs-assistant > p { color: var(--tx-2); font-size: 13.5px; margin: 0 0 14px; }
.da-row { display: flex; gap: 10px; }
.da-row .input { flex: 1; }
.da-row .btn { flex: 0 0 auto; }
.da-samples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.da-chip {
  font-size: 12px; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--tx-1);
  transition: background .15s, border-color .15s;
}
.da-chip:hover { background: var(--bg-3); border-color: var(--acc); color: var(--tx-0); }
.da-answer { margin-top: 0; max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.da-answer.show { margin-top: 16px; max-height: 1200px; }
.da-answer .ai-q { display: flex; gap: 8px; align-items: center; color: var(--tx-2); font-size: 13px; margin-bottom: 10px; }
.da-answer .ai-q svg { width: 14px; height: 14px; }
.da-answer .ai-a { display: flex; gap: 10px; align-items: flex-start; }
.da-answer .ai-a svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 2px; color: var(--acc-bright); }
.da-answer .ai-a p { margin: 0; color: var(--tx-0); font-size: 14px; line-height: 1.65; }
@media (max-width: 560px) {
  .da-row { flex-direction: column; }
  .ai-explain { margin-left: 14px; margin-right: 14px; }
}
