:root {
  --bg: #eef2f6; --panel: rgba(255,255,255,.94); --card: #ffffff; --text: #1b2430; --muted: #5b6878; --line: #d5dce4;
  --accent: #0b5cad; --ok: #22c55e; --okd: #137a3a; --warn: #f7b731; --warnd: #8a5a00; --err: #ff4d4d; --errd: #b42318;
  --radius: 12px; --shadow: 0 6px 24px rgba(20,30,45,.14); --nav: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px "Segoe UI", system-ui, sans-serif; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: #fff; width: 100%; min-height: 46px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
h2 { margin: 0; font-size: 22px; } h3 { margin: 18px 0 8px; font-size: 17px; } h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.muted { color: var(--muted); } .bad { color: var(--errd); font-weight: 700; } .okv { color: var(--okd); font-weight: 700; } .warnv { color: var(--warnd); font-weight: 700; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }

/* ---------- buttons ---------- */
.b { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; min-height: 46px; }
.b:hover { border-color: var(--accent); }
.b:disabled { opacity: .45; cursor: not-allowed; }
.b.small { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.b.big { min-height: 58px; padding: 12px 20px; font-size: 17px; }
.b.huge { min-height: 76px; font-size: 21px; padding: 14px 26px; }
.b.go { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.b.go:hover { background: #17834a; }
.b.red { background: #d92d20; border-color: #d92d20; color: #fff; }
.b.warnb { background: #fff6e0; border-color: var(--warn); }
.b.ghost { background: #fff; }
.b.on { outline: 3px solid var(--accent); outline-offset: 1px; }
.b.ghost.on { background: #e8f1fb; }

/* ---------- top navigation ---------- */
.nav { position: fixed; top: 0; left: 0; right: 0; height: var(--nav); display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: #13202f; color: #fff; z-index: 20; }
.brand { color: #fff; text-decoration: none; letter-spacing: .08em; white-space: nowrap; font-size: 15px; }
.links { display: flex; gap: 4px; overflow-x: auto; flex: 1 1 auto; min-width: 0; scrollbar-width: thin; }
.links a { color: #d6e2ee; text-decoration: none; padding: 8px 11px; border-radius: 8px; white-space: nowrap; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.links a:hover { background: rgba(255,255,255,.08); }
.links a.on { background: #fff; color: #13202f; font-weight: 700; }
.links .n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.18); font-size: 11px; font-weight: 800; }
.links a.on .n { background: #13202f; color: #fff; }
.nav-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.who { font-size: 12px; color: #b9c7d6; white-space: nowrap; }
.opbtn { background: #fff; color: #13202f; border: 0; border-radius: 8px; padding: 8px 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.opbtn.need { background: #ffd166; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(255,209,102,.4); } }
.demorep { min-height: 34px; padding: 4px 8px; width: auto; font-size: 13px; color: #13202f; background: #fff; font-weight: 600; }
.badge { padding: 4px 10px; border-radius: 999px; font-weight: 800; font-size: 11px; letter-spacing: .08em; white-space: nowrap; }
.badge.demo { background: #fff1db; color: #b26b00; } .badge.live { background: #e3f7ea; color: var(--okd); } .badge.stale { background: #ffe3e3; color: var(--errd); }

main { position: fixed; top: var(--nav); left: 0; right: 0; bottom: 0; overflow: hidden; }
.view { position: absolute; inset: 0; overflow: auto; }
.boot { display: grid; place-content: center; justify-items: center; gap: 14px; font-size: 17px; color: var(--muted); text-align: center; }
.spin { width: 38px; height: 38px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login { display: grid; place-items: center; }
.loginbox { width: min(420px, 92vw); display: grid; gap: 8px; }
.loginbox label { font-size: 13px; color: var(--muted); }

/* ---------- 3D view ---------- */
.v3d { overflow: hidden; }
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
.flow { position: absolute; top: 10px; left: 250px; right: 10px; display: flex; align-items: center; gap: 4px; overflow-x: auto; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 4; }
.chip { display: flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line); background: #fff; white-space: nowrap; cursor: pointer; font-size: 13px; }
.chip:hover { border-color: var(--accent); }
.chip .n { font-weight: 800; color: #fff; width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; }
.chip .cnt { font-weight: 800; }
.chip .dot, .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; background: #9aa6b4; }
.arrow { color: var(--muted); }
.left3d { position: absolute; top: 10px; left: 10px; width: 230px; display: flex; flex-direction: column; gap: 8px; z-index: 4; max-height: calc(100% - 110px); }
.clock { font-weight: 700; font-size: 13px; padding: 10px 12px; }
.clock small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; margin-top: 2px; }
.find { min-height: 44px; }
.find.nf { border-color: var(--err); }
.alarms { overflow: auto; font-size: 12px; padding: 10px 12px; }
.alarms h4 { margin: 0 0 6px; font-size: 11px; }
.al { display: grid; grid-template-columns: 40px 1fr; gap: 6px; padding: 5px 0; border-top: 1px solid var(--line); cursor: pointer; }
.al .t { color: var(--muted); } .al.err .m { color: var(--errd); } .al.warn .m { color: var(--warnd); }
.al .src { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; }
.kpi { position: absolute; bottom: 10px; left: 250px; right: 10px; display: flex; gap: 8px; padding: 8px; overflow-x: auto; z-index: 4;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.kcard { min-width: 110px; padding: 6px 10px; border-radius: 9px; background: #f7f9fb; border: 1px solid var(--line); flex: 1 0 auto; }
.kl { font-size: 10px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; white-space: nowrap; }
.kv { font-size: 20px; font-weight: 800; white-space: nowrap; } .ks { font-size: 10px; color: var(--muted); white-space: nowrap; }
.kcard.alarm .kv { color: var(--errd); } .kcard.good .kv { color: var(--okd); }
.stpanel { position: absolute; top: 70px; right: 10px; width: 350px; max-height: calc(100% - 160px); overflow: auto; padding: 12px; z-index: 6;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.sp-head { display: flex; align-items: center; gap: 8px; } .sp-head h3 { margin: 0; flex: 1; font-size: 15px; }
.sp-x { border: 0; background: none; font-size: 18px; cursor: pointer; }
.sp-state { display: flex; align-items: center; gap: 6px; margin: 6px 0 10px; font-weight: 700; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 6px; cursor: pointer; background: #fff; align-items: center; }
.row:hover { border-color: var(--accent); } .row .num { font-weight: 800; } .row .meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.pill { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; display: inline-block; }
.bar { grid-column: 1 / -1; height: 7px; background: #e6ebf0; border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.nowebgl { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); font-size: 18px; padding: 40px; text-align: center; z-index: 50; }

/* ---------- department screens ---------- */
.rep { padding: 14px; }
.rhead { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.rhead h2 { display: flex; align-items: center; gap: 10px; flex: 1; }
.rhead h2 .n { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #13202f; color: #fff; font-size: 15px; }
.rbody { display: grid; grid-template-columns: 300px 1fr; gap: 14px; align-items: start; }
.queue { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - var(--nav) - 90px); overflow: auto; padding-right: 2px; }
.queue h4 { margin: 4px 0; display: flex; justify-content: space-between; }
.queue h4 .cnt { background: #13202f; color: #fff; border-radius: 999px; padding: 1px 9px; }
.qempty { padding: 6px 2px; }
.qcard { text-align: left; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; display: grid; gap: 4px; }
.qcard:hover { border-color: #8fb3da; }
.qcard.sel { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11,92,173,.15); }
.qcard .q1 { display: flex; align-items: center; gap: 8px; font-size: 17px; } .qcard .q1 .dot { margin-left: auto; width: 14px; height: 14px; }
.qcard .q3, .qcard .q4 { font-size: 12px; }
.qt { color: var(--muted); font-weight: 600; }
.detail { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px 22px; min-height: 300px; }
.dhead { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 6px; }
.dhead h2 { font-size: 26px; } .dstate { text-align: right; display: grid; gap: 6px; justify-items: end; }
.comp { font-size: 15px; font-weight: 600; margin-top: 4px; }
.eyebrow { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.hint { padding: 40px 10px; text-align: center; color: var(--muted); font-size: 18px; }
.done-msg { background: #e3f7ea; color: var(--okd); padding: 14px; border-radius: 10px; font-weight: 700; font-size: 17px; margin-bottom: 10px; }
.next { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--line); }
.next .b { width: 100%; }
.dfoot { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; } .dfoot .b { flex: 1 1 200px; }
.alarmbox { background: #fff0f0; border: 1px solid #ffc9c9; color: var(--errd); padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-weight: 700; }
.banner { background: #fff6e0; border: 1px solid #ffd98a; padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-weight: 600; }
.banner.bad { background: #fff0f0; border-color: #ffc9c9; color: var(--errd); }
.counter { display: flex; align-items: center; gap: 14px; margin: 14px 0; flex-wrap: wrap; }
.cbig { font-size: 54px; font-weight: 900; min-width: 190px; } .cbig small { font-size: 18px; color: var(--muted); font-weight: 600; }
.rows { display: grid; gap: 10px; margin: 12px 0; }
.mrow { display: grid; grid-template-columns: 1fr 140px 1.3fr 90px; gap: 10px; align-items: center; background: #f7f9fb; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.mrow .ml { font-size: 20px; } .mrow .mc { font-size: 34px; font-weight: 900; text-align: center; } .mrow .mc small { font-size: 16px; color: var(--muted); }
.tot { font-size: 17px; margin: 8px 0; }
.choice { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; } .choice .b { flex: 1 1 110px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; align-items: start; }
.form4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; margin: 10px 0; background: #f7f9fb; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.fl { display: grid; gap: 4px; } .fl > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.stack { display: grid; gap: 8px; }
.li { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; margin: 6px 0; background: #fff; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.li.done { background: #f2fbf5; }
.li .x { margin-left: auto; border: 0; background: #f1f4f7; border-radius: 7px; width: 32px; height: 32px; cursor: pointer; }
.acgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.accard { border: 2px solid var(--line); border-radius: 12px; padding: 10px; background: #fff4ec; cursor: pointer; display: grid; gap: 6px; }
.accard.free { background: #f7f9fb; cursor: default; } .accard.alarm { border-color: var(--err); background: #fff0f0; }
.accard .bar i { background: #ff8a34; }
.cart { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; border: 2px solid var(--line); border-radius: 12px; padding: 10px; margin: 8px 0; background: #fff; }
.cart.ready { border-color: var(--ok); background: #f2fbf5; }
.order { display: grid; grid-template-columns: 1fr auto auto auto auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 8px 0; background: #fff; }
.order.done { background: #f2fbf5; } .order .pal { font-size: 18px; }
.gate { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.gate span { padding: 6px 10px; border-radius: 9px; font-weight: 700; }
.gok { background: #e3f7ea; color: var(--okd); } .gno { background: #ffe3e3; color: var(--errd); text-decoration: line-through; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
table.t th, table.t td { text-align: left; padding: 6px 7px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t th { color: var(--muted); font-weight: 600; }
table.t.big { font-size: 15px; } table.t.big td { padding: 8px; }
table.t .kg { width: 110px; display: inline-block; } table.t .sp { width: 80px; display: inline-block; }
tr.badrow td { background: #fff0f0; }

/* ---------- admin ---------- */
.admin { padding: 14px; } .admin-wrap { max-width: 1100px; margin: 0 auto; display: grid; gap: 14px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 8px; }

/* ---------- drawer (batch report), modal, toast ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15,23,35,.3); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(700px, 100vw); background: #fff; z-index: 41; overflow: auto; padding: 18px 20px 40px; box-shadow: var(--shadow); }
.dr-head { display: flex; align-items: flex-start; gap: 10px; } .dr-head h2 { margin: 2px 0 6px; }
.dr-x { margin-left: auto; border: 0; background: #f1f4f7; border-radius: 8px; padding: 8px 12px; font-size: 16px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; align-items: center; }
.chip2 { padding: 4px 10px; border-radius: 999px; background: #f1f4f7; font-size: 12px; font-weight: 600; display: inline-flex; gap: 5px; align-items: center; }
.path { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin: 10px 0 14px; }
.step { text-align: center; font-size: 10px; padding: 6px 2px; border-radius: 8px; background: #f1f4f7; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step b { display: block; font-size: 13px; } .step.done { background: #e3f7ea; color: var(--okd); } .step.cur { color: #fff; font-weight: 700; } .step.todo { opacity: .55; }
.sec { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 10px 0; border-left-width: 6px; }
.sec h3 { margin: 0 0 8px; font-size: 14px; } .sec.off { opacity: .5; } .sec.hist { border-left-color: #13202f; }
.kvs { display: grid; grid-template-columns: 190px 1fr; gap: 4px 10px; font-size: 13px; margin: 0; }
.kvs dt { color: var(--muted); } .kvs dd { margin: 0; font-weight: 600; }
.modal { position: fixed; inset: 0; background: rgba(15,23,35,.45); z-index: 60; display: grid; place-items: center; padding: 16px; }
.mbox { background: #fff; border-radius: 14px; padding: 18px 20px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: var(--shadow); }
.mbox h3 { margin-top: 0; }
.mform { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mf { display: grid; gap: 4px; } .mf label { font-size: 13px; color: var(--muted); font-weight: 600; }
.mf.s1 { grid-column: span 1; } .mf.s2 { grid-column: span 2; } .mf.s3 { grid-column: span 3; }
.mact { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; } .mact .b { min-width: 120px; }
.opgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin: 10px 0; }
.addop { display: flex; gap: 8px; margin-top: 10px; }
.toast { position: fixed; top: calc(var(--nav) + 10px); left: 50%; transform: translateX(-50%); padding: 14px 20px; font-weight: 700; z-index: 70;
  background: #fff; border-radius: 12px; box-shadow: var(--shadow); border-left: 7px solid var(--ok); max-width: min(680px, 92vw); font-size: 16px; }
.toast.err { border-left-color: var(--err); color: var(--errd); }

@media (max-width: 1000px) {
  .rbody { grid-template-columns: 1fr; }
  .queue { position: static; max-height: none; flex-direction: row; overflow-x: auto; }
  .queue h4 { display: none; } .qcard { min-width: 220px; }
  .mrow { grid-template-columns: 1fr 110px; } .mrow .b { grid-column: span 1; }
  .acgrid { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .flow, .kpi { left: 10px; } .flow { top: auto; bottom: 86px; }
  .left3d { width: 190px; }
  .order { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .nav { gap: 6px; padding: 0 6px; } .brand { display: none; } .who { display: none; }
  .left3d { display: none; } .stpanel { left: 10px; width: auto; }
  .kvs { grid-template-columns: 120px 1fr; } .mform { grid-template-columns: 1fr; } .mf.s1, .mf.s2 { grid-column: span 1; }
  .cart { grid-template-columns: 1fr 1fr; } .cart > div:first-child { grid-column: 1 / -1; }
  .dhead { flex-direction: column; } .dstate { justify-items: start; text-align: left; }
}
