:root {
  --bg: #0f141b;
  --panel: #161d26;
  --panel-2: #1c2531;
  --line: #273342;
  --text: #e8ecf1;
  --muted: #8d99a9;
  --plate: #f6c400;
  --plate-ink: #15171a;
  --ok: #3ccb9a;
  --warn: #f2a33a;
  --bad: #f0545c;
  --info: #6aa8ff;
  --r-sm: 6px;
  --r-md: 10px;
  --font: 'Barlow', system-ui, sans-serif;
  --font-cond: 'Barlow Condensed', 'Barlow', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); }
a:hover { color: var(--plate); }
:focus-visible { outline: 2px solid var(--plate); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-cond); font-weight: 600; letter-spacing: .01em; margin: 0; line-height: 1.15; }
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- number plate (the brand mark) ---------- */
.plate {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--plate); color: var(--plate-ink);
  font: 700 1.15rem/1 var(--font-cond); letter-spacing: .08em;
  padding: .4rem .7rem .35rem; border-radius: 5px;
  border: 2px solid #1a1a1a; box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
  text-decoration: none; white-space: nowrap;
}
.plate .gb {
  background: #1d4ca8; color: #fff; font-size: .55rem; letter-spacing: .02em;
  align-self: stretch; display: grid; place-items: center; padding: 0 .3rem; margin: -.4rem 0 -.35rem -.7rem;
  border-radius: 3px 0 0 3px;
}
.plate-lg { font-size: 2.2rem; padding: .6rem 1rem .5rem; }
.plate-lg .gb { font-size: .8rem; margin: -.6rem 0 -.5rem -1rem; padding: 0 .45rem; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; background: linear-gradient(to right, #121821 239px, var(--line) 239px 240px, transparent 240px); }
.side {
  border-right: 1px solid var(--line); padding: 1.25rem 1rem; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 1.5rem; background: #121821;
}
.side .app-name { color: var(--muted); font-size: .85rem; margin-top: .5rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .7rem; border-radius: var(--r-sm);
  text-decoration: none; color: var(--muted); font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a[aria-current="page"] { color: var(--text); background: var(--panel-2); box-shadow: inset 3px 0 0 var(--plate); }
.nav .count { margin-left: auto; background: var(--bad); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .45rem; font-weight: 600; }
.side-foot { margin-top: auto; font-size: .85rem; color: var(--muted); }
.side-foot form { display: inline; }

main { padding: 2rem clamp(1rem, 3vw, 2.5rem) 4rem; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head p { margin: .35rem 0 0; color: var(--muted); max-width: 60ch; }

/* ---------- surfaces ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1.25rem; }
.panel + .panel, .stack > * + * { margin-top: 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .9rem; }
.panel-head a { font-size: .9rem; color: var(--muted); }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

/* status strip on overview: the "is it running" sentence */
.state-bar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 1rem 1.25rem; border-radius: var(--r-md); margin-bottom: 1rem;
  background: var(--panel); border: 1px solid var(--line);
}
.state-bar.on { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.state-bar .lamp { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.state-bar.on .lamp { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.state-bar.attn .lamp { background: var(--warn); }
.state-bar .say { font-size: 1.05rem; font-weight: 500; flex: 1 1 16rem; }
.state-bar form { margin-left: auto; }

/* numbers */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; margin-bottom: 1rem; }
.figure { background: var(--panel); padding: 1rem 1.15rem; }
.figure b { display: block; font: 600 2rem/1.1 var(--font-cond); }
.figure span { color: var(--muted); font-size: .9rem; }
.figure .delta { color: var(--ok); font-size: .85rem; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem; justify-content: center;
  font: 600 .95rem/1 var(--font); padding: .7rem 1rem; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); color: var(--text); }
.btn-primary { background: var(--plate); color: var(--plate-ink); border-color: var(--plate); }
.btn-primary:hover { filter: brightness(1.06); color: var(--plate-ink); border-color: var(--plate); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: .45rem .7rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; font-weight: 500; margin-bottom: .35rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .3rem; }
input[type=text], input[type=email], input[type=date], textarea, select {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: .65rem .75rem; font: inherit;
}
textarea { min-height: 9rem; resize: vertical; }
.field + .field { margin-top: 1rem; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 0; border-top: 1px solid var(--line); }
.switch:first-child { border-top: 0; padding-top: 0; }
.switch .what { font-weight: 500; }
.toggle { position: relative; width: 46px; height: 26px; flex: none; }
.toggle input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.toggle span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .15s; }
.toggle span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; background: var(--text); border-radius: 50%; transition: transform .15s; }
.toggle input:checked + span { background: var(--ok); }
.toggle input:checked + span::after { transform: translateX(20px); }
.toggle input:focus-visible + span { outline: 2px solid var(--plate); outline-offset: 2px; }

/* ---------- status chips ---------- */
.chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; padding: .2rem .55rem; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--bad); } .chip.info { color: var(--info); }

