:root {
  color-scheme: dark;
  --bg: #05090d;
  --panel: #071017;
  --panel-2: #09151c;
  --line: #123641;
  --line-bright: #1b6472;
  --text: #d7f5f7;
  --muted: #71929a;
  --cyan: #58efe8;
  --blue: #4b8eff;
  --violet: #9b91ff;
  --danger: #ff6c75;
  --shadow: 0 20px 60px rgba(0,0,0,.48);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  overflow: hidden;
}
button, input { font: inherit; }
button { color: inherit; }

.app-shell { height: 100%; display: flex; flex-direction: column; }
.topbar {
  height: 74px;
  flex: 0 0 74px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #08131a 0%, #050c11 100%);
  box-shadow: 0 8px 30px rgba(0,0,0,.28);
  position: relative;
  z-index: 1000;
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: .5;
}

.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid var(--cyan); color: var(--cyan);
  border-radius: 50%; font-weight: 900; font-size: 14px;
  box-shadow: 0 0 22px rgba(88,239,232,.14), inset 0 0 16px rgba(88,239,232,.06);
}
.brand-title { font-size: 13px; letter-spacing: .14em; font-weight: 800; white-space: nowrap; }
.brand-sub { margin-top: 4px; color: var(--muted); font-size: 10px; letter-spacing: .12em; }
.top-stats { display: flex; align-items: stretch; gap: 10px; }
.top-stat {
  min-width: 110px; padding: 7px 10px;
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center;
}
.top-stat span { color: var(--muted); font-size: 9px; letter-spacing: .14em; }
.top-stat strong { margin-top: 4px; color: var(--cyan); font-size: 12px; }

.workspace { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 318px minmax(0, 1fr); }
.sidebar {
  min-height: 0; overflow: auto; background: rgba(5,12,17,.98);
  border-right: 1px solid var(--line); position: relative; z-index: 900;
}
.panel-section { padding: 16px; border-bottom: 1px solid rgba(18,54,65,.72); }
.section-head { display: flex; justify-content: space-between; align-items: center; }
.section-kicker { color: var(--muted); font-size: 10px; letter-spacing: .16em; font-weight: 700; }
.text-button {
  background: transparent; border: 0; padding: 0; color: var(--cyan); cursor: pointer; font-size: 10px;
}
.text-button:hover { text-shadow: 0 0 10px rgba(88,239,232,.45); }

