:root {
  --bg: #eef2f7; --surface: #ffffff; --surface-2: #f8fafc; --line: #e2e8f0; --text: #0f172a; --muted: #475569; --faint: #94a3b8;
  --navy: #1f3f7a; --navy-2: #16305e; --supplier: #1f3f7a; --logistics: #b45309; --farm: #15803d; --hub: #334155;
  --ok: #15803d; --watch: #ca8a04; --low: #e11d48; --critical: #951243;
  --radius: 14px; --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0b1220; --surface: #111a2e; --surface-2: #0f172a; --line: #24324d; --text: #e5edf8; --muted: #a9b4c7; --faint: #64748b; }
}
:root[data-theme="dark"] { --bg: #0b1220; --surface: #111a2e; --surface-2: #0f172a; --line: #24324d; --text: #e5edf8; --muted: #a9b4c7; --faint: #64748b; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; display: flex; flex-direction: column; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); }

/* ── top bar ── */
.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--navy-2); color: #fff; position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 17px; letter-spacing: .2px; }
.brand small { display: block; font-size: 11.5px; color: #b9c6dd; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #1f3f7a, #15803d 55%, #b45309); display: grid; place-items: center; font-weight: 800; font-size: 14px; border: 1px solid rgba(255,255,255,.35); }
.roles { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.role { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; color: #dbe5f5; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); text-decoration: none; font-size: 13px; }
.role i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.role small { color: #9fb0cc; font-size: 11.5px; }
.role.on { background: #fff; color: var(--text); border-color: #fff; }
.role.on small { color: var(--muted); }
.top-right { display: flex; align-items: center; gap: 8px; }
.clock { font-size: 13px; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.1); white-space: nowrap; }
.btn { border: 1px solid transparent; border-radius: 10px; padding: 9px 14px; font-weight: 600; font-size: 14px; background: var(--navy); color: #fff; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.3); color: #fff; padding: 6px 12px; font-size: 13px; }
.btn.sec { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.green { background: var(--farm); } .btn.amber { background: var(--logistics); } .btn.red { background: #b91c1c; }
.btn.block { width: 100%; padding: 13px; font-size: 15px; border-radius: 12px; }
.btn:disabled { opacity: .45; cursor: default; }

/* ── stage ── */
#stage { flex: 1; padding: 22px 20px 90px; }
.split { display: grid; grid-template-columns: minmax(260px, 360px) auto; gap: 36px; justify-content: center; align-items: start; }
.intro { padding-top: 30px; }
.intro .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.intro h1 { font-size: 30px; line-height: 1.15; margin: 8px 0 10px; }
.intro p { color: var(--muted); line-height: 1.5; font-size: 15px; }
.who { display: flex; gap: 10px; align-items: center; margin-top: 16px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; }

/* ── phone ── */
.phone { width: 390px; height: clamp(600px, calc(100vh - 240px), 800px); border: 11px solid #0b1220; border-radius: 46px; background: var(--surface-2); overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(15,23,42,.25); position: relative; }
.statusbar { height: 30px; display: flex; justify-content: space-between; align-items: center; padding: 6px 22px 0; font-size: 12.5px; font-weight: 600; color: #fff; }
.app-head { padding: 4px 18px 14px; color: #fff; }
.app-head b { font-size: 20px; display: block; }
.app-head small { font-size: 12.5px; opacity: .9; }
.app-body { flex: 1; overflow-y: auto; padding: 10px 12px 14px; }
.app-tabs { display: flex; justify-content: space-around; padding: 8px 4px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.app-tabs a { font-size: 11px; color: var(--muted); text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 56px; }
.app-tabs a span { font-size: 18px; line-height: 1; }
.app-tabs a.on { color: var(--text); font-weight: 700; }
.farm .app-head, .farm .statusbar { background: var(--farm); }
.driver .app-head, .driver .statusbar { background: var(--logistics); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 9px; box-shadow: var(--shadow); }
.card.tap { cursor: pointer; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.big { font-size: 24px; font-weight: 750; letter-spacing: -.3px; }
.mid { font-size: 18px; font-weight: 700; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12.5px; } .tiny { font-size: 11.5px; }
.bar { height: 7px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; color: #fff; background: var(--faint); }
.b-ok { background: var(--ok); } .b-watch { background: var(--watch); } .b-low { background: var(--low); } .b-critical { background: var(--critical); }
.fill-ok { background: var(--ok); } .fill-watch { background: var(--watch); } .fill-low { background: var(--low); } .fill-critical { background: var(--critical); }
.alert { border-radius: 12px; padding: 11px 13px; margin-bottom: 10px; background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239; font-size: 13.5px; }
.alert b { display: block; }
.note { border-radius: 12px; padding: 11px 13px; margin-bottom: 10px; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; font-size: 13.5px; }
.good { border-radius: 12px; padding: 11px 13px; margin-bottom: 10px; background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; font-size: 13.5px; }
.section-t { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 4px 8px; }
.kv { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.field { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.field input { width: 110px; text-align: right; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--surface-2); }
.st { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; background: var(--line); color: var(--text); }
.st-requested { background: #fef3c7; color: #92400e; } .st-ordered { background: #dbeafe; color: #1e40af; } .st-scheduled { background: #e0e7ff; color: #3730a3; }
.st-weighed { background: #ffedd5; color: #9a3412; } .st-signed, .st-paid { background: #dcfce7; color: #166534; } .st-rejected { background: #fee2e2; color: #991b1b; }
.st-draft { background: #f1f5f9; color: #334155; } .st-open { background: #fef3c7; color: #92400e; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 20px 20px 0 0; padding: 16px 16px 22px; box-shadow: 0 -10px 40px rgba(15,23,42,.25); z-index: 5; animation: up .25s ease-out; }
.sheet h3 { margin: 0 0 8px; }
.scrim { position: absolute; inset: 0; background: rgba(15,23,42,.35); z-index: 4; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sig { height: 90px; border: 1px dashed var(--faint); border-radius: 10px; background: var(--surface-2); margin: 10px 0; position: relative; }
.sig svg { position: absolute; inset: 0; }
.photos { display: flex; gap: 8px; margin: 8px 0; }
.photo { width: 84px; height: 60px; border-radius: 8px; background: linear-gradient(135deg, #1e293b, #334155); color: #7dd3fc; font: 700 15px/60px ui-monospace, Menlo, monospace; text-align: center; }

/* ── driver ── */
.viewfinder { height: 420px; border-radius: 16px; background: radial-gradient(circle at 50% 40%, #334155, #0b1220); position: relative; display: grid; place-items: center; color: #e2e8f0; }
.qrbox { width: 190px; height: 190px; border: 3px solid #fbbf24; border-radius: 16px; display: grid; place-items: center; background: repeating-linear-gradient(45deg, rgba(255,255,255,.06) 0 6px, transparent 6px 12px); }
.qr { width: 120px; height: 120px; background: conic-gradient(#fff 0 25%, #0b1220 0 50%, #fff 0 75%, #0b1220 0) 0 0 / 20px 20px; border: 8px solid #fff; }
.indicator { font: 700 44px/1 ui-monospace, Menlo, monospace; color: #22c55e; background: #0b1220; border-radius: 12px; padding: 18px; text-align: right; letter-spacing: 1px; }
.pick { display: block; width: 100%; text-align: left; border: 2px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.pick.on { border-color: var(--logistics); background: #fff7ed; }

/* ── desktop apps ── */
.desk { max-width: 1320px; margin: 0 auto; }
.desk-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.desk-head .mark { width: 42px; height: 42px; border-radius: 11px; color: #fff; display: grid; place-items: center; font-weight: 800; }
.desk-head h1 { font-size: 22px; margin: 0; }
.desk-head p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.subnav { display: flex; gap: 4px; margin-left: auto; background: var(--surface); padding: 4px; border-radius: 11px; border: 1px solid var(--line); }
.subnav a { padding: 7px 13px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.subnav a.on { background: var(--navy); color: #fff; }
.supplier .subnav a.on { background: var(--supplier); } .dispatch .subnav a.on { background: var(--logistics); } .hub .subnav a.on { background: var(--hub); }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); } .g2 { grid-template-columns: 1.4fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel > h3 { margin: 0; padding: 12px 16px; font-size: 15px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.panel .pad { padding: 14px 16px; }
.kpi { padding: 14px 16px; }
.kpi .v { font-size: 28px; font-weight: 750; letter-spacing: -.5px; }
.kpi .l { color: var(--muted); font-size: 13px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr.hl td { background: #fffbeb; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.req { border: 2px solid #fbbf24; border-radius: var(--radius); background: var(--surface); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.req.done { border-color: var(--line); opacity: .8; }
.mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.mini div { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.mini b { display: block; font-size: 18px; }
.mini span { font-size: 12px; color: var(--muted); }

/* dispatch board */
.board { display: grid; grid-template-columns: 110px repeat(7, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.board > div { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px; min-height: 92px; font-size: 13px; }
.board .bh { min-height: 0; background: var(--surface-2); font-weight: 700; font-size: 12.5px; }
.board .bh.today { background: #fff7ed; color: #9a3412; }
.board .truck { background: var(--surface-2); font-weight: 700; }
.board .cell.drop { background: #fff7ed; outline: 2px dashed var(--logistics); outline-offset: -4px; cursor: pointer; }
.lchip { border-radius: 9px; padding: 6px 8px; margin-bottom: 6px; background: #eef2ff; border-left: 4px solid #6366f1; font-size: 12px; line-height: 1.3; }
.lchip.dg { background: #fef3c7; border-color: #ca8a04; } .lchip.lmin { background: #ffe4e6; border-color: #e11d48; } .lchip.corn { background: #ecfccb; border-color: #65a30d; }
.lchip.done { opacity: .55; }
.order { border: 1px solid var(--line); border-left: 4px solid var(--logistics); border-radius: 10px; padding: 10px; background: var(--surface); margin-bottom: 8px; cursor: pointer; font-size: 13px; }
.order.sel { outline: 3px solid #fbbf24; }
.assign { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 10px; align-items: end; margin-top: 12px; }
.assign label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.assign select, .assign input { padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }

/* hub */
.conn { padding: 14px 16px; }
.conn .row b { font-size: 15px; }
.badge { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 9px; }
.badge.on { background: #dcfce7; color: #166534; } .badge.off { background: #f1f5f9; color: #475569; }
.evt { font: 600 11.5px ui-monospace, Menlo, monospace; padding: 2px 7px; border-radius: 6px; background: #eef2ff; color: #3730a3; }
tr.fresh td { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #fef9c3; } to { background: transparent; } }
.tgt { display: inline-block; font-size: 11.5px; padding: 2px 7px; border-radius: 6px; background: #dcfce7; color: #166534; margin-right: 4px; }

/* tour, toasts */
.tourbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 34px; z-index: 30; background: #0b1220; color: #fff; border-radius: 16px; padding: 12px 14px 12px 18px; display: flex; align-items: center; gap: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.35); max-width: min(920px, calc(100vw - 32px)); width: max-content; }
.tourbar[hidden] { display: none; }
.tourbar .n { font-size: 12px; color: #93c5fd; font-weight: 700; white-space: nowrap; }
.tourbar .c { font-size: 15.5px; line-height: 1.35; }
.tourbar .btn { padding: 7px 12px; font-size: 13px; white-space: nowrap; }
.toasts { position: fixed; bottom: 118px; right: 20px; z-index: 40; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0b1220; color: #fff; border-radius: 14px; padding: 12px 14px; width: 320px; box-shadow: 0 12px 30px rgba(0,0,0,.3); font-size: 13.5px; animation: up .25s ease-out; }
.toast b { display: block; margin-bottom: 2px; }
.toast small { color: #93c5fd; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.hilite { outline: 3px solid #fbbf24 !important; outline-offset: 3px; border-radius: 12px; transition: outline-color .2s; }
.demo-foot { position: fixed; bottom: 0; left: 0; right: 0; text-align: center; font-size: 11.5px; color: var(--faint); padding: 6px; background: var(--bg); }
.welcome { max-width: 720px; margin: 40px auto; background: var(--surface); border-radius: 20px; padding: 30px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.welcome h1 { margin: 0 0 8px; }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.trio div { border-radius: 14px; padding: 14px; color: #fff; }
.trio b { display: block; font-size: 16px; } .trio span { font-size: 13px; opacity: .92; }

@media (max-width: 1600px) { .brand small { display: none; } }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g2, .g3 { grid-template-columns: 1fr; } .assign { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; justify-items: center; } .dispatch .grid { grid-template-columns: 1fr !important; } .desk-head { flex-wrap: wrap; } .subnav { margin-left: 0; max-width: 100%; overflow-x: auto; } .intro { padding-top: 0; max-width: 390px; } .board { overflow-x: auto; } }
@media (max-width: 480px) {
  #stage { padding: 12px 8px 110px; }
  .phone { width: 100%; max-width: 390px; height: 760px; border-width: 6px; border-radius: 30px; }
  .roles { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .role small { display: none; }
  .brand small { display: none; }
  .trio { grid-template-columns: 1fr; }
  .board { display: block; }
  .g4 { grid-template-columns: 1fr 1fr; }
  .kpi .v { font-size: 22px; }
  .panel { max-width: 100%; }
  .board > div { min-height: 0; }
  table.t { display: block; overflow-x: auto; }
  .mini { grid-template-columns: 1fr 1fr; }
  .toast { width: calc(100vw - 40px); }
}

/* ── tablet + phone polish (demo for JP) ── */
@media (max-width: 1200px) {
  .topbar { flex-wrap: nowrap; gap: 12px; }
  .roles { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .roles::-webkit-scrollbar { display: none; }
  .role { white-space: nowrap; }
  .role small { display: none; }
  .toasts { top: 70px; bottom: auto; right: 12px; }
  .toasts .toast:not(:last-child) { display: none; }
}
@media (max-width: 900px) {
  .board { grid-template-columns: 88px repeat(7, minmax(108px, 1fr)); overflow-x: auto; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; padding: 8px 10px; }
  .intro { display: none; }
  .split { gap: 0; }
  .tourbar { left: 8px; right: 8px; transform: none; bottom: 26px; width: auto; max-width: none; flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .tourbar .c { flex: 1 1 100%; order: -1; font-size: 14px; }
  .tourbar .n { margin-right: auto; }
  .toasts { top: auto; bottom: 150px; left: 8px; right: 8px; }
  .toast { width: auto; }
  .board { display: grid; overflow-x: auto; }
  .board > div { min-height: 70px; }
  .desk-head .mark { display: none; }
  #stage { padding-bottom: 170px; }
}
.grid > * { min-width: 0; }
@media (max-width: 600px) {
  .phone { height: max(460px, calc(100dvh - 300px)); }
  .toasts { top: 140px; bottom: auto; }
  .assign { grid-template-columns: 1fr; }
  .dispatch .grid, .supplier .grid { grid-template-columns: 1fr !important; }
}
