/* ===== Design tokens ===== */
:root {
  color-scheme: dark;
  --bg: #07131f;
  --c1: #0f2a43;
  --c2: #153a58;
  --c3: #1c4a6d;
  --accent: #2dd4bf;
  --text: #eaf3fb;
  --muted: #8aa6bf;
  --danger: #ff6b6b;
  --ok: #34d399;
  --line: #1b3f5e;
  --field: #0a1e32;
  --field-line: #2b5c8a;
  --warn-bg: #4a2a0a;
  --warn-line: #ffb347;
}

/* ===== Base ===== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Tahoma, 'Segoe UI', Arial, sans-serif;
  overflow: hidden;
}

/* Opaque strip under the iPhone clock/battery so scrolled content never shows through them. */
body::before {
  position: fixed;
  z-index: 8000;
  inset: 0 0 auto;
  height: env(safe-area-inset-top);
  background: var(--bg);
  content: '';
  pointer-events: none;
}

#app {
  position: relative;
  height: 100%;
}

main {
  position: absolute;
  inset: 0;
}

h2 {
  margin: 16px 0 8px;
  font-size: 16px;
}

a {
  color: var(--accent);
}

button {
  padding: 10px 14px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--c3);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

button:active {
  opacity: 0.7;
}

button:disabled {
  opacity: 0.4;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.pri {
  border-color: var(--accent);
  background: #0f8f7e;
}

button.dng {
  border-color: var(--danger);
  background: #5a1f2a;
}

button.block {
  width: 100%;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 4px;
  padding: 11px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

textarea {
  min-height: 64px;
}

.color-input {
  height: 46px;
  padding: 3px;
}

label {
  display: block;
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
}

label.flush {
  margin: 0;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.row > * {
  flex: 1;
}

.muted {
  color: var(--muted);
  font-size: 12.5px;
}

.spaced {
  margin: 14px 0;
}

.spaced-input {
  margin-top: 12px;
}

.ltr {
  display: inline-block;
  direction: ltr;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-inline-end: 6px;
  border-radius: 50%;
  vertical-align: middle;
}

.tag {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 7px;
  border-radius: 8px;
  background: #0b3b44;
  color: var(--accent);
  font-size: 11px;
  direction: ltr;
}

.ic {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.danger-text {
  color: var(--danger);
}

.footnote {
  margin: 10px 0 40px;
}

.clickable {
  cursor: pointer;
}

pre {
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--field-line);
  border-radius: 10px;
  background: var(--field);
  font-size: 12px;
  text-align: left;
  white-space: pre-wrap;
  direction: ltr;
}

/* ===== Pages ===== */
.page {
  position: absolute;
  inset: 0;
  z-index: 900;
  display: none;
  overflow: auto;
  padding: max(10px, env(safe-area-inset-top)) 14px 30px;
  background: var(--bg);
}

.page.on {
  display: block;
}

.ph {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0 12px;
}

.ph b {
  display: block;
  font-size: 18px;
}

.ph small {
  color: var(--muted);
  font-size: 12px;
}

.back {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
}

/* ===== Home ===== */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 14px;
}

.brand .grow {
  flex: 1;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 0.3px;
  text-align: right;
  direction: ltr;
  overflow-wrap: anywhere;
}

.brand .sub {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1.5px;
  text-align: right;
  direction: ltr;
}

#gear {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 19px;
}

.panel {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--c1);
}

#welcomeTitle {
  font-size: 19px;
}

.tagline {
  margin-top: 4px;
}

.mapcard {
  margin-top: 12px;
  padding: 12px;
  border-radius: 20px;
  background: var(--c2);
}

.mrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mrow b {
  font-size: 17px;
  direction: ltr;
}

.mrow.sm {
  color: var(--accent);
  font-size: 13px;
  direction: ltr;
}

.mrow.sm span:last-child {
  color: var(--text);
}

.badge {
  padding: 4px 10px;
  border-radius: 12px;
  background: #0b3a2e;
  color: var(--ok);
  font-size: 12px;
  direction: ltr;
}

#mini {
  height: clamp(260px, 46vh, 420px);
  margin: 0;
  overflow: hidden;
  border-radius: 14px;
  background: var(--field);
  direction: ltr;
  pointer-events: none;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 118px;
  padding: 16px;
  border: 0;
  border-radius: 20px;
  background: var(--c3);
  text-align: right;
}

.tile b {
  display: block;
  font-size: 19px;
}