.search-wrap { position: relative; margin-top: 10px; }
.search-wrap input {
  width: 100%; height: 42px; padding: 0 38px 0 12px;
  border: 1px solid var(--line-bright); outline: none; background: #061117;
  color: var(--text); border-radius: 8px; box-shadow: inset 0 0 18px rgba(0,0,0,.2);
}
.search-wrap input:focus { border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(88,239,232,.18), 0 0 26px rgba(88,239,232,.08); }
.search-wrap input::placeholder { color: #4e6f77; }
.icon-button {
  position: absolute; top: 7px; right: 7px; width: 28px; height: 28px; border-radius: 6px;
  background: transparent; border: 0; color: var(--muted); font-size: 20px; cursor: pointer;
}
.icon-button:hover { color: var(--text); background: #0a1c23; }

.search-results {
  position: absolute; top: 48px; left: 0; right: 0; max-height: 400px; overflow: auto;
  background: #061017; border: 1px solid var(--line-bright); border-radius: 8px; z-index: 2000; box-shadow: var(--shadow);
}
.search-result {
  min-height: 58px; display: grid; grid-template-columns: 34px 1fr auto; gap: 9px; align-items: center;
  padding: 8px 10px; border-bottom: 1px solid rgba(18,54,65,.55); cursor: pointer;
}
.search-result:last-child { border-bottom: 0; }
.search-result:hover, .search-result:focus { background: #0a1d24; outline: none; }
.result-dot { width: 30px; height: 30px; border: 1px solid var(--line-bright); border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: #08151a; }
.result-dot img { width: 100%; height: 100%; object-fit: cover; }
.result-name { font-weight: 800; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-sub { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.result-type { color: var(--cyan); font-size: 9px; }

.filter-list { margin-top: 10px; display: grid; gap: 8px; }
.checkbox-row {
  display: grid; grid-template-columns: 18px 1fr; grid-template-rows: auto auto; column-gap: 8px; padding: 8px 9px;
  border: 1px solid transparent; border-radius: 7px; cursor: pointer;
}
.checkbox-row:hover { background: #08171e; border-color: var(--line); }
.checkbox-row input { grid-row: 1 / span 2; width: 16px; height: 16px; accent-color: var(--cyan); margin-top: 2px; }
.checkbox-name { font-size: 10px; font-weight: 800; }
.checkbox-code { margin-top: 3px; color: var(--muted); font-size: 8px; }

.telemetry-grid { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.telemetry-grid > div { padding: 10px; border: 1px solid var(--line); background: #07131a; border-radius: 7px; }
.telemetry-grid span { display: block; color: var(--muted); font-size: 8px; letter-spacing: .12em; }
.telemetry-grid strong { display: block; margin-top: 5px; color: var(--cyan); font-size: 18px; }
.legend-section p { color: #76929a; font-size: 9px; line-height: 1.6; margin: 10px 0 0; }
code { color: var(--cyan); }

.map-stage { min-width: 0; min-height: 0; position: relative; background: #071017; }
#map { position: absolute; inset: 0; }

/* Dark command-center treatment on the actual OSM raster tiles. */
.leaflet-tile-pane { filter: brightness(.48) contrast(1.18) saturate(.62) hue-rotate(142deg); }
.leaflet-container { background: #04090d; font-family: inherit; }
.leaflet-control-zoom { border: 1px solid var(--line-bright) !important; box-shadow: 0 8px 30px rgba(0,0,0,.4) !important; }
.leaflet-control-zoom a {
  width: 34px !important; height: 34px !important; line-height: 32px !important;
  color: var(--cyan) !important; background: rgba(5,15,19,.92) !important; border-color: var(--line) !important;
}
.leaflet-control-zoom a:hover { background: #0a1d24 !important; color: #fff !important; }
.leaflet-control-attribution {
  background: rgba(5,10,14,.82) !important; color: #68848c !important;
  border: 1px solid rgba(18,54,65,.72); border-radius: 4px 0 0 0;
}
.leaflet-control-attribution a { color: #86c4ca !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #061117; color: var(--text); }
.leaflet-popup-content-wrapper { border: 1px solid var(--line-bright); box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 12px 14px; }

.map-hud {
  position: absolute; z-index: 800; pointer-events: none;
  padding: 9px 10px; background: rgba(4,12,16,.72); border: 1px solid rgba(27,100,114,.72); backdrop-filter: blur(5px);
  box-shadow: 0 12px 35px rgba(0,0,0,.26);
}
.top-left { top: 14px; left: 14px; min-width: 192px; }
.top-right { top: 14px; right: 14px; display: flex; gap: 7px; align-items: center; }
.bottom-left { left: 14px; bottom: 28px; }
.hud-line { display: flex; justify-content: space-between; gap: 18px; font-size: 9px; line-height: 1.7; }
.hud-line span { color: var(--muted); }
.hud-line strong { color: var(--cyan); }
.hud-button, .zoom-readout {
  pointer-events: auto; border: 1px solid var(--line-bright); background: rgba(5,15,19,.92); color: var(--cyan);
  height: 30px; padding: 0 10px; border-radius: 5px; font-size: 9px; letter-spacing: .1em; cursor: pointer;
}
.hud-button:hover { background: #0a1d24; }
.zoom-readout { display: grid; place-items: center; cursor: default; }
.status-hud { display: flex; align-items: center; gap: 7px; font-size: 9px; color: var(--cyan); }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 14px rgba(88,239,232,.8); }

.wh-marker {
  width: 34px; height: 34px; border-radius: 50%; position: relative; display: grid; place-items: center;
  background: #07141a; border: 2px solid var(--marker, var(--cyan));
  box-shadow: 0 0 0 2px rgba(2,9,12,.9), 0 0 14px color-mix(in srgb, var(--marker, var(--cyan)) 50%, transparent);
}
.wh-marker::before { content: ""; position: absolute; inset: -6px; border: 1px solid color-mix(in srgb, var(--marker, var(--cyan)) 35%, transparent); border-radius: 50%; }
.wh-marker img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.wh-marker.is-selected { transform: scale(1.18); box-shadow: 0 0 0 2px rgba(2,9,12,.95), 0 0 23px color-mix(in srgb, var(--marker, var(--cyan)) 75%, transparent); }
.marker-label {
  margin-left: 22px; margin-top: -3px; white-space: nowrap; color: #d5f6f7; font-size: 9px; text-shadow: 0 1px 4px #000, 0 0 8px #000; pointer-events: none;
}

.modal[hidden] { display: none !important; }
.modal { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(1,6,9,.78); backdrop-filter: blur(5px); }
.modal-window {
  position: relative; z-index: 1; width: min(760px, 100%); max-height: min(820px, calc(100vh - 40px)); overflow: auto;
  background: linear-gradient(180deg, #08161d 0%, #050d12 100%); border: 1px solid var(--line-bright); border-radius: 12px;
  box-shadow: 0 30px 100px rgba(0,0,0,.72), 0 0 45px rgba(31,126,142,.11);
}
.modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 2; width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(4,11,15,.86); color: #8aadb5; font-size: 24px; cursor: pointer;
}
.modal-close:hover { color: #fff; border-color: var(--cyan); }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 0; }
.detail-main { padding: 22px; }
.detail-photo { width: 100%; height: 300px; object-fit: cover; display: block; border-right: 1px solid var(--line); background: #071017; }
.detail-type { color: var(--cyan); font-size: 9px; letter-spacing: .14em; }
.detail-name { margin-top: 6px; font-size: 24px; font-weight: 900; line-height: 1.1; }
.detail-id { margin-top: 7px; color: var(--muted); font-size: 10px; }
.detail-address { margin-top: 18px; color: #b4d0d5; font-size: 11px; line-height: 1.55; }
.detail-coords { margin-top: 7px; color: #65848d; font-size: 9px; }
.info-table { margin-top: 18px; border-top: 1px solid var(--line); }
.info-row { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid rgba(18,54,65,.62); font-size: 10px; }
.info-key { color: var(--muted); }
.info-value { color: var(--text); text-align: right; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 15px; }
.pill { padding: 5px 7px; border: 1px solid var(--line); border-radius: 999px; font-size: 8px; color: #9bb9bf; background: #07141a; }
.pill.hot { border-color: rgba(88,239,232,.45); color: var(--cyan); }
.pill.violet { border-color: rgba(155,145,255,.42); color: #bbb4ff; }
.detail-section { margin-top: 20px; }
.detail-section-title { color: var(--muted); font-size: 9px; letter-spacing: .13em; margin-bottom: 8px; }
.process-list { display: grid; gap: 8px; }
.process-item { padding: 9px; border: 1px solid var(--line); background: #07131a; border-radius: 7px; }
.process-name { font-size: 10px; font-weight: 800; }
.process-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.meta-chip { padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; font-size: 8px; color: var(--muted); }
.media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.media-item { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; aspect-ratio: 16 / 10; background: #071017; }
.media-item img { width: 100%; height: 100%; display: block; object-fit: cover; }
.detail-side { padding: 18px; border-left: 1px solid var(--line); background: rgba(4,11,15,.45); }
.side-kicker { color: var(--muted); font-size: 8px; letter-spacing: .13em; }
.side-big { margin-top: 7px; color: var(--cyan); font-size: 18px; font-weight: 800; }
.source-file { margin-top: 16px; color: #66858c; font-size: 8px; line-height: 1.55; word-break: break-word; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); z-index: 4000;
  opacity: 0; pointer-events: none; transition: .2s ease;
  padding: 9px 13px; border: 1px solid var(--line-bright); background: rgba(5,14,18,.94); color: var(--cyan); border-radius: 7px; font-size: 9px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  body { overflow: auto; }
  .app-shell { min-height: 100%; height: auto; }
  .topbar { height: auto; min-height: 72px; align-items: flex-start; padding: 12px; gap: 12px; flex-wrap: wrap; }
  .top-stats { width: 100%; overflow-x: auto; }
  .top-stat { min-width: 96px; }
  .workspace { grid-template-columns: 1fr; min-height: calc(100vh - 120px); }
  .sidebar { order: 2; border-right: 0; border-top: 1px solid var(--line); max-height: none; }
  .map-stage { order: 1; height: 64vh; min-height: 480px; }
  .top-left { top: 10px; left: 10px; }
  .top-right { top: 10px; right: 10px; }
  .bottom-left { left: 10px; bottom: 32px; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-photo { height: 240px; border-right: 0; border-bottom: 1px solid var(--line); }
  .detail-side { border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 560px) {
  .brand-title { font-size: 11px; }
  .brand-sub { font-size: 8px; }
  .brand-mark { width: 36px; height: 36px; }
  .top-stat { min-width: 88px; }
  .map-stage { height: 58vh; min-height: 420px; }
  .map-hud.top-left { display: none; }
  .modal { padding: 10px; }
  .detail-main { padding: 16px; }
  .detail-name { font-size: 20px; }
  .media-grid { grid-template-columns: 1fr; }
}

/* Ozon warehouse image markers on Leaflet map:
 *  always display a centered square crop, then round it. */

.wh-marker {
  position: relative;
  overflow: hidden;
}

.wh-marker-image {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 50%;
}

.wh-marker-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
}
