:root {
  --bg: #070914; --bg2: #0c1022; --panel: rgba(18, 23, 46, .72); --panel-solid: #121730;
  --line: rgba(148, 163, 255, .14); --line-strong: rgba(148, 163, 255, .28);
  --text: #eef0ff; --muted: #9aa3c7; --gold: #e9c46a; --gold2: #f4a261;
  --violet: #8b7bff; --cyan: #4fd1c5; --rose: #ff6b8b; --ok: #3ddc97;
  --radius: 18px; --shadow: 0 24px 60px -24px rgba(0, 0, 0, .7), 0 1px 0 rgba(255,255,255,.04) inset;
  --font: "Inter", "SF Pro Display", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; color: var(--text); font: 15px/1.6 var(--font); letter-spacing: .005em;
  background: radial-gradient(1200px 700px at 85% -10%, rgba(139,123,255,.22), transparent 60%),
              radial-gradient(900px 600px at -10% 20%, rgba(79,209,197,.14), transparent 60%),
              linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
.aurora { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.aurora span { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(90px); opacity: .22; animation: drift 26s ease-in-out infinite alternate; }
.aurora span:nth-child(1) { background: #6d5dfc; top: -18vmax; right: -10vmax; }
.aurora span:nth-child(2) { background: #e9c46a; bottom: -24vmax; left: -14vmax; opacity: .12; animation-duration: 32s; }
.aurora span:nth-child(3) { background: #2bb3a8; top: 30%; left: 40%; opacity: .1; animation-duration: 38s; }
@keyframes drift { to { transform: translate3d(-6vmax, 5vmax, 0) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .aurora span { animation: none; } html { scroll-behavior: auto; } }

a { color: var(--gold); text-decoration: none; } a:hover { text-decoration: underline; }
.topbar, main, .foot { position: relative; z-index: 1; }
.topbar {
  position: sticky; top: 0; display: flex; align-items: center; gap: 20px; padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(7, 9, 20, .62); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line); z-index: 10;
}
.wordmark { display: inline-flex; align-items: baseline; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: .02em; text-decoration: none !important; }
.wordmark.small { font-size: 15px; }
.wm-arqs { background: linear-gradient(135deg, var(--gold), var(--gold2)); -webkit-background-clip: text; background-clip: text; color: transparent; letter-spacing: .16em; }
.wm-app { color: var(--text); font-weight: 600; }
.topnav { display: flex; gap: 22px; margin-left: auto; }
.topnav a { color: var(--muted); font-weight: 500; font-size: 14px; }
.topnav a:hover { color: var(--text); text-decoration: none; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: rgba(255,255,255,.03); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; box-shadow: 0 0 0 3px rgba(107,114,128,.2); }
.status-pill.ok i { background: var(--ok); box-shadow: 0 0 0 3px rgba(61,220,151,.18), 0 0 12px var(--ok); }
.status-pill.bad i { background: var(--rose); }

main { max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px) 48px; }
.hero { padding: clamp(40px, 8vw, 92px) 0 clamp(28px, 4vw, 44px); max-width: 880px; }
.eyebrow { text-transform: uppercase; letter-spacing: .22em; font-size: 12px; color: var(--gold); font-weight: 600; margin: 0 0 14px; }
h1 { font-size: clamp(32px, 5.4vw, 60px); line-height: 1.04; letter-spacing: -.025em; margin: 0 0 20px; font-weight: 750; }
h1 em { font-style: normal; background: linear-gradient(100deg, #c9c2ff 0%, var(--violet) 40%, var(--cyan) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { font-size: clamp(16px, 1.6vw, 18.5px); color: #c3c9e8; max-width: 760px; margin: 0 0 24px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-badges span { padding: 7px 14px; border-radius: 99px; font-size: 13px; color: #dfe3ff; background: linear-gradient(180deg, rgba(139,123,255,.16), rgba(139,123,255,.05)); border: 1px solid var(--line-strong); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; margin-bottom: 22px; }
.card {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px clamp(16px, 2.2vw, 26px);
  box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); min-width: 0;
}
section.card { margin-bottom: 22px; }
.card.glow::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(140deg, rgba(233,196,106,.6), rgba(139,123,255,.25) 40%, transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
h2 { font-size: 18px; margin: 0; letter-spacing: -.01em; font-weight: 650; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; padding: 4px 10px; border-radius: 99px; }
.tag.demo { color: #1b1300; background: linear-gradient(135deg, var(--gold), var(--gold2)); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

input, select, textarea {
  width: 100%; min-width: 0; font: inherit; color: var(--text); background: rgba(5, 7, 18, .6); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 11px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { font: 13px/1.55 var(--mono); resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
select option { background: var(--panel-solid); }
input:focus, select:focus, textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139,123,255,.25); }
.field { display: grid; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field em { font-style: normal; font-weight: 400; }
.row-form { display: flex; gap: 10px; }
.row-form input { flex: 1; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-btns.wide { grid-column: 1 / -1; }
.spacer { flex: 1; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 14px 0; text-transform: uppercase; letter-spacing: .14em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 14px var(--font); color: var(--text); cursor: pointer;
  padding: 11px 18px; border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.04); transition: transform .12s, background .15s, box-shadow .15s; white-space: nowrap; }
.btn:hover { background: rgba(255,255,255,.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { color: #160f00; border: 0; background: linear-gradient(135deg, var(--gold) 0%, var(--gold2) 100%); box-shadow: 0 10px 26px -12px rgba(244,162,97,.8); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

.key-reveal { margin-top: 14px; padding: 14px; border-radius: 14px; border: 1px dashed rgba(233,196,106,.55); background: rgba(233,196,106,.07); }
.warn { margin: 0 0 10px; color: #f6dfa4; font-size: 13.5px; }
.key-box { display: flex; gap: 10px; align-items: center; }
.key-box code { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 13px var(--mono); color: #fff; background: rgba(0,0,0,.35); padding: 10px 12px; border-radius: 10px; }
.ws-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 4px 0 14px; }
.ws-meta div { background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.ws-meta dt { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.ws-meta dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; font-size: 14px; }
.form-msg { min-height: 1em; margin: 10px 0 0; font-size: 13.5px; color: var(--rose); }
.form-msg.ok { color: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: linear-gradient(160deg, rgba(139,123,255,.12), rgba(79,209,197,.04)); min-width: 0; }
.stat-n { display: block; font-size: clamp(22px, 2.6vw, 30px); font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }

.needs-ws { transition: opacity .2s; }
body:not(.connected) .needs-ws { opacity: .55; }
body:not(.connected) .needs-ws :is(button, input, select, textarea) { pointer-events: none; }

.dataset-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.dataset-list li { padding: 13px 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.025); cursor: pointer; transition: border-color .15s, background .15s; }
.dataset-list li:hover, .dataset-list li.active { border-color: rgba(233,196,106,.55); background: rgba(233,196,106,.05); }
.dataset-list li.empty { cursor: default; color: var(--muted); text-align: center; border-style: dashed; }
.ds-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.ds-name { font-weight: 650; font-family: var(--mono); font-size: 14px; }
.ds-count { font-size: 13px; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font: 11.5px var(--mono); padding: 3px 8px; border-radius: 8px; background: rgba(139,123,255,.12); border: 1px solid rgba(139,123,255,.22); color: #d5d0ff; }
.chip b { color: var(--cyan); font-weight: 500; }
.new-ds summary { cursor: pointer; color: var(--gold); font-weight: 600; font-size: 14px; margin: 6px 0 12px; }
.field-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.field-row label.req { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.field-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--gold); }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { color: var(--rose); background: rgba(255,107,139,.1); }

.ingest-out { margin-top: 12px; font-size: 13.5px; }
.ingest-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.pill { padding: 4px 10px; border-radius: 99px; font-weight: 600; font-size: 12.5px; }
.pill.ok { background: rgba(61,220,151,.14); color: var(--ok); }
.pill.dup { background: rgba(79,209,197,.12); color: var(--cyan); }
.pill.bad { background: rgba(255,107,139,.14); color: var(--rose); }
.err-list { margin: 0; padding-left: 18px; color: #ffc2cf; font-size: 13px; }

.query-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
.filters { grid-column: 1 / -1; display: grid; gap: 8px; margin-bottom: 12px; }
.filter-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .8fr) minmax(0, 1.4fr) auto; gap: 8px; }
.table-wrap { margin-top: 16px; overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
th { position: sticky; top: 0; background: rgba(12, 16, 34, .95); color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
tbody tr:hover td { background: rgba(139,123,255,.06); }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
td.empty { text-align: center; color: var(--muted); padding: 28px; white-space: normal; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 360px; overflow: auto; }
.timeline li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.timeline li.empty { display: block; color: var(--muted); text-align: center; border: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; background: var(--violet); box-shadow: 0 0 10px var(--violet); }
.dot.ingest { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot.export { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.ev-action { font-weight: 600; font-family: var(--mono); font-size: 13px; }
.ev-detail { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.ev-time { color: var(--muted); font-size: 12px; white-space: nowrap; }

.code { margin: 0; padding: 16px; border-radius: 14px; background: rgba(3, 5, 14, .75); border: 1px solid var(--line); overflow-x: auto; font: 12.5px/1.6 var(--mono); color: #d9ddff; }
.code .c { color: #7f88b5; }

.foot { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; justify-content: space-between; max-width: 1240px; margin: 0 auto; padding: 26px clamp(16px, 4vw, 48px) 40px; border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; z-index: 50; padding: 12px 18px; border-radius: 12px;
  background: var(--panel-solid); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 14px; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .query-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .topnav { display: none; }
  .status-pill { margin-left: auto; }
  .row-form { flex-direction: column; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ws-meta { grid-template-columns: 1fr; }
  .query-form { grid-template-columns: 1fr 1fr; }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .filter-row input { grid-column: 1 / 2; }
  .field-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .row-btns.wide .btn { flex: 1 1 auto; }
  .row-btns.wide .spacer { display: none; }
  .foot { flex-direction: column; align-items: flex-start; }
}

/* ---- Data Convergence additions ---- */
.flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 0 0 26px; }
.flow-step { padding: 16px 18px; border-radius: 16px; border: 1px solid var(--line); background: linear-gradient(160deg, rgba(233,196,106,.08), rgba(139,123,255,.06) 60%, rgba(79,209,197,.05)); }
.flow-step b { display: block; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
.flow-step span { color: #cfd4f2; font-size: 14px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px; border-radius: 16px; border: 1px solid var(--line); background: rgba(5,7,18,.55); margin: 0 0 18px; }
.tab { font: 600 14px var(--font); color: var(--muted); background: none; border: 0; padding: 10px 16px; border-radius: 11px; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: #160f00; background: linear-gradient(135deg, var(--gold), var(--gold2)); }
.tab .count { margin-left: 6px; font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: rgba(255,107,139,.2); color: var(--rose); }
.tab[aria-selected="true"] .count { background: rgba(0,0,0,.18); color: #160f00; }
.panel[hidden] { display: none; }
.map-row { display: grid; grid-template-columns: minmax(0, 1.2fr) 18px minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.map-row .arrow { color: var(--gold); text-align: center; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.review-list { display: grid; gap: 14px; }
.review { border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: rgba(255,255,255,.025); }
.review-reason { font-size: 13px; color: #f6dfa4; margin: 0 0 12px; }
.review-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
.review-pair > div { border-radius: 12px; border: 1px solid var(--line); padding: 12px; background: rgba(5,7,18,.5); min-width: 0; }
.review-pair h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.src-badge { display: inline-block; font: 11px var(--mono); padding: 2px 7px; border-radius: 7px; background: rgba(79,209,197,.12); border: 1px solid rgba(79,209,197,.28); color: var(--cyan); margin-left: 6px; }
tbody tr.clickable { cursor: pointer; }
.drawer { position: fixed; inset: 0; z-index: 40; display: flex; justify-content: flex-end; background: rgba(3,4,12,.55); backdrop-filter: blur(4px); }
.drawer[hidden] { display: none; }
.drawer-body { width: min(560px, 100%); height: 100%; overflow: auto; background: var(--panel-solid); border-left: 1px solid var(--line-strong); padding: 22px; box-shadow: var(--shadow); }
.drawer-body h2 { margin-bottom: 4px; }
.prov { width: 100%; font-size: 13px; }
.prov td, .prov th { white-space: normal; }
.win { color: var(--ok); font-weight: 700; }
pre.raw { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 960px) { .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) {
  .flow { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .review-pair { grid-template-columns: 1fr; }
  .map-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .map-row .arrow { display: none; }
  .tab { padding: 9px 12px; font-size: 13px; }
}
