:root {
  --ink: #01001c;
  --ink-soft: rgba(1, 0, 28, 0.84);
  --panel: rgba(10, 12, 28, 0.91);
  --panel-solid: #101322;
  --accent: #ff5c00;
  --text: #f7f8ff;
  --muted: #aeb3c6;
  --line: rgba(255, 255, 255, 0.14);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
  font: inherit;
}

#map {
  z-index: 0;
}

/* Critical Leaflet layout fallback. Keeps tiles positioned even if CDN CSS is delayed. */
.leaflet-container {
  overflow: hidden;
  background: var(--ink);
  outline-offset: 1px;
  touch-action: none;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container {
  font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
  border: 0;
  filter: inherit;
  visibility: hidden;
}

.leaflet-tile-loaded {
  visibility: inherit;
}

.leaflet-map-pane {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control {
  float: left;
  clear: both;
}

.leaflet-right .leaflet-control {
  float: right;
}

.leaflet-top .leaflet-control {
  margin-top: 10px;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 10px;
}

.leaflet-left .leaflet-control {
  margin-left: 10px;
}

.leaflet-right .leaflet-control {
  margin-right: 10px;
}

.status-panel {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 800;
  width: min(330px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
p,
dl {
  margin: 0;
}

h1 {
  color: var(--text);
  font-size: 22px;
  font-weight: 780;
  letter-spacing: 0;
}

.current-time {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

h2 {
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.heartbeat {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2ecc71;
  box-shadow: 0 0 0 5px rgba(46, 204, 113, 0.14);
}

.heartbeat.offline {
  background: #8a8e9c;
  box-shadow: 0 0 0 5px rgba(138, 142, 156, 0.18);
}

.status-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  font-size: 13px;
}

.status-list div,
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-list dt,
.field-row span,
.metric-label,
.eyebrow,
.detail-stats span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-list dd {
  margin: 0;
  color: var(--text);
  text-align: right;
}

.header-sensor-list {
  display: grid;
  gap: 7px;
  max-height: 155px;
  margin: 12px 0 0;
  padding: 12px 0 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  list-style: none;
  font-size: 12px;
}

.header-sensor-list li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.header-sensor-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-sensor-age {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.field-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

select,
input[type="range"] {
  min-width: 145px;
  accent-color: var(--accent);
}

select {
  max-width: 176px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

input[type="text"],
input[type="url"],
input[type="file"],
input[type="number"] {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.hidden {
  display: none;
}

.map-footer {
  position: fixed;
  left: 50%;
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 760;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 24px);
  padding: 6px 10px;
  border: 1px solid rgba(255, 92, 0, 0.18);
  border-radius: 999px;
  background: rgba(1, 0, 28, 0.62);
  color: rgba(247, 248, 255, 0.72);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  pointer-events: auto;
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.map-footer a {
  color: rgba(255, 92, 0, 0.86);
  text-decoration: none;
  white-space: nowrap;
}

.map-footer a:hover {
  color: #ff7a2f;
}

.top-tools {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 860;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tool-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(1, 0, 28, 0.9);
  color: var(--text);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.26);
  cursor: pointer;
}

.tool-button span {
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}

.tool-button .settings-icon {
  position: relative;
  width: 20px;
  height: 20px;
  border: 3px solid var(--text);
  border-radius: 50%;
  background:
    linear-gradient(var(--text), var(--text)) 50% -6px / 3px 7px no-repeat,
    linear-gradient(var(--text), var(--text)) 50% calc(100% + 6px) / 3px 7px no-repeat,
    linear-gradient(90deg, var(--text), var(--text)) -6px 50% / 7px 3px no-repeat,
    linear-gradient(90deg, var(--text), var(--text)) calc(100% + 6px) 50% / 7px 3px no-repeat;
}

.tool-button .settings-icon::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--text);
}

.zoom-tool {
  font-size: 24px;
  font-weight: 850;
  line-height: 1;
}

.tool-button-icon {
  font-size: 23px;
  font-weight: 850;
  line-height: 1;
}

.floating-panel {
  position: fixed;
  top: 66px;
  right: 16px;
  z-index: 855;
  width: min(330px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.floating-panel h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

.floating-panel fieldset {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.floating-panel fieldset + fieldset,
.settings-block + .settings-block {
  margin-top: 14px;
}

.floating-panel legend,
.stacked-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.floating-panel label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 13px;
}

.floating-panel input[type="radio"],
.floating-panel input[type="checkbox"] {
  accent-color: var(--accent);
}

.settings-panel {
  max-height: calc(100vh - 92px);
  overflow: auto;
}

.settings-block {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.settings-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.settings-button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.sensor-settings-list {
  display: grid;
  gap: 8px;
}

.sensor-settings-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.sensor-settings-summary {
  display: grid;
  grid-template-columns: 12px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.sensor-settings-summary strong,
.sensor-settings-summary small {
  display: block;
}

.sensor-settings-summary small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.sensor-source-url {
  max-width: 100%;
  overflow: hidden;
  color: rgba(247, 248, 255, 0.72) !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sensor-settings-body {
  padding: 10px;
  border-top: 1px solid var(--line);
}

.sensor-source-detail {
  display: grid;
  gap: 4px;
  margin: 0 0 10px;
  padding: 8px 9px;
  border: 1px solid rgba(255, 92, 0, 0.22);
  border-radius: 6px;
  background: rgba(1, 0, 28, 0.34);
  color: #fff;
  font-size: 11px;
  line-break: anywhere;
}

.sensor-source-detail span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8a8e9c;
}

.status-dot.status-ok {
  background: #2ecc71;
}

.status-dot.status-warning {
  background: #ffd166;
}

.status-dot.status-alarm {
  background: #ff4d4d;
}

.status-dot.header-online {
  background: #2ecc71;
}

.status-dot.header-offline {
  background: #ff4d4d;
}

.inline-error {
  margin: 0 0 10px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(255, 77, 77, 0.12);
  color: #ffd1d1;
  font-size: 12px;
  line-height: 1.35;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.segment-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.segment-button.active,
.small-button.active {
  background: var(--accent);
  color: #fff;
}

.stacked-field {
  display: grid !important;
  align-items: start !important;
  gap: 7px !important;
  margin-bottom: 10px;
}

.stacked-field select,
.stacked-field input[type="range"] {
  width: 100%;
  max-width: none;
}

.action-button,
.small-button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.action-button {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
}

.small-button {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.muted-button,
.secondary-button {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.help-text {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.map-pick-mode #map {
  cursor: crosshair;
}

.event-plan-layer {
  overflow: visible;
  pointer-events: none;
}

.event-plan-layer.editing {
  pointer-events: auto;
}

.event-plan-frame {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: center center;
}

.event-plan-layer img {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
}

.event-plan-layer.editing .event-plan-frame {
  cursor: move;
}

.plan-handle {
  position: absolute;
  display: none;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 2px solid rgba(1, 0, 28, 0.92);
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
}

.event-plan-layer.editing .plan-handle {
  display: block;
}

.plan-scale-nw {
  top: -8px;
  left: -8px;
  cursor: nwse-resize;
}

.plan-scale-ne {
  top: -8px;
  right: -8px;
  cursor: nesw-resize;
}

.plan-scale-se {
  right: -8px;
  bottom: -8px;
  cursor: nwse-resize;
}

.plan-scale-sw {
  bottom: -8px;
  left: -8px;
  cursor: nesw-resize;
}

.plan-rotate-handle {
  top: -28px;
  left: calc(50% - 8px);
  cursor: grab;
}

.plan-preview {
  width: 100%;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  aspect-ratio: 16 / 9;
}

.plan-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.upload-dialog {
  width: min(430px, calc(100vw - 32px));
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: var(--shadow);
}

.upload-dialog::backdrop {
  background: rgba(1, 0, 28, 0.72);
}

.leaflet-control-layers,
.leaflet-control-zoom a {
  border: 1px solid var(--line) !important;
  background: var(--panel) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow);
}

.leaflet-control-layers {
  border-radius: 8px;
}

.leaflet-control-layers label {
  color: var(--text);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel-solid);
  color: var(--text);
}

.leaflet-popup-content-wrapper {
  border-radius: 14px;
}

.leaflet-popup-tip {
  border-radius: 3px;
}

.leaflet-popup-content {
  margin: 14px;
}

.wind-div-icon {
  background: transparent;
  border: 0;
  overflow: visible;
  position: relative;
}

.wind-marker-shell {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 116px;
  height: 94px;
  transform: translateX(-50%) scale(var(--visual-scale, 2));
  transform-origin: center bottom;
}

.wind-marker {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto auto auto;
  align-items: center;
  justify-items: center;
  width: 116px;
  height: 86px;
  padding: 8px 9px;
  box-sizing: border-box;
  border: 2px solid var(--status-color);
  border-radius: 8px;
  background: rgba(1, 0, 28, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  color: var(--text);
}

.wind-marker.status-warning {
  border-width: 4px;
  background: rgba(1, 0, 28, 0.94);
  color: var(--text);
  animation: windMarkerPulseWarning 1.2s ease-in-out infinite;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(255, 209, 102, 0.36);
  --marker-muted-color: rgba(240, 244, 255, 0.72);
}

.wind-marker.status-alarm {
  border-width: 6px;
  background: rgba(1, 0, 28, 0.96);
  color: #fff;
  animation: windMarkerPulseAlarm 0.9s ease-in-out infinite;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34), 0 0 0 3px rgba(255, 77, 77, 0.44);
  --marker-muted-color: rgba(255, 255, 255, 0.78);
}

.wind-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--status-color);
  border-bottom: 2px solid var(--status-color);
  background: rgba(1, 0, 28, 0.9);
  transform: translateX(-50%) rotate(45deg);
}

.wind-marker.status-warning::after {
  border-right-width: 4px;
  border-bottom-width: 4px;
  background: rgba(1, 0, 28, 0.94);
}

.wind-marker.status-alarm::after {
  border-right-width: 6px;
  border-bottom-width: 6px;
  background: rgba(1, 0, 28, 0.96);
}

@keyframes windMarkerPulseWarning {
  0%,
  100% {
    border-color: rgba(255, 209, 102, 0.86);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(255, 209, 102, 0.32);
  }

  50% {
    border-color: rgba(255, 209, 102, 1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32), 0 0 0 5px rgba(255, 209, 102, 0.46);
  }
}

@keyframes windMarkerPulseAlarm {
  0%,
  100% {
    border-color: rgba(255, 77, 77, 0.9);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34), 0 0 0 3px rgba(255, 77, 77, 0.38);
  }

  50% {
    border-color: rgba(255, 77, 77, 1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.36), 0 0 0 7px rgba(255, 77, 77, 0.52);
  }
}

.wind-arrow {
  grid-row: 2;
  width: 28px;
  height: 28px;
  transform-origin: 50% 50%;
}

.wind-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: var(--status-color);
}

.wind-name {
  grid-column: 1 / -1;
  margin-bottom: 5px;
  overflow: hidden;
  color: var(--marker-muted-color, var(--muted));
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  width: 100%;
}

.wind-value {
  grid-column: 2;
  grid-row: 2;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.wind-value strong {
  display: block;
  font: inherit;
}

.wind-value span {
  display: block;
  margin-top: 2px;
  color: var(--marker-muted-color, var(--muted));
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
}

.wind-max {
  grid-column: 1 / -1;
  margin-top: 5px;
  width: 100%;
  color: #f7f8ff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.wind-max span {
  margin-left: 3px;
  color: var(--marker-muted-color, var(--muted));
  font-size: 8px;
}

.sensor-popup {
  min-width: 270px;
  padding: 2px;
}

.sensor-popup strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
}

.popup-panels {
  display: grid;
  gap: 5px;
}

.popup-panel {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.popup-panel span {
  color: var(--muted);
}

.popup-panel strong {
  margin: 0;
  text-align: right;
  font-size: 13px;
  font-weight: 850;
}

.popup-tabbar {
  display: none;
  gap: 6px;
  margin: 8px 0;
}

.popup-tabbar button {
  width: auto;
  min-height: 34px;
  padding: 7px 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 11px;
}

.popup-tabbar button.active {
  background: var(--accent);
  color: #fff;
}

.sensor-popup button,
.range-button,
.icon-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.popup-actions {
  display: grid !important;
  grid-template-columns: 1fr auto;
  gap: 8px !important;
  margin-top: 12px;
}

.sensor-popup button {
  width: 100%;
  padding: 9px 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.popup-actions button:last-child {
  min-width: 78px;
  background: rgba(255, 255, 255, 0.12);
}

.mobile-popup-sheet {
  display: none;
}

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 920;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(430px, 100vw);
  height: 100%;
  padding: 22px;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: rgba(8, 10, 24, 0.96);
  box-shadow: var(--shadow);
  transform: translateX(104%);
  transition: transform 180ms ease;
}

.detail-panel.open {
  transform: translateX(0);
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.detail-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin-bottom: 5px;
}

.icon-button {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 18px;
}

.detail-current {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-current > div,
.detail-stats > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.detail-current strong {
  display: block;
  margin-top: 6px;
  color: #fff;
  font-size: 25px;
  line-height: 1.1;
}

.detail-current small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.range-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.range-button {
  min-height: 38px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 800;
}

.range-button.active {
  background: var(--accent);
}

.chart-stack {
  display: grid;
  gap: 12px;
}

.chart-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 225px;
  height: 225px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.compact-chart {
  min-height: 210px;
  height: 210px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  min-height: 0;
}

.chart-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.chart-title-row small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

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

.detail-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 16px;
}

@media (max-width: 760px) {
  html,
  body {
    overflow: hidden;
  }

  .status-panel {
    top: max(8px, env(safe-area-inset-top));
    left: 8px;
    width: calc(100vw - 68px);
    max-height: 38dvh;
    padding: 10px 11px;
    border-radius: 8px;
  }

  .brand-row h1 {
    max-width: calc(100vw - 130px);
    overflow: hidden;
    font-size: 17px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .current-time {
    font-size: 12px;
  }

  .status-list {
    display: none;
  }

  .header-sensor-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 72px;
    margin-top: 8px;
    padding-top: 8px;
    overflow: auto;
  }

  .header-sensor-list li {
    display: inline-grid;
    grid-template-columns: 9px minmax(0, auto);
    gap: 5px;
    max-width: 100%;
    padding: 4px 7px;
    border: 1px solid rgba(255, 92, 0, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 11px;
  }

  .header-sensor-name {
    max-width: 132px;
  }

  .header-sensor-age {
    display: none;
  }

  .top-tools {
    top: max(8px, env(safe-area-inset-top));
    right: 8px;
    gap: 5px;
  }

  .map-footer {
    bottom: max(6px, env(safe-area-inset-bottom));
    gap: 6px;
    max-width: calc(100vw - 16px);
    padding: 5px 8px;
    font-size: 10px;
  }

  .tool-button {
    width: 42px;
    height: 42px;
  }

  .floating-panel {
    top: calc(max(8px, env(safe-area-inset-top)) + 52px);
    right: 58px;
    width: calc(100vw - 74px);
    max-height: calc(100dvh - 74px - env(safe-area-inset-bottom));
    padding: 12px;
    border-radius: 8px;
    overflow: auto;
  }

  .settings-panel {
    top: calc(max(8px, env(safe-area-inset-top)) + 52px);
    left: 8px;
    right: 58px;
    width: auto;
    max-height: calc(100dvh - 66px - env(safe-area-inset-bottom));
  }

  .leaflet-top.leaflet-right {
    top: 188px;
  }

  .wind-marker-shell {
    transform: translateX(-50%) scale(calc(var(--visual-scale, 2) * 0.5));
  }

  .leaflet-popup-pane {
    display: none;
  }

  .mobile-popup-sheet {
    position: fixed;
    right: 8px;
    bottom: calc(42px + env(safe-area-inset-bottom));
    left: 8px;
    z-index: 940;
    display: block;
    max-height: min(58dvh, 430px);
    padding: 12px;
    overflow: auto;
    border: 1px solid rgba(255, 92, 0, 0.22);
    border-radius: 12px;
    background: rgba(16, 19, 34, 0.96);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
  }

  .mobile-popup-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    font-size: 22px;
    line-height: 1;
  }

  .sensor-popup {
    width: 100%;
    min-width: 0;
  }

  .sensor-popup > strong {
    margin-bottom: 10px;
  }

  .popup-tabbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .popup-panels {
    gap: 8px;
  }

  .popup-panel {
    display: none;
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(255, 92, 0, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
  }

  .popup-panel.active {
    display: grid;
    gap: 4px;
  }

  .popup-panel span {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .popup-panel strong {
    text-align: left;
    font-size: 18px;
  }

  .popup-actions {
    grid-template-columns: 1fr;
  }

  .sensor-popup button,
  .popup-actions button:last-child {
    width: 100%;
    min-width: 0;
    min-height: 38px;
  }

  .detail-panel {
    top: auto;
    bottom: 0;
    width: 100%;
    height: min(88dvh, 680px);
    padding: 14px;
    border-top: 1px solid var(--line);
    border-left: 0;
    border-radius: 12px 12px 0 0;
    transform: translateY(104%);
  }

  .detail-panel.open {
    transform: translateY(0);
  }

  .detail-current,
  .detail-stats {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .detail-header {
    gap: 10px;
  }

  .detail-header h2 {
    font-size: 18px;
  }

  .detail-header-actions {
    flex-wrap: nowrap;
  }

  .detail-current strong {
    font-size: 20px;
  }

  .range-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .range-button {
    min-width: 0;
    min-height: 38px;
  }

  .chart-wrap {
    min-height: 170px;
    height: 170px;
    padding: 10px;
  }

  .compact-chart {
    min-height: 165px;
    height: 165px;
  }

  .chart-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .detail-stats strong {
    font-size: 14px;
  }
}
