:root {
  --ui-font-family: system-ui, Arial, sans-serif;
  --ui-label-size: 0.82rem;
  --ui-hint-size: 0.7rem;
  --ui-heading-size: 0.95rem;
  --ui-control-height: 40px;
  --heading-ink: var(--text);
  --bg: #09111f;
  --card: #111a2b;
  --line: #24314b;
  --text: #e8eef8;
  --mut: #9eb0c9;
  --grn: #22c55e;
  --acc: #60a5fa;
  --inbg: #0e1726;
  --pill-bg: #17243a;
  --pill-text: #e8eef8;
  --pill-line: #3a4b67;
  --pill-green: #86efac;
  --pill-green-bg: #163c2c;
  --pill-red: #fca5a5;
  --pill-blue: #93c5fd;
  --pill-active-bg: #163c2c;
}
body.light {
  --heading-ink: #000000;
  --bg: #f7f9fc;
  --card: #ffffff;
  --line: #d4dce8;
  --text: #101828;
  --mut: #5a6a80;
  --inbg: #f2f5fa;
  --pill-bg: #fff;
  --pill-text: #101828;
  --pill-line: #d4dce8;
  --pill-green: #15803d;
  --pill-green-bg: #ecfdf1;
  --pill-red: #b91c1c;
  --pill-blue: #1d4ed8;
  --pill-active-bg: #dcfce7;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: var(--ui-font-family);
  background: var(--bg);
  color: var(--text);
}
.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 14px 40px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 12px;
}
h1 {
  margin: 0;
  font-size: 1.35rem;
  cursor: pointer;
  user-select: none;
}
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--pill-line);
  background: var(--pill-bg);
  color: var(--pill-text);
  font-size: 0.8rem;
  margin: 2px;
  cursor: pointer;
  user-select: none;
}
.pill.red {
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--pill-red);
  background: var(--pill-bg);
}
.pill.green {
  border-color: rgba(34, 197, 94, 0.5);
  color: var(--pill-green);
  background: var(--pill-green-bg);
}
.pill.blue {
  border-color: rgba(59, 130, 246, 0.45);
  color: var(--pill-blue);
  background: var(--pill-bg);
}
.pill.grey {
  border-color: var(--pill-line);
  color: var(--mut);
  background: var(--pill-bg);
  cursor: default;
  opacity: 1;
}
body.light .pill.green {
  color: var(--pill-green);
  background: var(--pill-green-bg);
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 14px;
  overflow: hidden;
}
.card h2 {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 1.05rem;
}
.admExpLine {
  padding: 6px 16px;
  font-size: 0.78rem;
  color: var(--mut);
  border-bottom: 1px solid var(--line);
}
.h2sub {
  padding: 4px 16px 12px;
  font-size: 0.78rem;
  color: var(--mut);
  display: flex;
  align-items: center;
  gap: 10px;
}
.h2sub .pill {
  font-size: 0.68rem;
  padding: 3px 9px;
  margin: 0;
  flex-shrink: 0;
}
.body {
  padding: 14px;
}
.field {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
label {
  font-size: 0.92rem;
}
.hint {
  color: var(--mut);
  font-size: 0.78rem;
  white-space: pre-line;
}
.req {
  font-size: 0.72rem;
  color: #fca5a5;
  margin-left: 4px;
}
body.light .req {
  color: #dc2626;
}
input,
select,
textarea {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--inbg);
  color: var(--text);
  font-size: 16px;
  min-height: 44px;
}
textarea {
  min-height: 72px;
}
#uCamps {
  min-height: 150px;
}
.input-row {
  display: flex;
  gap: 8px;
}
.input-row input,
.input-row select {
  flex: 1;
  min-width: 0;
}
.scan-btn {
  flex: 0 0 auto;
  min-width: 78px;
  border-radius: 10px;
  background: #fecaca;
  color: #7f1d1d;
  border: 1px solid #f87171;
  font-weight: 800;
  font-size: 1rem;
  min-height: 44px;
}
.inline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.submit-row {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}
.submit-row .btn {
  flex: 1;
  width: 100%;
}
.btn {
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 700;
  background: var(--acc);
  color: #07111f;
  min-height: 44px;
  font-size: 1rem;
}
.btn.dark {
  background: #1d2941;
  color: #e8eef8;
  border: 1px solid #24314b;
}
body.light .btn.dark {
  background: #e4eaf3;
  color: #101828;
  border-color: #c9d4e4;
}
.btn.green {
  background: var(--grn);
  color: #05210d;
}
.btn.red {
  background: #fb7185;
  color: #3b0a12;
}
.btn.gpsG {
  background: var(--grn);
  color: #05210d;
}
.btn.gpsY {
  background: #fbbf24;
  color: #3b2b00;
}
.btn.gpsR {
  background: #fb7185;
  color: #3b0a12;
}
.btn.sm {
  padding: 8px 10px;
  min-height: 38px;
  font-size: 0.9rem;
  min-width: 78px;
}
.btn.xs {
  padding: 6px 8px;
  min-height: 32px;
  font-size: 0.78rem;
  min-width: 64px;
  font-weight: 700;
}
.btn.tiny {
  padding: 5px 6px;
  min-height: 30px;
  font-size: 0.72rem;
  min-width: 52px;
  border-radius: 8px;
  font-weight: 700;
}
.btn.del {
  background: #fecaca;
  color: #7f1d1d;
  border: 1px solid #f87171;
}
.btn.on {
  outline: 2px solid var(--grn);
}
.status {
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--mut);
  font-size: 0.88rem;
  background: transparent;
}
.status.good {
  border-color: rgba(34, 197, 94, 0.4);
  color: #15803d;
}
.status.bad {
  border-color: rgba(239, 68, 68, 0.4);
  color: #b91c1c;
}
.status.warn {
  border-color: rgba(245, 158, 11, 0.4);
  color: #b45309;
}
body:not(.light) .status.good {
  color: #bbf7d0;
}
body:not(.light) .status.bad {
  color: #fecaca;
}
body:not(.light) .status.warn {
  color: #fde68a;
}
#gpsSt {
  white-space: pre-line;
}
.switch {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.switch button {
  flex: 1;
  border: 0;
  padding: 12px;
  background: transparent;
  color: var(--text);
  min-height: 44px;
  font-size: 1rem;
}
.switch button.onE {
  background: var(--grn);
  color: #05210d;
  font-weight: 800;
}
.switch button.onW {
  background: #3b82f6;
  color: #fff;
  font-weight: 800;
}
.switch button.onF {
  background: var(--acc);
  color: #07111f;
  font-weight: 800;
}
.mini {
  font-size: 0.8rem;
  color: var(--mut);
}
.hidden {
  display: none !important;
}
#cnt {
  font-weight: 800;
  margin-top: 8px;
  color: var(--text);
}
#missingBox {
  font-size: 0.82rem;
  margin-top: 6px;
  color: #fca5a5;
}
body.light #missingBox {
  color: #dc2626;
}
#missingBox.ok {
  color: #86efac;
}
body.light #missingBox.ok {
  color: #15803d;
}
#gpsLink {
  color: #60a5fa;
  margin-top: 4px;
  display: inline-block;
}
#toolMapCanvas {
  height: min(60vh, 600px);
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--inbg);
}
.map-label {
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.15;
  color: #14532d;
  background: rgba(220, 252, 231, 0.9);
  border: 1px solid rgba(22, 101, 52, 0.55);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}
