:root {
  --bg: #0f0f10;
  --panel: #18181b;
  --panel-2: #202024;
  --line: #2a2a30;
  --text: #f2f2f2;
  --muted: #9a9aa3;
  --gold: #c9a24b;
  --gold-2: #e2c16f;
  --green: #3fb950;
  --red: #f0605d;
  --amber: #f0b429;
  --blue: #58a6ff;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.4;
  -webkit-font-smoothing: antialiased; padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--gold-2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.container { max-width: 980px; margin: 0 auto; padding: 0 16px 40px; }
header.top {
  position: sticky; top: 0; z-index: 20; background: rgba(15,15,16,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; align-items: center; gap: 12px;
}
header.top .brand { font-weight: 700; letter-spacing: .04em; color: var(--gold); text-transform: uppercase; font-size: 13px; }
header.top .brand small { display: block; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 12px; }
header.top nav { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
header.top nav a, header.top nav button {
  background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 13px;
}
header.top nav a.active { border-color: var(--gold); color: var(--gold-2); }
h1 { font-size: 22px; margin: 18px 0 8px; }
h2 { font-size: 16px; margin: 20px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.card.gold { border-color: rgba(201,162,75,.45); background: linear-gradient(180deg, rgba(201,162,75,.10), rgba(201,162,75,.02)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; padding: 10px 14px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 14px; min-height: 40px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--gold); color: #1a1405; border-color: var(--gold); }
.btn.good { background: rgba(63,185,80,.15); border-color: rgba(63,185,80,.5); color: #7ee787; }
.btn.bad { background: rgba(240,96,93,.12); border-color: rgba(240,96,93,.5); color: #ff8a86; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.big { min-height: 64px; font-size: 18px; border-radius: 16px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; background: #101013; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); min-height: 42px;
}
textarea { min-height: 80px; resize: vertical; }
label.field { display: block; margin: 8px 0; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--panel-2); }
.chip.pending { color: var(--amber); border-color: rgba(240,180,41,.4); }
.chip.approved { color: var(--green); border-color: rgba(63,185,80,.4); }
.chip.scheduled { color: var(--blue); border-color: rgba(88,166,255,.4); }
.chip.posted { color: var(--gold-2); border-color: rgba(201,162,75,.5); }
.chip.rejected { color: var(--red); border-color: rgba(240,96,93,.45); }
.chip.uploading { color: var(--muted); }
.chip.warn { color: var(--amber); border-color: rgba(240,180,41,.5); }
.chip.top20 { color: #1a1405; background: var(--gold); border-color: var(--gold); }
.progress { height: 8px; background: #101013; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress > div { height: 100%; background: var(--gold); width: 0%; transition: width .2s; }
.progress.green > div { background: var(--green); }
.counter { display: flex; align-items: baseline; gap: 8px; }
.counter .big { font-size: 44px; font-weight: 800; color: var(--gold-2); line-height: 1; }
.counter .of { font-size: 18px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 10px; }
.stat { background: var(--panel-2); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
.week { display: flex; gap: 6px; align-items: flex-end; height: 56px; margin-top: 10px; }
.week .d { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: var(--muted); height: 100%; justify-content: flex-end; }
.week .bar { width: 100%; background: var(--line); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.week .bar > i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--gold); border-radius: 4px 4px 0 0; }
.dropzone { border: 2px dashed rgba(201,162,75,.5); border-radius: 16px; padding: 22px 14px; text-align: center; background: rgba(201,162,75,.04); }
.dropzone.over { background: rgba(201,162,75,.12); }
.dropzone input { display: none; }
.uplist .item { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.thumb { width: 64px; height: 96px; border-radius: 8px; background: #101013 center/cover no-repeat; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; }
.thumb.wide { width: 96px; height: 96px; }
.list .item { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.list .item .title { font-weight: 600; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; margin: 0 -16px; padding-left: 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 0 0 auto; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; font-size: 14px; color: var(--muted); }
.tabs button.active { border-color: var(--gold); color: var(--gold-2); background: rgba(201,162,75,.08); }
.tabs button b { color: var(--text); margin-left: 4px; }
.review { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .review { grid-template-columns: 300px 1fr; } }
.player { background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 9/16; max-height: 70vh; display: flex; align-items: center; justify-content: center; }
.player video { width: 100%; height: 100%; object-fit: contain; }
.player .poster { width: 100%; height: 100%; background: center/cover no-repeat; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.player .poster span { background: rgba(0,0,0,.55); border-radius: 999px; padding: 12px 18px; font-weight: 700; }
.meta dl { display: grid; grid-template-columns: 90px 1fr; gap: 4px 8px; margin: 0; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.product { display: flex; gap: 10px; align-items: center; background: var(--panel-2); border-radius: 10px; padding: 8px; }
.product img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #000; }
.slots .slot { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); align-items: center; }
.slots .slot .t { font-family: ui-monospace, Menlo, monospace; color: var(--muted); }
.slots .slot.empty .t { color: #55555c; }
.slots .slot .cell { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-height: 34px; }
.slots .slot.empty .cell { color: #55555c; font-size: 13px; }
.slots .slot.posted .cell { opacity: .6; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #26262c; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; font-size: 14px; max-width: 92vw; }
.toast.bad { background: #5a1e1c; }
.toast.good { background: #1e4a2a; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 720px) { .modal-bg { align-items: center; } }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 0 0; padding: 16px; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; }
@media (min-width: 720px) { .modal { border-radius: 16px; } }
.scanner video { width: 100%; border-radius: 12px; background: #000; max-height: 60vh; object-fit: cover; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.kpi b { font-size: 26px; display: block; }
.kpi span { color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; }
.logo { font-size: 26px; font-weight: 800; color: var(--gold); letter-spacing: .02em; }
.logo small { display: block; font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: .12em; text-transform: uppercase; }
.hint { font-size: 13px; color: var(--muted); }
.warnbox { border: 1px solid rgba(240,180,41,.5); background: rgba(240,180,41,.08); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; }
.sr { position: absolute; left: -9999px; }

/* ---- dispatch ---- */
@media (max-width: 520px) { header.top nav { margin-left: 0; width: 100%; } }
header.top nav::-webkit-scrollbar { display: none; }
h3 { font-size: 17px; }
.card.red { border-color: rgba(240,96,93,.5); background: rgba(240,96,93,.06); }
.card.green { border-color: rgba(63,185,80,.45); background: rgba(63,185,80,.06); }
.row.nowrap { flex-wrap: nowrap; }
.right { text-align: right; }
.btn.icon { min-width: 42px; padding: 8px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; background: #101013; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); min-height: 44px; font-size: 16px;
}
.chip.muted { color: var(--muted); }
.chip.gold { color: #1a1405; background: var(--gold); border-color: var(--gold); }
.tabs button.alert b { color: var(--red); }
.list .item:first-child { border-top: 0; }
.list .item .sub { font-size: 13px; color: var(--muted); }
.list .item .amt { font-weight: 700; font-size: 16px; text-align: right; white-space: nowrap; }
.list .item.sel { background: rgba(201,162,75,.06); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.check { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 15px; color: #1a1405; flex: 0 0 auto; }
.item.sel .check { background: var(--gold); border-color: var(--gold); }
.stop { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 10px 0; background: var(--panel); }
.stop.done { opacity: .75; border-color: rgba(63,185,80,.4); }
.stop.returned { border-color: rgba(240,96,93,.45); }
.stop .head { display: flex; align-items: baseline; gap: 8px; }
.stop .num { font-weight: 800; font-size: 18px; }
.stop .money { margin-left: auto; font-weight: 800; font-size: 22px; color: var(--gold-2); white-space: nowrap; }
.stop .name { font-size: 16px; font-weight: 600; margin-top: 2px; }
.stop .addr { color: var(--muted); font-size: 14px; }
.stop .note { background: rgba(240,180,41,.1); border: 1px solid rgba(240,180,41,.35); border-radius: 8px; padding: 6px 9px; margin-top: 8px; font-size: 14px; }
.stop .items { font-size: 13px; color: var(--muted); margin-top: 6px; }
.stop .actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.stop .finish { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; margin-top: 8px; }
.stop .seq { display: inline-flex; width: 26px; height: 26px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.big-amount { font-size: 30px; font-weight: 800; color: var(--gold-2); margin: 6px 0 10px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; padding: 5px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 500; word-break: break-word; }
.kv b.note { color: var(--amber); }
ul.items { margin: 10px 0; padding-left: 18px; font-size: 14px; }
.detail .actions { margin-top: 10px; }
.detail .actions .btn { flex: 1 1 auto; }
.events { margin-top: 12px; }
.events .ev { padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.sticky-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(24,24,27,.97); border-top: 1px solid var(--gold); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); backdrop-filter: blur(10px); }
.sticky-bar .inner { max-width: 900px; margin: 0 auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sticky-bar select { width: auto; flex: 1 1 120px; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
.errbox { border: 1px solid rgba(240,96,93,.5); background: rgba(240,96,93,.08); border-radius: 10px; padding: 8px 10px; font-size: 13px; margin: 8px 0; }
.okbox { border: 1px solid rgba(63,185,80,.5); background: rgba(63,185,80,.08); border-radius: 10px; padding: 8px 10px; font-size: 13px; margin: 8px 0; }
.datebar { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.datebar .label { flex: 1; text-align: center; font-weight: 700; font-size: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); padding: 8px 12px; color: var(--muted); font-size: 14px; }
.chips button.active { border-color: var(--gold); color: var(--gold-2); background: rgba(201,162,75,.1); }
.menu { position: relative; }
.pill-num { display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; text-align: center; }
.driver-card .bar { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 70; background: #5a1e1c; color: #fff; text-align: center; padding: 6px; font-size: 13px; display: none; }
body.is-offline .offline { display: block; }

/* ---- hub: header wraps on phones; dispatch pages leave room for the sticky assign bar ---- */
header.top { flex-wrap: wrap; }
header.top .brand { text-decoration: none; }
header.top nav a.hub { padding: 6px 10px; font-size: 15px; }
@media (max-width: 520px) { header.top nav { margin-left: 0; width: 100%; } }
body.dispatch { padding-bottom: calc(env(safe-area-inset-bottom) + 80px); }
input[type=search] { width: 100%; background: #101013; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); min-height: 42px; }
.chip.muted { color: var(--muted); }
.chip.gold { color: #1a1405; background: var(--gold); border-color: var(--gold); }
.btn.icon { min-width: 42px; padding: 8px; }
.row.nowrap { flex-wrap: nowrap; }
.right { text-align: right; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
.tabs button.alert b { color: var(--red); }
.list .item .sub { font-size: 13px; color: var(--muted); }
.list .item .amt { font-weight: 700; font-size: 16px; text-align: right; white-space: nowrap; }
.list .item.sel { background: rgba(201,162,75,.06); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.list .item:first-child { border-top: 0; }
/* ---- hub home tiles ---- */
.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 14px; }
@media (min-width: 640px) { .tiles { grid-template-columns: 1fr 1fr; } }
.tile { display: flex; gap: 14px; align-items: center; padding: 18px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); color: var(--text); text-decoration: none; min-height: 96px; }
.tile .ic { font-size: 34px; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; border-radius: 14px; background: rgba(201,162,75,.12); border: 1px solid rgba(201,162,75,.35); flex: 0 0 auto; }
.tile b { font-size: 18px; display: block; }
.tile span { color: var(--muted); font-size: 13px; }
.tile .role { display: inline-block; margin-top: 4px; }
.tile.on:active { transform: scale(.99); }
.tile.off { opacity: .45; pointer-events: none; filter: grayscale(1); }
.tile.soon { border-style: dashed; }
.who { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.avatar { width: 44px; height: 44px; border-radius: 999px; background: var(--gold); color: #1a1405; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.rolegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
