:root {
  --bg: #05080f;
  --bg-2: #080d18;
  --panel: #0c1320;
  --panel-2: #101a2b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #edf2fb;
  --muted: #8b97ad;
  --accent: #2f6bff;
  --accent-2: #7aa2ff;
  --good: #3ddc97;
  --warn: #f6b94a;
  --bad: #ff6b6b;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); color: var(--text); }

body {
  font: 15px/1.55 Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(34px, 5vw, 62px); line-height: 1.05; letter-spacing: -0.03em; font-weight: 700; }
h2 { font-size: 22px; line-height: 1.2; letter-spacing: -0.01em; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }

a { color: var(--accent-2); text-decoration: none; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------------------------------------------------------------- nav */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 28px;
  background: rgba(5, 8, 15, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2f6bff, #8b5cf6 55%, #ec4899);
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  letter-spacing: 0.02em;
}
.brand-name { font-weight: 700; letter-spacing: -0.01em; }

.nav-links { display: flex; gap: 4px; }
.nav-link {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 500;
}
.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.nav-link.active { color: var(--text); background: rgba(47, 107, 255, 0.16); }

.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.coverage { font-size: 12px; color: var(--muted); white-space: nowrap; }

.ghost {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: transparent;
  padding: 8px 14px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
}
.primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 9px 16px;
  border-radius: 9px;
  font-weight: 600;
}
.primary:hover { filter: brightness(1.08); }
.secondary {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 8px 13px;
  border-radius: 9px;
  font-weight: 500;
  font-size: 13px;
}
.secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }
.secondary:disabled { opacity: 0.4; cursor: not-allowed; }

/* -------------------------------------------------------------- hero */

.hero {
  position: relative;
  padding: 84px 24px 0;
  text-align: center;
  overflow: hidden;
}

.hero-glow {
  position: absolute;
  inset: -200px 0 auto;
  height: 700px;
  background:
    radial-gradient(420px 320px at 50% 32%, rgba(47, 107, 255, 0.22), transparent 70%),
    radial-gradient(520px 320px at 62% 10%, rgba(139, 92, 246, 0.16), transparent 70%),
    radial-gradient(420px 300px at 38% 18%, rgba(236, 72, 153, 0.1), transparent 70%);
  pointer-events: none;
}

.kicker {
  position: relative;
  color: var(--accent-2);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 18px;
}
.hero h1 { position: relative; }
.sub {
  position: relative;
  max-width: 680px;
  margin: 20px auto 0;
  color: var(--muted);
  font-size: 17px;
}

.hero-search {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 820px;
  margin: 36px auto 0;
  padding: 14px 16px 12px;
  background: rgba(16, 26, 43, 0.9);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: left;
}
.hero-search textarea {
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  min-height: 30px;
  max-height: 120px;
}
.hero-search textarea::placeholder { color: #6c7a92; }

.hero-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch-track {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #263043;
  position: relative;
  transition: background 0.18s ease;
}
.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #c7d2e5;
  transition: transform 0.18s ease;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(16px); background: #fff; }
.switch-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; }

.send {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  line-height: 1;
}
.send:hover { filter: brightness(1.1); }

.hero-tabs {
  display: flex;
  justify-content: center;
  gap: 28px;
  max-width: 820px;
  margin: 26px auto 0;
  border-bottom: 1px solid var(--line);
}
.hero-tab {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 12px 2px;
  font-weight: 600;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.hero-tab:hover { color: var(--text); }
.hero-tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* --------------------------------------------------------- workspace */

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1280px;
  margin: 26px auto 40px;
  padding: 0 24px;
  align-items: start;
}
@media (max-width: 960px) { .workspace { grid-template-columns: 1fr; } }

.results-pane, .detail-pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 200px;
}
.results-pane { position: sticky; top: 76px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; }
@media (max-width: 960px) { .results-pane { position: static; max-height: none; } }

.pane-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

.results { display: flex; flex-direction: column; gap: 6px; overflow: auto; }
.results-empty { color: var(--muted); font-size: 14px; padding: 18px 4px; }

.result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
}
.result:hover { background: rgba(255, 255, 255, 0.04); }
.result.active { background: rgba(47, 107, 255, 0.12); border-color: rgba(47, 107, 255, 0.4); }
.result .r-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .r-meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.result .r-risk { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.result .r-risk.low { color: var(--good); }
.result .r-risk.medium { color: var(--warn); }
.result .r-risk.high, .result .r-risk.critical { color: var(--bad); }

.ai-answer {
  margin-top: 14px;
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid rgba(47, 107, 255, 0.35);
  border-radius: 10px;
  font-size: 14px;
  white-space: pre-wrap;
}
.ai-answer .ai-tag { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 6px; font-weight: 700; }

/* ------------------------------------------------------------ detail */

.empty-state { padding: 46px 20px; text-align: center; }
.empty-icon {
  width: 54px; height: 54px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 14px; border: 1px solid var(--line-strong);
  font-size: 26px; color: var(--accent-2);
}
.empty-state p { max-width: 440px; margin: 10px auto 0; font-size: 14px; }
.empty-facts { display: flex; justify-content: center; gap: 38px; margin-top: 28px; }
.empty-facts div { display: flex; flex-direction: column; }
.empty-facts strong { font-size: 22px; }
.empty-facts span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.company-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.eyebrow { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.company-head h2 { font-size: 28px; letter-spacing: -0.02em; }
.company-head #company-meta { margin-top: 6px; font-size: 13px; }
.company-badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  white-space: nowrap;
}
.badge.low { background: rgba(61, 220, 151, 0.14); color: var(--good); }
.badge.medium { background: rgba(246, 185, 74, 0.14); color: var(--warn); }
.badge.high, .badge.critical { background: rgba(255, 107, 107, 0.14); color: var(--bad); }
.badge.outline { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); }