.building-cluster-wrap {
  background: transparent;
  border: 0;
}
.building-cluster-icon {
  position: relative;
  max-width: 148px;
  min-width: 58px;
  padding: 6px 23px 6px 8px;
  border: 1px solid rgba(22, 101, 52, 0.5);
  border-radius: 10px;
  background: rgba(220, 252, 231, 0.86);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.3);
  color: #14532d;
  text-align: left;
  line-height: 1.15;
  white-space: normal;
  backdrop-filter: blur(2px);
}
.building-cluster-icon .cluster-names {
  font-size: 0.68rem;
  font-weight: 750;
  overflow-wrap: anywhere;
  color: #14532d;
}
.building-cluster-icon .cluster-names span {
  display: block;
}
:is(#toolMapCanvas, .sums-map) .leaflet-popup-content-wrapper {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(22, 101, 52, 0.5);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.3);
  color: #14532d;
  backdrop-filter: blur(2px);
}
:is(#toolMapCanvas, .sums-map) .leaflet-popup-content {
  margin: 10px 12px;
  font-size: 0.8rem;
  line-height: 1.4;
}
:is(#toolMapCanvas, .sums-map) .leaflet-popup-content strong {
  font-weight: 750;
}
:is(#toolMapCanvas, .sums-map) .leaflet-popup-tip {
  background: #fff;
}
:is(#toolMapCanvas, .sums-map) .mapbox-logo-control {
  background: rgba(255, 255, 255, 0.88);
  padding: 3px 5px;
  border-radius: 5px;
}
:is(#toolMapCanvas, .sums-map) .mapbox-logo-control img {
  display: block;
  width: 74px;
  height: auto;
}
.building-cluster-icon .cluster-count {
  position: absolute;
  top: -7px;
  right: -7px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 21px;
  height: 21px;
  padding: 0 4px;
  border: 2px solid rgba(240, 253, 244, 0.95);
  border-radius: 999px;
  background: rgba(21, 128, 61, 0.92);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.22);
}