.tile small {
  display: block;
  color: #9fc0da;
  font-size: 14px;
  text-align: right;
  direction: ltr;
}

.det-title {
  font-size: 17px;
  font-weight: bold;
}

.det {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.det:last-child {
  border: 0;
}

.det span:first-child {
  color: var(--muted);
}

.det span:last-child {
  font-weight: bold;
  text-align: left;
}

.chips {
  display: flex;
  gap: 8px;
}

.chips div {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--c1);
  text-align: center;
}

.chips b {
  display: block;
  color: var(--accent);
  font-size: 20px;
}

.chips span {
  color: var(--muted);
  font-size: 12px;
}

/* ===== Cards ===== */
.card {
  margin: 9px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--c1);
}

.card.subc {
  margin-inline-start: 22px;
  border-style: dashed;
}

.card[data-h] {
  cursor: pointer;
}

.card .t {
  font-size: 15px;
  font-weight: bold;
}

.card .s {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
}

/* ===== Map ===== */
#mapwrap {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#maphead {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(54px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 10px 0;
  border-bottom: 1px solid var(--line);
  background: var(--c1);
}

#maphead .back {
  width: 40px;
  height: 40px;
  font-size: 19px;
}

#maphead .mt {
  flex: 1;
  font-weight: bold;
  text-align: right;
  direction: ltr;
}

#maphead .mt small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: normal;
  direction: rtl;
}

#mstats {
  color: var(--accent);
  font-size: 12px;
}

#map {
  position: absolute;
  top: calc(54px + env(safe-area-inset-top));
  right: 0;
  bottom: 0;
  left: 0;
  background: var(--field);
  direction: ltr;
}

.fab {
  position: absolute;
  top: calc(66px + env(safe-area-inset-top));
  left: 10px;
  z-index: 800;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fab button {
  width: 46px;
  height: 46px;
  padding: 0;
  border-color: var(--accent);
  border-radius: 14px;
  background: #0f2a43ee;
  box-shadow: 0 3px 12px #0007;
  font-size: 20px;
}

.fab button.off {
  opacity: 0.45;
}

#banner {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top));
  right: 10px;
  left: 68px;
  z-index: 850;
  display: none;
  padding: 9px 10px;
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: #0f2a43f5;
  font-size: 13px;
  line-height: 1.6;
}

#banner .row {
  margin-top: 7px;
}

#banner button {
  padding: 8px 6px;
  font-size: 13px;
}

#netwarn {
  position: absolute;
  right: 10px;
  bottom: 12px;
  left: 68px;
  z-index: 850;
  display: none;
  padding: 9px 10px;
  border: 1px solid var(--warn-line);
  border-radius: 12px;
  background: var(--warn-bg);
  font-size: 13px;
  line-height: 1.6;
}

#netwarn button {
  padding: 6px;
  font-size: 13px;
}

.landmark span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid #ffe14d;
  border-radius: 50%;
  background: #000a;
  font-size: 18px;
}

.leaflet-tooltip.hno {
  padding: 1px 5px;
  border: 0;
  background: #000a;
  box-shadow: none;
  color: #fff;
  font-size: 11px;
  direction: rtl;
}

.hlabel {
  pointer-events: none;
}

.hlabel span {
  position: absolute;
  max-width: none;
  transform: translate(-50%, -50%);
  font-weight: 800;
  white-space: nowrap;
  direction: rtl;
  text-shadow:
    0 0 3px #000,
    0 0 3px #000,
    0 1px 5px #000;
}

.hlabel.sub span {
  font-weight: 600;
  filter: brightness(1.25);
}

.leaflet-tooltip.hno::before {
  display: none;
}

.z-lo .hno {
  display: none;
}

/* Vertex handles used while editing a boundary shape */
.vh i,
.vm i {
  display: block;
  border-radius: 50%;
  box-sizing: border-box;
}

.vh i {
  width: 100%;
  height: 100%;
  border: 3px solid #000;
  background: #ffe14d;
}

.vh.sel i {
  border-color: #fff;
  background: #ff5a5a;
}

.vm i {
  width: 14px;
  height: 14px;
  margin: 6px;
  border: 2px solid #000;
  background: #fffa;
}

/* ===== Sheet and toast ===== */
#sheetBg {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: #000a;
}

#sheetBg.on {
  display: flex;
}

#sheet {
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  overflow: auto;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  border: 1px solid var(--accent);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: var(--bg);
}

