:root {
  --bg: #f4f3f1; --surface: #ffffff; --surface-2: #ecebe8; --text: #1b1b1b; --muted: #5b5b5b; --border: #cfccc6;
  --accent: #b71c1c; --accent-ink: #ffffff; --ok: #1b7f3b; --warn: #a65f00; --bad: #c62828; --info: #1f5fa8;
  --focus: #1f5fa8; --shadow: 0 2px 10px rgba(0,0,0,.12); --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414; --surface: #1f1f1f; --surface-2: #2a2a2a; --text: #f1f1f1; --muted: #b3b3b3; --border: #3b3b3b;
    --accent: #ef5350; --accent-ink: #1b0000; --ok: #4caf72; --warn: #f0a540; --bad: #ff6b6b; --info: #74a9ef; --focus: #74a9ef;
    --shadow: 0 2px 12px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141414; --surface: #1f1f1f; --surface-2: #2a2a2a; --text: #f1f1f1; --muted: #b3b3b3; --border: #3b3b3b;
  --accent: #ef5350; --accent-ink: #1b0000; --ok: #4caf72; --warn: #f0a540; --bad: #ff6b6b; --info: #74a9ef; --focus: #74a9ef;
  --shadow: 0 2px 12px rgba(0,0,0,.5); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 17px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--info); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 10px;
  border: 2px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); touch-action: manipulation; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { border-color: var(--bad); color: var(--bad); }
.btn.block { width: 100%; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: .9em; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.iconbtn { min-width: 48px; min-height: 48px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); cursor: pointer; font-size: 20px; box-shadow: var(--shadow); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .8em; font-weight: 600; background: var(--surface-2); }
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.pill.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.pill.info { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }

input[type=text], input[type=password], input[type=number], input[type=tel], input[type=date], input[type=time], input[type=url], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 2px solid var(--border); border-radius: 10px; background: var(--surface); }
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; font-weight: 600; margin-bottom: 4px; }

.seg { display: flex; border: 2px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; min-height: 50px; border: 0; background: var(--surface); cursor: pointer; font-weight: 600; padding: 6px 8px; border-left: 2px solid var(--border); }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--info); color: #fff; }
.seg button.okb[aria-pressed="true"] { background: var(--ok); }
.seg button.badb[aria-pressed="true"] { background: var(--bad); }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #222; color: #fff; padding: 12px 18px;
  border-radius: 10px; box-shadow: var(--shadow); z-index: 1000; max-width: min(92vw, 520px); font-weight: 600; }
.toast.toast-bad { background: var(--bad); color: #fff; }

/* Map */
.mm { position: relative; overflow: hidden; touch-action: none; background: #dfe3df; user-select: none; -webkit-user-select: none; }
:root[data-theme="dark"] .mm, .dark .mm { background: #2b302b; }
.mm-wrap, .mm-pane { position: absolute; inset: 0; }
.mm-tiles, .mm-markers { position: absolute; left: 0; top: 0; }
.mm-tile { position: absolute; left: 0; top: 0; width: 256px; height: 256px; image-rendering: auto; pointer-events: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mm-tile { filter: brightness(.75) contrast(1.1) saturate(.8); } }
.mm-svg { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.mm-marker { position: absolute; left: 0; top: 0; cursor: pointer; }
.mm-marker > * { transform: translate(-50%, -50%); }
.mm-zoom { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.mm-zoom button { width: 44px; height: 44px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); font-size: 22px; font-weight: 700; box-shadow: var(--shadow); cursor: pointer; }
.mm-attr { position: absolute; right: 0; bottom: 0; font-size: 11px; background: rgba(255,255,255,.8); color: #333; padding: 1px 6px; z-index: 5; pointer-events: none; }
.mm-box { position: absolute; border: 2px dashed var(--info); background: color-mix(in srgb, var(--info) 15%, transparent); z-index: 6; pointer-events: none; }
.mm-boxmode { cursor: crosshair; }
.mm-user { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 50; }
.mm-acc { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(31,95,168,.15); border: 1px solid rgba(31,95,168,.4); }
.mm-dot { position: absolute; width: 18px; height: 18px; transform: translate(-50%, -50%); border-radius: 50%; background: #1f6fd1; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.25); }
.mm-head { position: absolute; left: 50%; top: 50%; width: 0; height: 0; margin-left: -6px; margin-top: -24px; border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-bottom: 12px solid #1f6fd1; transform-origin: 6px 24px; }

/* Object markers */
.pin { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
  border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); position: relative; }
.pin.dim { opacity: .45; width: 22px; height: 22px; font-size: 11px; border-width: 2px; }
.pin.done::after { content: "✓"; }
.pin.mangel { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad), 0 1px 4px rgba(0,0,0,.45); }
.pin.mangel::after { content: "!"; }
.pin.nf::after { content: "?"; }
.pin.queued { border-style: dashed; }
.pin.near { outline: 3px solid #ffd400; outline-offset: 2px; }
.pin.sel { outline: 4px solid var(--focus); outline-offset: 3px; }
.pin.square { border-radius: 6px; }
.pin.diamond { border-radius: 4px; transform: rotate(45deg); }
.pin.diamond::after { transform: rotate(-45deg); }
.pin .by { position: absolute; right: -9px; bottom: -9px; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid #fff; }
.station { width: 34px; height: 34px; border-radius: 8px; background: #b71c1c; color: #fff; display: grid; place-items: center; font-size: 18px; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); }

.emblem { display: inline-grid; place-items: center; border-radius: 50%; flex: none; }
.emblem img { width: 72%; height: 72%; }

@media print { .noprint { display: none !important; } }
.mm[data-zl="s"] .pin { width: 14px; height: 14px; border-width: 2px; font-size: 0; }
.mm[data-zl="s"] .pin.dim { width: 10px; height: 10px; }
.mm[data-zl="s"] .pin .by { display: none; }
.mm[data-zl="m"] .pin { width: 22px; height: 22px; font-size: 11px; border-width: 2px; }
.mm[data-zl="m"] .pin.dim { width: 16px; height: 16px; font-size: 0; }