.tool-search-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  flex-wrap: nowrap;
}
.tool-search-controls input {
  flex: 1;
  min-width: 64px;
  max-width: none;
  min-height: 32px;
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(34, 197, 94, 0.6);
  background: var(--inbg);
  color: var(--text);
}
.tool-search-controls .pill {
  flex-shrink: 0;
  white-space: nowrap;
}
.tool-maps-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  min-height: 34px;
}
.tool-maps-row .pill {
  margin: 0;
  white-space: nowrap;
}
.tool-map-control {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}
.tool-map-control button {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d4dce8;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #101828;
  font:
    700 0.7rem system-ui,
    Arial,
    sans-serif;
}
.tool-map-control button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tool-map-control button.on {
  border-color: rgba(22, 101, 52, 0.6);
  background: rgba(187, 247, 208, 0.78);
  color: #14532d;
}
.tool-map-control button.location {
  color: #166534;
}
.tool-map-control button.location.on {
  border-color: rgba(22, 101, 52, 0.6);
  background: rgba(187, 247, 208, 0.78);
  color: #14532d;
}
.tool-current-dot {
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.5);
}
.map-point-wrap {
  background: transparent;
  border: 0;
}
.map-point-icon {
  position: relative;
  display: block;
  width: 26px;
  height: 26px;
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  background: #f97316;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.65),
    0 0 0 2px rgba(124, 45, 18, 0.9);
}
.map-point-icon::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}
:is(#toolMapCanvas, .sums-map) .leaflet-control-zoom a {
  background: rgba(220, 252, 231, 0.78);
  color: #14532d;
  border-color: rgba(22, 101, 52, 0.45);
}
:is(#toolMapCanvas, .sums-map) .leaflet-control-zoom a:hover {
  background: rgba(187, 247, 208, 0.92);
}
:is(#toolMapCanvas, .sums-map) .leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.72);
  color: #253449;
  border-radius: 5px;
}
:is(#toolMapCanvas, .sums-map) .leaflet-control-attribution a {
  color: #14532d;
}
#toolMapProviderStatus {
  min-height: 1em;
}
.cluster-picker {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(17, 26, 43, 0.5);
  backdrop-filter: blur(5px);
}
body.light .cluster-picker {
  background: rgba(255, 255, 255, 0.5);
}
.cluster-panel-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.cluster-panel-actions {
  display: flex;
  gap: 5px;
  margin-left: auto;
  align-items: center;
  flex-shrink: 0;
}
.cluster-panel-actions .pill {
  margin: 0;
  min-height: 30px;
  padding: 4px 9px;
  font-size: 0.74rem;
}
.cluster-filter {
  width: min(100%, 240px);
  min-height: 32px;
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(34, 197, 94, 0.65);
  background: var(--inbg);
  color: var(--text);
}
.cluster-building-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
  max-height: 32vh;
  overflow: auto;
  margin-top: 8px;
}
.cluster-building-list .btn {
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .cluster-building-list {
    grid-template-columns: 1fr;
    max-height: 30vh;
  }
}
@media (max-width: 600px) {
  #toolMapCanvas {
    height: 56vh;
    height: 56svh;
    min-height: 300px;
    max-height: 620px;
  }
}
body.light #gpsLink {
  color: #1d4ed8;
}
.etable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 560px;
}
.etable th {
  white-space: nowrap;
  font-size: 0.72rem;
  color: var(--mut);
  text-align: center;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}
