/* DripDash control room: the map is the screen, the rest floats on it like it's underwater glass. */
html, body { height: 100%; overflow: hidden; }

/* --- map ---------------------------------------------------------------------------- */
#map { position: fixed; inset: 0; background: var(--bg); }
/* the vector basemap (basemap.js) is drawn in the DripDash palette; only the fallback raster tiles need darkening */
body.raster-dark .leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) saturate(0.6) brightness(0.72) contrast(0.95); }
.leaflet-container { background: var(--map-bg); font: inherit; }
/* the dark vignette only suits a dark map */
body:not(.map-dark) .tint { display: none; }
.tint { position: fixed; inset: 0; pointer-events: none; z-index: 401;
  background: radial-gradient(120% 90% at 60% 40%, transparent 50%, var(--scrim)); }
.leaflet-control-attribution { background: var(--glass-strong) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar a { background: var(--glass); color: var(--text); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--surface-raised); color: var(--aqua); }
.leaflet-tooltip.tip { background: var(--surface-solid); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 28px rgb(var(--shade) / 0.5); padding: 7px 10px; font-size: 13.5px; }
.leaflet-tooltip.tip::before { display: none; }

/* a leak: a droplet pin in its severity colour */
.leak-pin { position: relative; width: 30px; height: 40px; color: var(--c); }
.leak-pin .lvl { font: 800 12px/1 system-ui, sans-serif; fill: var(--pin-ring); }
.leak-pin svg { position: absolute; inset: 0; filter: drop-shadow(0 0 6px var(--c)) drop-shadow(0 3px 4px rgb(var(--shade) / 0.6)); }
.leak-pin svg { transform-origin: 50% 100%; } /* a new pin lands like a drop, on anime.js (control.js) */
.pin-ripple { position: absolute; left: 50%; bottom: -4px; width: 30px; height: 10px; margin-left: -15px; border-radius: 50%;
  border: 2px solid var(--c); pointer-events: none; opacity: 0; }
.leak-pin.waiting::after, .leak-pin.sev4::after { content: ""; position: absolute; left: 50%; bottom: -2px; width: 34px; height: 12px;
  margin-left: -17px; border-radius: 50%; border: 2px solid var(--c); animation: puddle 2s ease-out infinite; }
@keyframes puddle { from { transform: scale(0.3); opacity: 1; } to { transform: scale(1.8); opacity: 0; } }
.leak-pin.done { opacity: 0.45; filter: grayscale(0.6); }
.leak-pin.on { z-index: 2; } .leak-pin.on svg { transform: scale(1.25); transform-origin: 50% 100%; }

/* a technician: a round badge with initials; a moving vehicle shows its heading */
/* busy: ringed in the colour of the leak they're heading to. free: quiet and hollow. off shift: dashed */
.tech-pin { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: var(--tech-bg); border: 2.5px solid var(--ring, var(--tech)); color: var(--text); font-size: 12.5px; font-weight: 700;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ring, var(--tech)) 22%, transparent), 0 4px 10px rgb(var(--shade) / 0.5); transition: transform 0.2s; }
.tech-pin.free { background: var(--surface-raised); border-color: var(--faint); color: var(--muted); box-shadow: 0 4px 10px rgb(var(--shade) / 0.5); }
.tech-pin.off { background: var(--surface-raised); border: 2px dashed var(--faint); color: var(--muted); box-shadow: none; }
.tech-pin.live::before { content: ""; position: absolute; right: -2px; top: -2px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--good); border: 2px solid var(--pin-ring); }
.tech-pin .nose { position: absolute; inset: -9px; transform: rotate(var(--h, 0deg)); pointer-events: none; opacity: 0;
  transition: transform 0.9s ease, opacity 0.3s; } /* turns smoothly, the short way round (control.js) */
.tech-pin.moving .nose { opacity: 1; }
.tech-pin .nose::before { content: ""; position: absolute; left: 50%; top: 0; margin-left: -5px;
  border: 5px solid transparent; border-bottom: 7px solid var(--ring, var(--tech)); border-top: 0; }
