:root {
  --bg: #000; --card: #1c1c1e; --card2: #2c2c2e; --text: #fff; --dim: #8e8e93;
  --green: #30d158; --red: #ff453a; --yellow: #ffd60a; --orange: #ff9f0a; --blue: #0a84ff; --cyan: #64d2ff;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
#app { height: 100dvh; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--card2); cursor: pointer; }
button:active { filter: brightness(1.25); }
.leaflet-control-attribution { font-size: 10px; background: rgba(0,0,0,.55) !important; color: #ddd !important; margin: 4px !important; border-radius: 6px; }
.leaflet-control-attribution a { color: #9cf !important; }
button.primary { background: var(--blue); font-weight: 700; }
button.good { background: var(--green); color: #000; font-weight: 700; }
button.danger { background: var(--red); font-weight: 700; }
button.dark-red { background: #8c0000; font-weight: 700; }
button.orange { background: var(--orange); color: #000; font-weight: 700; }
button[disabled] { opacity: .4; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card2); border: 0; border-radius: 10px; padding: 10px 12px; width: 100%; }
label.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
label.row input[type=checkbox] { width: 24px; height: 24px; }

header { display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-t) + 8px) 12px 8px; background: #0b0b0c; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--card); font-size: 13px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.dot.ok { background: var(--green); } .dot.wait { background: var(--yellow); }
.spacer { flex: 1; }
#clock { font: 700 14px ui-monospace, Menlo, monospace; }

main { position: relative; flex: 1; min-height: 0; }
.screen { position: absolute; inset: 0; display: none; overflow-y: auto; }
.screen.active { display: block; }
#screen-map { overflow: hidden; }
#map { position: absolute; inset: 0; background: #1a1a1a; }

nav { display: flex; background: #0b0b0c; padding-bottom: var(--safe-b); border-top: 1px solid #222; }
nav button { flex: 1; background: none; border-radius: 0; padding: 10px 4px 8px; font-size: 12px; color: var(--dim); position: relative; }
nav button.active { color: var(--blue); }
nav button b { display: block; font-size: 20px; margin-bottom: 2px; font-weight: 400; }
.badge { position: absolute; top: 4px; left: calc(50% + 8px); min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; }

.overlay-top { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 500; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.overlay-top > * { pointer-events: auto; }
.pill { padding: 8px 14px; border-radius: 999px; background: rgba(28,28,30,.92); font-weight: 600; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.pill.red { background: var(--red); } .pill.green { background: var(--green); color: #000; }
.pill button { padding: 4px 10px; font-size: 13px; }
.mapbtns { position: absolute; right: 8px; top: 56px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.mapbtns button { width: 44px; height: 44px; padding: 0; border-radius: 50%; background: rgba(28,28,30,.92); font-size: 20px; }
.bottombar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 500; padding: 10px 10px 10px; background: rgba(20,20,22,.92); backdrop-filter: blur(12px); }
.quick { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.quick button { border-radius: 999px; white-space: nowrap; padding: 9px 16px; }
.actions { display: flex; gap: 8px; }
.actions .hit { flex: 1; min-height: 50px; font-size: 17px; }
.actions button { min-height: 50px; }

.pin { width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid #fff; color: #fff; font-weight: 700; display: grid; place-items: center; box-shadow: 0 1px 4px #0008; }
.pin.out { border-color: var(--red); border-width: 4px; }
.pin.sq { border-radius: 9px; width: 32px; height: 32px; }
.pinwrap { display: flex; flex-direction: column; align-items: center; }
.pinlabel { margin-top: 2px; padding: 0 5px; border-radius: 8px; background: #000a; color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; }
.leaflet-container { font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--text); }
.leaflet-popup-content { margin: 12px; min-width: 180px; }
.popup h4 { margin: 0 0 8px; } .popup .col { display: flex; flex-direction: column; gap: 8px; }

.pad { padding: 12px 12px 24px; }
.tiles { display: flex; gap: 8px; margin-bottom: 12px; }
.tile { flex: 1; text-align: center; background: var(--card); border-radius: 12px; padding: 10px 4px; }
.tile b { display: block; font-size: 26px; } .tile span { font-size: 12px; color: var(--dim); }
.card { background: var(--card); border-radius: 14px; padding: 4px 14px; margin-bottom: 14px; }
.card h3 { margin: 12px 0 4px; font-size: 13px; text-transform: uppercase; color: var(--dim); font-weight: 600; letter-spacing: .03em; }
.card p.note { color: var(--dim); font-size: 13px; margin: 6px 0 10px; }
.member { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #2c2c2e; cursor: pointer; }
.member:last-child { border-bottom: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex: none; }
.member .info { flex: 1; min-width: 0; } .member .name { font-weight: 700; }
.member .sub { font-size: 13px; color: var(--cyan); display: flex; gap: 10px; flex-wrap: wrap; }
.member .st { text-align: right; font-weight: 700; font-size: 14px; } .member .ago { font-size: 12px; color: var(--dim); font-weight: 400; }
.arrow { display: inline-block; }

#chatlist { padding: 12px; display: flex; flex-direction: column; gap: 8px; padding-bottom: 150px; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 16px; background: var(--card2); align-self: flex-start; word-break: break-word; }
.bubble.me { background: var(--blue); align-self: flex-end; }
.bubble small { display: block; color: var(--dim); font-weight: 700; font-size: 12px; } .bubble.me small { display: none; }
.sys { text-align: center; color: var(--dim); font-size: 12px; }
.cmd { align-self: flex-start; background: var(--orange); color: #000; font-weight: 800; padding: 5px 12px; border-radius: 999px; font-size: 14px; }
.cmd.help { background: var(--red); color: #fff; } .cmd.me { align-self: flex-end; }
.chatbar { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px; background: rgba(20,20,22,.95); }
.chatbar form { display: flex; gap: 8px; margin-top: 6px; }

.sheet-bg { position: fixed; inset: 0; background: #0009; z-index: 2000; display: flex; align-items: flex-end; }
.sheet { width: 100%; background: var(--card); border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; max-height: 85dvh; overflow-y: auto; }
.sheet h3 { margin: 0 0 4px; text-align: center; font-size: 15px; color: var(--dim); }
.sheet button { text-align: left; }
.hint { color: var(--dim); font-size: 13px; padding: 4px 14px 16px; }
.center { max-width: 440px; margin: 0 auto; padding: calc(var(--safe-t) + 40px) 20px 30px; display: flex; flex-direction: column; gap: 14px; }
.center h1 { margin: 0; font-size: 30px; }
.banner { position: fixed; left: 8px; right: 8px; top: calc(var(--safe-t) + 8px); z-index: 3000; padding: 12px 14px; border-radius: 14px; background: var(--card2); font-weight: 700; box-shadow: 0 4px 18px #000a; }
.banner.danger { background: var(--red); }