.etable td {
  padding: 8px 6px;
  border-bottom: 1px solid rgba(127, 140, 160, 0.25);
  vertical-align: middle;
  white-space: nowrap;
  text-align: center;
}
.etable td.cid {
  white-space: nowrap;
}
.rowbtns {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  justify-content: center;
}
.dlg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 10px;
  z-index: 50;
  overflow-y: auto;
}
.dlg.open {
  display: flex;
}
body.scanner-open {
  overflow: hidden;
  overscroll-behavior: none;
}
.panel {
  width: 100%;
  max-width: 340px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-top: 4vh;
}
.panel .hd {
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.panel .hd b {
  font-size: 0.95rem;
  white-space: nowrap;
}
.hd-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
#dlg {
  overflow: hidden;
  align-items: center;
  overscroll-behavior: contain;
  padding: 24px;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
#dlg .panel {
  display: flex;
  flex-direction: column;
  max-width: 460px;
  height: 88vh;
  height: min(88svh, 780px);
  max-height: calc(100svh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  min-height: 0;
  overflow: hidden;
  margin-top: 0;
  overscroll-behavior: contain;
}
#dlg .hd {
  position: relative;
  flex: 0 0 auto;
  z-index: 3;
  padding: 8px 12px;
}
.scanner-fixed {
  flex: 0 0 auto;
  padding: 10px 12px 0;
  min-width: 0;
}
.vwrap {
  position: relative;
  height: clamp(220px, 38vh, 320px);
  height: clamp(220px, 38svh, 320px);
  background: #000;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
#vid {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 50%;
  background: var(--inbg);
}
#dlg .scanner-status:empty {
  visibility: hidden;
}
#dlg .scanner-status {
  margin: 6px 0 0;
  padding: 4px 6px;
  border: 0;
  border-radius: 0;
  height: 26px;
  min-height: 26px;
  line-height: 18px;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scanner-camera {
  padding-top: 4px;
}
.scanner-camera select {
  min-height: 40px;
  padding: 8px 10px;
}
.scanner-body {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.scanner-body > * {
  flex-shrink: 0;
}
.scanner-toolbar,
.scanner-pill-group {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
#dlg .pill {
  margin: 0;
  min-height: 44px;
  font-weight: 650;
  text-align: center;
  white-space: normal;
  line-height: 1.2;
}
#dlg .hd-btns .pill {
  min-height: 38px;
  padding: 6px 10px;
  font-size: 0.76rem;
  white-space: nowrap;
}
#dlg .pill.onF,
#dlg .pill.green {
  border-color: rgba(34, 197, 94, 0.5);
  color: var(--pill-green);
  background: var(--pill-active-bg);
}
#dlg .pill:disabled {
  cursor: default;
  opacity: 0.5;
}
#dlg .pill:focus-visible {
  outline: 2px solid #16a34a;
  outline-offset: 2px;
}
#dlg .field {
  margin: 0;
  min-width: 0;
}
.scanner-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}
.scanner-wide {
  grid-column: 1/-1;
}
#dlg #dbg {
  font-size: 0.74rem;
  line-height: 1.5;
  height: calc(7.5em + 16px);
  max-height: calc(7.5em + 16px);
  margin: 0;
  padding: 8px;
  white-space: pre;
  overflow-x: auto;
  overflow-wrap: normal;
}
#dlg .scanner-footer {
  flex: 0 0 auto;
  align-self: stretch;
  text-align: right;
  margin: 0;
  padding: 5px 10px;
  color: var(--mut);
  background: var(--card);
  border-top: 1px solid var(--line);
  font-size: 0.65rem;
  line-height: 1.4;
}
@media (max-width: 380px) {
  .scanner-body {
    padding: 10px;
  }
  .scanner-fixed {
    padding: 10px 10px 0;
  }
  .scanner-toolbar .pill {
    flex: 1 1 120px;
  }
  .scanner-settings .scanner-pill-group .pill {
    flex: 1 1 40px;
  }
}
@media (max-height: 600px) {
  .vwrap {
    height: clamp(140px, 34vh, 220px);
    height: clamp(140px, 34svh, 220px);
  }
  #dlg .hd {
    padding: 5px 10px;
  }
  .scanner-fixed {
    padding-top: 6px;
  }
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
th,
td {
  padding: 8px;
  border-bottom: 1px solid rgba(127, 140, 160, 0.25);
  text-align: left;
}
.twrap {
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.twrap thead th {
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 2;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--mut);
  font-size: 0.72rem;
  font-weight: 700;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.chip.on {
  border-color: rgba(34, 197, 94, 0.6);
  background: rgba(34, 197, 94, 0.08);
  color: #15803d;
}
.chip.dragging {
  opacity: 0.35;
}
.chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}
.scol {
  display: inline-flex;
  flex-direction: column;
  line-height: 1;
  margin-left: 3px;
  vertical-align: middle;
}
.scol .sarr {
  color: #b9c6d8;
  font-size: 0.55rem;
}
body.light .scol .sarr {
  color: #9aa7b8;
}
.scol .sarr.on {
  color: var(--acc);
  font-weight: 800;
}
th.sortable {
  cursor: pointer;
  user-select: none;
}
.adm {
  display: none;
}
.adm.open {
  display: block;
}
body.isAdmin .hideOnAdmin {
  display: none !important;
}
body.isAdmin #admBox {
  display: block !important;
}
#dbg {
  font-size: 0.65rem;
  color: #7a8ba3;
  margin-top: 6px;
  max-height: 90px;
  overflow-y: auto;
  background: #080c14;
  padding: 5px 7px;
  border-radius: 6px;
  font-family: monospace;
  white-space: pre-wrap;
  display: none;
}
body.light #dbg {
  background: #eef2f8;
  color: #40506a;
}
#dbg.show {
  display: block;
}
.h2row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--line);
}
.h2row b {
  font-size: 1.05rem;
}
.h2row .pill {
  margin: 0;
}
#bPayTgl,
#bCfgTgl,
#bToolTgl,
#bDataRedirect,
#bFltTgl {
  border-color: rgba(34, 197, 94, 0.6);
}
body.light #bPayTgl,
body.light #bCfgTgl,
body.light #bToolTgl,
body.light #bDataRedirect,
body.light #bFltTgl {
  color: #15803d;
}
body:not(.light) #bPayTgl,
body:not(.light) #bCfgTgl,
body:not(.light) #bToolTgl,
body:not(.light) #bDataRedirect,
body:not(.light) #bFltTgl {
  color: #15803d;
}
#bResend {
  margin-right: 6px;
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
}
.dot.ok {
  background: var(--grn);
}
.dot.err {
  background: #ef4444;
}
.dot.pend {
  background: #f59e0b;
}

