:root {
  --obsidian: #0B0913;
  --surface: #14101F;
  --surface-2: #1C172C;
  --violet: #8B6CFF;
  --ice: #EDEAF7;
  --dusk: #8A84A3;
  --mint: #4CC79A;
  --red: #E06284;
  --amber: #E8B35A;
  --line: rgba(139, 108, 255, 0.12);
  --line-soft: rgba(138, 132, 163, 0.16);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--obsidian); color: var(--ice);
  font-family: 'Sora', -apple-system, 'Helvetica Neue', sans-serif;
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.mono, td.num, th.num, .kpi .val { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; font-weight: 500; font-variant-numeric: tabular-nums; }
button, input { font: inherit; color: inherit; }

.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

/* Sidebar */
.side {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 22px 14px 16px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 2px 10px 20px; text-decoration: none; }
.brand img { height: 36px; display: block; }
.brand .app-name { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dusk); }
.nav-item, .order-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; border-radius: 9px; padding: 9px 10px; cursor: pointer; color: var(--dusk);
}
.nav-item:hover, .order-item:hover { background: var(--surface-2); color: var(--ice); }
.nav-item.on, .order-item.on { background: rgba(139, 108, 255, 0.14); color: var(--ice); }
.nav-item .ico { width: 16px; text-align: center; color: var(--violet); }
.side-label { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dusk); padding: 20px 10px 8px; }
.order-item .t { min-width: 0; }
.order-item .t b { display: block; font-weight: 500; font-size: 13px; color: var(--ice); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-item .t span { display: block; font-size: 11px; color: var(--dusk); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-left: auto; }
.avatar { width: 30px; height: 30px; border-radius: 50%; flex: none; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--violet); overflow: hidden; }
.avatar.lg { width: 52px; height: 52px; font-size: 17px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.side-foot { margin-top: auto; padding: 16px 10px 0; font-size: 11px; color: var(--dusk); display: flex; justify-content: space-between; gap: 8px; }
.link-btn { background: none; border: 0; color: var(--violet); cursor: pointer; font-size: 11px; }
.link-btn:hover { text-decoration: underline; }

/* Main */
main { padding: 28px 36px 80px; min-width: 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.head h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.head .sub { color: var(--dusk); font-size: 12.5px; margin-top: 3px; }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* own row under the title, left aligned: the buttons never move when the date text changes */
.head > .controls { flex-basis: 100%; min-height: 36px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { background: none; border: 0; padding: 6px 13px; border-radius: 7px; cursor: pointer; color: var(--dusk); font-size: 12.5px; }
.seg button:hover { color: var(--ice); }
.seg button.on { background: var(--violet); color: #fff; }
.range { color: var(--dusk); font-size: 12px; display: flex; align-items: center; gap: 6px; min-height: 30px; }
.range input[type=date] { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; color-scheme: dark; font-size: 12px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; width: 28px; height: 28px; cursor: pointer; color: var(--ice); }
.step:hover { border-color: var(--violet); }

.order-head { display: flex; align-items: center; gap: 16px; }
.order-head .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--dusk); font-size: 12.5px; margin-top: 4px; }
.chip { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 999px; padding: 2px 10px; font-size: 11.5px; color: var(--ice); }
.inline-input { background: transparent; border: 1px dashed var(--line-soft); border-radius: 999px; padding: 2px 10px; font-size: 11.5px; width: 150px; }
.inline-input:focus, .cell-input:focus, .field input:focus { outline: none; border-color: var(--violet); border-style: solid; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px; }
.kpi .lab { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dusk); }
.kpi .val { font-size: 23px; margin-top: 7px; letter-spacing: -0.02em; }
.kpi .hint { font-size: 11px; color: var(--dusk); margin-top: 3px; }
.good { color: var(--mint); } .bad { color: var(--red); } .muted { color: var(--dusk); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 22px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { font-size: 13.5px; font-weight: 600; }
.card-head .note { font-size: 11.5px; color: var(--dusk); }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dusk); font-weight: 500; text-align: left; padding: 11px 14px; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }
tr.total td { background: rgba(139, 108, 255, 0.07); font-weight: 600; }
td .small { display: block; font-size: 10.5px; color: var(--dusk); font-family: 'Sora', sans-serif; }
th.grp { text-align: center; border-left: 1px solid var(--line); color: var(--ice); letter-spacing: 0.04em; text-transform: none; font-size: 12px; }
td.grp-l, th.grp-l { border-left: 1px solid var(--line); }
.live { font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber); margin-left: 6px; font-family: 'Sora', sans-serif; }
.cell-input { width: 92px; text-align: right; background: var(--obsidian); border: 1px solid var(--line-soft); border-radius: 7px; padding: 5px 8px; font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.cell-input.saved { border-color: var(--mint); }
.cell { display: flex; align-items: center; gap: 10px; }
.cell b { font-weight: 500; }

.chart { padding: 14px 18px 6px; }
.chart svg { width: 100%; height: 240px; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 4px 18px 16px; font-size: 12px; color: var(--dusk); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bars { padding: 16px 18px; display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 220px 1fr 70px; gap: 12px; align-items: center; font-size: 12.5px; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }

.btn { background: var(--violet); color: #fff; border: 0; border-radius: 9px; padding: 9px 16px; cursor: pointer; font-weight: 500; font-size: 13px; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: none; border: 1px dashed var(--line-soft); color: var(--dusk); margin-top: 8px; }
.btn.ghost:hover { color: var(--ice); border-color: var(--violet); }
.btn.full { width: 100%; }
.btn.danger { background: none; color: var(--red); border: 1px solid rgba(224, 98, 132, 0.3); padding: 5px 11px; font-size: 11.5px; }
.empty { padding: 44px 18px; text-align: center; color: var(--dusk); }
.err { color: var(--red); font-size: 12px; margin-top: 8px; }
.foot-note { color: var(--dusk); font-size: 11.5px; line-height: 1.7; max-width: 820px; }

#modal:empty { display: none; }
#modal { position: fixed; inset: 0; background: rgba(5, 4, 10, 0.72); display: grid; place-items: center; z-index: 10; }
.dialog { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: min(460px, 92vw); }
.dialog h3 { font-size: 16px; margin-bottom: 4px; }
.dialog p { color: var(--dusk); font-size: 12.5px; margin-bottom: 16px; }
.field { display: grid; gap: 5px; margin-bottom: 13px; }
.field label { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dusk); }
.field input { background: var(--obsidian); border: 1px solid var(--line-soft); border-radius: 9px; padding: 10px 12px; }
.dialog .row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.dialog .row .btn.ghost { margin: 0; border-style: solid; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  main { padding: 20px 16px 60px; }
  .bar-row { grid-template-columns: 110px 1fr 56px; }
}

.inline-input.wide { width: 300px; border-radius: 8px; }
.ext { color: var(--violet); text-decoration: none; font-size: 11.5px; }
.ext:hover { text-decoration: underline; }
td a.ext.small { display: block; font-family: 'Sora', sans-serif; font-size: 10.5px; }
.order-head .meta + .meta { margin-top: 6px; }

.cell-input.failed { border-color: var(--red); }
.spend-grid th .small { display: block; font-size: 10.5px; letter-spacing: 0; text-transform: none; color: var(--dusk); margin-top: 2px; }
.spend-grid .cell-input { width: 110px; }
.spend-grid td { padding-top: 7px; padding-bottom: 7px; }

/* active / inactive */
.show-seg { display: flex; margin: 0 0 8px; }
.show-seg button { flex: 1; padding: 5px 6px; font-size: 11.5px; white-space: nowrap; }
.order-item.off { opacity: 0.55; }
.status { font-size: 10.5px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; border-radius: 999px; padding: 3px 10px; vertical-align: 3px; margin-left: 8px; }
.status.is-on { color: var(--mint); background: rgba(76, 199, 154, 0.12); }
.status.is-off { color: var(--dusk); background: var(--surface-2); }
#toggle-active { font-size: 12px; font-weight: 400; margin-left: 6px; vertical-align: 3px; }

/* KPI range colours */
.warn { color: var(--amber); }
td.good .small, td.warn .small, td.bad .small { color: var(--dusk); }
.kpi-legend { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; font-size: 11.5px; color: var(--dusk); margin: 0 0 12px; }
.kpi-legend b { color: var(--ice); font-weight: 500; }
.kpi-legend i { font-style: normal; margin-left: 8px; }

/* KPI Trends: numbers only */
.trend-table th .small { display: block; font-size: 10px; letter-spacing: 0; text-transform: none; color: var(--dusk); margin-top: 2px; }
.trend-table td.num { font-size: 13.5px; }
.trend-table td:first-child, .trend-table th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.trend-table tr.total td:first-child { background: #1a1530; }
.trend-table td.tot { font-weight: 600; background: rgba(139, 108, 255, 0.05); }

/* platform + model filter under the page head */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -8px 0 18px; }
.select { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; color: var(--ice); font: inherit; font-size: 12.5px; color-scheme: dark; cursor: pointer; }
.select:focus { outline: none; border-color: var(--violet); }
.select.sm { padding: 2px 8px; border-radius: 999px; font-size: 11.5px; }

/* ===== Order Control ===== */
.shell { grid-template-columns: 232px 1fr; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--dusk); opacity: .5; }
.dot.good { background: var(--mint); opacity: 1; } .dot.warn { background: var(--amber); opacity: 1; } .dot.bad { background: var(--red); opacity: 1; }
.dot.blocked { border-radius: 2px; background: var(--red); opacity: 1; box-shadow: 0 0 0 3px rgba(224, 98, 132, .2); }
.tag { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; border-radius: 5px; padding: 1px 6px; flex: none; }
.tag.warmup { color: var(--amber); background: rgba(232, 179, 90, .12); }
.tag.order { color: var(--violet); background: rgba(139, 108, 255, .14); }
.tag.block { color: var(--red); background: rgba(224, 98, 132, .12); }
.tag.late { color: var(--amber); background: rgba(232, 179, 90, .12); }

/* pipeline: four stages, one thin line per order */
.flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
.col { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; min-height: 180px; overflow: hidden; }
.col.over { border-color: var(--violet); }
.col-head { padding: 13px 14px 11px; border-bottom: 1px solid var(--line); position: relative; }
.col-head h2 { font-size: 12.5px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; }
.col-head h2 span { font-family: 'JetBrains Mono', monospace; color: var(--violet); font-size: 13px; }
.col-head .sum { font-size: 11px; color: var(--dusk); margin-top: 2px; }
.col-head .step-no { font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--dusk); }
.lines { max-height: calc(100vh - 250px); overflow-y: auto; }
.line { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 31px; cursor: pointer; position: relative; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; text-decoration: none; color: var(--ice); }
.line:hover { background: var(--surface-2); }
.line .nm { min-width: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line .nm i { font-style: normal; color: var(--dusk); font-size: 11px; margin-left: 6px; }
.line .v { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; flex: none; color: var(--dusk); }
.line .v.good { color: var(--mint); } .line .v.warn { color: var(--amber); } .line .v.bad { color: var(--red); }
.line .under { position: absolute; left: 0; bottom: -1px; height: 2px; background: var(--violet); opacity: .8; }
.line .under.good { background: var(--mint); } .line .under.warn { background: var(--amber); } .line .under.bad { background: var(--red); }
.line.dragging { opacity: .4; }
.col .none { padding: 22px 12px; color: var(--dusk); font-size: 11.5px; text-align: center; }
.search { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 12.5px; width: 200px; }
.search:focus { outline: none; border-color: var(--violet); }

/* progress */
.pbar { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.pbar .bar-track { flex: 1; height: 7px; }
.pbar .pc { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; width: 46px; text-align: right; }
.bar-fill.v { background: var(--violet); } .bar-fill.good { background: var(--mint); } .bar-fill.warn { background: var(--amber); } .bar-fill.bad { background: var(--red); }
.stage-pill { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--dusk); }
.stage-pill.progress { color: var(--violet); } .stage-pill.finished { color: var(--mint); }
td.name b { font-weight: 500; } td.name .small { margin-top: 1px; }
.big-bar { padding: 18px; }
.big-bar .bar-track { height: 12px; }
.big-bar .row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.big-bar .row b { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 500; letter-spacing: -.02em; }
.big-bar .row span { color: var(--dusk); font-size: 12.5px; }
.links { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; padding: 16px 18px; font-size: 12.5px; align-items: center; }
.links .k { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--dusk); }
.links a { color: var(--violet); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.links a:hover { text-decoration: underline; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.two .card { margin-bottom: 22px; }
.dialog.wide { width: min(600px, 94vw); max-height: 92vh; overflow-y: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.field select, .field textarea { background: var(--obsidian); border: 1px solid var(--line-soft); border-radius: 9px; padding: 10px 12px; color: var(--ice); font: inherit; color-scheme: dark; }
.field input[type=date] { color-scheme: dark; }
.field .hint { font-size: 11px; color: var(--dusk); }
.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--dusk); cursor: pointer; }
.banner { background: rgba(224, 98, 132, .1); border: 1px solid rgba(224, 98, 132, .3); border-radius: 12px; padding: 11px 16px; font-size: 12.5px; margin-bottom: 18px; }
.banner.info { background: rgba(232, 179, 90, .08); border-color: rgba(232, 179, 90, .28); }
.kpi-table td:first-child { color: var(--ice); }
.kpi-table td.num { font-size: 13.5px; }
@media (max-width: 1100px) { .flow { grid-template-columns: 1fr 1fr; } .two { grid-template-columns: 1fr; } }
#order-list .order-item .dot { margin-left: 0; }
#order-list .order-item { padding: 7px 10px; }
#order-list { overflow-y: auto; min-height: 0; }
