:root {
  --ink: #0b1830;
  --ink-2: #4a5873;
  --ink-3: #8592a8;
  --surface: #f2f5fa;
  --card: #ffffff;
  --line: #dce3ee;
  --brand: #2747f5;
  --brand-ink: #1a33c2;
  --brand-tint: #e8ecff;
  --mint: #6ff0c0;
  --clean: #0e9f6e;
  --clean-tint: #e3f6ee;
  --unver: #c98a04;
  --unver-tint: #fbf1d9;
  --bad: #d8452e;
  --bad-tint: #fce9e5;
  --queue: #c9d2e0;
  --display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--surface); color: var(--ink); font: 15px/1.5 var(--body); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.015em; margin: 0; line-height: 1.15; }
h1 { font-size: clamp(24px, 4vw, 32px); }
h2 { font-size: 18px; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.boot { padding: 48px; text-align: center; color: var(--ink-3); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ---- top bar */
.top { position: sticky; top: 0; z-index: 10; background: var(--ink); color: #fff; }
.top-in { max-width: 1160px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand b { font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.05; display: block; }
.brand span { display: block; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #9fb0d0; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { color: #c5d0e6; padding: 7px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { color: #fff; text-decoration: none; background: rgba(255, 255, 255, 0.08); }
.nav a.on { color: #fff; background: rgba(255, 255, 255, 0.14); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { color: #c5d0e6; font-size: 13px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkbtn { background: none; border: 0; color: #c5d0e6; font: inherit; font-size: 13px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.linkbtn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

main { max-width: 1160px; margin: 0 auto; padding: 28px 20px 64px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head p { margin-top: 6px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 { margin-bottom: 12px; }

/* ---- buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font: 600 14px var(--body); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #b9c4d6; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.sm { min-height: 32px; padding: 4px 11px; font-size: 13px; border-radius: 8px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font: 15px var(--body); }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.linkbtn2 { background: none; border: 0; padding: 0; margin-top: 12px; color: var(--ink-2); font: 13px var(--body); text-decoration: underline; cursor: pointer; }
.err { color: var(--bad); font-size: 14px; margin: 8px 0; min-height: 20px; }

/* ---- sign in */
.gate { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.gate-art { background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; overflow: hidden; }
.gate-art h1 { font-size: clamp(30px, 4.4vw, 52px); max-width: 12em; }
.gate-art h1 em { font-style: normal; color: var(--mint); }
.gate-art p { color: #a9b7d3; max-width: 34em; }
.demo-rail { display: grid; grid-template-columns: repeat(18, 1fr); gap: 5px; max-width: 460px; }
.demo-rail i { aspect-ratio: 1; border-radius: 4px; background: rgba(255, 255, 255, 0.1); animation: sort 5.4s infinite; }
@keyframes sort { 0%, 20% { background: rgba(255, 255, 255, 0.1); } 35% { background: var(--brand); } 55%, 100% { background: var(--c, var(--clean)); } }
.gate-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.gate-form form { width: 100%; max-width: 360px; }
.gate-form h2 { font-size: 24px; margin-bottom: 6px; }
.gate-form .muted { margin-bottom: 22px; }
.gate-form .btn { width: 100%; }

/* ---- lists */
.lrow { display: grid; grid-template-columns: minmax(0, 1.6fr) 110px minmax(120px, 1fr) 90px; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); color: inherit; }
.lrow:first-of-type { border-top: 0; }
a.lrow:hover { text-decoration: none; background: #fafbfe; }
.lrow .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface); color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.run { background: var(--brand-tint); color: var(--brand-ink); }
.pill.run::before { animation: pulse 1.2s infinite; }
.pill.ok { background: var(--clean-tint); color: #0a7450; }
.pill.warn { background: var(--unver-tint); color: #8a5e00; }
.pill.off { background: var(--surface); color: var(--ink-3); }
.pill.bad { background: var(--bad-tint); color: #a8301d; }
@keyframes pulse { 50% { opacity: 0.25; } }
.bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--queue); }
.bar i { display: block; height: 100%; transition: width 0.6s ease; }
.bar .c { background: var(--clean); }
.bar .u { background: var(--unver); }
.bar .b { background: var(--bad); }
.empty { text-align: center; padding: 40px 16px; }
.empty p { margin: 8px 0 18px; }

/* ---- upload and mapping */
.drop { display: block; border: 2px dashed #b9c4d6; border-radius: var(--r); padding: 44px 20px; text-align: center; background: #fff; cursor: pointer; }
.drop.over, .drop:hover { border-color: var(--brand); background: var(--brand-tint); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop b { font-family: var(--display); font-size: 20px; display: block; margin-bottom: 4px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin: 14px 0; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 12px; text-align: left; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--line); }
th { background: var(--surface); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.pick { background: var(--brand-tint); }
th.pick { color: var(--brand-ink); box-shadow: inset 0 -2px 0 var(--brand); }
.progress { height: 10px; border-radius: 99px; background: var(--queue); overflow: hidden; margin: 12px 0 6px; }
.progress i { display: block; height: 100%; width: 0; background: var(--brand); transition: width 0.3s; }

/* ---- list page: stages, rail, bins */
.stages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.stage { padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid transparent; }
.stage b { display: block; font-size: 13px; }
.stage span { font-size: 12px; color: var(--ink-2); font-family: var(--mono); }
.stage.now { background: var(--brand-tint); border-color: var(--brand); }
.stage.now b { color: var(--brand-ink); }
.stage.past b::after { content: " ✓"; color: var(--clean); }
.rail { display: grid; grid-template-columns: repeat(auto-fill, minmax(14px, 1fr)); gap: 4px; }
.rail i { aspect-ratio: 1; border-radius: 3px; background: var(--queue); transition: background 0.5s; }
.rail i.s1 { background: #9fb1ff; animation: pulse 1.4s infinite; }
.rail i.s2 { background: var(--brand); animation: pulse 1.4s infinite; }
.rail.big { grid-template-columns: repeat(auto-fill, minmax(8px, 1fr)); gap: 2px; }
.rail.few { display: flex; }
.rail.few i { flex: 1; aspect-ratio: auto; height: 26px; border-radius: 5px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.activity { margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--surface); font-size: 13px; }
.bins { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
.bin { background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--k); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.bin h3 { font-size: 15px; }
.bin .n { font: 500 30px/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.bin .pct { font-size: 12px; color: var(--ink-2); font-family: var(--mono); }
.bin p { font-size: 13px; color: var(--ink-2); flex: 1; }
.bin .btn { margin-top: 8px; }
.bin.clean { --k: var(--clean); }
.bin.unver { --k: var(--unver); }
.bin.bad { --k: var(--bad); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; }

/* ---- checker card */
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; background: var(--ink-3); }
.dot.online { background: var(--clean); box-shadow: 0 0 0 4px var(--clean-tint); }
.dot.starting { background: var(--brand); animation: pulse 1.2s infinite; }
.dot.blocked { background: var(--bad); }
.state { font-family: var(--display); font-weight: 700; font-size: 17px; display: flex; align-items: center; margin-bottom: 6px; }

/* ---- dialog and toasts */
dialog { border: 0; border-radius: 14px; padding: 22px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(11, 24, 48, 0.3); color: var(--ink); }
dialog::backdrop { background: rgba(11, 24, 48, 0.5); }
dialog h2 { margin-bottom: 14px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: #fff; padding: 11px 15px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(11, 24, 48, 0.25); }
.toast.bad { background: var(--bad); }

@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
  .gate { grid-template-columns: 1fr; }
  .gate-art { padding: 28px 20px; min-height: 0; }
  .gate-art .demo-rail { display: none; }
}
@media (max-width: 640px) {
  .top-in { gap: 10px; padding: 10px 14px; }
  .nav { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .who { display: none; }
  main { padding: 20px 14px 56px; }
  .card { padding: 16px; }
  .lrow { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .lrow .bar { grid-column: 1 / -1; }
  .lrow .rows { display: none; }
  .bins { grid-template-columns: 1fr; }
  .stages { grid-template-columns: repeat(2, 1fr); }
  .head .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
