:root {
  --header-height: 50px;
  --sheet-height: 60px;
}
.hko-legend { width: 238px; box-sizing: border-box; max-width: calc(100vw - 24px); max-height: max(72px, calc(100dvh - var(--header-height) - var(--sheet-height) - 130px)); overflow-y: auto; overscroll-behavior: contain; padding: 9px; border: 1px solid #dce3e5; border-radius: 4px; background: #fff; color: #203337; font-size: 11px; line-height: 1.5; box-shadow: 0 2px 6px #00000012; }
.hko-legend[hidden] { display: none; }
.hko-legend strong { display: block; font-size: 11px; }
.hko-source { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 7px; margin-bottom: 5px; }
.hko-key { width: 10px; height: 10px; box-sizing: border-box; margin-top: 3px; }
.hko-grid-key { background: #16a34a70; }
.hko-station-key { border: 2px solid #16a34a; border-radius: 50%; }
.hko-station-marker { background: transparent; display: grid; place-items: center; }
.hko-station-dot { display: grid; place-items: center; box-sizing: border-box; width: 12px; height: 12px; border: 2px solid var(--rain-color); border-radius: 50%; background: var(--rain-fill); color: #475569; font-size: 10px; line-height: 1; }
.hko-station-dot.unavailable { width: 15px; height: 15px; background: #fff; }
.hko-station-dot.configured { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #20252b; }
.hko-station-detail { box-sizing: border-box; width: 238px; max-width: calc(100vw - 56px); padding: 12px 30px 12px 12px; white-space: normal; overflow-wrap: anywhere; font-size: 12px; }
.hko-station-marker:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }
.hko-station-open #mapCtrl { visibility: hidden !important; }
.hko-forecast-status, .hko-station-status { overflow-wrap: anywhere; }
.hko-scale { display: flex; margin-top: 8px; height: 21px; }
.hko-scale span { flex: 1; text-align: center; color: #111; }
.hko-scale span:nth-child(2), .hko-scale span:nth-child(3), .hko-scale span:nth-last-child(-n+2) { color: #fff; }
.hko-unit { text-align: right; }
.hko-issued { margin-top: 4px; overflow-wrap: anywhere; }
.hko-legend small { display: block; margin-top: 4px; font-size: 10px; }

button, input, select, textarea { font-family: Arial, sans-serif; }
button { touch-action: manipulation; }
button:focus-visible, [role="tab"]:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
* { letter-spacing: 0 !important; }
.fhdr { padding-top: env(safe-area-inset-top); min-height: 50px; height: calc(50px + env(safe-area-inset-top)); }
.sample-badge { color: #6b7280; font-size: 12px; white-space: nowrap; }
.map-ctrl, .ap-card { top: calc(var(--header-height) + 8px); }
.detail-panel { top: var(--header-height); }
.bottom-sheet { padding-bottom: env(safe-area-inset-bottom); }
.bottom-sheet[data-state="collapsed"] .bs-body { visibility: hidden; }
.bottom-sheet[data-state="collapsed"] .srb-row { display: none; }
.site-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sc, .sc-spark, .ov-card, .health-card, .ah-snap-card { min-width: 0; }
.bs-toprow { min-height: 48px; }
.bs-cycle-btn { min-width: 28px; min-height: 28px; }
.bs-body, .dp-body { overscroll-behavior: contain; }
.sc { border-radius: 12px; }
.ap-card, .mc-card { border-radius: 10px; }
.modal, .alert-popup { border-radius: 14px; }
.map-unavailable { display: grid; place-content: center; padding: 100px 24px 50vh; text-align: center; font-size: 14px; }
.leaflet-bottom { bottom: var(--sheet-height); transition: bottom .32s; }
.leaflet-control-attribution { max-width: calc(100vw - 20px); font-size: 10px; }
.overlay-bg, .alert-overlay { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.modal, .alert-popup { max-width: 100%; max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; }
.btn-row, .chart-tb, .gal-filter-row { flex-wrap: wrap; }
.trend-chart { position: relative; width: 100%; height: 200px; }
.solar-chart { height: 180px; }
#dp-chart .cbox, #dp-overview .cbox { position: relative; }
#miniEmpty, #waterEmpty, #solarEmpty { position: absolute; top: 45%; left: 28px; right: 28px; padding: 8px; background: #f9fafbe8; text-align: center; }
#ovCards { grid-template-rows: 96px 79px; }
#ovCards .ov-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-body { overflow-wrap: anywhere; }
#dp-alerts, .dmsec { min-width: 0; }
.table-scroll { overflow-x: auto; max-width: 100%; }
.atable { min-width: 0; table-layout: fixed; }
.atable th, .atable td { padding-left: 4px; padding-right: 4px; overflow-wrap: anywhere; }
.atable th:nth-child(1) { width: 25%; }
.atable th:nth-child(2) { width: 11%; }
.atable th:nth-child(3) { width: 18%; }
.atable th:nth-child(4) { width: 30%; }
.atable th:nth-child(5) { width: 16%; }
.cal-tbl { min-width: 320px; }
.toast { max-width: calc(100vw - 24px); white-space: normal; text-align: center; bottom: max(22px, env(safe-area-inset-bottom)); }
.viewer-img { max-height: 70dvh; }
.viewer-caption { max-width: 90vw; text-align: center; }
.viewer-ctrl-row { max-width: calc(100vw - 24px); flex-wrap: wrap; justify-content: center; gap: 8px; }
.viewer-btn { padding: 8px 10px; }
.viewer-close { top: max(14px, env(safe-area-inset-top)); }
[hidden] { display: none !important; }
button:disabled { cursor: not-allowed; opacity: .55; }
.dp-tab { flex: 0 0 auto; background: #fff; border-top: 0; border-left: 0; border-right: 0; font-family: inherit; }
.fhdr h1 { font-size: 17px; }
.weather-status { border: 0; background: transparent; color: #6b7280; display: inline-flex; padding: 2px; }
.mute-btn, .mc-btn, .ovr-btn, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.lucide { width: 14px; height: 14px; flex-shrink: 0; }
.bs-cycle-btn .lucide { width: 16px; height: 16px; }
.bs-toprow { min-height: 40px; }
.control-caption { font-size: 13px; color: #9ca3af; }
.axis-caption { font-size: 13px; color: #9ca3af; margin: 0 0 10px; line-height: normal; }
#dp-chart > .chart-heading { margin: 8px 0 4px; }
#dp-chart > .axis-caption:last-of-type { margin-bottom: 8px; }
.section-empty { color: #9ca3af; font-size: 13px; line-height: 1.5; padding: 5px 0; }
.section-action { margin-top: 8px; }
.device-toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
.risk-fill { width: 0; background: #9ca3af; }
.risk-pct { color: #9ca3af; }
.sc-head .sc-id { flex: none; }
.sc-head .sc-name { min-width: 0; }
.sc-foot .sc-spark { height: 34px; position: relative; min-width: 0; }
.sc-foot .sc-wl-badge { font-size: 15px; background: #f3f4f6; color: #374151; max-width: 48%; white-space: nowrap; }
.sc-dot.unknown { background: #9ca3af; }
.sc-img .mode-badge { position: absolute; bottom: 5px; left: 7px; z-index: 2; background: #ffffffed; color: #6b7280; border-radius: 4px; padding: 2px 6px; font-size: 13px; }
.sc-img .sc-img-ls { max-width: 64%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.sc-wl-lbl { overflow-wrap: anywhere; }
.hero-img { height: 200px; border-radius: 10px; }
.hero-img .site-img-photo { object-fit: cover; }
.hero-cam, .hero-ts { max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-item { height: auto; border: 2px solid transparent; background: #fff; }
.image-item img { height: 100%; object-fit: cover; }
.gt2-meta { min-height: 40px; }
.image-time { font-size: 13px; }
dialog.modal { margin: auto; padding: 0; width: 430px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); transform: none; }
dialog::backdrop { background: #0007; }
#closeConfig { padding: 3px 8px; font-size: 13px; min-height: 25px; }
#cfgTitle { min-width: 0; overflow-wrap: anywhere; }
#cfgPop .crow select { width: 149px; max-width: 46%; min-width: 0; padding: 5px; border: 1px solid #e5e7eb; border-radius: 6px; background: #f9fafb; color: inherit; }
#cfgPop .crow label { min-width: 0; }
#cfgPop .cnote { overflow-wrap: anywhere; }
#cfgPop #c-register-cm { width: 16px; height: 16px; flex: 0 0 16px; }
dialog.alert-popup { margin: auto; padding: 0; max-width: calc(100vw - 24px); border: 0; }
.alert-content { padding: 11px 15px; }
.location-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; font-size: 13px; margin-bottom: 8px; }
.location-grid span { display: block; color: #9ca3af; }
.viewer-btn { display: inline-flex; align-items: center; gap: 5px; }
.sc { position: relative; text-align: left; color: inherit; font: inherit; }
.sc-id { min-width: 0; overflow-wrap: anywhere; flex: 1; }
.sc-wl-badge { white-space: normal; font-size: 14px; max-width: 55%; }
.photo-empty { color: #6b7280; background: #eef1f1; width: 100%; height: 100%; display: grid; place-items: center; font-size: 13px; }
.data-notice { padding: 8px 12px; background: #fff7ed; color: #9a3412; font-size: 13px; line-height: 1.5; flex-shrink: 0; }
.empty-state { padding: 16px 8px; font-size: 13px; line-height: 1.6; color: #6b7280; }
.site-grid > .empty-state { grid-column: 1 / -1; }
.card-error { padding: 6px 8px; font-size: 12px; color: #b91c1c; }
.status-unavailable { background: #f3f4f6; color: #6b7280; }
.bs-chip { border: 0; }
.chart-heading { font-size: 13px; font-weight: 600; color: #374151; margin: 0 0 6px; line-height: normal; }
.hero-img { background: #eef1f1; display: block; padding: 0; }
.hero-img .site-img-photo { object-fit: cover; }
.image-item { padding: 0; border: 2px solid transparent; background: #fff; min-width: 0; height: auto; text-align: left; position: relative; border-radius: 8px; overflow: hidden; cursor: pointer; }
.image-item img { width: 100%; height: 100%; object-fit: cover; }
.image-time { display: block; font-size: 11px; padding: 4px; overflow-wrap: anywhere; }
.img-viewer { z-index: 800; }
dialog.img-viewer { margin: 0; padding: 12px; border: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; color: #fff; }
.viewer-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; width: min(1200px, calc(100vw - 100px)); height: min(72dvh, 850px); min-height: 0; }
.viewer-frame { margin: 0; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.viewer-frame figcaption { font-size: 14px; color: #d1d5db; flex: 0 0 auto; }
.viewer-frame .viewer-img { width: 100%; min-height: 0; flex: 1; max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-missing { display: grid; place-items: center; width: 100%; flex: 1; color: #9ca3af; font-size: 14px; }
@media (max-width: 600px) {
  .viewer-pair { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); width: calc(100vw - 24px); height: 68dvh; gap: 10px; }
  .viewer-caption { font-size: 12px; }
}
.lm-unavailable .lm-dot { background: #9ca3af; }
.gt2-note { display: block; }
.health-card, .hc-label { overflow-wrap: anywhere; }
.gal-sec-title { margin: 0; }
.hero-img { font: inherit; }

@media (min-width: 1101px) {
  .bs-toprow { min-height: 42px; height: 42px; }
  .bs-cycle-btn { min-width: 0; min-height: 0; }
  .sc { border-left-width: 4px; }
}

@media (max-width: 1100px) {
  .fhdr { height: auto; flex-wrap: wrap; gap: 8px 12px; padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
  .fhdr-logo { flex: 1; min-width: 0; }
  .fhdr-search { position: static; order: 3; left: auto; transform: none; width: 100%; min-height: 38px; }
  .fhdr-right { gap: 8px; }
  .site-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .bottom-sheet:has(+ .detail-panel.open) .site-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .bs-vtabs { display: none; }
}

@media (max-width: 600px) {
  .fhdr { gap: 8px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .fhdr-logo { gap: 7px; }
  .fhdr-sub, #clock, .operator-name { display: none; }
  .fhdr-right { gap: 6px; }
  .sample-badge { font-size: 11px; }
  .mute-btn { min-height: 36px; padding: 4px 8px; }
  .fhdr-search { padding: 5px 10px; min-height: 40px; }
  .sf-input, .sf-select, .crow input, .reason-input { font-size: 16px; }
  .sf-select { max-width: 115px; font-size: 14px; }
  .sf-input { width: 0; }
  .map-ctrl { right: 8px; gap: 5px; max-height: calc(100dvh - var(--header-height) - var(--sheet-height) - 20px); overflow-y: auto; }
  .mc-card { padding: 4px; }
  .mc-btn { min-height: 36px; padding: 5px 8px; font-size: 12px; }
  .mc-zoom { width: 36px; height: 36px; }
  .detail-panel { width: 100%; border-left: 0; }
  .dp-hdr { padding: 8px 10px; }
  .dp-top { margin-bottom: 2px; }
  .dp-back { width: 38px; height: 38px; }
  .dp-title { font-size: 15px; }
  .dp-meta { padding-left: 45px; gap: 8px; }
  .dp-tabs { min-height: 44px; }
  .dp-tab { padding: 13px 12px; }
  .dp-body { padding: 12px 10px max(16px, env(safe-area-inset-bottom)); }
  .bs-toprow { gap: 5px; padding: 6px 10px; }
  .bs-cycle-btn { width: 36px; height: 36px; }
  .bs-title { flex: 1; }
  .bs-chips { order: 2; flex: 0 0 100%; justify-content: space-between; gap: 4px; }
  .bs-chip { padding: 6px; font-size: 12px; }
  .srb-row { order: 3; flex: 0 0 100%; justify-content: flex-end; }
  .srb { min-height: 32px; }
  .site-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .bs-body { padding: 4px 10px 12px; }
  .sc-head { padding: 8px; }
  .sc-name { white-space: normal; }
  .sc-img { height: 180px; }
  .sc-foot { padding: 6px 8px 8px; }
  .ov-grid { gap: 6px; }
  .ov-card { padding: 8px; }
  .ov-lbl { font-size: 12px; }
  .ov-sub { line-height: 1.5; }
  .health-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ah-snapshot { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-tb { gap: 4px; }
  .ctb { flex: 0 1 auto; min-height: 36px; padding: 4px 8px; }
  .hero-img { height: 210px; }
  .hero-expand-btn { opacity: 1; }
  .modal-head, .modal-body { padding: 12px; }
  .crow { gap: 6px; align-items: center; }
  .crow label { min-width: 0; line-height: 1.5; }
  .crow input { width: 76px; flex: 0 0 76px; min-height: 38px; }
  .crow .unit { margin-left: 0; width: 28px; flex: 0 0 28px; }
  .btn { min-height: 36px; }
  .btn-row { gap: 6px; }
  .alert-overlay { align-items: center; justify-content: center; }
  .alert-pf { flex-wrap: wrap; padding: 10px; }
  .alert-ph { padding: 10px; }
  .prow { gap: 10px; }
  .prv { text-align: right; }
  .viewer-nav { display: none; }
  .viewer-img { max-width: calc(100vw - 20px); }
  .viewer-btn { min-height: 40px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body[data-login-pending] { visibility: hidden; }
.logout-btn { display: grid; place-items: center; flex: 0 0 30px; width: 30px; height: 30px; padding: 5px; background: #fff; border: 1px solid #e5e7eb; border-radius: 4px; color: #6b7280; cursor: pointer; }
.logout-btn svg { width: 16px; height: 16px; }
body.login-page { margin: 0; min-height: 100dvh; height: auto; overflow: auto; display: grid; place-items: center; padding: 24px; box-sizing: border-box; background: linear-gradient(135deg, #f0f6ff, #f7f9fa 65%, #f1f8f5); color: #1f2937; }
.login-panel { width: 100%; max-width: 360px; }
.login-brand { margin-bottom: 28px; }
.login-brand h1 { margin: 0 0 8px; font-size: 30px; color: #2563eb; }
.login-brand p { margin: 0; font-size: 13px; line-height: 1.6; color: #6b7280; }
.login-panel form { border-top: 2px solid #2563eb; padding-top: 20px; }
.login-panel h2 { margin: 0 0 20px; font-size: 18px; }
.login-panel label { display: block; margin: 16px 0 6px; font-size: 13px; }
.login-panel input { width: 100%; min-width: 0; box-sizing: border-box; height: 42px; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; font-size: 16px; }
.login-panel button { width: 100%; min-height: 42px; margin-top: 24px; border: 0; border-radius: 4px; padding: 10px; background: #2563eb; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.login-panel button:disabled { opacity: 0.6; cursor: wait; }
#loginError { color: #b91c1c; font-size: 13px; line-height: 1.5; }
.range-modal { width: min(400px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; }
.range-modal form { margin: 0; }
.range-modal .modal-head { justify-content: space-between; }
.range-modal label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 600; }
.range-modal input, .range-modal select { display: block; box-sizing: border-box; width: 100%; min-width: 0; min-height: 42px; padding: 8px; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; font: inherit; }
.range-time-row { display: grid; grid-template-columns: minmax(0, 1fr) 92px; gap: 8px; margin-bottom: 18px; }
#rangeError { color: #b91c1c; font-size: 13px; line-height: 1.5; }
.applied-range { margin: 0 0 12px; color: #475569; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.range-title { line-height: 1.5; }
.range-title span { display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
.event-status { margin: 4px 0 8px; color: #92400e; font-size: 11px; }
.history-range-link { padding: 0; border: 0; background: none; color: #2563eb; font: inherit; text-align: left; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.history-range-link:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.chart-event-tooltip { position: absolute; z-index: 3; max-width: calc(100% - 16px); box-sizing: border-box; padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; box-shadow: 0 2px 6px #0002; color: #374151; font-size: 11px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; pointer-events: none; }