:root {
  --bg: #0a0c0f;
  --panel: #11151a;
  --panel-2: #151a21;
  --line: #1f2630;
  --line-2: #2a323e;
  --text: #e7ebf0;
  --muted: #8a93a1;
  --dim: #5b6472;
  --accent: #f0a33a;
  --accent-soft: #f0a33a22;
  --ok: #45d483;
  --bad: #f4695f;
  --warn: #f3c14a;
  --info: #6aa9ff;
  --r: 10px;
  --font: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
/* an author display rule beats the UA [hidden] rule: the overlay stayed on top of a live app */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; font-size: 12px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--muted); font-weight: 500; }

/* ---------------------------------------------------------------- gate */
.gate { position: fixed; inset: 0; display: grid; place-items: center; background:
  radial-gradient(1200px 600px at 50% -10%, #171d25 0%, var(--bg) 60%); z-index: 50; }
.gate-card { width: 340px; padding: 28px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; display: grid; gap: 10px; box-shadow: 0 24px 80px #0008; }
.gate-card h1 { font-size: 18px; }
.brand-mark { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(160deg, #f5b963, #c97e1f); color: #191204; font-weight: 800;
  letter-spacing: -0.04em; font-size: 16px; }
.brand-mark.small { width: 26px; height: 26px; border-radius: 8px; font-size: 11px; }
.gate-card input { background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 10px 12px; outline: none; }
.gate-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* thin dark scrollbars: the default light ones break the surface */
* { scrollbar-width: thin; scrollbar-color: #2a323e transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2a323e; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
.feed { overflow-x: hidden; }
.ev > div { min-width: 0; }

/* ---------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: 208px minmax(0, 1fr) 0; height: 100vh; }
.app.mika-open { grid-template-columns: 208px minmax(0, 1fr) 360px; }

.side { background: var(--panel); border-right: 1px solid var(--line); display: flex;
  flex-direction: column; padding: 14px 10px; gap: 6px; min-height: 0; }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 14px; font-weight: 600;
  letter-spacing: -0.01em; }
#nav { display: grid; gap: 2px; }
#nav a { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 7px;
  color: var(--muted); transition: background 120ms, color 120ms; }
#nav a i { font-style: normal; width: 14px; text-align: center; color: var(--dim); font-size: 12px; }
#nav a:hover { background: var(--panel-2); color: var(--text); }
#nav a.active { background: var(--accent-soft); color: var(--text); }
#nav a.active i { color: var(--accent); }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding: 8px; }
.node-health { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.linkish { background: none; border: 0; color: var(--dim); padding: 0; cursor: pointer;
  text-align: left; font-size: 12px; }
.linkish:hover { color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { height: 54px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; border-bottom: 1px solid var(--line); background: #0c0f13e6;
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.crumbs { display: flex; align-items: baseline; gap: 10px; font-weight: 600; }
.crumbs .muted { font-weight: 400; font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.picker { background: var(--panel); border: 1px solid var(--line-2); border-radius: 7px;
  padding: 5px 9px; color: var(--muted); max-width: 230px; }
.spend { display: flex; gap: 6px; align-items: baseline; font-family: var(--mono); font-size: 12px; }
.live { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; }
.live .dot, .node-health .dot { background: var(--ok); box-shadow: 0 0 0 3px #45d48322; }
.live.stale .dot { background: var(--warn); box-shadow: 0 0 0 3px #f3c14a22; }

.view { padding: 18px; overflow: auto; min-height: 0; display: grid; gap: 16px;
  align-content: start; }

/* ---------------------------------------------------------------- atoms */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.grid { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 14px; display: grid; gap: 4px; }
.stat .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat .v { font: 600 24px/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.stat .h { color: var(--dim); font-size: 11px; }

.btn { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 7px;
  padding: 6px 11px; cursor: pointer; transition: border-color 120ms, background 120ms; }
.btn:hover { border-color: var(--dim); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1204;
  font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.icon { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer;
  line-height: 1; padding: 2px 6px; border-radius: 6px; }
.icon:hover { background: var(--panel-2); color: var(--text); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: #45d48333; background: #45d4830f; }
.pill.bad { color: var(--bad); border-color: #f4695f33; background: #f4695f0f; }
.pill.warn { color: var(--warn); border-color: #f3c14a33; background: #f3c14a0f; }
.pill.info { color: var(--info); border-color: #6aa9ff33; background: #6aa9ff0f; }
.pill.dim { color: var(--dim); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--dim); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid #171c23; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: default; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #141922; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

.bar { height: 5px; border-radius: 3px; background: #1b212a; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.feed { display: grid; gap: 0; max-height: 340px; overflow: auto; }
.ev { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 7px 4px;
  border-bottom: 1px solid #151a20; font-size: 12px; }
.ev:last-child { border-bottom: 0; }
.ev .t { color: var(--dim); font-family: var(--mono); font-size: 11px; }
.ev .k { color: var(--text); }
.ev .p { color: var(--muted); font-family: var(--mono); font-size: 11px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

/* coverage heatmap */
.heat { overflow: auto; max-height: 58vh; border: 1px solid var(--line); border-radius: var(--r); }
.heat table { border-collapse: separate; border-spacing: 3px; }
.heat th { position: sticky; top: 0; background: var(--panel); z-index: 2; border: 0;
  writing-mode: vertical-rl; transform: rotate(180deg); height: 108px; padding: 4px 2px;
  font-size: 10px; letter-spacing: 0; text-transform: none; white-space: nowrap; }
.heat td.host { position: sticky; left: 0; background: var(--panel); z-index: 1;
  font-family: var(--mono); font-size: 11px; white-space: nowrap; padding-right: 12px; border: 0; }
.cell { width: 15px; height: 15px; border-radius: 3px; background: #171c23; }
.cell.clean { background: #2f8f5b; }
.cell.found { background: var(--bad); }
.cell.candidate { background: var(--accent); }
.cell.blocked { background: #4a5260; }
.cell.na { background: #232a34; }
.cell.open { background: #141a21; box-shadow: inset 0 0 0 1px #202733; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .cell { width: 11px; height: 11px; }

/* ---------------------------------------------------------------- mika */
.mika { background: var(--panel); border-left: 1px solid var(--line); display: none;
  flex-direction: column; min-height: 0; }
.app.mika-open .mika { display: flex; }
.mika-head { display: flex; align-items: center; justify-content: space-between; padding: 12px;
  border-bottom: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 9px; }
.who div { display: grid; }
.who .muted { font-size: 11px; }
.orb { width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: conic-gradient(from 210deg, #f0a33a, #6aa9ff, #45d483, #f0a33a);
  box-shadow: inset 0 0 0 3px #11151a; }
.mika-log { flex: 1; overflow: auto; padding: 12px; display: grid; gap: 10px; align-content: start; }
.msg { padding: 9px 11px; border-radius: 10px; font-size: 12px; max-width: 100%; }
.msg.mika { background: var(--panel-2); border: 1px solid var(--line); }
.msg.you { background: var(--accent-soft); border: 1px solid #f0a33a33; justify-self: end; }
.msg .meta { color: var(--dim); font-size: 10px; margin-top: 6px; font-family: var(--mono); }
.mika-form { display: grid; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.mika-form textarea { resize: none; background: var(--bg); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 9px 10px; outline: none; }
.mika-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mika-open { display: none; position: fixed; right: 18px; bottom: 18px; width: 46px; height: 46px;
  border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer;
  place-items: center; box-shadow: 0 10px 30px #0008; z-index: 20; }
.app:not(.mika-open) .mika-open { display: grid; }

/* ---------------------------------------------------------------- drawer */
.drawer { position: fixed; inset: 0; background: #05070a99; backdrop-filter: blur(2px); z-index: 30;
  display: flex; justify-content: flex-end; }
.drawer-panel { width: min(560px, 92vw); background: var(--panel); border-left: 1px solid var(--line);
  padding: 20px; overflow: auto; position: relative; }
.drawer-x { position: absolute; top: 12px; right: 12px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 14px; margin: 12px 0; }
.kv .k { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  overflow: auto; font: 11px/1.5 var(--mono); color: #cfd6df; }
.chain { display: grid; gap: 6px; }
.chain div { padding: 7px 10px; background: var(--panel-2); border-radius: 7px;
  border-left: 2px solid var(--accent); font-size: 12px; }

.empty { padding: 26px; text-align: center; color: var(--dim); }

@media (max-width: 900px) {
  .app { grid-template-columns: 56px minmax(0, 1fr) 0; }
  .app.mika-open { grid-template-columns: 56px minmax(0, 1fr) 0; }
  .brand span:last-child, #nav a span, .side-foot, #nav a { font-size: 0; }
  #nav a { justify-content: center; padding: 10px 0; }
  #nav a i { font-size: 15px; width: auto; }
  .mika-open { display: grid; }
  .spend, .picker { display: none; }
}