.tech-pin.bounce { animation: hop 0.5s ease 3; }
/* driving (or at a job): the van is drawn in 3D underneath (crew3d.js); the badge shrinks to an initials tag over it */
.tech-pin.in-van { position: absolute; left: 50%; top: 50%; width: auto; height: auto; padding: 0 6px; border-width: 1.5px; border-radius: 99px;
  font-size: 10px; line-height: 15px; transform: translate(-50%, -205%); box-shadow: 0 2px 6px rgb(var(--shade) / 0.5); white-space: nowrap; }
.tech-pin.in-van .nose { display: none; }
.tech-pin.in-van.live::before { right: -4px; top: -4px; width: 8px; height: 8px; }
.tech-pin.in-van.bounce { animation: none; }
.tech-pin.parked { opacity: 0; pointer-events: none; }
@keyframes hop { 40% { transform: translateY(-9px); } }
.eta-tag { background: var(--glass-strong); border: 1px solid var(--line); color: var(--foam); border-radius: 99px;
  padding: 1px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; box-shadow: none; }
.eta-tag::before { display: none; }
body.far .eta-tag { display: none; }

/* the crew's way to the leak: water flowing along the road. Without the road server, a fainter dotted estimate */
.flow { stroke-linecap: round; stroke-linejoin: round; animation: flow 0.9s linear infinite; filter: drop-shadow(0 0 3px currentColor); }
.flow.road { stroke-dasharray: 14 6; }
.flow.estimate { stroke-dasharray: 2 10; filter: none; }
@keyframes flow { to { stroke-dashoffset: -20; } }
.trail { filter: drop-shadow(0 0 2px currentColor); }

/* the ping: a drop falls, splashes, and ripples out */
.splash { position: relative; width: 0; height: 0; pointer-events: none; }
/* the drop's shadow grows and sharpens as it falls */
.splash .shadow { position: absolute; left: -14px; top: -4px; width: 28px; height: 8px; border-radius: 50%; background: rgb(var(--shade) / 0.5);
  filter: blur(3px); transform: scale(0.2); opacity: 0; animation: shadow 0.5s cubic-bezier(.55, 0, 1, .45) forwards; }