#pH th {
  white-space: nowrap;
  font-size: 0.72rem;
  color: var(--mut);
  text-align: center;
}
#pB td {
  text-align: center;
  vertical-align: middle;
}
#pB td.jcell {
  white-space: nowrap;
}
.jsonblk {
  font-family: monospace;
  font-size: 0.68rem;
  background: #080c14;
  color: #c8d6ea;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  max-height: 280px;
  overflow: auto;
  text-align: left;
}
body.light .jsonblk {
  background: #eef2f8;
  color: #101828;
}
.btn.tiny.sq {
  min-width: 34px;
  padding: 4px 8px;
}
.ver {
  font-size: 0.6rem;
  color: #5a6a7a;
  text-align: right;
  margin-top: 4px;
}

/* Fixed thumb controls stay reachable while camera/debug settings scroll. */
.scanner-instruction {
  margin: 0;
  color: var(--mut);
  font-size: 0.8rem;
  line-height: 1.4;
  flex: 1 1 100%;
}
.scanner-bottom-controls {
  flex: 0 0 auto;
  padding: 6px 20px 8px;
  background: var(--card);
  border-top: 1px solid var(--line);
}
.scanner-torch-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 2px;
}
#dlg #flTgl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 12px;
}
.torch-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.scanner-zoom-control label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--mut);
}
#zoomValue {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.scanner-zoom-track {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.74rem;
  color: var(--mut);
}
#zoomSlider {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: #22c55e;
  cursor: pointer;
  touch-action: none;
  overscroll-behavior: contain;
}
#zoomSlider:focus-visible {
  outline: 2px solid #16a34a;
  outline-offset: 2px;
  border-radius: 8px;
}
.scanner-bottom-controls:has(> .hidden:first-child + .hidden:last-child) {
  display: none;
}
@media (max-height: 600px) {
  .scanner-bottom-controls {
    padding: 2px 20px;
  }
  .scanner-torch-row {
    margin: 0;
  }
  .vwrap {
    height: clamp(110px, 30svh, 180px);
  }
}

/* Shared accordion action dimensions and typography, including native buttons. */
.admin-section-toggle {
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1.2;
  padding: 6px 11px;
  min-height: 0;
  appearance: none;
}

/* Submission actions follow the active form; status dots keep their success/error colours. */
#submissionLogCard #bPayTgl {
  border-color: color-mix(in srgb, var(--surface-accent) 60%, transparent);
  color: var(--surface-accent);
}

/* Each table inherits its panel accent, including Water's blue. */
#eB tr:nth-child(even),
#pB tr.row-banded,
#tB tr:nth-child(even) {
  background: var(--row-band);
}

/* Single-choice checkboxes keep Water installation input quick on a phone. */
.water-location-builder {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 4px 0 14px;
  padding: 10px 12px;
  min-width: 0;
}
.water-location-builder legend {
  color: var(--pill-blue);
  font-size: var(--ui-label-size);
  font-weight: 600;
  padding: 0 5px;
}
.water-location-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.water-location-fields .field {
  margin: 0;
  min-width: 0;
}
.water-location-fields [data-water-field="installLocation"],
.water-location-fields [data-water-field="feedType"] {
  grid-column: 1 / -1;
}
.water-location-fields label,
.water-location-fields .field > span {
  font-size: var(--ui-label-size);
}
.water-location-fields .hint {
  font-size: var(--ui-hint-size);
}
.water-location-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.water-location-choice {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 5px 8px;
  border: 1px solid var(--pill-line);
  border-radius: 9px;
  background: var(--pill-bg);
  color: var(--pill-text);
  cursor: pointer;
}
.water-location-choice:has(input:checked) {
  border-color: var(--pill-blue);
  background: color-mix(in srgb, var(--pill-blue) 14%, var(--pill-bg));
}
.water-location-choice input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  margin: 0;
  accent-color: var(--pill-blue);
}
.water-location-fields input[readonly] {
  opacity: 0.85;
}
.water-location-fields select:disabled {
  opacity: 0.5;
}
.water-location-fields [hidden] {
  display: none !important;
}

