:root {
  color-scheme: dark;
  --bg: #070b12;
  --panel: #111827;
  --line: #263244;
  --text: #e8eef8;
  --muted: #93a4b8;
  --cyan: #8ee7f3;
  --red: #ef4444;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}
.login-locked header,
.login-locked main,
.login-locked .modal {
  display: none;
}
.login-screen {
  display: none;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 30%, rgba(142, 231, 243, 0.13), transparent 34%),
    #050810;
}
.login-locked .login-screen {
  display: grid;
}
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid rgba(142, 231, 243, 0.28);
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.94);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}
.login-card h1 {
  font-size: 34px;
}
.login-card input,
.login-card button {
  width: 100%;
}
.login-error {
  min-height: 18px;
  color: #fca5a5;
  font-size: 13px;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #0b111c;
}
h1, h2, p { margin: 0; }
h1 { font-size: 28px; }
p { color: var(--muted); margin-top: 4px; }
.auth {
  display: flex;
  gap: 8px;
}
#token,
#saveToken {
  display: none;
}
input, button {
  height: 38px;
  border: 1px solid var(--line);
  background: #141d2b;
  color: var(--text);
  padding: 0 12px;
  border-radius: 6px;
}
button { cursor: pointer; }
.primary {
  border-color: rgba(142, 231, 243, 0.55);
  background: #123047;
  color: var(--cyan);
}
.admin-action,
.top-action {
  display: none;
  border-color: rgba(142, 231, 243, 0.45);
  color: var(--cyan);
}
.admin-action.visible,
.top-action.visible {
  display: inline-flex;
  align-items: center;
}
.danger-action {
  border-color: rgba(239, 68, 68, 0.55);
  color: #fecaca;
  background: #35151a;
}
main {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: 1fr;
  grid-template-areas:
    "devices map";
  gap: 12px;
  padding: 12px;
  align-items: stretch;
  height: calc(100vh - 72px);
  min-height: 520px;
  overflow: hidden;
  transition: grid-template-columns 0.2s ease;
}
main.viewer-layout {
  grid-template-columns: 1fr;
  grid-template-areas: "map";
}

body.viewer-app:not(.events-page) {
  overflow: hidden;
}

body.viewer-app header {
  display: none;
}

body.viewer-app:not(.events-page) main {
  height: 100vh;
  padding: 0;
  display: block;
}

body.viewer-app.events-page {
  overflow: auto;
}

body.viewer-app.events-page main.events-main {
  padding: 10px;
}

body.viewer-app .map-panel {
  height: 100vh;
  border-radius: 0;
  border: 0;
}

body.viewer-app .map-head {
  display: none;
}

