/* Layout: header bar, left work panel (search, towns, shared list), map on the right; stacked on phones */
:root {
  --navy: #14365A; --navy-2: #1f4a75; --orange: #F28C28; --orange-ink: #9a4d05;
  --bg: #f3f5f8; --panel: #ffffff; --line: #d9e0e8; --ink: #15212e; --muted: #5b6b7c;
  --ok: #1f7a4a; --ok-bg: #e3f4ea; --warn-bg: #fff1e2; --bad: #a3302a; --bad-bg: #fbe7e5;
  --chip: #e9eef4;
  --f-display: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1620; --panel: #152230; --line: #2a3a4c; --ink: #e6edf4; --muted: #9aabbd;
    --ok: #7fd4a4; --ok-bg: #173527; --warn-bg: #3a2a17; --bad: #f2a29c; --bad-bg: #3d1e1c; --chip: #1f3044;
    --orange-ink: #f6b06a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1620; --panel: #152230; --line: #2a3a4c; --ink: #e6edf4; --muted: #9aabbd;
  --ok: #7fd4a4; --ok-bg: #173527; --warn-bg: #3a2a17; --bad: #f2a29c; --bad-bg: #3d1e1c; --chip: #1f3044;
  --orange-ink: #f6b06a; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--f-body); }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; margin: 0; text-wrap: balance; }
h2 { font-size: 17px; letter-spacing: .02em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.top { display: flex; align-items: center; gap: 12px; background: var(--navy); color: #fff;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); }
.top img { width: 34px; height: 34px; }
.top h1 { font-size: 22px; letter-spacing: .01em; }
.top h1 span { color: var(--orange); }
.top .sub { font-size: 13px; opacity: .75; }
.top .me { margin-left: auto; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.top select { background: var(--navy-2); border: 1px solid #ffffff33; border-radius: 6px; padding: 4px 6px; color: #fff; }
.top .link { background: none; border: 0; color: #fff; opacity: .8; cursor: pointer; text-decoration: underline; }

body:has(> .app) { display: flex; flex-direction: column; }
.app { display: grid; grid-template-columns: minmax(360px, 440px) 1fr; flex: 1; min-height: 0; }
.panel { overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel); }
.sec { padding: 14px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
#map { min-height: 300px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field { display: grid; gap: 3px; font-size: 13px; color: var(--muted); }
.field > input, .field > select, .field > textarea { color: var(--ink); }
input[type=text], input[type=number], input[type=date], input[type=url], input[type=password], select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; min-width: 0; width: 100%; }
textarea { min-height: 60px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 8px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #1b1004; font-weight: 600; }
.btn.primary:hover { filter: brightness(.95); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn:disabled { opacity: .5; cursor: default; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; }
.checks label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.hint { font-size: 13px; color: var(--muted); }
.err { font-size: 13px; color: var(--bad); }

.inputwrap { position: relative; display: flex; gap: 6px; }
.sugg { position: absolute; top: 100%; left: 0; right: 0; z-index: 1000; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; margin-top: 4px; box-shadow: 0 8px 24px #0002; max-height: 280px; overflow-y: auto; }
.sugg button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.sugg button:hover, .sugg button:focus { background: var(--chip); }
.sugg small { color: var(--muted); display: block; }

.pts { display: grid; gap: 6px; }
.pt { display: flex; gap: 8px; align-items: center; background: var(--chip); border-radius: 8px; padding: 6px 8px; font-size: 14px; }
.pt b { font-family: var(--f-display); background: var(--navy); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; font-size: 13px; flex: none; }
.pt span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pt button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }

.range { display: flex; gap: 10px; align-items: center; }
.range input { flex: 1; accent-color: var(--orange); }
.range output { font-family: var(--f-display); font-size: 20px; font-weight: 600; min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }

.zonecard { background: var(--warn-bg); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; }
.towns { display: grid; }
.town { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.town.hl { background: var(--warn-bg); }
.town .nm { font-weight: 600; min-width: 0; }
.town .nm small { font-weight: 400; color: var(--muted); }
.town .mins { font-family: var(--f-display); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--orange-ink); text-align: right; }
.town .links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.plat { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: 13px; background: var(--panel); }
.plat:hover { border-color: var(--muted); }
.plat i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.stays { display: grid; gap: 8px; }
.stay { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; }
.stay .h { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.stay .h a { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.stay .meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.stay .note { font-size: 14px; white-space: pre-wrap; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.pill.rasta { background: var(--chip); color: var(--ink); }
.pill.rezervuota { background: var(--ok-bg); color: var(--ok); }
.pill.atmesta { background: var(--bad-bg); color: var(--bad); }
.stay .acts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.stay .acts select { width: auto; padding: 3px 6px; font-size: 13px; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--panel); color: var(--ink); }
dialog::backdrop { background: #0008; }
dialog form { padding: 16px; display: grid; gap: 10px; }
.leaflet-container { font: inherit; }
.mk { background: var(--navy); color: #fff; border: 2px solid #fff; border-radius: 50%; display: grid; place-items: center; font: 600 13px var(--f-display); box-shadow: 0 1px 4px #0006; }

@media (max-width: 820px) {
  body:has(> .app) { display: block; height: auto; }
  .app { display: flex; flex-direction: column-reverse; }
  #map { height: 46vh; position: sticky; top: 0; z-index: 1; }
  .panel { border-right: 0; overflow: visible; }
  .top .sub { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
.workers { display: flex; flex-wrap: wrap; gap: 6px; }
.wchip { display: inline-flex; align-items: center; gap: 4px; background: var(--chip); color: var(--ink); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 14px; }
.wchip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 4px; }
.stay .who { font-size: 14px; }
.stay .who b { font-weight: 600; }
.pill.baigta { background: var(--chip); color: var(--muted); }
.usedbox { background: var(--ok-bg); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; margin-bottom: 8px; }
.usedbox h3 { font-size: 15px; }
.used { display: grid; font-size: 14px; }
.used a { font-weight: 600; overflow-wrap: anywhere; }
.bedpin { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; display: grid; place-items: center; box-shadow: 0 1px 4px #0006; }
.apt { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.apt.hl { background: var(--warn-bg); }
.apt img { width: 110px; height: 82px; object-fit: cover; border-radius: 8px; display: block; background: var(--chip); }
.apt-b { display: grid; gap: 4px; min-width: 0; }
.apt-h { display: flex; gap: 8px; justify-content: space-between; align-items: baseline; }
.apt-h a { font-weight: 600; overflow-wrap: anywhere; }
.apt-h .mins { font-family: var(--f-display); font-weight: 600; color: var(--orange-ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.apt-t { font-size: 13px; }
a.btn { text-decoration: none; display: inline-block; }
@media (max-width: 420px) { .apt { grid-template-columns: 84px 1fr; } .apt img { width: 84px; height: 64px; } }
.srcdot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.warnt { color: var(--orange-ink); }
.leaflet-control-layers { font-size: 13px; border-radius: 8px; }
.leaflet-control-layers-expanded { padding: 4px 8px; }
.leaflet-control-layers-base label { margin: 2px 0; }
.usedtag { font-size: 13px; color: #1f7a4a; font-weight: 600; }
.banner { background: #a3302a; color: #fff; padding: 8px 16px; font-size: 14px; font-weight: 600; }
