:root { --ink: #0f172a; --mut: #475569; --line: #e2e8f0; --blue: #2563eb; --ok: #15803d; --bad: #b91c1c; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: radial-gradient(120% 90% at 50% 35%, #2a3854 0%, #141b29 70%, #0c111b 100%); overflow: hidden; font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--ink); }
canvas#c { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.card { background: #fff; border: 2px solid var(--line); border-radius: 14px; }
.left { position: fixed; left: 16px; top: 16px; width: 310px; display: flex; flex-direction: column; gap: 10px; }
.right { position: fixed; right: 16px; top: 16px; width: 270px; display: flex; flex-direction: column; gap: 10px; }
.head { padding: 12px 14px; }
.head h1 { margin: 0; font-size: 18px; font-weight: 700; }
.clock { margin-top: 4px; font-size: 15px; color: var(--mut); font-variant-numeric: tabular-nums; }
.speed { display: flex; gap: 6px; margin-top: 10px; }
.speed button, .views button { font: 600 14px Inter, system-ui, sans-serif; color: var(--blue); background: #fff; border: 2px solid var(--line); border-radius: 9px; padding: 6px 10px; cursor: pointer; }
.speed button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.chain { padding: 4px 14px 10px; }
.step { padding: 10px 0; border-top: 2px solid var(--line); }
.step:first-child { border-top: 0; }
.step .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.step .name { font-size: 16px; font-weight: 700; }
.step .big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.step .why { margin-top: 4px; font-size: 14px; line-height: 1.35; color: var(--mut); }
.step .book { margin-top: 3px; font-size: 13px; color: #64748b; }
.sw { flex: none; width: 54px; height: 30px; border-radius: 15px; border: 0; background: #cbd5e1; position: relative; cursor: pointer; transition: background .2s; }
.sw::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; transition: transform .2s; }
.sw.on { background: var(--blue); }
.sw.on::after { transform: translateX(24px); }
.kpis { padding: 6px 14px; }
.kpi { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 8px 0; border-top: 2px solid var(--line); }
.kpi:first-child { border-top: 0; }
.kpi span { font-size: 14px; color: var(--mut); }
.kpi b { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi b.bad { color: var(--bad); }
.kpi b.ok { color: var(--ok); }
.log { padding: 10px 14px; }
.log h2, .map h2 { margin: 0 0 6px; font-size: 14px; font-weight: 700; }
.log button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 4px 0; font: 14px/1.3 Inter, system-ui, sans-serif; color: var(--ink); cursor: pointer; }
.log button i { font-style: normal; color: var(--mut); font-variant-numeric: tabular-nums; margin-right: 6px; }
.log button.SHORT, .log button.STARVED, .log button.BEHIND, .log button.WAITING { color: var(--bad); }
.map { position: fixed; left: 342px; right: 302px; bottom: 16px; padding: 10px 14px 8px; }
.map svg { display: block; width: 100%; height: auto; }
.map text { font-family: Inter, system-ui, sans-serif; }
.map .box { cursor: pointer; }
.views { position: fixed; left: 342px; top: 16px; display: flex; gap: 6px; }
#load { position: fixed; inset: 0; display: grid; place-items: center; color: #9fb0c8; font-size: 16px; background: #131a27; transition: opacity .6s; }
@media (max-width: 1300px) and (min-width: 821px) { .left, .right, .map, .views { zoom: 0.78; } }
.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; font: 700 15px Inter, system-ui, sans-serif; color: var(--blue); background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.tabs button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
#pane-numbers, #pane-terms { display: flex; flex-direction: column; gap: 10px; }
#pane-numbers[hidden], #pane-terms[hidden] { display: none; }
.term { padding: 12px 14px; }
.term h2 { margin: 0; font-size: 17px; font-weight: 700; }
.term p { margin: 6px 0 0; font-size: 14px; line-height: 1.4; color: var(--ink); }
.term a { display: inline-block; margin-top: 8px; font-size: 14px; font-weight: 600; color: var(--blue); }
.term svg { display: block; width: 100%; height: auto; margin-top: 8px; }
.termlist { padding: 10px; display: flex; flex-wrap: wrap; gap: 6px; max-height: 42vh; overflow: auto; }
.termlist button { font: 600 14px Inter, system-ui, sans-serif; color: var(--blue); background: #fff; border: 2px solid var(--line); border-radius: 9px; padding: 6px 9px; cursor: pointer; }
.termlist button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.tag { position: fixed; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; pointer-events: none; font: 600 13px Inter, system-ui, sans-serif; padding: 2px 8px; border-radius: 9px; background: #fff; border: 2px solid #94a3b8; color: var(--ink); }
.tag.work { border-color: #16a34a; }
.tag.walk { border-color: #d97706; }
.tag.search { border-color: #dc2626; }
.tag.lead { border-color: #f97316; }
.map.hot { outline: 4px solid #f59e0b; }
.left, .right, .map, .views { z-index: 2; }
.map[hidden], .doc[hidden] { display: none; }
.views button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.doc { position: fixed; left: 342px; top: 64px; width: min(660px, calc(100vw - 342px - 302px)); max-height: calc(100vh - 96px); overflow: auto; padding: 10px 12px 12px; z-index: 3; }
.dochead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.doctabs { display: flex; gap: 6px; }
.doc button { font: 600 14px Inter, system-ui, sans-serif; color: var(--blue); background: #fff; border: 2px solid var(--line); border-radius: 9px; padding: 6px 10px; cursor: pointer; }
.doc button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.doc svg { display: block; width: 100%; height: auto; }
.tag.note { background: #0f172a; color: #fff; border-color: #0f172a; font-size: 14px; padding: 4px 10px; }
.tag.wait { border-color: #94a3b8; }
.link { display: block; margin-top: 6px; padding: 0; border: 0; background: none; font: 600 14px Inter, system-ui, sans-serif; color: var(--blue); cursor: pointer; text-align: left; }
.term .act { display: block; margin-top: 8px; font: 600 14px Inter, system-ui, sans-serif; color: #fff; background: var(--blue); border: 0; border-radius: 9px; padding: 8px 12px; cursor: pointer; }
.steps { margin: 8px 0 0; padding: 0; list-style: none; }
.steps li { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; padding: 4px 8px; border-left: 5px solid #16a34a; margin-bottom: 3px; }
.steps li.walk { border-left-color: #d97706; }
.steps li.search { border-left-color: #dc2626; }
.steps li.now { background: #eff6ff; font-weight: 700; }
body.docopen .left { display: none; }
body.docopen .doc { left: 16px; top: 16px; width: min(600px, 46vw); max-height: calc(100vh - 32px); }
body.docopen .views { left: calc(min(600px, 46vw) + 32px); }
canvas#c { transition: filter 0.6s; }
#flow { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 1; }
.flowline { fill: none; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 14 12; animation: flowdash 0.7s linear infinite; }
.flowline.solid { stroke-dasharray: none; animation: none; stroke-width: 6; opacity: 0.9; }
@keyframes flowdash { from { stroke-dashoffset: 26; } to { stroke-dashoffset: 0; } }
#tags { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.hj { width: 100%; margin-top: 8px; border-collapse: collapse; table-layout: fixed; }
.hj th { font-size: 13px; font-weight: 700; padding: 3px 2px; text-align: center; }
.hj tr th:first-child { text-align: left; width: 58px; }
.hj td { border: 2px solid var(--line); height: 26px; text-align: center; padding: 0; }
.hj td i { display: inline-block; width: 70%; height: 16px; border-radius: 3px; vertical-align: middle; }
.dot { position: fixed; left: 0; top: 0; width: 26px; height: 26px; margin: 13px 0 0 0; border-radius: 50%; background: #f97316; border: 4px solid #fff; box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.45); pointer-events: none; animation: dotpulse 1s ease-in-out infinite; }
@keyframes dotpulse { 50% { box-shadow: 0 0 0 12px rgba(249, 115, 22, 0.15); } }
.chip { position: fixed; left: 0; top: 0; width: 34px; height: 24px; border-radius: 4px; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.5); pointer-events: none; }
.hjpanel { position: fixed; left: 342px; right: 302px; bottom: 16px; padding: 12px 16px; z-index: 2; }
.hjpanel[hidden] { display: none; }
.hjpanel h2 { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.hjpanel p { margin: 0 0 6px; font-size: 14px; line-height: 1.35; }
.hjrow { display: flex; gap: 10px; margin-top: 8px; }
.hjrow em { flex: none; width: 28px; height: 28px; border-radius: 14px; background: var(--ink); color: #fff; font: 700 15px/28px Inter, system-ui, sans-serif; text-align: center; font-style: normal; }
.hjrow > div { flex: 1; min-width: 0; }
.strip { display: flex; gap: 4px; }
.slot { flex: 1; min-width: 0; text-align: center; }
.slot span { display: block; font-size: 13px; font-weight: 600; color: var(--mut); font-variant-numeric: tabular-nums; }
.slot i { display: block; height: 30px; border-radius: 5px; position: relative; overflow: hidden; }
.slot.now span { color: var(--ink); font-weight: 700; }
.slot.now i { outline: 3px solid var(--ink); outline-offset: 1px; }
.slot.now b { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.55); }
.lotrow { display: flex; gap: 4px; }
.lotrow u { flex: 1; height: 18px; border-radius: 3px; text-decoration: none; }
.goods span { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; font-weight: 700; }
.goods u { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.batch { display: flex; height: 28px; border-radius: 5px; overflow: hidden; }
.batch i { font: 700 13px/28px Inter, system-ui, sans-serif; color: #fff; text-align: center; font-style: normal; white-space: nowrap; overflow: hidden; }

.kcard { position: fixed; left: 0; top: 0; font: 700 13px Inter, system-ui, sans-serif; color: #fff; padding: 3px 8px; border-radius: 5px; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.5); pointer-events: auto; cursor: pointer; white-space: nowrap; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); }
.kcard.sel { outline: 4px solid #f97316; font-size: 15px; z-index: 2; }
.loops { display: grid; gap: 6px; margin-top: 10px; }
.loops button { text-align: left; font: 700 14px Inter, system-ui, sans-serif; color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: 9px; padding: 7px 10px; cursor: pointer; }
.loops button span { display: block; font-weight: 500; font-size: 13px; color: var(--mut); }
.loops button.on { border-color: var(--blue); background: #eff6ff; }
.kface { margin-top: 10px; border: 3px solid; border-radius: 8px; overflow: hidden; padding-bottom: 4px; }
.kface h3 { margin: 0 0 4px; padding: 6px 10px; color: #fff; font-size: 15px; }
.kface p { display: flex; justify-content: space-between; gap: 10px; margin: 0; padding: 3px 10px; font-size: 14px; }
.kface p span { color: var(--mut); }
.kface p b { text-align: right; }
.know { font-weight: 700; }

.loops.compact { grid-template-columns: 1fr 1fr; }
.loops.compact button span { display: none; }
.right { max-height: calc(100vh - 32px); }
#pane-terms { min-height: 0; }
#pane-terms { flex: 1 1 auto; }
#term { flex: 0 1 auto; overflow-y: auto; min-height: 140px; }
#termlist { flex: 0 1 auto; min-height: 110px; overflow-y: auto; }
.ksteps { display: flex; gap: 6px; }
.ksteps div { flex: 1; min-width: 0; font-size: 14px; line-height: 1.3; padding: 8px 10px; border-radius: 8px; background: #f1f5f9; color: var(--ink); }
.ksteps div em { display: block; font-style: normal; font-weight: 700; color: var(--mut); }
.ksteps div.now { background: var(--blue); color: #fff; font-weight: 700; }
.ksteps div.now em { color: #fff; }
.kface p { padding: 2px 10px; }

.views .hint { flex-basis: 100%; font: 500 13px Inter, system-ui, sans-serif; color: #fff; text-shadow: 0 1px 2px rgba(15, 23, 42, 0.8); margin-top: 2px; }
.views { flex-wrap: wrap; }

/* ---------- phone layout ---------- */
.tabs button[data-p="plant"], #sheetBtn { display: none; }
#pane-plant[hidden] { display: none; }
@media (hover: none) { .views .hint { display: none; } }
body.compact .left { left: 8px; right: 8px; top: 8px; width: auto; }
body.compact .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; }
body.compact .head h1 { display: none; }
body.compact .clock { margin: 0; font-size: 14px; }
body.compact .speed { margin: 0; gap: 4px; }
body.compact .speed button { padding: 5px 8px; }
body.compact .views { left: 8px; right: 8px; top: 60px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
body.compact .views button { flex: none; }
body.compact .views .hint { display: none; }
body.compact .right { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 46vh; background: #f1f5f9; border-radius: 16px 16px 0 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.3); gap: 8px; z-index: 3; }
body.compact .tabs button[data-p="plant"], body.compact #sheetBtn { display: block; }
body.compact .tabs button { padding: 8px 6px; }
body.compact #sheetBtn { flex: none; padding: 8px 12px; }
body.compact #pane-plant, body.compact #pane-numbers, body.compact #pane-terms { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
body.compact #pane-numbers > *, body.compact #pane-terms > * { flex: none; }
body.compact.sheetmin #pane-plant, body.compact.sheetmin #pane-numbers, body.compact.sheetmin #pane-terms { display: none; }
body.compact #term { overflow: visible; min-height: 0; }
body.compact #termlist { max-height: none; overflow: visible; min-height: 0; }
body.compact .hjpanel { position: static; padding: 10px 12px; }
body.compact .hjpanel h2 { font-size: 15px; }
body.compact .ksteps, body.compact .strip { overflow-x: auto; padding-bottom: 4px; }
body.compact .ksteps div { flex: 0 0 132px; }
body.compact .slot { flex: 0 0 50px; }
body.compact .map { position: static; flex: none; overflow-x: auto; padding: 8px 10px; }
body.compact .map svg { width: 720px; }
body.compact .doc { position: static; width: auto; max-height: none; overflow: auto; flex: 1 1 auto; min-height: 0; padding: 8px 10px; }
body.compact.docopen #pane-plant, body.compact.docopen #pane-numbers, body.compact.docopen #pane-terms, body.compact.docopen .map { display: none; }
body.compact.sheetmin .doc, body.compact.sheetmin .map { display: none; }
body.compact.docopen .right { max-height: 50vh; }
body.compact .doc svg { min-width: 560px; }
body.compact .tag.note { white-space: normal; max-width: 62vw; text-align: center; }

#load p { margin: 0 0 10px; text-align: center; }
#load .bar { width: 220px; height: 8px; border-radius: 4px; background: #2a3854; overflow: hidden; }
#load .bar i { display: block; height: 100%; width: var(--p, 4%); background: #60a5fa; transition: width 0.2s; }

/* ---------- panels hidden: only the floor and the view buttons ---------- */
body.bare .left, body.bare .right, body.bare .hjpanel { display: none; }
body.bare .views { left: 16px; }
body.compact.bare .views { left: 8px; top: 8px; }