#sheet h3 {
  margin: 0 0 2px;
  font-size: 18px;
}

.idbox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #0b3b44;
}

.idbox b {
  color: var(--accent);
  font-size: 16px;
  direction: ltr;
}

#toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  z-index: 3000;
  display: none;
  max-width: 88vw;
  padding: 9px 16px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: #000d;
  color: #fff;
  font-size: 13px;
  text-align: center;
  transform: translateX(-50%);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- map search, pin, POIs ---------- */

#msearch {
  position: absolute;
  top: calc(62px + env(safe-area-inset-top));
  right: 10px;
  left: 68px;
  z-index: 840;
}

#mapwrap.moding #msearch {
  display: none;
}

#msq {
  width: 100%;
  box-shadow: 0 3px 12px #0007;
}

#msres {
  display: none;
  max-height: 46vh;
  margin-top: 6px;
  overflow-y: auto;
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: #0f2a43f5;
}

.mres {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: right;
}

.mres .mt2 {
  flex: 1;
  min-width: 0;
}

.mres small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

#pinchip {
  position: absolute;
  right: 10px;
  bottom: 12px;
  left: 68px;
  z-index: 860;
  display: none;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: #0f2a43f5;
}

.pc-t {
  font-weight: bold;
}

.pc-s {
  color: var(--muted);
  font-size: 13px;
}

#pinchip .row {
  margin-top: 8px;
}

#pinchip button {
  padding: 8px 6px;
  font-size: 13px;
}

.pin span {
  font-size: 30px;
  filter: drop-shadow(0 2px 3px #000a);
}

.poi span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #0b2a44e6;
  font-size: 15px;
}

#map.z-nopoi .poi {
  display: none;
}

.gps {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  align-items: center;
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0b3b4455;
}

.gps > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.gps b {
  color: var(--accent);
  font-size: 14px;
}

.gps button {
  grid-row: 1 / span 2;
  grid-column: 2;
  width: 44px;
  padding: 8px;
}

.view {
  margin: 6px 0 10px;
}

#printSheet {
  display: none;
}

@page {
  size: A4;
  margin: 0;
}

@media print {
  #app,
  #sheetBg,
  #toast,
  #lock,
  body::before {
    display: none !important;
  }

  html,
  body {
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    background: #fff;
  }

  #printSheet {
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: 210mm;
    margin: 0 auto;
    padding: 14mm 12mm;
    color: #000;
    direction: rtl;
    font-family: inherit;
    font-size: 11pt;
    line-height: 1.5;
  }

  #printSheet h2 {
    margin: 0 0 4mm;
    padding-bottom: 3mm;
    border-bottom: 2px solid #000;
    color: #000;
    font-size: 16pt;
    text-align: center;
  }

  #printSheet .pstat {
    margin: 0 0 4mm;
    font-size: 10.5pt;
    text-align: center;
  }

  #printSheet table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
  }

  #printSheet tr {
    break-inside: avoid;
  }

  #printSheet th,
  #printSheet td {
    padding: 2.2mm 3mm;
    border: 1px solid #666;
    overflow-wrap: anywhere;
    text-align: right;
    vertical-align: top;
  }

  #printSheet th {
    width: 30%;
    background: #eee;
    font-weight: bold;
  }

  #printSheet table.rep th {
    width: auto;
    text-align: center;
    font-size: 10pt;
  }

  #printSheet table.rep td {
    padding: 1.6mm 2mm;
    font-size: 10pt;
  }

  #printSheet table.rep thead {
    display: table-header-group;
  }
}

/* ---------- lock screen ---------- */

#lock {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 30%, #2a0705, #050101 70%);
  overflow-y: auto;
}

#lock[hidden] {
  display: none;
}

body.locked #app {
  visibility: hidden;
}

.lock-box {
  display: grid;
  gap: 12px;
  width: min(100%, 380px);
  text-align: center;
}

.lock-logo {
  justify-self: center;
  border-radius: 24px;
  box-shadow: 0 0 30px #7a120988;
}

.lock-box h2 {
  margin: 0;
  font-size: 20px;
}

.lock-box p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
}

.lk-msg {
  min-height: 20px;
  color: #ff8a7a;
  font-size: 13px;
}

.recovery {
  padding: 14px 8px;
  border: 1px dashed #b8892b;
  border-radius: 12px;
  background: #000a;
  color: #ffd98a;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 18px;
  letter-spacing: 1px;
  user-select: all;
}

.check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--fg, #fff);
}