body.viewer-app #openLayersMap,
body.viewer-app #mapFallback {
  height: 100vh;
  border-radius: 0;
}
body.admin-app:not(.events-page) {
  overflow: hidden;
}
body.admin-app header,
body.admin-app:not(.events-page) #devicesPanel,
body.admin-app:not(.events-page) .map-head,
body.admin-app:not(.events-page) #trackSummary {
  display: none !important;
}
body.admin-app:not(.events-page) main {
  height: 100vh;
  min-height: 0;
  padding: 0;
  display: block;
}
body.admin-app:not(.events-page) .map-panel {
  height: 100vh;
  border: 0;
  border-radius: 0;
  padding: 0;
}
body.admin-app:not(.events-page) #openLayersMap,
body.admin-app:not(.events-page) #mapFallback {
  height: 100vh;
  border-radius: 0;
}
body.admin-app .map-compass {
  transform: none;
  transform-origin: right bottom;
}
body.admin-app.events-page {
  overflow: auto;
}
body.admin-app.events-page header {
  display: none !important;
}
body.admin-app.events-page main.events-main {
  padding: 8px;
}
body.admin-app.events-page .events-full-panel {
  border-radius: 0;
}
html.admin-android {
  height: 100%;
  overflow: hidden;
}
html.admin-android body.admin-app {
  height: 100%;
  overflow: hidden;
}
html.admin-android:has(body.events-page),
html.admin-android body.admin-app.events-page {
  height: auto;
  min-height: 100%;
  overflow: auto;
}
html.admin-android body.admin-app.events-page main.events-main {
  height: auto;
  min-height: 100vh;
  overflow: visible;
  padding: 10px 10px 24px;
  display: block;
}
html.admin-android body.admin-app.events-page .events-full-panel {
  overflow: visible;
}
html.admin-android body.admin-app:not(.events-page) header {
  display: none !important;
}
html.admin-android body.admin-app:not(.events-page) main {
  height: 100vh;
  min-height: 0;
  padding: 0;
  display: block;
  overflow: hidden;
  position: relative;
}
html.admin-android body.admin-app:not(.events-page) main.devices-collapsed {
  display: block;
}
html.admin-android body.admin-app:not(.events-page) #devicesPanel {
  display: flex !important;
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 10px;
  width: min(390px, calc(100vw - 84px));
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  z-index: 30;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}
html.admin-android body.admin-app:not(.events-page) #devices,
html.admin-android body.admin-app:not(.events-page) #devicesPager {
  touch-action: pan-y;
  overscroll-behavior: contain;
}
html.admin-android body.admin-app:not(.events-page) #toggleDevicesPanel {
  position: fixed;
  left: 0;
  top: 50vh;
  transform: translateY(-50%);
  z-index: 60;
  width: 42px;
  height: 58px;
  border-radius: 0 12px 12px 0;
  border-left: 0;
  background: rgba(20, 32, 50, 0.94);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.38);
}
html.admin-android body.admin-app:not(.events-page) #devicesPanel.collapsed {
  width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  pointer-events: none;
}
html.admin-android body.admin-app:not(.events-page) #devicesPanel.collapsed .panel-head {
  display: block;
}
html.admin-android body.admin-app:not(.events-page) #devicesPanel.collapsed #toggleDevicesPanel {
  pointer-events: auto;
}
html.admin-android body.admin-app:not(.events-page) .map-head {
  display: none !important;
}
html.admin-android body.admin-app:not(.events-page) #trackSummary {
  display: none !important;
}
html.admin-android body.admin-app:not(.events-page) .map-panel {
  height: 100vh;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  position: relative;
  z-index: 1;
}
html.admin-android body.admin-app:not(.events-page) #openLayersMap,
html.admin-android body.admin-app:not(.events-page) #mapFallback {
  flex: 1 1 auto;
  height: 100vh;
  min-height: 0;
  border-radius: 0;
}
html.admin-android body.admin-app.events-page {
  height: 100%;
  overflow: auto;
}
html.admin-android body.admin-app.events-page main.events-main {
  min-height: 100vh;
  padding: 10px 10px 24px;
}
html.admin-android .modal-card {
  top: 12px;
  right: 12px;
  left: auto;
  max-height: calc(100vh - 24px);
}
main.devices-collapsed {
  grid-template-columns: 52px 1fr;
}
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 12px;
  min-height: 0;
}
.map-panel {
  grid-area: map;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
  overflow: hidden;
}
.devices-panel {
  grid-area: devices;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  transition: width 0.2s ease, padding 0.2s ease;
}
.devices-panel[hidden] {
  display: none;
}
.devices-panel.collapsed {
  width: 52px;
  padding: 10px 8px;
}
.devices-panel.collapsed h2,
.devices-panel.collapsed .devices,
.devices-panel.collapsed .pager {
  display: none;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.map-head {
  margin-bottom: 8px;
}
.map-admin-controls {
  display: none;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.map-admin-controls.visible {
  display: flex;
}
.map-admin-controls button {
  height: 30px;
  padding: 0 10px;
}
.map-admin-controls button.active {
  border-color: rgba(142, 231, 243, 0.9);
  background: #123047;
  color: #e8fbff;
  box-shadow: 0 0 0 1px rgba(142, 231, 243, 0.16);
}
.map-admin-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.map-admin-controls input {
  width: 16px;
  height: 16px;
  padding: 0;
}
.map-admin-controls select {
  height: 30px;
  min-width: 92px;
  padding: 0 8px;
  font-size: 13px;
}
.collapse-button {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  color: var(--cyan);
}
.devices {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  min-height: 32px;
}
.pager button {
  width: 34px;
  height: 30px;
  padding: 0;
}
.form-grid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.form-grid label {
  display: grid;
  gap: 5px;
}
.form-grid label span {
  color: var(--muted);
  font-size: 13px;
}
.coord-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
select {
  height: 38px;
  border: 1px solid var(--line);
  background: #141d2b;
  color: var(--text);
  padding: 0 12px;
  border-radius: 6px;
}
.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.form-grid .checkline {
  display: flex;
}
.checkline input {
  width: 18px;
  height: 18px;
  padding: 0;
}
.token-result {
  display: none;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(142, 231, 243, 0.45);
  border-radius: 7px;
  background: #07131f;
  color: var(--cyan);
  word-break: break-all;
  font-size: 13px;
}
.events {
  display: grid;
  gap: 10px;
}
.event, .device {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #0d1420;
}
.edit-device {
  width: 100%;
  height: 30px;
  margin-top: 8px;
  font-size: 13px;
}
.event strong, .device strong { color: var(--cyan); }
.meta { color: var(--muted); font-size: 13px; margin-top: 5px; }
.event-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.event-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  background: rgba(15, 23, 36, 0.92);
  color: #cbd5e1;
  font-size: 12px;
}
.event-badge.media.pending {
  border-color: rgba(250, 204, 21, 0.5);
  color: #fde68a;
}
.event-badge.media.complete {
  border-color: rgba(34, 197, 94, 0.5);
  color: #86efac;
}
.event-badge.duplicate {
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}
.status.alarm { color: #fca5a5; }
.status.online { color: #86efac; }
.status.stale { color: #fde68a; }
.status.offline,
.status.silent { color: #cbd5e1; }
.event img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: #030712;
  margin-top: 8px;
}
audio {
  width: 100%;
  margin-top: 8px;
}
#openLayersMap,
#mapFallback {
  width: 100%;
  flex: 1;
  height: 100%;
  min-height: 0;
  background:
    linear-gradient(rgba(38, 50, 68, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(38, 50, 68, 0.28) 1px, transparent 1px),
    #070b12;
  background-size: 64px 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
#openLayersMap {
  overflow: hidden;
}
#mapFallback {
  display: none;
}
.track-summary {
  position: absolute;
  left: 24px;
  bottom: 24px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: min(680px, calc(100% - 48px));
  padding: 9px 12px;
  border: 1px solid rgba(142, 231, 243, 0.3);
  border-radius: 8px;
  background: rgba(7, 11, 18, 0.78);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
.track-summary strong {
  color: var(--cyan);
}
.map-compass {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 5;
  width: 150px;
  height: 176px;
  pointer-events: none;
  color: rgba(232, 238, 248, 0.88);
  text-align: center;
  text-shadow: 0 2px 7px rgba(0, 0, 0, 0.78);
}
.compass-dial {
  position: relative;
  width: 136px;
  height: 136px;
  margin: 0 auto;
  border: 1px solid rgba(142, 231, 243, 0.22);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(142, 231, 243, 0.09) 0 3px, transparent 4px),
    radial-gradient(circle, rgba(7, 11, 18, 0.03) 0 42%, rgba(7, 11, 18, 0.16) 72%, rgba(7, 11, 18, 0.26) 100%);
  box-shadow:
    0 0 0 4px rgba(7, 11, 18, 0.05),
    0 14px 38px rgba(0, 0, 0, 0.16),
    inset 0 0 22px rgba(142, 231, 243, 0.08);
}
.compass-rings {
  position: absolute;
  inset: 13px;
  border: 1px solid rgba(232, 238, 248, 0.18);
  border-radius: 50%;
}
.compass-rings::before,
.compass-rings::after {
  content: "";
  position: absolute;
  inset: 23px;
  border: 1px solid rgba(142, 231, 243, 0.13);
  border-radius: 50%;
}
.compass-rings::after {
  inset: 34px;
  border-color: rgba(255, 255, 255, 0.10);
}
.compass-dir {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  color: rgba(232, 238, 248, 0.72);
}
.compass-dir.north,
.compass-dir.east,
.compass-dir.south,
.compass-dir.west {
  color: rgba(255, 255, 255, 0.92);
  font-size: 16px;
}
.compass-dir.north { top: 13px; left: 50%; color: rgba(142, 231, 243, 0.95); }
.compass-dir.east { top: 50%; left: calc(100% - 13px); }
.compass-dir.south { top: calc(100% - 13px); left: 50%; }
.compass-dir.west { top: 50%; left: 13px; }
.compass-dir.ne { top: 23px; left: calc(100% - 23px); }
.compass-dir.se { top: calc(100% - 23px); left: calc(100% - 23px); }
.compass-dir.sw { top: calc(100% - 23px); left: 23px; }
.compass-dir.nw { top: 23px; left: 23px; }
.compass-needle {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%) rotate(0deg);
  transform-origin: 50% 50%;
}
.compass-needle::before {
  content: "";
  position: absolute;
  left: -5px;
  bottom: -5px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 56px solid #ff1c24;
  filter: drop-shadow(0 0 7px rgba(255, 28, 36, 0.55));
}
.compass-needle::after {
  content: "";
  position: absolute;
  left: -4px;
  top: -5px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 39px solid rgba(232, 238, 248, 0.50);
}
.compass-center {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background: #ff1c24;
  box-shadow: 0 0 10px rgba(255, 28, 36, 0.54);
}
.compass-bearing {
  display: inline-block;
  margin-top: 7px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 28, 36, 0.45);
  border-radius: 999px;
  background: rgba(7, 11, 18, 0.52);
  color: #ff6b70;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}
.ol-viewport {
  background:
    linear-gradient(rgba(38, 50, 68, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(38, 50, 68, 0.28) 1px, transparent 1px),
    #070b12;
  background-size: 64px 64px;
}
.layer-switcher {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  display: flex;
  gap: 6px;
  padding: 6px;
  background: rgba(7, 11, 18, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(4px);
}
.layer-switcher button {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}
.layer-switcher button.active {
  border-color: var(--cyan);
  color: var(--cyan);
}
.pick-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1320;
}
.pick-panel.picking {
  border-color: rgba(142, 231, 243, 0.7);
  box-shadow: 0 0 0 1px rgba(142, 231, 243, 0.2) inset;
}
.pick-status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}
.modal.open {
  display: block;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(3px);
  pointer-events: auto;
}
.modal-card {
  position: absolute;
  top: 78px;
  right: 28px;
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 110px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0f1724;
  padding: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
  pointer-events: auto;
}
.token-modal-card {
  width: min(680px, calc(100vw - 32px));
}
.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 18px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.token-create {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 8px;
  margin-top: 12px;
}
.token-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.modal-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}
.token-section-title {
  margin-top: 4px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.token-section-title.muted-title {
  color: var(--muted);
}
.token-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.token-log-head select {
  width: 96px;
}
.access-admin-log {
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}
.server-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.server-tabs button {
  border-color: var(--line);
  background: #101827;
}
.server-tabs button.active {
  border-color: var(--cyan);
  background: #123d54;
  color: #dff8ff;
}
.server-tab-panel[hidden] {
  display: none;
}
.access-log-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.access-log-controls select {
  width: 96px;
}
.access-row {
  grid-template-columns: 170px 140px 170px 1fr;
}
.diagnostics-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) minmax(220px, 1.2fr);
  gap: 10px;
  margin-top: 14px;
}
.diagnostic-total,
.diagnostic-time {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1320;
  padding: 12px;
  font-weight: 700;
}
.diagnostic-total.ok { color: #86efac; border-color: rgba(134, 239, 172, 0.34); }
.diagnostic-total.warn { color: #fde68a; border-color: rgba(253, 230, 138, 0.34); }
.diagnostic-total.fail { color: #fca5a5; border-color: rgba(252, 165, 165, 0.34); }
.diagnostic-time { color: var(--muted); }
.diagnostics-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.diagnostic-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1320;
}
.diagnostic-row.ok { border-color: rgba(134, 239, 172, 0.22); }
.diagnostic-row.warn { border-color: rgba(253, 230, 138, 0.34); }
.diagnostic-row.fail { border-color: rgba(252, 165, 165, 0.42); }
.diagnostic-badge {
  border-radius: 999px;
  padding: 6px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  background: #152032;
}
.diagnostic-row.ok .diagnostic-badge { color: #86efac; }
.diagnostic-row.warn .diagnostic-badge { color: #fde68a; }
.diagnostic-row.fail .diagnostic-badge { color: #fca5a5; }
.profile-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  gap: 14px;
  margin-top: 14px;
}
.profile-side {
  display: grid;
  gap: 12px;
  align-content: start;
}
.profile-list-item {
  display: grid;
  gap: 4px;
  text-align: left;
  justify-content: stretch;
  border-color: var(--line);
  background: #0b1320;
}
.profile-list-item.active {
  border-color: var(--cyan);
  background: #123047;
}
.profile-list-item span {
  color: var(--muted);
  font-size: 12px;
}
.profile-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0b1320;
}
.profile-bulk-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #102033, #0b1320);
}
.profile-bulk-panel h3 {
  margin: 0;
}
.profile-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.profile-bulk-panel label {
  display: grid;
  gap: 5px;
}
.profile-bulk-panel label span {
  color: var(--muted);
  font-size: 12px;
}
.profile-bulk-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.profile-device-list {
  display: grid;
  gap: 6px;
  max-height: 300px;
  overflow: auto;
  padding-right: 4px;
}
.profile-device-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1724;
}
.profile-device-row:hover {
  border-color: rgba(125, 211, 252, 0.5);
}
.profile-device-row strong {
  display: block;
}
.profile-device-row em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
  margin-left: 6px;
}
.profile-device-row b {
  display: inline-block;
  width: fit-content;
  margin-top: 5px;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 800;
}
.profile-device-row.online b {
  color: #86efac;
  background: rgba(34, 197, 94, 0.16);
}
.profile-device-row.offline b {
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.13);
}
.profile-device-row small,
.profile-empty {
  color: var(--muted);
  font-size: 12px;
}
.profile-alarms {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.profile-alarm {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #0f1724;
}
.profile-alarm h3 {
  margin-top: 0;
}
.profile-alarm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
}
.profile-alarm-grid label {
  display: grid;
  gap: 5px;
}
.profile-alarm-grid span {
  color: var(--muted);
  font-size: 12px;
}
@media (max-width: 980px) {
  .profile-layout {
    grid-template-columns: 1fr;
  }
}
.maintenance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.maintenance-grid label {
  display: grid;
  gap: 5px;
}
.maintenance-grid label span {
  color: var(--muted);
  font-size: 13px;
}
.maintenance-grid .checkline {
  grid-column: 1 / -1;
}
.security-log {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.security-row {
  display: grid;
  grid-template-columns: 150px 120px 130px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0b1320;
  color: var(--muted);
  font-size: 12px;
}
.security-row strong {
  color: var(--cyan);
}
.security-row.warn strong {
  color: #fca5a5;
}
.token-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1320;
}
.token-item.disabled {
  opacity: 0.55;
}
.request-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.disable-token {
  height: 32px;
}
h3 {
  margin: 16px 0 0;
  font-size: 16px;
}
.events-page main.events-main {
  display: block;
  height: auto;
  min-height: calc(100vh - 72px);
  overflow: visible;
}
.events-full-panel {
  max-width: 1180px;
  margin: 0 auto;
  min-height: auto;
}
.events-toolbar {
  display: grid;
  grid-template-columns: 1fr 180px 180px 180px 160px;
  gap: 8px;
  margin-bottom: 12px;
}
.security-toolbar {
  grid-template-columns: 1fr 160px;
}
.update-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.update-form label {
  display: grid;
  gap: 6px;
}
.update-form label span {
  color: var(--muted);
  font-size: 13px;
}
.update-form .wide {
  grid-column: 1 / -1;
}
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #141d2b;
  color: var(--text);
  padding: 10px 12px;
  resize: vertical;
  font-family: Arial, sans-serif;
}
.update-actions {
  display: flex;
  gap: 8px;
}
.update-item {
  align-items: start;
}
.events-page .event {
  display: grid;
  gap: 4px;
}
.event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}
.event-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #0b1320;
  font-size: 13px;
}
.event-status.confirmed { color: #86efac; border-color: rgba(34, 197, 94, 0.45); }
.event-status.checking { color: #fde68a; border-color: rgba(250, 204, 21, 0.45); }
.event-status.false { color: #cbd5e1; opacity: 0.75; }
.event-status-select {
  height: 30px;
  font-size: 13px;
}
.events-page .event img {
  max-height: 420px;
}
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.health-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1420;
}
.health-card span {
  color: var(--muted);
  font-size: 13px;
}
.health-card strong {
  color: var(--text);
  font-size: 17px;
  overflow-wrap: anywhere;
}
.map-picking #openLayersMap {
  cursor: crosshair;
}
#openLayersMap.measuring {
  cursor: crosshair;
}
.map-picking .modal-backdrop {
  display: none;
}
.map-picking .modal-card {
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
}
.map-pick-hint {
  display: none;
  position: absolute;
  left: 24px;
  top: 58px;
  z-index: 5;
  padding: 10px 12px;
  border: 1px solid rgba(142, 231, 243, 0.65);
  border-radius: 8px;
  background: rgba(7, 11, 18, 0.88);
  color: var(--cyan);
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
.map-popup {
  position: relative;
  min-width: 260px;
  max-width: min(460px, calc(100vw - 42px));
  display: none;
  padding: 10px 12px;
  border: 1px solid rgba(142, 231, 243, 0.55);
  border-radius: 8px;
  background: rgba(7, 11, 18, 0.95);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.38);
  color: var(--text);
  font-size: 13px;
}
.map-popup.visible {
  display: block;
}
.map-popup strong {
  color: var(--cyan);
  padding-right: 24px;
}
.map-popup-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  padding: 0;
}
.map-popup-shot-link {
  display: block;
  margin-top: 9px;
  border: 1px solid rgba(142, 231, 243, 0.24);
  border-radius: 7px;
  overflow: hidden;
  background: #030712;
}
.map-popup-shot {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
}
.map-popup-media-wait {
  margin-top: 9px;
  padding: 10px;
  border: 1px dashed rgba(148, 163, 184, 0.32);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(15, 23, 36, 0.7);
}
.map-popup-audio {
  width: 100%;
  margin-top: 8px;
}
.map-picking .map-pick-hint {
  display: block;
}
@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
    grid-template-areas:
      "devices"
      "map";
    grid-template-rows: minmax(170px, 34vh) 1fr;
    height: auto;
    min-height: calc(100vh - 72px);
    overflow: visible;
  }
  main.viewer-layout {
    grid-template-areas: "map";
    grid-template-rows: minmax(420px, calc(100vh - 120px));
  }
  header { flex-direction: column; align-items: stretch; }
  #openLayersMap,
  #mapFallback {
    min-height: 420px;
  }
  .modal-card {
    top: 16px;
    right: 16px;
    left: 16px;
    width: auto;
  }
  .coord-grid,
  .pick-panel,
  .token-create,
  .events-toolbar {
    grid-template-columns: 1fr;
  }
  .security-row {
    grid-template-columns: 1fr;
  }
}
