/* Admin console — dark sidebar, stat cards, card tables.
   Deliberately small and hand-written. No framework, no build step. */
:root {
  --bg: #0f1720; --panel: #16212e; --line: #24313f;
  --text: #e7eef5; --muted: #8fa3b5; --accent: #22d3c5;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, sans-serif; }
.admin { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--panel); border-right: 1px solid var(--line); padding: 20px 0; }
.brand { font-weight: 700; padding: 0 20px 20px; color: var(--accent); }
.sidebar nav a { display: block; padding: 10px 20px; color: var(--muted); text-decoration: none; }
.sidebar nav a:hover, .sidebar nav a.active { color: var(--text); background: rgba(255,255,255,.04); }
.content { flex: 1; }
.topbar { padding: 20px 28px; border-bottom: 1px solid var(--line); }
.body { padding: 28px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.stat-label { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.stat-value { display: block; font-size: 28px; font-weight: 600; margin-top: 6px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.login { max-width: 320px; margin: 15vh auto; display: grid; gap: 12px; }
.login input, .login button { padding: 10px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.login button { background: var(--accent); color: #06121a; font-weight: 600; cursor: pointer; }
.error { color: #ff6b6b; }

/* Table pages: leads, users, workspaces. */
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); }
tbody tr:hover { background: rgba(255,255,255,.02); }
td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }
code { background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 4px; }

.banner { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; border: 1px solid var(--line); }
.banner.ok { background: rgba(34,211,197,.10); border-color: var(--accent); }
.banner.err { background: rgba(255,107,107,.10); border-color: #ff6b6b; color: #ffb4b4; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge.ok { background: rgba(34,211,197,.15); color: var(--accent); }
.badge.warn { background: rgba(255,107,107,.15); color: #ff9b9b; }
.badge.run { background: rgba(232,162,61,.16); color: #e0b45c; }

.inline { display: inline; margin: 0; }
.inline select, .btn { border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 6px; padding: 6px 10px; font: inherit; cursor: pointer; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:hover { border-color: var(--accent); }

/* Agent 1 — run form + bucket result (ported from agent1.css). */
.a1-form { display: flex; gap: 10px; margin: 4px 0 24px; flex-wrap: wrap; }
.a1-form input { flex: 1; min-width: 200px; padding: 10px 12px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; }
.a1-form button { padding: 10px 20px; border-radius: 6px; border: 0; background: var(--accent);
  color: #06121a; font-weight: 600; cursor: pointer; }
.a1-meta { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.a1-meta b { color: var(--text); }
.a1-error { background: #3b1f24; border: 1px solid #6b2f38; color: #ffb3bd;
  padding: 12px 14px; border-radius: 6px; margin-bottom: 20px; }
.a1-dna { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 24px; }
.a1-dna h2 { font-size: 13px; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.dna-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.dna-item { display: flex; flex-direction: column; }
.dna-item .k { font-size: 11px; text-transform: uppercase; color: var(--muted); }
.dna-def { display: grid; gap: 12px; }
.dna-def .def-row { display: grid; grid-template-columns: 190px 1fr; gap: 16px; align-items: start; }
.dna-def .def-row .k { color: var(--accent); font-weight: 600; }
.dna-def .def-row .v { color: var(--muted); }
@media (max-width: 640px) { .dna-def .def-row { grid-template-columns: 1fr; gap: 2px; } }
.bucket { margin-bottom: 28px; }
.bucket > header { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 14px; }
.bucket h2 { font-size: 17px; }
.bucket .q { color: var(--muted); font-size: 13px; }
.bucket .note { color: #e0b45c; font-size: 12px; margin-top: 4px; }
.lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.list.muted { opacity: .68; }
.list h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.list .count { color: var(--accent); }
.list ul { list-style: none; display: grid; gap: 10px; }
.list li { display: grid; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.05); }
.list .name { font-weight: 600; }
.list .reason { color: var(--muted); font-size: 12px; }
.list .signals { color: var(--accent); font-size: 11px; }
.list .empty { color: #5c6e7f; font-size: 12px; }
.tag { display: inline-block; font-size: 10px; text-transform: uppercase; padding: 1px 6px; border-radius: 99px; margin-left: 6px; }
.tag.high { background: #12312c; color: #5be9dd; }
.tag.grounded { background: #10312a; color: #3fe0b0; }
.tag.verify { background: #3a2f16; color: #e0b45c; }
.tag.thin { background: #3b1f24; color: #ffb3bd; }
.research { margin-top: 30px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.research summary { cursor: pointer; color: var(--muted); }
.research pre { white-space: pre-wrap; margin-top: 10px; color: var(--muted); font-size: 12px; }
.a1-running { display: flex; align-items: center; gap: 18px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 24px; }
.a1-spinner { width: 44px; height: 44px; margin: 0 auto 20px; border: 4px solid rgba(255,255,255,.18);
  border-top-color: var(--accent); border-radius: 50%; animation: a1spin 1s linear infinite; }
@keyframes a1spin { to { transform: rotate(360deg); } }
.a1-l-big { font-size: 1.15rem; font-weight: 600; margin: 0 0 6px; }
.a1-l-small { font-size: .85rem; color: var(--muted); margin: 6px 0; line-height: 1.4; }
.a1-l-timer { font-size: 1.5rem; font-weight: 700; margin: 14px 0; font-variant-numeric: tabular-nums; }

/* Nia — Company Brain test chat. */
.nia-new { display: grid; grid-template-columns: 200px 180px 1fr auto; gap: 10px; align-items: start;
  margin: 4px 0 24px; }
.nia-new select, .nia-new textarea { padding: 10px 12px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; }
.nia-new textarea { resize: vertical; }
.nia-new button { padding: 10px 20px; border-radius: 6px; border: 0; background: var(--accent);
  color: #06121a; font-weight: 600; cursor: pointer; height: fit-content; }
@media (max-width: 720px) { .nia-new { grid-template-columns: 1fr; } }

.nia-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.nia-summary { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 16px; }
.nia-summary summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.nia-summary p { margin-top: 10px; color: var(--text); white-space: pre-wrap; font-size: 13px; }

.nia-thread { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
.nia-msg { max-width: 78%; display: flex; flex-direction: column; gap: 4px; }
.nia-msg.user { align-self: flex-end; align-items: flex-end; }
.nia-msg.assistant { align-self: flex-start; }
.nia-role { font-size: 11px; text-transform: uppercase; color: var(--muted); }
.nia-bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; white-space: pre-wrap; line-height: 1.5; }
.nia-msg.user .nia-bubble { background: rgba(34,211,197,.10); border-color: var(--accent); }
.nia-bubble.nia-working { color: var(--muted); font-style: italic; animation: niapulse 1.1s ease-in-out infinite; }
@keyframes niapulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }

/* Rendered-markdown answer bubbles (tables/lists/code from Nia). */
.nia-bubble.nia-md { white-space: normal; }
.nia-md > :first-child { margin-top: 0; }
.nia-md > :last-child { margin-bottom: 0; }
.nia-md p { margin: 0 0 8px; }
.nia-md ul, .nia-md ol { margin: 4px 0 8px 20px; }
.nia-md li { margin: 2px 0; }
.nia-md h1, .nia-md h2, .nia-md h3, .nia-md h4 { font-size: 14px; margin: 10px 0 4px; }
.nia-md strong { color: var(--text); font-weight: 600; }
.nia-md a { color: var(--accent); }
.nia-md table { width: auto; margin: 8px 0; border: 1px solid var(--line); border-radius: 0; background: transparent; }
.nia-md th, .nia-md td { border: 1px solid var(--line); padding: 5px 10px; font-size: 13px; text-transform: none; }
.nia-md th { background: rgba(255,255,255,.05); color: var(--text); }
.nia-md code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.nia-md pre { background: rgba(0,0,0,.28); padding: 10px 12px; border-radius: 6px; overflow-x: auto; margin: 8px 0; }
.nia-md pre code { background: none; padding: 0; }
.nia-tools { display: flex; flex-wrap: wrap; gap: 4px; }
.nia-model-badge { font-size: 10px; background: rgba(34,211,197,.12); color: var(--accent);
  padding: 1px 7px; border-radius: 99px; margin-left: 6px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.nia-model-select { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; font-size: 13px; min-width: 160px; }
.nia-compose textarea[readonly] { opacity: .6; }
.nia-compose button:disabled { opacity: .6; cursor: default; }

.nia-compose { display: flex; gap: 10px; align-items: center;
  position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); }
.nia-compose textarea { flex: 1; padding: 10px 12px; border-radius: 6px; resize: vertical;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; }
.nia-compose button { padding: 10px 24px; border-radius: 6px; border: 0; background: var(--accent);
  color: #06121a; font-weight: 600; cursor: pointer; }

/* ── nia blocks ──────────────────────────────────────────────────────────── */
.nia-evidence { margin-top: 10px; }
.nia-evidence summary { cursor: pointer; font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); list-style: none; display: flex; align-items: center; gap: 6px; }
.nia-evidence summary::before { content: "\25B6"; font-size: 8px; transition: transform .15s; }
.nia-evidence[open] summary::before { transform: rotate(90deg); }
.nia-evidence summary::-webkit-details-marker { display: none; }

.nia-chart { margin-top: 8px; padding: 10px 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 8px; }
.nia-chart-title { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px; }
.nia-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.nia-bar-label { width: 110px; flex-shrink: 0; font-size: 12px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nia-bar-track { flex: 1; height: 14px; border-radius: 4px; background: rgba(255,255,255,.06); overflow: hidden; }
.nia-bar-fill { height: 100%; border-radius: 4px; }
.nia-bar-val { width: 38px; text-align: right; font-size: 12px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.nia-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.nia-stat-tile { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 100px; }
.nia-stat-label { font-size: 9px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.nia-stat-value { font-size: 20px; font-weight: 700; color: var(--accent); }

.nia-table-block { margin-top: 8px; padding: 10px 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 8px; }
.nia-table-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.06); font-size: 12px; }
.nia-table-row:last-child { border-bottom: none; }

.nia-rec { margin-top: 8px; padding: 10px 12px; background: rgba(14,122,110,.1); border: 1px solid rgba(14,122,110,.25);
  border-radius: 8px; }
.nia-rec-label { font-size: 9px; font-weight: 700; letter-spacing: .1em; color: #22d3c5; margin-bottom: 4px; }
.nia-rec-text { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.5; }
.nia-rec-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid rgba(14,122,110,.2); }
.nia-rec-col-label { font-size: 8px; font-weight: 700; letter-spacing: .1em; color: #22d3c5; margin-bottom: 2px; }
.nia-rec-cols p { font-size: 12px; color: var(--text); line-height: 1.4; margin: 0; }

.nia-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.nia-sources-label { font-size: 9px; font-weight: 700; letter-spacing: .1em; color: var(--muted); }
.nia-source-tag { font-size: 10px; font-weight: 500; color: var(--muted); background: rgba(255,255,255,.06);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 7px; }

.nia-explore { margin-top: 10px; }
.nia-explore-label { font-size: 9px; font-weight: 700; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px; }
.nia-explore-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.nia-explore-card { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; text-align: left; cursor: pointer; font: inherit; color: var(--text); transition: border-color .15s; }
.nia-explore-card:hover { border-color: var(--accent); }
.nia-explore-cat { display: block; font-size: 8px; font-weight: 700; letter-spacing: .1em; margin-bottom: 2px; }
.nia-explore-q { display: block; font-size: 11px; font-weight: 500; line-height: 1.4; }

/* ── workspace detail ─────────────────────────────────────────────────────── */
.ws-head { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start;
  justify-content: space-between; margin: 4px 0 8px; }
.kv { border-collapse: collapse; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 3px 16px 3px 0; vertical-align: top; }
.kv td { padding: 3px 0; }
.ws-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; max-width: 320px; }
.ws-actions p { flex-basis: 100%; margin: 0; }
.ws-sec { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  margin: 28px 0 10px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.sm { font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; border-color: var(--line); }