.check input {
  width: auto;
}

.link {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
}

#bkWarn:empty {
  display: none;
}

.warnbox {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--warn-line);
  border-radius: 12px;
  background: var(--warn-bg);
  font-size: 13px;
  line-height: 1.7;
}

.pw {
  position: absolute;
  inset: 0;
  transform: scale(var(--ps, 1));
  transform-origin: center;
}

.pin .pw {
  transform-origin: 50% 94%;
}

.pulse i {
  position: absolute;
  inset: 12px;
  border: 2px solid #ff4d3a;
  border-radius: 50%;
  animation: pulse-ring 1.8s ease-out infinite;
}

.pulse i:nth-child(2) {
  animation-delay: 0.9s;
}

.pulse b {
  position: absolute;
  inset: 25px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #ff4d3a;
  box-shadow: 0 0 14px #ff4d3a;
}

@keyframes pulse-ring {
  from {
    opacity: 1;
    transform: scale(0.4);
  }

  to {
    opacity: 0;
    transform: scale(1.7);
  }
}

.bio {
  padding: 16px;
  font-size: 17px;
}

/* ---------- cameras ---------- */

.camsec,
.fsec {
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid var(--field-line);
  border-radius: 14px;
  background: #ffffff06;
}

.fsec h4,
.camsec > b {
  display: block;
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 14px;
}

.fgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 10px;
}

.fgrid.three {
  grid-template-columns: repeat(3, 1fr);
}

.fgrid .full {
  grid-column: 1 / -1;
}

.fgrid label {
  min-width: 0;
  margin: 6px 0;
}

.fsec textarea {
  margin: 0;
}

.camrow {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: #ffffff08;
}

.camrow .dng {
  width: 100%;
  margin-top: 8px;
}

label.chk {
  display: flex;
  align-items: center;
  gap: 8px;
}

label.chk input {
  width: auto;
  margin: 0;
}

.cam-btn {
  background: #0f8f7e;
}

.camview {
  position: fixed;
  inset: 0;
  z-index: 8500;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  background: #02060a;
}

.cv-head,
.cv-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
}

.cv-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cv-actions a {
  color: var(--accent);
  white-space: nowrap;
}

.cv-body {
  position: relative;
  display: grid;
  flex: 1;
  min-height: 0;
  place-items: center;
}

.cv-body video,
.cv-body img,
.cv-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
  object-fit: contain;
}

#cv_msg.bad {
  color: #ff8a7a;
}

.cmp {
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
  font-size: 13.5px;
}

.cmp th,
.cmp td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--field-line);
  text-align: start;
}

.cmp th {
  color: var(--muted);
  font-weight: 600;
}

.tile.wide {
  grid-column: 1 / -1;
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-inline-end: 6px;
  border-radius: 50%;
}

.bar {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font-size: 13px;
}

.bar i {
  position: relative;
  height: 9px;
  border-radius: 6px;
  background: var(--field);
  overflow: hidden;
}

.bar i::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--w);
  border-radius: 6px;
  background: var(--accent);
  content: '';
}

#mfilter {
  display: flex;
  gap: 5px;
  margin-top: 6px;
}

#mfilter button {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #0b1f33e6;
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 2px 8px #0006;
}

#mfilter button.on {
  border-color: var(--accent);
  background: #0f8f7e;
}

/* ---------- camera mode of the map ---------- */
.camicon span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #0f8f7e;
  font-size: 15px;
  box-shadow: 0 2px 8px #000a;
}

.camicon.sel span {
  background: #e4572e;
  transform: scale(1.2);
}

#camdock {
  position: absolute;
  top: 150px;
  right: 10px;
  z-index: 855;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 150px;
  max-height: calc(100% - 300px);
  padding: 8px;
  overflow-y: auto;
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: #0b1f33f2;
}

#camdock[hidden] {
  display: none;
}

.cd-t {
  font-size: 13px;
  font-weight: bold;
}

#camdock .cd-i {
  display: block;
  width: 100%;
  padding: 7px 8px;
  border-radius: 10px;
  background: #12344f;
  text-align: start;
}

#camdock .cd-i.on {
  border-color: #fff;
  background: #e4572e;
}

#camdock .cd-i small {
  display: block;
  overflow: hidden;
  opacity: 0.75;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#camdock .cd-i b {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camview.float {
  inset: auto 170px 14px auto;
  width: min(420px, calc(100vw - 190px));
  height: auto;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 30px #000c;
  z-index: 880;
}