/* Shared panel typography follows the compact mobile form design. */
.app-surface {
  --surface-accent: var(--pill-green);
  --row-band: color-mix(in srgb, var(--surface-accent) 7%, var(--card));
  font-family: var(--ui-font-family);
}
.app-surface input,
.app-surface select,
.app-surface textarea,
.app-surface button {
  font-family: inherit;
}
.app-surface[data-form="water"],
.app-surface [data-form="water"] {
  --surface-accent: var(--pill-blue);
  --row-band: color-mix(in srgb, var(--surface-accent) 7%, var(--card));
}
.app-surface h2,
.app-surface .h2row > b {
  color: var(--heading-ink);
  font-size: var(--ui-heading-size);
  font-weight: 600;
}
.app-surface .field {
  gap: 4px;
  margin-bottom: 10px;
}
.app-surface .field > label {
  color: var(--surface-accent);
  font-size: var(--ui-label-size);
  font-weight: 600;
}
.app-surface .field > label.heading-label {
  color: var(--heading-ink);
}
.app-surface .hint {
  font-size: var(--ui-hint-size);
}
.mobile-form input:not([type="checkbox"]),
.mobile-form select,
.mobile-form textarea,
#admBox input:not([type="checkbox"]),
#admBox select,
#admBox textarea {
  padding: 8px 10px;
  min-height: var(--ui-control-height);
  /* 16px avoids iOS focus zoom while labels/hints stay compact. */
  font-size: 16px;
}
.mobile-form textarea,
#admBox textarea {
  min-height: 64px;
}
.mobile-form .scan-btn {
  min-height: var(--ui-control-height);
  min-width: 66px;
  font-size: var(--ui-label-size);
  font-weight: 600;
}
.mobile-form .water-location-fields .field {
  margin-bottom: 0;
}

.mobile-form .switch button,
#admBox .switch button {
  padding: 8px 10px;
  min-height: var(--ui-control-height);
  font-size: var(--ui-label-size);
  font-weight: 600;
}

.app-surface .mini {
  font-size: var(--ui-hint-size);
}
#admBox .status {
  font-size: var(--ui-label-size);
}
.app-surface .btn:not(.xs, .tiny) {
  min-height: var(--ui-control-height);
  padding: 8px 10px;
  font-size: var(--ui-label-size);
  font-weight: 600;
}
.app-surface .chip.on {
  color: var(--pill-green);
}
.app-surface th,
#admBox th,
.etable th {
  color: var(--heading-ink);
  font-weight: 600;
}

/* Optional Elect details use the same compact vocabulary as Water, with green accents. */
.elect-installation-builder {
  min-width: 0;
  margin: 4px 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.elect-installation-builder > legend {
  cursor: default;
  color: var(--pill-green);
  font-size: var(--ui-label-size);
  font-weight: 600;
}
.elect-installation-fields {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}
.elect-detail-group {
  grid-column: 1 / -1;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.elect-detail-heading {
  margin-bottom: 6px;
  color: var(--pill-green);
  font-size: var(--ui-label-size);
  font-weight: 600;
}
.elect-detail-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.elect-detail-body > .field {
  min-width: 0;
  margin: 0;
  grid-column: 1 / -1;
}
.elect-phase-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.elect-phase-grid .field {
  min-width: 0;
  margin: 0;
}
.elect-choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.elect-choice {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 140px;
  padding: 6px 8px;
  min-height: 40px;
  border: 1px solid var(--pill-line);
  border-radius: 9px;
  background: var(--pill-bg);
  color: var(--pill-text);
  cursor: pointer;
  font-size: var(--ui-label-size);
}
.elect-choice:has(input:checked) {
  border-color: var(--pill-green);
  background: color-mix(in srgb, var(--pill-green) 14%, var(--pill-bg));
}
.elect-choice input[type="checkbox"] {
  appearance: auto;
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--pill-green);
  flex: 0 0 auto;
}
.elect-detail-group [hidden] {
  display: none !important;
}
.elect-phase-grid input {
  min-width: 0;
}

body.embedded-seal-scanner {
  margin: 0;
  padding: 0;
  overflow: hidden;
}
body.embedded-seal-scanner > .wrap {
  display: none;
}
body.embedded-seal-scanner #dlg {
  padding: 4px;
}
body.embedded-seal-scanner #dlg .panel {
  width: 100%;
  height: calc(100svh - 8px);
  max-height: none;
  margin: 0;
}

.water-installation-type-choices {
  flex-wrap: nowrap;
}
.water-installation-type-choices .water-location-choice {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 5px 8px;
}