/* ---------- video rows ---------- */
.vlist { display: flex; flex-direction: column; }
.vrow { display: grid; grid-template-columns: 56px minmax(0,1fr) auto; gap: .9rem; align-items: center; padding: .8rem 0; border-top: 1px solid var(--line); text-decoration: none; }
.vrow:first-child { border-top: 0; }
.vrow:hover .vtitle { color: var(--plate); }
.thumb { width: 56px; aspect-ratio: 9/16; border-radius: 5px; background: var(--panel-2) center/cover no-repeat; border: 1px solid var(--line); }
.vtitle { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vmeta { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vside { text-align: right; display: flex; flex-direction: column; align-items: end; gap: .3rem; }

/* journey: TikTok → file → AI → YouTube, drawn as a lane with dashed road marking */
.journey { display: grid; grid-template-columns: repeat(5, 1fr); position: relative; margin: .5rem 0 1.25rem; }
.journey::before { content: ''; position: absolute; left: 10%; right: 10%; top: 14px; border-top: 2px dashed var(--line); }
.journey .stop { text-align: center; position: relative; font-size: .85rem; color: var(--muted); }
.journey .dot { width: 30px; height: 30px; border-radius: 50%; margin: 0 auto .4rem; background: var(--bg); border: 2px solid var(--line); display: grid; place-items: center; position: relative; }
.journey .stop.done { color: var(--text); }
.journey .stop.done .dot { background: var(--plate); border-color: var(--plate); }
.journey .stop.done .dot::after { content: ''; width: 9px; height: 5px; border-left: 2px solid var(--plate-ink); border-bottom: 2px solid var(--plate-ink); transform: rotate(-45deg) translate(1px,-1px); }
.journey .stop.now .dot { border-color: var(--plate); box-shadow: 0 0 0 4px color-mix(in srgb, var(--plate) 22%, transparent); }
.journey .stop.stuck .dot { border-color: var(--warn); }
.journey .stop.fail .dot { border-color: var(--bad); }

/* connections */
.conn { display: grid; grid-template-columns: 44px 1fr auto; gap: 1rem; align-items: center; }
.conn + .conn { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.conn .logo { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); }
.conn .logo svg { width: 24px; height: 24px; }
.conn .who { font-weight: 600; }

/* notices */
.notice { border-left: 3px solid var(--info); background: var(--panel); padding: .85rem 1rem; border-radius: 0 var(--r-sm) var(--r-sm) 0; margin-bottom: 1rem; }
.notice.warn { border-color: var(--warn); } .notice.bad { border-color: var(--bad); } .notice.ok { border-color: var(--ok); }
.notice p:last-child { margin: 0; }
.flash { margin-bottom: 1rem; }

/* notifications & events */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 10px 1fr auto; gap: .8rem; padding: .75rem 0; border-top: 1px solid var(--line); align-items: start; }
.feed li:first-child { border-top: 0; }
.feed .mark { width: 8px; height: 8px; border-radius: 50%; margin-top: .45rem; background: var(--muted); }
.feed .success .mark, .feed .info-ok .mark { background: var(--ok); }
.feed .warn .mark { background: var(--warn); } .feed .error .mark { background: var(--bad); } .feed .info .mark { background: var(--info); }
.feed .unread .t { font-weight: 600; }
.feed time { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.feed .b { color: var(--muted); font-size: .9rem; word-break: break-word; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: .5rem .5rem; border-bottom: 1px solid var(--line); }
td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* tabs (filter links) */
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { text-decoration: none; padding: .4rem .8rem; border-radius: 999px; color: var(--muted); border: 1px solid var(--line); font-size: .9rem; }
.tabs a[aria-current="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* chart */
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); }
.chart .lbl { fill: var(--muted); font: 14px var(--font); }
.chart .ln { fill: none; stroke: var(--plate); stroke-width: 2.25; }
.chart .area { fill: color-mix(in srgb, var(--plate) 8%, transparent); }
.chart .pt { fill: var(--plate); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .btn { margin-top: .75rem; }
.hashtags { display: flex; gap: .4rem; flex-wrap: wrap; }
.hashtags span { background: var(--panel-2); border-radius: 4px; padding: .1rem .45rem; font-size: .85rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.desc-preview { white-space: pre-line; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: .8rem; font-size: .92rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* sign-in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.signin .card { max-width: 420px; width: 100%; text-align: center; }
.signin h1 { margin: 1.5rem 0 .5rem; font-size: 1.8rem; }
.signin .btn { width: 100%; margin-top: 1.5rem; }

/* ---------- mobile ---------- */
.mobile-top, .tabbar { display: none; }
@media (max-width: 900px) {
  .grid-main, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .figures { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .shell { display: block; background: none; }
  .side { display: none; }
  .mobile-top { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: #121821; position: sticky; top: 0; z-index: 5; }
  .mobile-top .plate { font-size: .95rem; }
  main { padding: 1.25rem 1rem 6rem; }
  h1 { font-size: 1.6rem; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
    background: #121821; border-top: 1px solid var(--line); padding: .35rem 0 calc(.35rem + env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: .15rem; font-size: .7rem; color: var(--muted); text-decoration: none; padding: .25rem 0; }
  .tabbar a svg { width: 20px; height: 20px; }
  .tabbar a[aria-current="page"] { color: var(--plate); }
  .state-bar form { margin-left: 0; width: 100%; }
  .state-bar form .btn { width: 100%; }
  .journey .stop { font-size: .72rem; }
  .vrow { grid-template-columns: 44px minmax(0,1fr); }
  .thumb { width: 44px; }
  .vside { grid-column: 2; flex-direction: row; align-items: center; justify-content: start; text-align: left; }
  .conn { grid-template-columns: 40px 1fr; }
  .conn > :last-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