.company-actions { display: flex; align-items: center; gap: 8px; margin: 16px 0 6px; flex-wrap: wrap; }
.toast { margin-left: auto; font-size: 12px; color: var(--good); }

.detail-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin: 14px 0 18px; }
.detail-tab {
  background: none; border: 0; color: var(--muted);
  padding: 10px 0; font-weight: 600; font-size: 13px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.detail-tab:hover { color: var(--text); }
.detail-tab.active { color: var(--text); border-bottom-color: var(--accent); }

.view { display: none; }
.view.active { display: block; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 18px; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; }
.stat .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat .v { font-size: 17px; font-weight: 700; margin-top: 2px; }
.stat .v.negative { color: var(--bad); }
.stat .v.positive { color: var(--good); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }

.block { margin-top: 18px; }
.block h3 { margin-bottom: 10px; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 11px; background: var(--panel-2); border-radius: 8px; font-size: 14px; }
.list .role { color: var(--muted); font-size: 12px; }

.identity { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 13px; }
.identity dt { color: var(--muted); }
.identity dd { margin: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 1px solid var(--line-strong); }
.timeline li { margin: 0 0 12px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -19px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.timeline .t-kind { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.timeline .t-title { font-weight: 600; font-size: 14px; }
.timeline.compact li { margin-bottom: 8px; }

.chart-wrap { position: relative; height: 260px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; font-size: 12px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.chip.primary { border-color: rgba(47, 107, 255, 0.55); color: var(--accent-2); }
.chip .ver { color: var(--muted); font-size: 10px; }

.raw { margin-top: 4px; }
.raw summary { cursor: pointer; color: var(--accent-2); font-size: 13px; }
.raw pre {
  margin: 10px 0 0; padding: 12px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 9px; color: var(--muted); font-size: 12px; white-space: pre-wrap;
  max-height: 320px; overflow: auto;
}
.person-details { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }

.graph { height: 420px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }

.chat-block { margin-top: 0; }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; margin-bottom: 10px; }
.msg { padding: 10px 12px; border-radius: 10px; white-space: pre-wrap; font-size: 14px; }
.msg.assistant { background: var(--panel-2); border: 1px solid var(--line); }
.msg.user { background: var(--accent); color: #fff; align-self: flex-end; max-width: 90%; }
.msg.error { background: rgba(255, 107, 107, 0.12); border: 1px solid rgba(255, 107, 107, 0.3); color: var(--bad); }
.chat-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-form textarea {
  flex: 1; resize: vertical; min-height: 42px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 9px; padding: 10px 12px; font: inherit;
}
.chat-form textarea:focus { outline: 2px solid rgba(47, 107, 255, 0.35); border-color: var(--accent); }
.sources { margin-top: 8px; }

.footer {
  display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  max-width: 1280px; margin: 0 auto; padding: 22px 24px 30px;
  color: var(--muted); font-size: 12px; border-top: 1px solid var(--line);
}
.footer-links { display: flex; gap: 16px; }

@media (max-width: 640px) {
  .nav { padding: 12px 16px; gap: 12px; }
  .nav-links { display: none; }
  .coverage { display: none; }
  .hero { padding-top: 52px; }
  .workspace { padding: 0 12px; }
}

/* --------------------------------------------------------------- admin */

.admin { max-width: 1200px; margin: 36px auto 60px; padding: 0 24px; }
.admin-title { font-size: 30px; letter-spacing: -0.02em; margin-bottom: 6px; }
.admin-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 26px 0; }
.admin-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.admin-card .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.admin-card .v { font-size: 24px; font-weight: 700; margin-top: 2px; }

.panel-block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-top: 18px; }
.panel-block h2 { font-size: 17px; }

.admin-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.admin-form input {
  background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text);
  border-radius: 9px; padding: 9px 11px; font: inherit; min-width: 160px;
}
.admin-form input:focus { outline: 2px solid rgba(47, 107, 255, 0.35); border-color: var(--accent); }
.admin-form .wide { flex: 1 1 320px; }
.admin-form .narrow { width: 90px; min-width: 90px; }
.admin-form select {
  background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text);
  border-radius: 9px; padding: 9px 11px; font: inherit;
}
.admin-form .check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.admin-filter {
  width: 100%; margin-bottom: 10px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 9px; padding: 9px 11px; font: inherit;
}

.token-input {
  background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text);
  border-radius: 9px; padding: 8px 11px; font: inherit; width: 190px;
}

.actions { display: flex; gap: 6px; justify-content: flex-end; }
.mini {
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line-strong);
  color: var(--text); border-radius: 7px; padding: 5px 9px; font-size: 11px; font-weight: 600;
}
.mini:hover { background: rgba(255, 255, 255, 0.1); }
.mini.danger { color: var(--bad); border-color: rgba(255, 107, 107, 0.35); }
.mini-input {
  width: 100px; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: 5px 7px; font: inherit; font-size: 12px;
}
.pre {
  margin-top: 12px; padding: 12px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 9px; color: var(--muted); font-size: 12px; white-space: pre-wrap; max-height: 280px; overflow: auto;
}