/* Three abbreviated panel choices keep their accessible full-name hint badges. */
.elect-panel-choices {
  flex-wrap: nowrap;
}
.elect-panel-choices .elect-choice {
  flex: 1 1 0;
  min-width: 0;
  justify-content: flex-start;
  gap: 5px;
  padding: 6px 5px;
}
.elect-option-hint {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 10px;
  color: var(--mut);
  flex: 0 0 auto;
}
.elect-option-hint:focus::after {
  content: attr(aria-label);
  position: absolute;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 6px;
  z-index: 5;
  max-width: 220px;
  transform: translateY(-32px);
}

.mobile-form .field[hidden],
.mobile-form .field > input[hidden],
.mobile-form .field > select[hidden] {
  display: none !important;
}

.elect-panel-choices .elect-option-hint {
  margin-left: auto;
}
.mobile-form[data-form="elect"] input[readonly] {
  background: color-mix(in srgb, var(--pill-green) 8%, var(--pill-bg));
}

/* Fixed tracks keep orphan checklist items aligned with the row above. */
.mobile-form .elect-choice-group:not(.elect-panel-choices),
.mobile-form .water-location-choices:not(.water-installation-type-choices) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.mobile-form .elect-choice,
.mobile-form .water-location-choice {
  min-width: 0;
}
.mobile-form .elect-choice span:not(.elect-option-hint),
.mobile-form .water-location-choice span {
  overflow-wrap: anywhere;
}

.mobile-form-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.mobile-form-heading-row label {
  margin: 0;
}
.troubleshooting-toggle {
  margin-left: auto;
  min-height: 32px;
  white-space: nowrap;
}
.troubleshooting-feedback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 0 0 8px;
}
#troubleshootingStatus {
  line-height: 1.35;
  overflow-wrap: anywhere;
}
#troubleshootingStatus[data-kind="good"] {
  color: var(--surface-accent, var(--pill-green));
}
#troubleshootingStatus[data-kind="warn"] {
  color: #b45309;
}
body:not(.light) #troubleshootingStatus[data-kind="warn"] {
  color: #fbbf24;
}
.troubleshooting-matches {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  max-height: 200px;
  overflow: auto;
}
.troubleshooting-match {
  border: 1px solid var(--pill-line);
  border-radius: 9px;
  background: var(--pill-bg);
  color: var(--pill-text);
  padding: 8px;
  text-align: left;
  font-size: var(--ui-label-size);
  cursor: pointer;
}
.troubleshooting-match:focus {
  outline: 2px solid var(--surface-accent, var(--pill-green));
}

.troubleshooting-feedback.hidden,
.troubleshooting-matches.hidden {
  display: none !important;
}

.troubleshooting-match {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.35;
  min-height: 36px;
}

.water-location-fields [data-water-field="installLocationOther"] {
  grid-column: 1 / -1;
}

/* Compact optional old-meter details and one-handed ratio shortcut. */
.old-meter-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.old-meter-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.old-meter-heading {
  color: var(--surface-accent, var(--pill-green));
  font-size: var(--ui-label-size);
}
.old-meter-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.old-meter-fields[hidden] {
  display: none;
}
.ct-ratio-input-row {
  align-items: center;
}
.old-meter-section:has(> .old-meter-fields[hidden]) {
  padding: 4px 10px;
}
.old-meter-toggle {
  border-color: var(--surface-accent, var(--pill-green));
  margin: 0;
  min-height: 32px;
}
.ct-ratio-shortcut {
  flex-shrink: 0;
  margin: 0;
  min-height: 32px;
}
.field:has(input[readonly]) .ct-ratio-shortcut {
  opacity: 0.5;
  pointer-events: none;
}
@media (max-width: 480px) {
  .old-meter-fields {
    grid-template-columns: 1fr;
  }
}

#dataSld[hidden] {
  display: none !important;
}

/* Scanner debug expands the workspace while keeping success/status geometry fixed. */
#dlg.scanner-debug {
  padding: 12px;
}
#dlg.scanner-debug .panel {
  max-width: 920px;
  height: min(96svh, 900px);
  max-height: calc(100svh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.scanner-camera {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.scanner-camera label {
  margin: 0;
}
.scanner-debug-settings {
  min-width: 0;
}
#dlg .scanner-debug-settings summary {
  min-height: 38px;
  cursor: pointer;
  width: fit-content;
}
.scanner-settings-body {
  display: grid;
  gap: 8px;
  padding-top: 8px;
}
#dlg.scanner-debug .vwrap {
  height: clamp(180px, 32svh, 300px);
}
@media (min-width: 760px) {
  #dlg.scanner-debug .panel {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(250px, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }
  #dlg.scanner-debug .hd {
    grid-column: 1 / -1;
  }
  #dlg.scanner-debug .scanner-fixed {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  #dlg.scanner-debug .vwrap {
    height: auto;
    flex: 1 1 auto;
    min-height: 120px;
  }
  #dlg.scanner-debug .scanner-status,
  #dlg.scanner-debug .scanner-camera {
    flex: 0 0 auto;
  }
  #dlg.scanner-debug .scanner-body {
    grid-column: 2;
    grid-row: 2 / 4;
    border-left: 1px solid var(--line);
  }
  #dlg.scanner-debug .scanner-bottom-controls {
    grid-column: 1;
    grid-row: 3;
  }
  #dlg.scanner-debug .scanner-footer {
    grid-column: 1 / -1;
    grid-row: 4;
  }
}

