:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #18212d; --muted: #5d6b7c; --line: #dde3ea;
  --accent: #1f5fbf; --accent-ink: #fff; --soft: #eef3fb;
  --ok: #1d8a4e; --warn: #b26a00; --bad: #c0352b; --off: #7a8594; --plan: #5b5fc7;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.4; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, monospace; }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  background: #142235; color: #fff; padding: 0 16px; min-height: 52px; flex-wrap: wrap; }
.brand { font-weight: 700; display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.logo { background: #f5b301; color: #142235; border-radius: 6px; padding: 2px 6px; }
#nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; }
#nav a { color: #c9d4e3; padding: 15px 10px; white-space: nowrap; border-bottom: 3px solid transparent; }
#nav a.on { color: #fff; border-bottom-color: #f5b301; }
.savestate { font-size: 12px; color: #9fb0c6; white-space: nowrap; }
.savestate.err { color: #ffb4a8; font-weight: 600; }

main { max-width: 1280px; margin: 0 auto; padding: 18px 16px 60px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.click { cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.card.click:hover { border-color: #b8c7da; box-shadow: 0 2px 10px rgba(20,34,53,.08); }
.section { margin-top: 18px; }
.stat { font-size: 26px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 7px 12px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #9fb0c6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--soft); }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.st-Planned { background: #ecebfb; color: var(--plan); }
.st-Staged { background: #e8f1fd; color: #2a62b0; }
.st-Installed { background: #e3f4ea; color: var(--ok); }
.st-Active { background: #d5f0df; color: #116b38; }
.st-Offline { background: #eceff3; color: #56606d; }
.st-Needs.Repair, .st-NeedsRepair { background: #fde7e4; color: var(--bad); }
.st-Spare { background: #fff4dc; color: var(--warn); }
.st-Removed, .st-Stored { background: #f0f0f0; color: #777; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.pt { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.pt-Light { background: #fff3c4; color: #7a5a00; }
.pt-Inflatable { background: #dff0ff; color: #0f5b99; }
.pt-AlwaysOn { background: #e9e3ff; color: #5a3fb3; }
.boxtag { display: inline-block; padding: 0 6px; border-radius: 5px; font-size: 11px; font-weight: 700; color: #fff; white-space: nowrap; }

table.t { width: 100%; border-collapse: collapse; background: #fff; }
table.t th, table.t td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f8fafc; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f6f9fd; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #c9d2dd; border-radius: 7px; background: #fff; color: var(--ink); width: 100%; }
textarea { min-height: 60px; resize: vertical; }
select.inline { width: auto; padding: 2px 6px; font-size: 12px; }
input[type=checkbox] { width: auto; }
.f { display: flex; flex-direction: column; gap: 3px; }
.f > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.f.check { flex-direction: row; align-items: center; gap: 8px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 12px; }
.fgrid .wide { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: 9px; margin: 12px 0 0; padding: 10px 12px 12px; }
legend { font-weight: 700; font-size: 13px; padding: 0 6px; }
.filters { display: grid; grid-template-columns: 2fr repeat(6, 1fr); gap: 8px; margin-bottom: 12px; }
@media (max-width: 800px) { .filters { grid-template-columns: 1fr 1fr; } }

.modal { position: fixed; inset: 0; background: rgba(13,22,35,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; }
.modal .box { background: #fff; border-radius: 12px; width: 100%; max-width: 860px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .mhead { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal .mbody { padding: 14px 18px; }
.modal .mfoot { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #142235; color: #fff; padding: 9px 16px; border-radius: 8px; z-index: 60; }

/* box detail */
.feed { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.feed:last-child { border-bottom: 0; }
.chain { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; color: var(--muted); }
.chain .lnk { background: #f1f4f8; border-radius: 5px; padding: 1px 6px; color: var(--ink); }
.chain .arrow { color: #a3afbd; }
.ctl { border: 1px solid var(--line); border-radius: 10px; margin-top: 12px; overflow: hidden; background: #fff; }
.ctl-head { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ctl-head b { font-size: 15px; }
.ports { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.port { padding: 10px 12px; border-right: 1px solid var(--line); border-top: 1px solid var(--line); min-height: 70px; }
.port-name { font-weight: 700; font-size: 12px; display: flex; justify-content: space-between; gap: 6px; }
.port-name .sub { color: var(--muted); font-weight: 500; }
.plug { display: flex; gap: 6px; align-items: center; padding: 4px 0; font-size: 13px; cursor: pointer; }
.plug:hover { color: var(--accent); }
.empty { color: #a3afbd; font-size: 12px; font-style: italic; }
.warn-list li { margin: 4px 0; }
.bar { height: 8px; background: #e7ecf2; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.bar > i.hi { background: var(--warn); }
.bar > i.over { background: var(--bad); }

/* diagrams */
.diagram { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; padding: 10px; }
.diagram svg { display: block; max-width: none; }
.diagram.fit svg { max-width: 100%; height: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.trace-step { display: flex; gap: 10px; align-items: flex-start; }
.trace-step .rail { display: flex; flex-direction: column; align-items: center; width: 18px; }
.trace-step .rail i { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); margin-top: 4px; }
.trace-step .rail s { flex: 1; width: 2px; background: #c8d3e0; min-height: 26px; text-decoration: none; }
.trace-step .via { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }

/* print */
.print-only { display: none; }
.ppage { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.ppage h1 { font-size: 20px; }
.ppage table.t th { position: static; }
.ppage table.t td, .ppage table.t th { padding: 4px 6px; font-size: 11.5px; }
.labels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.label { border: 1px dashed #889; border-radius: 6px; padding: 8px; font-size: 11px; break-inside: avoid; }
.label b { font-size: 15px; display: block; }
.lidcard { border: 2px solid #142235; border-radius: 10px; padding: 14px; }
.lidcard .big { font-size: 40px; font-weight: 800; letter-spacing: .02em; }

@media print {
  @page { size: letter; margin: 0.45in; }
  body { background: #fff; font-size: 11.5px; }
  .noprint, .top, .modal, .toast { display: none !important; }
  .print-only { display: block; }
  main { max-width: none; padding: 0; }
  .card, .ppage, .diagram, .tablewrap { border: 0; padding: 0; box-shadow: none; }
  .ppage { margin: 0; break-after: page; }
  .ppage:last-child { break-after: auto; }
  .diagram { overflow: visible; }
  .diagram svg { max-width: 100%; height: auto; }
  table.t th { position: static; }
  tr, .ctl, .label { break-inside: avoid; }
  .pill, .pt, .boxtag, .bar > i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (max-width: 640px) {
  main { padding: 12px 10px 60px; }
  .feed { grid-template-columns: 1fr; }
  .labels { grid-template-columns: 1fr 1fr; }
  table.t th { top: 0; }
}

[hidden] { display: none !important; }

/* ---------- phone / iPhone ---------- */
.nav-ic, .nav-short { display: none; }
.devcards { display: none; }
.devcard { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.devcard b { font-size: 15px; }
.top { padding-top: env(safe-area-inset-top); }
@media (max-width: 700px) {
  body { font-size: 15px; -webkit-text-size-adjust: 100%; }
  .top { min-height: 46px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .brand { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  #projName { overflow: hidden; text-overflow: ellipsis; }
  #nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #142235; justify-content: space-around; gap: 0;
    padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid #2a3b52; overflow-x: auto; }
  #nav a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 4px 6px; min-width: 52px; flex: 1;
    border-bottom: 0; border-top: 3px solid transparent; font-size: 10.5px; }
  #nav a.on { border-top-color: #f5b301; border-bottom: 0; }
  .nav-ic { display: block; font-size: 19px; line-height: 1.1; }
  .nav-short { display: block; }
  .nav-long { display: none; }
  main { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }
  h1 { font-size: 20px; }
  .pagehead > .row, .pagehead > div:last-child { width: 100%; }
  .pagehead .btn { flex: 1 1 auto; justify-content: center; }
  .btn { padding: 10px 14px; min-height: 42px; }
  .btn.sm { padding: 6px 10px; min-height: 32px; font-size: 13px; }
  input, select, textarea { font-size: 16px; padding: 10px; }   /* stops iPhone auto-zoom */
  select.inline { font-size: 16px; padding: 5px 8px; }
  .devcards { display: block; }
  .devcards + .tablewrap { display: none; }
  .grid.g2, .grid.g3 { grid-template-columns: 1fr; }
  .grid.g4 { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  .ports { grid-template-columns: 1fr 1fr; }
  .port { min-height: 0; }
  .plug { padding: 7px 0; }
  .port .small a, .feed .small a { display: inline-block; padding: 6px 0; }
  .modal { padding: 0; }
  .modal .box { border-radius: 0; min-height: 100%; max-width: none !important; display: flex; flex-direction: column; }
  .modal form { display: flex; flex-direction: column; min-height: 100vh; }
  .modal .mhead { position: sticky; top: 0; background: #fff; z-index: 2; padding-top: calc(12px + env(safe-area-inset-top)); }
  .modal .mbody { flex: 1; }
  .modal .mfoot { position: sticky; bottom: 0; background: #fff; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .fgrid { grid-template-columns: 1fr; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .savestate { font-size: 11px; }
  .tabs a { padding: 8px 9px; }
  .diagram { padding: 6px; }
  .ctl-head { padding: 8px 10px; }
}
@media (max-width: 380px) { .ports { grid-template-columns: 1fr; } }

.fgrid > .locf { display: contents; }
.fgrid > .locf[hidden] { display: none !important; }
.ctlchip { display: inline-block; background: #e9e3ff; color: #3f2a8f; border-radius: 6px; padding: 1px 7px; font-weight: 600; }
.ctlchip.up { background: #f1eefc; color: #6a5aa8; font-weight: 500; }
.arrow { color: #a3afbd; }
@media print { .ctlchip { background: none; padding: 0; } }

/* photos */
.thumb { object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #eef1f5; cursor: zoom-in; vertical-align: middle; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 30px; }
.pwrap { position: relative; display: inline-block; }
.pdel { position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; font-size: 16px; line-height: 22px; cursor: pointer; padding: 0; }
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.88); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #ccd; padding: 16px; }
.lightbox img { max-width: 100%; max-height: calc(100% - 40px); border-radius: 8px; }
.demobar { background: #f5b301; color: #142235; text-align: center; padding: 6px 12px; font-weight: 700; font-size: 13px; }
.demobar a { color: #142235; text-decoration: underline; margin-left: 8px; }

/* yard map */
.mapgrid { display: grid; grid-template-columns: 1fr 230px; gap: 12px; align-items: start; }
.mapgrid:has(> .mapscroll:only-child) { grid-template-columns: 1fr; }
.mapscroll { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; max-height: calc(100vh - 190px); }
.mapwrap { position: relative; min-width: 100%; user-select: none; -webkit-user-select: none; }
.mapwrap > img { display: block; width: 100%; height: auto; pointer-events: none; }
.maplines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.maplines line { pointer-events: stroke; }
.mk { position: absolute; transform: translate(-50%, -50%); cursor: pointer; touch-action: none; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.25); z-index: 2; }
.mapwrap.editing .mk { cursor: grab; outline: 2px dashed rgba(31,95,191,.5); outline-offset: 2px; }
.mk-box { color: #fff; font-weight: 800; font-size: 13px; padding: 4px 8px; border-radius: 7px; border: 2px solid #fff; }
.mk-outlet { background: #fff8e1; border: 2px solid #e0b100; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 700; }
.mk-outlet span { margin-left: 4px; }
.mk-dev { background: #fff; border: 2px solid #999; border-radius: 999px; padding: 2px 8px 2px 4px; font-size: 11px; display: flex; align-items: center; gap: 4px; z-index: 1; }
.mk-dev i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.mk-out { opacity: .35; }
.maptray { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; max-height: calc(100vh - 190px); overflow: auto; }
.trayitem { padding: 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: grab; touch-action: none; background: #fafbfc; font-size: 13px; }
.mkghost { position: fixed; transform: translate(-50%, -50%); z-index: 90; background: var(--accent); color: #fff; padding: 4px 10px; border-radius: 7px; pointer-events: none; font-weight: 700; font-size: 13px; }
.lg { display: inline-block; width: 18px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
@media (max-width: 700px) {
  .mapgrid { grid-template-columns: 1fr; }
  .maptray { order: -1; max-height: 170px; display: flex; flex-wrap: wrap; gap: 6px; }
  .maptray h3 { width: 100%; margin: 0; }
  .trayitem { margin: 0; }
  .mapscroll { max-height: calc(100vh - 260px); }
}
@media print { .mapscroll { max-height: none; overflow: visible; border: 0; } .mk { box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* map zones */
.mz { position: absolute; border: 2px dashed; border-radius: 10px; pointer-events: none; z-index: 0; }
.mz-circle { border-radius: 50%; }
.mapwrap.editing .mz { pointer-events: auto; cursor: move; touch-action: none; }
.maplines { z-index: 1; }
.mz-label { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.mz-circle .mz-label { top: 50%; transform: translate(-50%, -50%); }
.mz-handle { position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); cursor: nwse-resize; }
.mz-circle .mz-handle { right: 12%; bottom: 12%; }
@media print { .mz, .mz-label { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
@media print { .mz-handle { display: none; } }

/* sign-in & accounts */
body.signedout { background: linear-gradient(180deg, #142235 0, #1f3a5f 42vh, #f4f6f9 42vh); min-height: 100vh; }
.logincard { max-width: 400px; margin: 9vh auto 0; padding: 26px 24px; box-shadow: 0 20px 50px rgba(0,0,0,.18); }
.loginlogo { width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 14px; background: #f5b301; color: #142235; font-size: 30px; display: flex; align-items: center; justify-content: center; }
.loginerr { background: #fde7e4; color: var(--bad); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; font-size: 13px; }
.userbtn { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.userbtn:hover { background: rgba(255,255,255,.18); }
.userbtn i { font-style: normal; font-size: 11px; color: #f5b301; }
body.viewonly [data-act="new-dev"], body.viewonly [data-act="new-box"], body.viewonly [data-act="new-outlet"], body.viewonly [data-act="new-type"],
body.viewonly [data-act="connect"], body.viewonly [data-act^="del-"], body.viewonly [data-act="edit-type"], body.viewonly [data-act="dup-dev"], body.viewonly [data-act="map-edit"], body.viewonly [data-act="reset"],
body.viewonly label:has(> [data-act="import-file"]), body.viewonly label:has(> [data-map-upload]), body.viewonly label:has(> [data-act="restore"]) { display: none !important; }
@media (max-width: 700px) { .userbtn span { display: none; } }

/* inventory */
.invcards { display: none; }
@media (max-width: 700px) { .invcards { display: block; } .invtable { display: none; } }
body.viewonly [data-act="inv-new"], body.viewonly [data-act="inv-use"], body.viewonly [data-act="inv-build"] { display: none !important; }

/* zone handles: rectangles/circles get 8, free shapes get corner dots + "add corner" pluses */
.mz-handle { display: none; }
.mz-h { position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); z-index: 3; touch-action: none; }
.mz-h-n, .mz-h-s { left: 50%; transform: translateX(-50%); cursor: ns-resize; } .mz-h-n { top: -9px; } .mz-h-s { bottom: -9px; }
.mz-h-e, .mz-h-w { top: 50%; transform: translateY(-50%); cursor: ew-resize; } .mz-h-e { right: -9px; } .mz-h-w { left: -9px; }
.mz-h-ne { top: -9px; right: -9px; cursor: nesw-resize; } .mz-h-sw { bottom: -9px; left: -9px; cursor: nesw-resize; }
.mz-h-nw { top: -9px; left: -9px; cursor: nwse-resize; } .mz-h-se { bottom: -9px; right: -9px; cursor: nwse-resize; }
.mz-circle .mz-h-ne { top: 12%; right: 12%; } .mz-circle .mz-h-nw { top: 12%; left: 12%; } .mz-circle .mz-h-se { bottom: 12%; right: 12%; } .mz-circle .mz-h-sw { bottom: 12%; left: 12%; }
.mzpoly { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.mapwrap.editing .mzpoly polygon { pointer-events: visiblePainted; cursor: move; touch-action: none; }
.mz-plabel { transform: translate(-50%, -50%); pointer-events: none; z-index: 1; }
.mapwrap.editing .mz-plabel { pointer-events: auto; cursor: pointer; touch-action: none; }
.mz-v, .mz-m { position: absolute; transform: translate(-50%, -50%); z-index: 3; touch-action: none; }
.mz-v { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid; cursor: grab; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.mz-m { width: 18px; height: 18px; border-radius: 50%; color: #fff; font: 700 14px/18px sans-serif; text-align: center; opacity: .75; cursor: copy; }
.mz-m:hover { opacity: 1; }
@media (max-width: 700px) { .mz-h, .mz-v { width: 22px; height: 22px; } .mz-m { width: 22px; height: 22px; line-height: 22px; } }
@media print { .mz-h, .mz-v, .mz-m { display: none; } .mzpoly polygon { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* ---------- iPad / tablet ---------- */
@media (min-width: 701px) and (max-width: 1180px) {
  .top { flex-wrap: wrap; row-gap: 0; padding-top: max(6px, env(safe-area-inset-top)); }
  .brand { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  #nav { order: 3; flex-basis: 100%; justify-content: space-between; gap: 0; border-top: 1px solid #2a3b52; }
  #nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px 7px; flex: 1; font-size: 12px; border-bottom-width: 3px; }
  .nav-ic { display: block; font-size: 19px; line-height: 1.1; }
  .nav-short { display: block; }
  .nav-long { display: none; }
}
@media (min-width: 701px) and (max-width: 1024px) {
  .devcards, .invcards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .devcards .devcard, .invcards .devcard { margin: 0; }
  .devcards + .tablewrap, .invtable { display: none; }
  .filters { grid-template-columns: repeat(3, 1fr); }
  .filters input { grid-column: 1 / -1; }
}
/* any touch screen (phone or iPad): finger-sized controls, no zoom-on-focus */
@media (pointer: coarse) {
  input, select, textarea, select.inline { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn.sm { min-height: 34px; }
  .mz-h, .mz-v { width: 24px; height: 24px; }
  .mz-m { width: 24px; height: 24px; line-height: 24px; }
  .mz-h-n { top: -12px; } .mz-h-s { bottom: -12px; } .mz-h-e { right: -12px; } .mz-h-w { left: -12px; }
  .mz-h-ne, .mz-h-nw { top: -12px; } .mz-h-se, .mz-h-sw { bottom: -12px; } .mz-h-ne, .mz-h-se { right: -12px; } .mz-h-nw, .mz-h-sw { left: -12px; }
}
/* wide phones / unfolded foldables: two card columns */
@media (min-width: 560px) and (max-width: 700px) {
  .devcards, .invcards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .devcards .devcard, .invcards .devcard { margin: 0; }
  .grid.g3 { grid-template-columns: 1fr 1fr; }
}
/* phones: all 9 tabs fit in the bottom bar */
@media (max-width: 700px) {
  #nav { overflow-x: hidden; }
  #nav a { min-width: 0; padding: 6px 0 5px; font-size: 10px; letter-spacing: -.01em; }
  .nav-ic { font-size: 18px; }
}

/* version + update bar */
.appver { font-size: 11px; color: #8ea2bb; background: rgba(255,255,255,.08); border-radius: 999px; padding: 1px 7px; white-space: nowrap; }
.updatebar { position: sticky; top: 0; z-index: 40; background: #1d8a4e; color: #fff; text-align: center; padding: 7px 12px; font-weight: 600; font-size: 14px; }
.updatebar button { margin-left: 10px; background: #fff; color: #1d8a4e; border: 0; border-radius: 999px; padding: 4px 12px; font: inherit; font-weight: 700; cursor: pointer; }

/* map marker sizes (Small is the default) + a bigger invisible touch area */
.mk { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.mk::before { content: ''; position: absolute; inset: -10px; }
.mapwrap.canmove .mk { cursor: grab; }
.mapwrap.canmove .mk:active { cursor: grabbing; }
.mk-size-s .mk-box { font-size: 9px; padding: 1px 4px; border-width: 1px; border-radius: 4px; }
.mk-size-s .mk-outlet { font-size: 8.5px; padding: 0 5px; border-width: 1px; }
.mk-size-s .mk-dev { font-size: 8px; padding: 0 5px 0 3px; border-width: 1px; gap: 3px; }
.mk-size-s .mk-dev i { width: 6px; height: 6px; }
.mk-size-s .mk { box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.mk-size-m .mk-box { font-size: 11px; padding: 2px 6px; border-radius: 6px; }
.mk-size-m .mk-outlet { font-size: 10.5px; padding: 2px 7px; }
.mk-size-m .mk-dev { font-size: 10px; padding: 1px 7px 1px 4px; }
.mk-size-m .mk-dev i { width: 8px; height: 8px; }

/* poles */
.poletag { display: inline-block; background: #6d4c41; color: #fff; font-weight: 800; font-size: 11px; padding: 0 7px; border-radius: 999px; line-height: 18px; }
.mk-pole { background: #6d4c41; color: #fff; font-weight: 800; border: 2px solid #fff; border-radius: 999px; font-size: 11px; min-width: 26px; height: 26px; padding: 0 5px; display: flex; align-items: center; justify-content: center; }
.mk-pole sup { font-size: 8px; margin-left: 1px; color: #ffd28a; }
.mk-size-s .mk-pole { font-size: 8.5px; min-width: 18px; height: 18px; border-width: 1px; padding: 0 3px; }
.mk-size-m .mk-pole { font-size: 10px; min-width: 22px; height: 22px; }
.poletaglabel { text-align: center; border-style: solid; }
/* poles are always perfect circles; the "items attached" count is a badge on the edge */
.mk-pole { width: 28px; height: 28px; min-width: 0; padding: 0; border-radius: 50%; overflow: visible; letter-spacing: -.02em; }
.mk-pole sup { position: absolute; top: -5px; right: -7px; margin: 0; background: #f5b301; color: #142235; border-radius: 999px; font-size: 8px; line-height: 12px; min-width: 12px; padding: 0 2px; text-align: center; }
.mk-size-s .mk-pole { width: 20px; height: 20px; font-size: 8px; padding: 0; }
.mk-size-s .mk-pole sup { font-size: 7px; line-height: 10px; min-width: 10px; top: -4px; right: -6px; }
.mk-size-m .mk-pole { width: 24px; height: 24px; font-size: 9.5px; padding: 0; }
.poletag { border-radius: 50%; min-width: 26px; height: 26px; line-height: 26px; padding: 0 2px; text-align: center; font-size: 10.5px; }
