:root {
  --bg: #0a0d12;
  --panel: #11161d;
  --panel2: #161c25;
  --line: #222b37;
  --text: #d7dee8;
  --muted: #7d8a9b;
  --green: #27d17f;
  --red: #ff4d6a;
  --amber: #ffb547;
  --blue: #4da3ff;
  --violet: #a77bff;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.45 -apple-system, "Inter", "Segoe UI", sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.up { color: var(--green); }
.down { color: var(--red); }
.err { color: var(--red); min-height: 18px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

input, select, textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; font: inherit; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
textarea { font-family: var(--mono); font-size: 12px; width: 100%; resize: vertical; }
input.tiny { width: 60px; }
input[type="checkbox"] { width: auto; }

.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 12px; font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #3a4757; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.primary { background: var(--green); color: #04130b; border-color: var(--green); font-weight: 600; }
.btn.danger { background: transparent; color: var(--red); border-color: #5a2531; }
.btn.sell { background: #2a1219; color: var(--red); border-color: #5a2531; font-weight: 600; }
.btn.ghost { background: transparent; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em; border: 1px solid var(--line); white-space: nowrap; }
.badge.dry { color: var(--amber); border-color: #5c4520; background: #241c0d; }
.badge.live { color: #fff; background: var(--red); border-color: var(--red); }

.brand { font-weight: 800; letter-spacing: .12em; font-size: 13px; }
.brand span { color: var(--green); margin-left: 4px; }

.login { position: fixed; inset: 0; display: grid; place-items: center; }
.login-card { display: grid; gap: 10px; width: min(340px, calc(100vw - 32px)); }

.top { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.spacer { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip b { color: var(--text); font-weight: 600; }
.chip.ok::before, .chip.bad::before, .chip.warn::before { content: "●"; margin-right: 5px; }
.chip.ok::before { color: var(--green); }
.chip.bad::before { color: var(--red); }
.chip.warn::before { color: var(--amber); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.slider { width: 34px; height: 18px; background: var(--line); border-radius: 999px; position: relative; transition: .15s; }
.slider::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: .15s; }
.switch input:checked + .slider { background: #12402a; }
.switch input:checked + .slider::after { left: 18px; background: var(--green); }
.switch-label { font-weight: 600; }

.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 10px 12px; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--green); }
.count { font-size: 11px; color: var(--muted); }

main { padding: 14px 16px 40px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.inline { display: flex; gap: 6px; align-items: center; }
#fromUrl { width: 320px; max-width: 60vw; }

/* narratives */
.ngrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
.ncard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; position: relative; }
.ncard.launched { border-color: #1d5a3c; }
.ncard.launching { border-color: var(--amber); }
.ncard.failed { border-color: #5a2531; }
.nhead { display: flex; gap: 10px; align-items: flex-start; }
.nimg { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; background: var(--panel2); flex: none; }
.nmeta { flex: 1; min-width: 0; }
.nauthor { font-size: 12px; color: var(--muted); }
.nauthor b { color: var(--text); }
.ntext { font-size: 12.5px; white-space: pre-wrap; word-break: break-word; max-height: 4.4em; overflow: hidden; }
.score { font: 700 22px/1 var(--mono); min-width: 44px; text-align: right; }
.score.hi { color: var(--green); } .score.mid { color: var(--amber); } .score.lo { color: var(--muted); }
.nstats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.nstats b { color: var(--text); font-weight: 600; }
.flags { display: flex; gap: 6px; flex-wrap: wrap; }
.flag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--panel2); border: 1px solid var(--line); }
.flag.bad { color: var(--red); border-color: #5a2531; }
.flag.warn { color: var(--amber); border-color: #5c4520; }
.flag.good { color: var(--green); border-color: #1d5a3c; }
.metaform { display: grid; grid-template-columns: 1fr 110px; gap: 6px; }
.metaform textarea { grid-column: 1 / -1; height: 52px; font-family: inherit; font-size: 12px; }
.gallery { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.gallery img { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; cursor: pointer; border: 2px solid transparent; background: var(--panel2); }
.gallery img:hover { border-color: #3a4757; }
.gallery img.sel { border-color: var(--green); }
.gallery .gen { font-size: 11px; color: var(--muted); padding: 4px 8px; border: 1px dashed var(--line); border-radius: 6px; }
.nactions select { width: auto; }
.nactions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nactions input { width: 70px; }
.auto { font-size: 11px; color: var(--muted); }

/* tech leads */
.consent { border-top: 1px solid var(--line); padding-top: 8px; display: grid; gap: 6px; }
.code { font: 700 15px var(--mono); color: var(--amber); letter-spacing: .05em; }
.ncard.verified { border-color: #1d5a3c; }
.ncard.rejected { opacity: .55; }

/* wave */
.wave-layout { display: grid; grid-template-columns: 270px 1fr; gap: 12px; }
.tlist { display: grid; gap: 6px; align-content: start; }
.tlist .inline input { flex: 1; }
.trow { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 8px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; }
.trow.sel { border-color: var(--green); }
.trow img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; background: var(--panel2); }
.trow .sym { font-weight: 700; }
.trow .sub { font-size: 11px; color: var(--muted); }
.phase { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; padding: 2px 7px; border-radius: 4px; text-transform: uppercase; }
.phase.launch { background: #1a2433; color: var(--blue); }
.phase.ignition { background: #3a2a07; color: var(--amber); }
.phase.pump { background: #0e3a24; color: var(--green); }
.phase.peak { background: #3b1730; color: #ff7ad9; }
.phase.cooling { background: #20262f; color: #9fb0c4; }
.phase.dump { background: #3a0f18; color: var(--red); }
.phase.flat, .phase.dead { background: #1a1f27; color: var(--muted); }
.phase.graduated { background: #251a40; color: var(--violet); }

.recent-head { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.recent { display: grid; gap: 2px; max-height: 420px; overflow: auto; }
.recent div { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.recent div:hover { background: var(--panel2); }
.tdetail { display: grid; gap: 12px; min-width: 0; }
.empty { color: var(--muted); padding: 40px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }
.thead { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.thead img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.thead .name { font-size: 18px; font-weight: 700; }
.bigmc { font: 700 28px/1 var(--mono); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.kpi .l { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font: 600 15px/1.3 var(--mono); }
.bar { height: 6px; background: var(--panel2); border-radius: 999px; overflow: hidden; margin-top: 5px; }
.bar > i { display: block; height: 100%; background: var(--green); }
.momentum { position: relative; height: 8px; background: linear-gradient(90deg, #3a0f18, #1a1f27 50%, #0e3a24); border-radius: 999px; margin-top: 6px; }
.momentum > i { position: absolute; top: -3px; width: 4px; height: 14px; background: var(--text); border-radius: 2px; }
.chartwrap { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.charttools { display: flex; gap: 4px; margin-bottom: 6px; }
.charttools button.active { border-color: var(--green); color: var(--green); }
#chart { height: 340px; }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.posgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-family: var(--mono); font-size: 12.5px; }
.posgrid span:nth-child(odd) { color: var(--muted); font-family: inherit; }
.sellrow { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.aeform { display: grid; grid-template-columns: 1fr 80px; gap: 6px 10px; align-items: center; font-size: 12px; }
.tape { max-height: 320px; overflow: auto; font-family: var(--mono); font-size: 12px; }
.tape div { display: grid; grid-template-columns: 64px 40px 1fr 90px 90px; gap: 6px; padding: 2px 4px; border-bottom: 1px solid #161c25; }
.tape .ours { background: #10261b; }
.tape .flash { animation: flash .6s; }
@keyframes flash { from { background: #233042; } }

/* analytics */
.agrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 12px; }
.agrid .card { min-width: 0; overflow-x: auto; }
.agrid h3 { margin: 0 0 8px; font-size: 13px; }
.lift { font-family: var(--mono); }
.lift.hi { color: var(--green); } .lift.lo { color: var(--red); } .lift.mid { color: var(--muted); }
.hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; align-items: end; height: 70px; margin-top: 8px; }
.hours i { display: block; background: #23415f; border-radius: 2px 2px 0 0; min-height: 2px; }
.hours i.now { background: var(--green); }
.hours-l { display: grid; grid-template-columns: repeat(24, 1fr); font-size: 9px; color: var(--muted); text-align: center; }
.bigstat { font: 700 26px/1.1 var(--mono); }
.note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
td.num { font-family: var(--mono); text-align: right; }
.steps { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: pre-wrap; }

.wtools { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 12px; }
.wtools .card { display: grid; gap: 8px; align-content: start; min-width: 0; }
.wtools .mono, td.mono { word-break: break-all; }
.wtools h3, .settings h3 { margin: 0 0 4px; font-size: 13px; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row > input:not([type=checkbox]), .row > select { flex: 1; }

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.settings .card { display: grid; gap: 8px; align-content: start; }
.field { display: grid; grid-template-columns: 1fr 120px; gap: 8px; align-items: center; }
.field.wide { grid-template-columns: 1fr; }
.field label { color: var(--muted); font-size: 12px; }
.savebar { position: sticky; bottom: 0; padding: 10px 0; background: var(--bg); display: flex; gap: 10px; align-items: center; }

.logs { font-family: var(--mono); font-size: 12px; }
.logs div { padding: 2px 0; border-bottom: 1px solid #141a22; white-space: pre-wrap; word-break: break-word; }
.logs .warn { color: var(--amber); } .logs .error { color: var(--red); }

.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal .row { justify-content: flex-end; }
.editor { display: grid; gap: 10px; width: min(380px, 100%); }
.editor canvas { width: 100%; aspect-ratio: 1; border-radius: 8px; background: repeating-conic-gradient(#1a2029 0 25%, #11161d 0 50%) 0 0 / 20px 20px; cursor: grab; touch-action: none; }
.editor canvas:active { cursor: grabbing; }
.editor .grid2 { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; font-size: 12px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--blue); padding: 10px 12px; border-radius: 8px; box-shadow: 0 6px 20px #0008; }
.toast.error { border-left-color: var(--red); } .toast.ok { border-left-color: var(--green); }

@media (max-width: 900px) {
  .wave-layout, .twocol { grid-template-columns: 1fr; }
  .ngrid { grid-template-columns: 1fr; }
  main { padding: 12px 16px 40px; }
  #chart { height: 260px; }
}

.funding-panel { margin-top: 20px; }
.funding-journal { overflow-x: auto; margin-top: 12px; }
.funding-journal td { vertical-align: top; }
