:root {
  --ink: #13232b; --muted: #5b6b73; --line: #e3e8ea; --bg: #f6f8f9; --accent: #0a7c86;
  --green: #1f9d55; --yellow: #e0a100; --red: #d64545; --closed: #6b4fa0; --unknown: #9aa5ab;
  --top: calc(56px + env(safe-area-inset-top));
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; }

.top { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); background: #fff; border-bottom: 1px solid var(--line); }
.title h1 { margin: 0; font-size: 18px; }
.status { font-size: 11px; color: var(--muted); max-width: 52vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; align-items: center; gap: 8px; }
.toggle { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.toggle button { border: 0; background: #fff; padding: 7px 14px; font-size: 14px; }
.toggle button.on { background: var(--accent); color: #fff; }
.refresh { border: 1px solid var(--line); background: #fff; border-radius: 999px; width: 36px; height: 36px; font-size: 18px; }
.refresh.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { position: fixed; top: var(--top); left: 0; right: 0; bottom: 0; }
#map { position: absolute; inset: 0; }
.list { position: absolute; inset: 0; z-index: 1001; background: var(--bg); overflow-y: auto; padding: 8px 10px 160px; -webkit-overflow-scrolling: touch; }
.row { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; width: 100%; text-align: left; }
.row .name { font-weight: 600; }
.row .sub { font-size: 12px; color: var(--muted); }
.row .grow { flex: 1; min-width: 0; }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dot.green { background: var(--green); } .dot.yellow { background: var(--yellow); } .dot.red { background: var(--red); }
.dot.closed { background: var(--closed); } .dot.unknown { background: var(--unknown); }
.legend { position: fixed; left: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 900; background: rgba(255,255,255,.95);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; font-size: 11px; display: flex; gap: 8px; flex-wrap: wrap; max-width: calc(100vw - 16px); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }

.pin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); }
.pin.far { outline: 2px dashed rgba(0,0,0,.45); outline-offset: 1px; }
.pin.green { background: var(--green); } .pin.yellow { background: var(--yellow); } .pin.red { background: var(--red); }
.pin.closed { background: var(--closed); } .pin.unknown { background: var(--unknown); }

.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100; background: #fff; border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,.18); max-height: 160px; overflow: hidden; transition: max-height .25s ease;
  padding: 0 14px calc(14px + env(safe-area-inset-bottom)); }
.sheet.open { max-height: 78vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.handle { display: block; width: 100%; border: 0; background: none; padding: 8px 0 4px; }
.handle span { display: block; width: 40px; height: 5px; border-radius: 3px; background: #cfd6d9; margin: 0 auto; }
.close { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 24px; color: var(--muted); padding: 4px 8px; }
.sheet h2 { margin: 0 0 2px; font-size: 18px; padding-right: 30px; }
.sheet .meta { font-size: 13px; color: var(--muted); }
.badge { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 6px; padding: 2px 6px; color: #fff; vertical-align: middle; }
.badge.green { background: var(--green); } .badge.yellow { background: var(--yellow); color: #3b2c00; } .badge.red { background: var(--red); }
.badge.closed { background: var(--closed); } .badge.unknown { background: var(--unknown); } .badge.far { background: #455a64; }
.next { margin: 8px 0; font-size: 14px; }
.sec { border-top: 1px solid var(--line); padding: 10px 0; }
.sec h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.windows { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; font-size: 13px; align-items: start; }
.windows .lbl { color: var(--muted); white-space: nowrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 14px; }
.kv dt { color: var(--muted); font-size: 12px; padding-top: 2px; }
.kv dd { margin: 0; }
.warn { color: #9a3d0a; }
.fail { color: var(--red); font-weight: 600; }
.small { font-size: 12px; color: var(--muted); }
.stamps { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; font-size: 13px; }
a { color: var(--accent); }
.leaflet-top.leaflet-left { top: 4px; }