.camview.float .cv-body {
  flex: none;
  aspect-ratio: 16 / 9;
}

.cv-live {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-inline-start: auto;
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
}

.cv-live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff3b30;
  animation: cvpulse 1.4s infinite;
}

@keyframes cvpulse {
  50% {
    opacity: 0.25;
  }
}

.cv-head button {
  padding: 4px 9px;
}

@media (max-width: 640px) {
  #camdock {
    top: auto;
    right: 10px;
    bottom: 12px;
    left: 68px;
    flex-direction: row;
    width: auto;
    max-height: none;
    overflow: auto hidden;
  }

  .cd-t {
    align-self: center;
    white-space: nowrap;
  }

  #camdock .cd-i {
    flex: 0 0 120px;
    width: 120px;
  }

  .camview.float {
    inset: auto 10px 74px 10px;
    width: auto;
  }

  .camview.float .cv-body {
    max-height: 34vh;
  }
}

/* ---------- photos ---------- */
.photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.photos img {
  width: 92px;
  height: 92px;
  border-radius: 10px;
  object-fit: cover;
}

.photos .ph {
  position: relative;
}

.photos .ph button {
  position: absolute;
  top: 2px;
  right: 2px;
  padding: 2px 6px;
  border-radius: 50%;
  background: #000a;
  font-size: 11px;
}

.filebtn {
  display: block;
  padding: 10px;
  border: 1px dashed var(--accent);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
}

.photobox {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  background: #000d;
}

.photobox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.campick[hidden] {
  display: none;
}

.campick {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  z-index: 4;
  padding: 10px 12px;
  border: 1px solid #ff5a48;
  border-radius: 14px;
  background: #0f1d2cf2;
}

.cp-t {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.cp-t button {
  padding: 3px 9px;
}

.cam-btn img,
#camdock .cd-i img {
  display: block;
  width: 100%;
  margin-bottom: 4px;
  border-radius: 8px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.cam-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.campick .cam-btn img {
  display: none;
}

/* ---------- property form: tabs + family ---------- */
.tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0 6px;
  padding: 4px;
  border-radius: 14px;
  background: var(--field);
}

.tabs button {
  flex: 1;
  padding: 10px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted, #9db4c8);
  font-weight: bold;
}

.tabs button.on {
  background: var(--accent);
  color: #062a24;
}

.pane[hidden] {
  display: none;
}

.fmrow {
  display: grid;
  grid-template-columns: 1fr 92px 64px 38px;
  gap: 6px;
  margin: 8px 0;
}

.fmrow input,
.fmrow select {
  min-width: 0;
  padding: 9px 8px;
}

.fmrow .dng {
  padding: 0;
}

@media (max-width: 420px) {
  .fmrow {
    grid-template-columns: 1fr 1fr 38px;
  }

  .fmrow [data-f='name'] {
    grid-column: 1 / -1;
  }

  .fmrow [data-f='age'] {
    grid-column: 2;
  }
}

/* ---------- polish ---------- */
.tile,
.card,
.mapcard,
.panel {
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.tile {
  background: linear-gradient(160deg, var(--c3), #17405f);
  box-shadow: 0 4px 14px #0006;
}

.tile:active {
  transform: scale(0.97);
}

.mapcard {
  padding: 8px;
  box-shadow: 0 6px 20px #0007;
}

#mini {
  border-radius: 16px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.card {
  box-shadow: 0 3px 10px #0005;
}

@media (hover: hover) {
  .tile:hover,
  .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px #0008;
  }
}

@media (min-width: 900px) {
  #mini {
    height: clamp(300px, 42vh, 380px);
  }

  .grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .tile.wide {
    grid-column: span 3;
    min-height: 90px;
  }
}

.idph button {
  width: 100%;
  margin-top: 6px;
}

.photos[hidden] {
  display: none;
}

/* ---------- settings ---------- */
.sgroup {
  margin: 22px 2px 6px;
  font-size: 15px;
}

.setc .t {
  margin-bottom: 2px;
}

.btngrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.btngrid .wide {
  grid-column: 1 / -1;
}

.camhelp {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
}

.camhelp summary {
  cursor: pointer;
  color: var(--accent);
}

.camhelp ol {
  padding-inline-start: 18px;
}

.setg {
  margin: 12px 0;
  border: 1px solid var(--field-line);
  border-radius: 16px;
  background: #ffffff06;
}

