:root {
  --bg: #f4f6f5; --panel: #ffffff; --ink: #18211d; --muted: #5b6a63; --line: #dbe2de;
  --brand: #0b6e4f; --brand-ink: #ffffff; --danger: #b3261e; --warn-bg: #fdecea; --soft: #eaf3ef;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111715; --panel: #1a2320; --ink: #e6eeea; --muted: #9db0a7; --line: #2c3a35; --brand: #3fb68b; --brand-ink: #06231a; --danger: #ff8a80; --warn-bg: #3a1f1d; --soft: #20302a; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
code { background: var(--soft); padding: 1px 4px; border-radius: 4px; font-size: 12px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1000; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); align-self: center; }
.tag { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; }
.layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; padding: 16px 20px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 10px; }
details { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; }
details[open] { padding-bottom: 14px; }
summary { cursor: pointer; font-weight: 600; padding: 11px 0; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.grid2 .field { margin-bottom: 0; }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
input[type=text], input[type=number], input[type=time], select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; }
textarea { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; white-space: pre; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, .btn:focus-within, .pin:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
button, .btn { font: inherit; border-radius: 7px; border: 1px solid var(--line); padding: 6px 12px; cursor: pointer; background: var(--panel); color: var(--ink); display: inline-block; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.wide { width: 100%; padding: 9px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.ghost:hover:not(:disabled) { background: var(--soft); }
.pill { background: var(--soft); border-radius: 99px; padding: 1px 8px; font-size: 12px; font-weight: 500; margin-left: 6px; }
.errors { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; color: var(--danger); }
.errors li { background: var(--warn-bg); border-radius: 6px; padding: 3px 8px; margin-top: 4px; }
.progress { height: 6px; background: var(--soft); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; width: 0; background: var(--brand); transition: width 0.2s; }
.status { margin: 8px 0 0; color: var(--muted); font-size: 13px; min-height: 1.4em; }
.status.bad { color: var(--danger); }
.main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.kpi .v { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi.bad .v { color: var(--danger); }
.map { height: 420px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--soft); position: relative; z-index: 0; }
.svgmap { width: 100%; height: 100%; display: block; }
.svgmap .grid { stroke: var(--line); stroke-width: 1; }
.svgmap .pin { cursor: pointer; }
.svgmap .pin text, .svgmap .depot text { fill: #fff; font-size: 11px; font-weight: 700; pointer-events: none; }
.svgmap .pin.sel circle { stroke: var(--ink); stroke-width: 3; }
.svgmap .depot rect { fill: #18211d; }
.svgmap .note { fill: var(--muted); font-size: 11px; }
.lpin { width: 26px; height: 26px; border-radius: 50%; color: #fff; font: 700 12px/26px system-ui; text-align: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); }
.lpin.sel { outline: 3px solid #18211d; }
.depotpin { background: #18211d; border-radius: 6px; }
.routes { display: grid; grid-template-columns: repeat(auto-fit, minmax(640px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; border-top: 4px solid var(--c); }
.card.drop { outline: 2px dashed var(--c); outline-offset: -4px; }
.card header { padding: 10px 14px 6px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.card h3 { margin: 0; font-size: 15px; }
.card .meta { color: var(--muted); font-size: 12px; padding: 0 14px 8px; }
.bar { height: 6px; background: var(--soft); border-radius: 4px; margin: 0 14px 8px; overflow: hidden; }
.bar > div { height: 100%; background: var(--c); }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 5px 8px; text-align: left; border-top: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.stop { cursor: grab; }
tr.stop.over td { border-top: 2px solid var(--c); }
tr.stop.sel { background: var(--soft); }
tr.depotrow td { color: var(--muted); }
.seq { display: inline-block; min-width: 22px; text-align: center; border-radius: 99px; color: #fff; background: var(--c); font-size: 12px; font-weight: 700; padding: 0 4px; }
.late { color: var(--danger); font-weight: 600; }
.lockbtn { padding: 0 6px; font-size: 12px; border-radius: 5px; }
.lockbtn.on { background: var(--c); color: #fff; border-color: var(--c); }
.links { display: flex; gap: 6px; flex-wrap: wrap; }
.links a { font-size: 12px; color: var(--brand); }
.empty { padding: 14px; color: var(--muted); }
#print-sheets { display: none; }
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px; }
  .routes { grid-template-columns: 1fr; }
  .tag { display: none; }
  .map { height: 320px; }
}
@media print {
  body > *:not(#print-sheets) { display: none !important; }
  #print-sheets { display: block; color: #000; background: #fff; }
  #print-sheets .sheet { page-break-after: always; }
  #print-sheets table { font-size: 12px; }
  #print-sheets th, #print-sheets td { border: 1px solid #999; }
  #print-sheets .sig { width: 120px; }
}