@keyframes shadow { to { transform: scale(1); opacity: 1; } 99% { opacity: 1; } }
.splash .drop { position: absolute; left: -16px; top: -150px; width: 32px; height: 44px;
  background: linear-gradient(#e0f7ff, var(--c)); clip-path: path("M16 0C16 0 0 19 0 28a16 16 0 0 0 32 0C32 19 16 0 16 0Z");
  animation: dropfall 0.5s cubic-bezier(.55, 0, 1, .45) forwards; transform-origin: 50% 100%; }
/* accelerates down, squashes flat on impact, and is gone */
@keyframes dropfall { 85% { transform: translateY(118px) scale(0.95, 1.08); opacity: 1; }
  100% { transform: translateY(124px) scale(1.7, 0.25); opacity: 0; } }
.splash .ring { position: absolute; left: -120px; top: -40px; width: 240px; height: 80px; border-radius: 50%;
  border: 3px solid var(--c); opacity: 0; animation: ring 1.8s cubic-bezier(.15, .7, .3, 1) forwards; animation-delay: var(--d); }
@keyframes ring { 0% { transform: scale(0.05); opacity: 1; border-width: 5px; } 100% { transform: scale(1); opacity: 0; border-width: 1px; } }
/* droplets: up and out to a peak (slowing), then down past the start (speeding up): an arc under gravity */
.splash .bit { position: absolute; left: -3px; top: -5px; width: 7px; height: 9px; opacity: 0; background: linear-gradient(#e0f7ff, var(--c));
  clip-path: path("M3.5 0C3.5 0 0 4.4 0 6.1A3.5 3.4 0 0 0 7 6.1C7 4.4 3.5 0 3.5 0Z"); scale: var(--s);
  animation: bit-x 0.9s linear 0.48s forwards, bit-y 0.9s 0.48s forwards; }
@keyframes bit-x { 0% { opacity: 1; translate: 0 0; } 100% { opacity: 0; translate: var(--x) 0; } }
@keyframes bit-y { 0% { transform: translateY(0); animation-timing-function: cubic-bezier(.2, .6, .4, 1); }
  45% { transform: translateY(var(--up)); animation-timing-function: cubic-bezier(.6, 0, .8, .4); } 100% { transform: translateY(var(--down)); } }
.splash .label { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); white-space: nowrap; opacity: 0;
  font-weight: 800; font-size: 15px; letter-spacing: 1.2px; color: var(--c); text-shadow: 0 0 12px var(--c), 0 2px 4px #000;
  animation: label 2.6s ease 0.6s forwards; }
@keyframes label { 0% { opacity: 0; transform: translate(-50%, 8px); } 15%, 75% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.splash .label.spelled { opacity: 1; animation: none; } /* spelled out letter by letter by anime.js (control.js) */

/* a route draws itself in on assignment (control.js), then flows */
.flow.drawing { animation: none; filter: drop-shadow(0 0 6px currentColor); }

/* a fixed leak drains: the drop sinks into the ground, a tick rises, sparkles */
.drained { position: relative; width: 0; height: 0; pointer-events: none; }
.drained .sink { position: absolute; left: -15px; top: -40px; width: 30px; height: 40px; background: var(--c);
  clip-path: path("M15 1C15 1 1 17 1 26a14 14 0 0 0 28 0C29 17 15 1 15 1z"); transform-origin: 50% 100%;
  animation: sink 0.6s cubic-bezier(.6, 0, .9, .5) forwards; }
@keyframes sink { to { transform: scale(1.4, 0); opacity: 0.4; } }
.drained .tick { position: absolute; left: -13px; top: -34px; width: 26px; height: 26px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 18px var(--good); opacity: 0; transform: scale(0.3);
  animation: tick 1.6s cubic-bezier(.3, 1.6, .5, 1) 0.45s forwards; }
.drained .tick::after { content: ""; position: absolute; left: 8px; top: 5px; width: 6px; height: 11px; border: solid var(--ink);
  border-width: 0 3px 3px 0; transform: rotate(45deg); }
@keyframes tick { 20% { opacity: 1; transform: scale(1); } 75% { opacity: 1; transform: scale(1) translateY(-6px); } 100% { opacity: 0; transform: scale(0.9) translateY(-14px); } }
.drained .spark { position: absolute; left: -2px; top: -23px; width: 4px; height: 4px; border-radius: 50%; background: #e0f7ff; opacity: 0;
  animation: spark 0.8s ease-out 0.55s forwards; }
@keyframes spark { 0% { opacity: 1; transform: rotate(var(--a)) translateY(0); } 100% { opacity: 0; transform: rotate(var(--a)) translateY(-26px); } }

/* --- top bar ----------------------------------------------------------------------------- */
.topbar { position: fixed; top: 14px; left: 14px; right: 14px; height: 58px; border-radius: var(--radius); z-index: 1000;
  display: flex; align-items: center; gap: 12px; padding: 0 12px 0 16px; }
.spacer { flex: 1; }
.pills { display: flex; gap: 6px; overflow: hidden; min-width: 0; flex-wrap: wrap; height: 29px; }
.pill { font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px;
  display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--sev-medium); }
.pill.on i { background: var(--good); box-shadow: 0 0 6px var(--good); }
.demo { display: flex; align-items: center; gap: 10px; padding-right: 10px; border-right: 1px solid var(--line); }
.btn.icon { padding: 7px; display: grid; place-items: center; }
#phonesBtn { display: inline-flex; align-items: center; gap: 6px; }
#phonesBtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.btn.icon svg { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.icon .on { display: none; }
.btn.icon[aria-pressed="true"] svg { stroke: var(--aqua); }
.btn.icon[aria-pressed="true"] .on { display: block; } .btn.icon[aria-pressed="true"] .off { display: none; }

.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--muted); white-space: nowrap; }
.switch input { display: none; }
.switch i { width: 36px; height: 20px; border-radius: 99px; background: var(--track); position: relative; transition: background 0.15s; flex-shrink: 0; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--knob); transition: transform 0.15s; }
.switch input:checked + i { background: var(--aqua); }
.switch input:checked + i::after { transform: translateX(16px); background: var(--ink); }
.switch input:checked ~ span { color: var(--text); }