.setg > summary {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.setg > summary::-webkit-details-marker {
  display: none;
}

.setg > summary::after {
  content: '‹';
  position: absolute;
  inset-inline-end: 0;
}

.setg > summary b {
  font-size: 15px;
}

.setg > summary small {
  color: var(--muted);
  font-size: 12px;
}

.setg[open] > summary {
  border-bottom: 1px solid var(--field-line);
}

.setg > .card {
  margin: 10px;
}

.setg.dang > summary b {
  color: #ff6b6b;
}

.setg > summary::after {
  top: 18px;
  color: var(--accent);
  font-size: 20px;
  transition: transform 0.2s;
}

.setg[open] > summary::after {
  transform: rotate(-90deg);
}

/* ---------- computers: 24" / 27" screens keep content centred and readable ---------- */
@media (min-width: 900px) {
  .page {
    padding-inline: max(14px, calc((100vw - 1080px) / 2));
  }

  #pg-set,
  #pg-search,
  #pg-draw {
    padding-inline: max(14px, calc((100vw - 760px) / 2));
  }

  .grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .tile.wide {
    grid-column: 1 / -1;
  }

  #dlist,
  #repHoods {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 12px;
  }

  #msearch {
    right: 10px;
    left: auto;
    width: min(640px, calc(100% - 78px));
  }

  #sheet {
    max-width: 620px;
  }
}

@media (min-width: 1700px) {
  .page {
    padding-inline: max(14px, calc((100vw - 1320px) / 2));
  }

  #pg-set,
  #pg-search,
  #pg-draw {
    padding-inline: max(14px, calc((100vw - 860px) / 2));
  }

  #dlist,
  #repHoods {
    grid-template-columns: repeat(3, 1fr);
  }
}

.lk-team {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

/* ---------- settings v2: one tidy list of groups ---------- */
.setg {
  margin: 10px 0;
  overflow: hidden;
  border-radius: 18px;
}

.setg > summary {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.setg > summary .gi {
  display: grid;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #ffffff10;
  font-size: 22px;
  place-items: center;
}

.setg > summary .gt {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.setg > summary::after {
  top: auto;
  position: static;
  flex: none;
}

.setg > .card {
  margin: 0;
  padding: 14px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.setg > .card + .card {
  border-top: 1px dashed var(--field-line);
}

.setg > .card .t {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 14px;
}

.setg .btngrid button {
  min-height: 44px;
}

/* ---------- dashboard ---------- */
#dash {
  display: grid;
  gap: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  --tone: #2dd4bf;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  padding: 12px 12px 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--tone) 16%, var(--c1)), var(--c1) 70%);
  text-align: right;
}

.stat::after {
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: var(--tone);
  content: '';
  opacity: 0.8;
}

.stat i {
  font-size: 20px;
  font-style: normal;
}

.stat b {
  color: var(--tone);
  font-size: 28px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat span {
  color: var(--muted);
  font-size: 12.5px;
}

.s-shops {
  --tone: #f5b942;
}

.s-people {
  --tone: #7aa8ff;
}

.s-cams {
  --tone: #ff7a7a;
}

.s-hoods {
  --tone: #c084fc;
}

.s-subs {
  --tone: #5eead4;
}

.dcard {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--c1);
}

.dcard h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.splitbar {
  display: flex;
  height: 14px;
  gap: 3px;
  overflow: hidden;
  border-radius: 8px;
}

.splitbar span {
  min-width: 6px;
  border-radius: 4px;
}

.legend {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend b {
  margin-inline-start: auto;
}

.legend small {
  width: 40px;
  color: var(--muted);
  text-align: left;
}

.hbar {
  display: grid;
  grid-template-columns: 38% 1fr 32px;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 13px;
}

.hbar span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hbar div {
  height: 8px;
  overflow: hidden;
  border-radius: 6px;
  background: #ffffff10;
}

.hbar u {
  display: block;
  height: 100%;
  border-radius: 6px;
}

.hbar b {
  text-align: left;
}

.recent {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 8px;
  width: 100%;
  margin: 6px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--c2);
  text-align: right;
}

.recent small {
  color: var(--muted);
  direction: ltr;
  text-align: right;
}

.recent em {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--accent);
  font-size: 11.5px;
  font-style: normal;
}

@media (min-width: 900px) {
  #dash {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats {
    grid-column: 1 / -1;
    grid-template-columns: repeat(6, 1fr);
  }

  #mini {
    height: clamp(340px, 46vh, 460px);
  }
}