#dlg.scanner-debug .scanner-instruction {
  display: none;
}
#dlg.scanner-debug .scanner-toolbar .pill {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.76rem;
}
#dlg.scanner-debug #bScanResume {
  min-width: 108px;
}

/* Scanned fields remain visible but guarded until an explicit Edit. */
.scan-btn.scan-edit {
  background: #fff2cf;
  color: #7a4b08;
  border-color: #d69b2d;
}
body:not(.light) .scan-btn.scan-edit {
  background: rgba(214, 155, 45, 0.18);
  color: #f8d68b;
}

.shared-fields {
  margin: 12px 0;
}
.shared-field-row {
  display: grid;
  grid-template-columns: 130px 1fr 2fr;
  gap: 8px;
  margin: 10px 0;
  align-items: start;
}
.shared-field-row label {
  font-size: 0.8rem;
}
.shared-field-row textarea {
  min-height: 54px;
}
.shared-field-row code {
  overflow-wrap: anywhere;
  font-size: 0.75rem;
  padding-top: 20px;
}
@media (max-width: 600px) {
  .shared-field-row {
    grid-template-columns: 1fr;
  }
  .shared-field-row code {
    padding-top: 0;
  }
}

/* Water controls are neutral until activated. Scan keeps the shared red treatment. */
.app-surface[data-form="water"] .pill:not(.red, .green, .blue) {
  background: var(--pill-bg);
}
.app-surface[data-form="water"] .pill.blue[aria-pressed="true"] {
  background: color-mix(in srgb, var(--pill-blue) 14%, var(--pill-bg));
}

.app-surface[data-form="water"] .old-meter-toggle[aria-expanded="true"] {
  background: color-mix(in srgb, var(--pill-blue) 14%, var(--pill-bg));
}

/* Explicit action pills remain neutral until a real toggle/expanded state is active. */
body button.pill.green:not([aria-pressed="true"]):not([aria-expanded="true"]),
body.light button.pill.green:not([aria-pressed="true"]):not([aria-expanded="true"]),
body .pill[data-inactive-outline]:not([aria-pressed="true"]):not([aria-expanded="true"]),
body.light .pill[data-inactive-outline]:not([aria-pressed="true"]):not([aria-expanded="true"]) {
  background: var(--pill-bg);
  border-color: var(--pill-green);
  color: var(--pill-green);
}

.mobile-form-heading-row {
  flex-wrap: wrap;
}
.mobile-form-heading-row > label {
  margin-right: auto;
}
.elect-pairing-feedback {
  margin-top: 5px;
  line-height: 1.35;
  color: var(--mut);
}
.elect-pairing-feedback[data-kind="good"] {
  color: var(--pill-green);
}
.elect-pairing-feedback[data-kind="warn"] {
  color: var(--pill-amber, #b45309);
}
.device-lookup-dialog {
  padding: 0;
  width: min(820px, calc(100vw - 24px));
  max-height: 88dvh;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
}
.device-lookup-dialog .data-dialog-header,
.device-lookup-dialog .data-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
}
.device-lookup-dialog .data-dialog-header {
  border-bottom: 1px solid var(--line);
}
.device-lookup-dialog .data-dialog-header h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--heading-ink);
}
.device-lookup-dialog .data-dialog-body {
  padding: 14px 16px;
  max-height: 64dvh;
  overflow: auto;
}
.device-lookup-dialog .data-dialog-footer {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}
.device-lookup-dialog .data-lookup-review {
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}
.device-lookup-dialog .data-lookup-review > div {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.device-lookup-pages {
  justify-content: space-between;
  margin-bottom: 8px;
}
#electPairingConfirmChange {
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* Pending review has priority over the neutral green action-pill outline. */
body .pill[data-review-pending="true"],
body.light .pill[data-review-pending="true"] {
  border-color: var(--pill-red) !important;
  color: var(--pill-red) !important;
  background: var(--pill-bg) !important;
}
.data-strict-import {
  display: flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
}
.data-strict-import input {
  width: auto;
  margin: 0;
}