/* --- side panel -------------------------------------------------------------------------- */
.panel { position: fixed; top: 86px; left: 14px; bottom: 14px; width: 392px; border-radius: var(--radius); z-index: 900;
  display: flex; flex-direction: column; padding: 14px 14px 0; overflow: hidden; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 8px 9px; background: rgb(var(--tint) / 0.05); transition: border-color 0.3s, background 0.3s; }
.stat.flash { animation: stat-flash 1.1s ease; }
@keyframes stat-flash { 0%, 30% { background: rgb(var(--primary2-rgb) / 0.22); border-color: rgb(var(--primary2-rgb) / 0.7); transform: scale(1.04); } }
.stat .v { font-size: 24px; font-weight: 800; line-height: 1.1; letter-spacing: -0.5px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat.hot .v { color: var(--sev-critical); } .stat.wait .v { color: var(--sev-medium); } .stat.good .v { color: var(--good); }
.stat.hot { border-color: color-mix(in srgb, var(--sev-critical) 45%, transparent); background: color-mix(in srgb, var(--sev-critical) 10%, transparent); }
.stat.zero .v { color: var(--faint); } /* nothing to look at: no alarm colour */
.tabs { display: flex; gap: 4px; margin-top: 12px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; color: var(--muted); padding: 8px 10px; font-size: 14.5px; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-color: var(--primary); }
.tab-body { flex: 1; overflow-y: auto; padding: 10px 2px 78px; scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
.waves-slot { position: absolute; left: 0; right: 0; bottom: 0; height: 64px; pointer-events: none; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.waves-slot::before { content: ""; position: absolute; inset: -24px 0 0; background: linear-gradient(transparent, var(--glass-strong) 45%); }
.waves-slot .tide { position: absolute; left: 0; bottom: 0; }

.filter { display: inline-flex; background: rgb(var(--tint) / 0.07); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 8px; }
.filter button { border: 0; background: none; color: var(--muted); padding: 4px 12px; border-radius: 7px; font-size: 13.5px; }
.filter button.on { background: rgb(var(--primary-rgb) / 0.18); color: var(--text); }

.leak { display: grid; grid-template-columns: 54px 1fr; gap: 10px; padding: 9px; border-radius: 12px; cursor: pointer;
  border-left: 3px solid var(--c); margin-bottom: 6px; background: rgb(var(--tint) / 0.035); transition: background 0.15s; }
.leak:hover, .leak.on { background: rgb(var(--tint) / 0.1); }
.leak:focus-visible, .tech:focus-visible, .btn:focus-visible, .tabs button:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }
.leak.fresh { animation: fresh 1.8s ease; }
@keyframes fresh { 0%, 40% { background: color-mix(in srgb, var(--c) 30%, transparent); } }
.leak img, .leak .noimg { width: 54px; height: 54px; border-radius: 9px; object-fit: cover; background: var(--surface-raised); }
.leak .l1 { display: flex; align-items: center; gap: 7px; }
.leak .code { font-weight: 650; font-size: 14px; }
.leak .age { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.leak .l2 { color: var(--muted); font-size: 13px; margin-top: 3px; line-height: 1.35; }
.leak .l2 b { color: var(--text); font-weight: 550; }
.leak.closed { opacity: 0.55; }

.tech { display: grid; grid-template-columns: 34px 1fr; gap: 4px 10px; align-items: center; padding: 9px 8px; border-radius: 12px; cursor: pointer; }
.tech > .acts { grid-column: 2; }
.tech:hover { background: rgb(var(--tint) / 0.08); }
.tech .tech-pin { width: 32px; height: 32px; font-size: 12px; }
.tech .sub { color: var(--muted); font-size: 13px; }
.tech .sub b { color: var(--foam); font-weight: 600; }
.tech .acts { display: flex; gap: 4px; align-items: center; }
.tech .acts button { border: 1px solid var(--line); background: none; border-radius: 8px; padding: 3px 8px; font-size: 12.5px; color: var(--muted); }
.tech .acts button:hover { color: var(--text); border-color: var(--aqua); }

.vehicle { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 9px 8px; border-bottom: 1px solid rgb(var(--tint) / 0.08); }
.vehicle .id { font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; }
.vehicle small { color: var(--muted); font-size: 12.5px; }
.vehicle select, .detail select { font: inherit; font-size: 13.5px; color: var(--text); background: var(--surface-solid); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; }
.how { margin-top: 14px; font-size: 13.5px; color: var(--muted); }
.how summary { cursor: pointer; color: var(--aqua); }
.how code, .how pre { display: block; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; color: var(--foam);
  font-size: 12.5px; word-break: break-all; white-space: pre-wrap; margin: 4px 0; }

.add { display: flex; gap: 6px; margin-top: 12px; }
.add input { flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--surface-solid); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.btn.ghost { width: 100%; margin-top: 10px; color: var(--muted); }
.hint, .note { color: var(--muted); font-size: 13.5px; margin: 8px 2px; }
.empty-list { text-align: center; color: var(--muted); padding: 26px 8px; font-size: 14px; }
.empty-list svg { width: 54px; height: 54px; display: block; margin: 0 auto 8px; opacity: 0.85; }

/* --- leak detail -------------------------------------------------------------------------- */
.detail { position: fixed; top: 86px; right: 14px; width: 360px; max-height: calc(100vh - 100px); overflow-y: auto; border-radius: var(--radius);
  z-index: 950; scrollbar-width: thin; animation: slide 0.25s ease; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.detail img { width: 100%; max-height: 260px; object-fit: cover; display: block; cursor: zoom-in; }
.detail .body { padding: 12px 14px 16px; }
.detail h3 { margin: 0; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.detail .x { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--field); font-size: 20px; }
.detail .status { margin-top: 6px; color: var(--aqua); font-weight: 600; }
.detail .kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgb(var(--tint) / 0.08); font-size: 14px; }
.detail .kv span:first-child { color: var(--muted); }
.detail .kv span:last-child { text-align: right; }
.detail h4 { margin: 14px 0 6px; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.detail .crew-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px; }
.detail .crew-row small { color: var(--muted); }
.detail .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.detail .acts .btn { font-size: 13.5px; padding: 7px 10px; }
.detail .log { font-size: 13px; color: var(--muted); }
.detail .log div { padding: 3px 0; }
.detail .send-row { display: flex; gap: 6px; margin-top: 6px; } .detail .send-row select { flex: 1; min-width: 0; }

/* --- legend, banner, toast, phones dialog --------------------------------------------------- */
.legend { position: fixed; right: 58px; bottom: 26px; border-radius: 12px; padding: 9px 12px; font-size: 13px; color: var(--muted); z-index: 800;
  display: flex; gap: 12px; align-items: center; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 12px; background: var(--c); clip-path: path("M4.5 0C4.5 0 0 5.6 0 7.8a4.5 4.4 0 0 0 9 0C9 5.6 4.5 0 4.5 0Z"); }
.banner { position: fixed; top: 86px; left: 50%; transform: translateX(-50%); z-index: 1100; min-width: 320px; max-width: min(520px, calc(100vw - 32px));
  overflow: hidden; cursor: pointer;
  border-radius: 16px; padding: 12px 16px 12px 14px; display: flex; gap: 12px; align-items: center;
  background: linear-gradient(110deg, color-mix(in srgb, var(--c) 28%, var(--surface-solid)), var(--surface-solid) 70%); border: 1px solid var(--c);
  box-shadow: 0 0 30px color-mix(in srgb, var(--c) 40%, transparent), 0 18px 50px rgb(var(--shade) / 0.6);
  transform-origin: 50% 0; } /* drops in on an anime.js spring (control.js) */
.banner img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; }
/* how long until it goes; resting the pointer on it pauses this */
.banner .countdown { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, 0.08); }
.banner .countdown i { display: block; height: 100%; background: var(--c); transform-origin: left; animation: countdown 7s linear forwards; }
.banner.held .countdown i { animation-play-state: paused; }
@keyframes countdown { to { transform: scaleX(0); } }
.banner b { font-size: 16px; } .banner small { display: block; color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--surface-solid); border: 1px solid var(--line);
  border-radius: 99px; padding: 10px 18px; z-index: 2000; box-shadow: 0 12px 40px rgb(var(--shade) / 0.6); }

.phones { border-radius: 20px; color: var(--text); padding: 22px 24px; max-width: 560px; width: calc(100% - 32px); }
.phones::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
.phones h2 { margin: 0 0 4px; }
.phones .close { position: absolute; right: 12px; top: 10px; border: 0; background: none; font-size: 26px; color: var(--muted); }
.qrs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.qrs figure { margin: 0; text-align: center; }
.qr { background: #fff; border-radius: 14px; padding: 10px; display: inline-block; line-height: 0; }
.qr img { width: 180px; height: 180px; image-rendering: pixelated; }
.qrs figcaption b { display: block; margin-top: 8px; } .qrs figcaption span { display: block; font-size: 12.5px; color: var(--muted); word-break: break-all; }
.secure-warn { color: var(--sev-medium); }

@media (max-width: 860px) {
  .topbar { height: auto; min-height: 58px; flex-wrap: wrap; padding: 8px 10px; }
  .pills, .demo .switch span, .legend { display: none; }
  .panel { width: auto; right: 14px; top: auto; height: 44vh; }
  .detail { left: 14px; right: 14px; width: auto; top: 86px; max-height: 50vh; }
  .qrs { grid-template-columns: 1fr; }
}

.qrs.one { grid-template-columns: 1fr; }
.big-code { font-family: ui-monospace, Menlo, monospace; font-size: 26px; letter-spacing: 3px; color: var(--foam); }
/* signed out: the map stays behind frosted glass */
.gate { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 16px;
  background: var(--scrim); backdrop-filter: blur(10px); }
.gate form { width: 100%; max-width: 360px; border-radius: 20px; padding: 24px; display: grid; gap: 10px; }
.gate h2 { margin: 6px 0 0; }
.gate input { font: inherit; color: var(--text); background: var(--surface-solid); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
.gate .error { color: var(--error); margin: 0; }

/* --- top bar: page tabs and the Display menu ------------------------------------------------- */
.topbar .btn { white-space: nowrap; }
.topbar > * { flex-shrink: 0; }
.topbar > .pills { flex-shrink: 1; }
@media (max-width: 1180px) { .topbar .pills { display: none; } .demo .switch span { display: none; } }
@media (max-width: 980px) { #phonesBtn { font-size: 0; gap: 0; } #phonesBtn svg { width: 20px; height: 20px; } }
.nav { display: flex; gap: 2px; background: rgb(var(--tint) / 0.06); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; white-space: nowrap; }
.nav a:hover { color: var(--text); }
.nav a.on { background: rgb(var(--primary-rgb) / 0.16); color: var(--text); box-shadow: inset 0 0 0 1px rgb(var(--primary-rgb) / 0.4); }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: 48px; min-width: 300px; padding: 12px; border-radius: 14px; display: none; z-index: 1200; }
.menu.open .menu-list { display: block; }
.menu-list h4 { margin: 2px 2px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; }
.menu-list h4 + * { margin-bottom: 14px; }
.seg { display: flex; background: rgb(var(--tint) / 0.07); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); padding: 6px 8px; border-radius: 7px; font-size: 13.5px; font-weight: 600; }
.seg button.on { background: rgb(var(--primary-rgb) / 0.18); color: var(--text); }

/* --- leak list: search, waiting clocks ------------------------------------------------------- */
.list-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.list-tools .filter { margin: 0; }
.list-tools input { flex: 1; min-width: 0; font: inherit; font-size: 13.5px; color: var(--text); background: var(--field);
  border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; }
.list-tools input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.clock { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.clock small { color: var(--faint); }
.clock.close { color: var(--sev-medium); }
.clock.late { color: var(--sev-critical); font-weight: 700; }
.warn { color: var(--sev-high); }

/* --- leak detail: the crew's report --------------------------------------------------------- */
.before-after { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.before-after a { position: relative; display: block; border-radius: 10px; overflow: hidden; }
.before-after img { width: 100%; height: 110px; object-fit: cover; display: block; cursor: zoom-in; }
.before-after a span { position: absolute; left: 6px; bottom: 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  background: var(--glass-strong); color: var(--text); padding: 2px 7px; border-radius: 6px; }
.before-after .nophoto { display: grid; place-items: center; height: 110px; border-radius: 10px; border: 1.5px dashed var(--line); color: var(--faint); font-size: 13px; }
.crew-notes { margin: 8px 0 0; padding: 8px 10px; border-left: 3px solid var(--tech); background: rgb(var(--tint) / 0.05); border-radius: 0 8px 8px 0; font-size: 14px; }

/* --- registering a technician ------------------------------------------------------------- */
.btn.wide { width: 100%; margin-bottom: 10px; }
.register form { display: grid; gap: 10px; margin-top: 12px; }
.register .field { display: grid; gap: 4px; font-size: 13.5px; color: var(--muted); }
.register .field em { font-style: normal; color: var(--faint); }
.register .field input { font: inherit; font-size: 15px; color: var(--text); background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.register .field input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.register .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.base-row { display: flex; gap: 8px; align-items: center; }
.base-row output { flex: 1; font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.register .error { color: var(--error); margin: 0; }

/* embedded (the Phone Lab): the control room alone, tighter */
body.embed #nav, body.embed #phonesBtn, body.embed #signOut, body.embed .pills { display: none; }
body.embed .topbar { top: 8px; left: 8px; right: 8px; }
body.embed .panel { top: 76px; left: 8px; bottom: 8px; right: auto; width: min(320px, 46vw); height: auto; }
body.embed .detail { top: 76px; right: 8px; left: auto; width: min(320px, 46vw); max-height: calc(100vh - 88px); }
body.embed .topbar { height: 56px; min-height: 0; flex-wrap: nowrap; }
body.embed .legend { display: none; }

/* --- the crew at work: a little worker by a leak while they're on site ------------------------------------ */
.work { position: relative; width: 0; height: 0; pointer-events: none; }
body.far .work { transform: scale(0.8); }
.worker { position: absolute; left: -44px; bottom: -3px; width: 40px; height: 40px; overflow: visible;
  filter: drop-shadow(0 2px 2px rgb(var(--shade) / 0.45)); }
.worker.flip { left: 4px; transform: scaleX(-1); }
.worker * { transform-box: view-box; }
.worker path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.worker .ol { stroke: #0b1620; }
.worker .shadow { fill: rgb(var(--shade) / 0.35); }
.worker .pipe rect { fill: #7f8c98; stroke: #0b1620; stroke-width: 1; }
.worker .pipe .joint { fill: #a4b0bb; }
.worker .boot { fill: #4a3424; stroke: #0b1620; stroke-width: 1; }
.worker .vest { fill: #ff7a1a; stroke: #0b1620; stroke-width: 1.1; }
.worker .stripe { stroke: #eef4f7; stroke-width: 1.3; stroke-linecap: butt; }
.worker .skin { fill: #b97a50; stroke: #0b1620; stroke-width: 1; }
.worker .eye { fill: #0b1620; }
.worker .hat { fill: #ffcc33; stroke: #0b1620; stroke-width: 1.1; }
.worker .tool { fill: #c5d0d8; stroke: #0b1620; stroke-width: 1; }
.worker .jaw { stroke: #0b1620; stroke-width: 1.6; }
.worker .spritz { fill: var(--c); opacity: 0; }
.worker .star { fill: #ffe066; stroke: #0b1620; stroke-width: 0.5; opacity: 0; }

/* working: leaning in, cranking the wrench on the joint, drips spritzing out */
.worker .torso { transform-origin: 17px 27px; transform: rotate(10deg); transition: transform 0.3s var(--spring); }
.worker .arm { transform-origin: 20px 16px; }
.worker .arm2 { transform-origin: 13.6px 16.4px; transition: transform 0.4s var(--spring); }
.work:not(.cheer):not(.leave) .torso { animation: work-lean 0.62s ease-in-out infinite alternate; }
.work:not(.cheer):not(.leave) .arm { animation: work-crank 0.62s ease-in-out infinite alternate; }
.work:not(.cheer):not(.leave) .spritz { animation: spritz 0.9s ease-out infinite; animation-delay: var(--d, 0s); }
.worker.flip .torso, .worker.flip .arm, .worker.flip .spritz { animation-delay: 0.31s !important; }
@keyframes work-lean { from { transform: rotate(7deg); } to { transform: rotate(14deg); } }
@keyframes work-crank { from { transform: rotate(-32deg); } to { transform: rotate(5deg); } }
@keyframes spritz { 0% { opacity: 0.95; transform: none; } 100% { opacity: 0; transform: translate(var(--x), var(--y)); } }
/* turning up: dropped in with a little squash */
.work.arrive .all { animation: work-arrive 0.55s var(--spring) backwards; animation-delay: var(--d, 0s); transform-origin: 20px 38px; }
@keyframes work-arrive { 0% { opacity: 0; transform: translateY(-14px) scale(0.7); } 70% { opacity: 1; transform: translateY(0) scale(1.08, 0.92); } }

/* job done: stands up straight, wrench held high and waved, two hops and some sparkle, then off */
.work.cheer .torso { transform: rotate(-2deg); }
.work.cheer .arm { transform: rotate(-100deg); animation: cheer-raise 0.45s var(--spring) backwards, cheer-wave 0.26s ease-in-out 0.45s 6 alternate; }
.work.cheer .arm2 { transform: rotate(128deg); }
.work.cheer .all { animation: cheer-hop 0.36s ease-out 0.2s 2; transform-origin: 20px 38px; }
.work.cheer .star { animation: star-pop 1.2s var(--out) var(--d) both; transform-box: fill-box; transform-origin: center; }
.work.cheer { animation: work-off 0.45s ease-in 2.4s forwards; }
.work.leave { animation: work-off 0.4s ease-in forwards; }
@keyframes cheer-raise { from { transform: rotate(-10deg); } }
@keyframes cheer-wave { to { transform: rotate(-86deg); } }
@keyframes cheer-hop { 0%, 100% { transform: none; } 15% { transform: scale(1.06, 0.92); } 50% { transform: translateY(-6px) scale(0.97, 1.04); } }
@keyframes star-pop { 0% { opacity: 0; scale: 0.2; rotate: -40deg; } 30% { opacity: 1; scale: 1.25; } 70% { opacity: 1; scale: 1; } 100% { opacity: 0; scale: 0.8; rotate: 20deg; } }
@keyframes work-off { to { opacity: 0; transform: translateY(4px); } }
body.far .work.cheer, body.far .work.leave { animation-name: work-off-far; }
@keyframes work-off-far { from { transform: scale(0.8); } to { opacity: 0; transform: scale(0.8) translateY(4px); } }

@media (prefers-reduced-motion: reduce) {
  .work, .work * { animation: none !important; }
  .work.cheer .star { opacity: 1; }
}

/* road routing offline: a plain warning across the top of the map (control.js) */
.roads-warn { position: fixed; z-index: 1090; transform: translateX(-50%); max-width: min(640px, calc(100vw - 32px));
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 12px 10px 16px; border-radius: 14px;
  background: color-mix(in srgb, var(--sev-medium) 22%, var(--surface-solid)); border: 1px solid var(--sev-medium); color: var(--text);
  box-shadow: 0 0 24px color-mix(in srgb, var(--sev-medium) 30%, transparent), 0 14px 40px rgb(var(--shade) / 0.5); font-size: 14px; }
.roads-warn b { font-weight: 800; }
.roads-warn span { color: var(--muted); flex: 1 1 260px; }
.roads-warn .btn { padding: 6px 12px; font-size: 13px; }
.roads-warn.ok { background: color-mix(in srgb, var(--good) 20%, var(--surface-solid)); border-color: var(--good);
  box-shadow: 0 0 24px color-mix(in srgb, var(--good) 28%, transparent), 0 14px 40px rgb(var(--shade) / 0.5); }
