:root {
  color-scheme: light;
  --unit-rail-height: calc(100vh - 340px);
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-strong: #f8fbfd;
  --text: #17212b;
  --muted: #687584;
  --line: #dbe4ec;
  --green: #16805a;
  --green-bg: #e7f6ef;
  --red: #b42318;
  --red-bg: #fde8e6;
  --amber: #b86e00;
  --amber-bg: #fff2d7;
  --teal: #0f766e;
  --blue: #2457a7;
  --shadow: 0 18px 45px rgba(31, 45, 61, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(241, 248, 253, 0.82)),
    url("./assets/sky-watercolor-bg.png") center top / cover fixed no-repeat,
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.modal-open {
  overflow: hidden;
}

.shell {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 10px 16px 14px;
}

.topbar,
.alert-band,
.overview-grid,
.metrics-row,
.content-grid {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 4px;
}

.topbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.header-metrics {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.header-metric {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 34px;
  min-width: 92px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 45, 61, 0.07);
}

.header-metric-label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.header-metric strong {
  display: block;
  margin-top: 1px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.1;
}

.header-metric-detail {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}

.header-metric-weather {
  min-width: 150px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.brand-lockup {
  display: flex;
  align-items: center;
  width: min(21vw, 255px);
  max-width: 100%;
  overflow: visible;
}

.brand-logo {
  display: block;
  width: min(24vw, 285px);
  max-width: none;
  height: auto;
  object-fit: contain;
  margin: -12px -22px -14px -10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.api-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(31, 45, 61, 0.07);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
}

.api-status.online .status-dot {
  background: var(--green);
}

.api-status.offline .status-dot {
  background: var(--red);
}

.install-app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid rgba(22, 128, 90, 0.28);
  border-radius: 999px;
  background: #edf9f3;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(31, 45, 61, 0.07);
}

.install-app-btn:hover {
  background: #e0f4e9;
}

.assistant-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 8px 22px rgba(31, 45, 61, 0.07);
}

.assistant-link-btn:hover {
  background: var(--surface-strong);
}

.alerts-toggle-btn {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid rgba(36, 87, 167, 0.28);
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(31, 45, 61, 0.07);
}

.alerts-toggle-btn.enabled {
  border-color: rgba(22, 128, 90, 0.28);
  background: var(--green-bg);
  color: var(--green);
}

.alerts-toggle-btn.blocked {
  border-color: rgba(180, 35, 24, 0.28);
  background: var(--red-bg);
  color: var(--red);
}

.alert-band {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #77e29b;
  border: 1px solid rgba(22, 128, 90, 0.34);
  box-shadow: var(--shadow);
}

.alert-band.danger {
  background: var(--red-bg);
  border-color: rgba(180, 35, 24, 0.25);
}

.alert-band.warning {
  background: var(--amber-bg);
  border-color: rgba(184, 110, 0, 0.25);
}

.alert-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green);
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
}

.danger .alert-icon {
  background: var(--red);
}

.warning .alert-icon {
  background: var(--amber);
}

.alert-title {
  color: var(--text);
  font-size: clamp(17px, 2.2vw, 24px);
  font-weight: 900;
  line-height: 1.08;
}

.alert-copy {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.alarm-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  margin: 0;
}

.clear-alarm-btn {
  min-height: 30px;
  padding: 6px 12px;
  border: 1px solid rgba(180, 35, 24, 0.3);
  border-radius: 8px;
  background: var(--red-bg);
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.clear-alarm-btn:disabled {
  border-color: var(--line);
  background: #edf1f5;
  color: var(--muted);
  cursor: default;
}

.sound-alarm-btn {
  min-height: 30px;
  padding: 6px 12px;
  border: 1px solid rgba(36, 87, 167, 0.28);
  border-radius: 8px;
  background: #eaf2ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.sound-alarm-btn.muted {
  border-color: var(--line);
  background: #edf1f5;
  color: var(--muted);
}

.sound-alarm-btn.needs-unlock {
  border-color: rgba(184, 110, 0, 0.28);
  background: var(--amber-bg);
  color: var(--amber);
}

#alarmLatchState {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 12px;
  align-items: start;
  margin: 0 0 12px;
}

.left-column {
  display: grid;
  gap: 12px;
}

.status-column {
  display: grid;
  gap: 8px;
}

.mobile-nav {
  display: none;
}

.mobile-nav-btn {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.mobile-nav-btn.active {
  border-color: rgba(22, 128, 90, 0.35);
  background: var(--green-bg);
  color: var(--green);
}

.metric {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(31, 45, 61, 0.08);
}

.metric-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  font-size: 26px;
  line-height: 1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.right-rail {
  display: grid;
  gap: 12px;
  align-content: start;
}

.units-panel {
  overflow: auto;
  padding: 12px;
  border: 1px solid #c5cfda;
  border-radius: 8px;
  background: #d9e0e8;
  box-shadow: 0 12px 32px rgba(31, 45, 61, 0.08);
  min-height: 320px;
  height: max(320px, var(--unit-rail-height));
}

.units-panel .section-heading {
  margin-bottom: 10px;
}

.units-panel .section-heading h2 {
  color: #182330;
}

.units-panel .section-heading span {
  color: #4f5f73;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  margin-bottom: 8px;
  color: var(--muted);
}

.section-heading h2 {
  color: var(--text);
}

.section-heading span {
  font-size: 13px;
  font-weight: 700;
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.notes-panel {
  overflow: auto;
  padding: 12px;
  border: 1px solid #c5cfda;
  border-radius: 8px;
  background: #d9e0e8;
  box-shadow: 0 12px 32px rgba(31, 45, 61, 0.08);
}

.notes-panel .section-heading {
  margin-bottom: 8px;
}

.notes-panel .section-heading h2 {
  color: #182330;
}

.notes-panel .section-heading span {
  color: #4f5f73;
}

.notes-input {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  padding: 10px;
  border: 1px solid #b7c4d4;
  border-radius: 8px;
  background: #f3f7fb;
  color: #142233;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
}

.notes-input:focus-visible {
  outline: 2px solid rgba(36, 87, 167, 0.42);
  outline-offset: 1px;
}

.notes-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.notes-save-btn {
  min-height: 30px;
  padding: 6px 12px;
  border: 1px solid rgba(22, 128, 90, 0.3);
  border-radius: 8px;
  background: var(--green-bg);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.notes-list {
  margin-top: 10px;
  max-height: calc((5 * 74px) + (4 * 8px));
  overflow: auto;
}

.notes-list .note-item {
  min-height: 72px;
}

.notes-list .note-item p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "head"
    "sensors"
    "summary"
    "meta";
  align-items: start;
  row-gap: 6px;
  min-height: 126px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(31, 45, 61, 0.08);
}

.unit-card.present {
  border-color: rgba(22, 163, 74, 0.44);
  background: linear-gradient(180deg, #dff7e8 0%, #f4fff8 100%);
  box-shadow:
    0 12px 32px rgba(22, 163, 74, 0.14),
    0 0 0 1px rgba(22, 163, 74, 0.12);
}

.unit-card.alert {
  border-color: rgba(180, 35, 24, 0.32);
  background: linear-gradient(180deg, #fff8f7, #ffffff);
}

.unit-card.high-risk {
  border-color: rgba(147, 79, 6, 0.42);
  box-shadow:
    0 12px 28px rgba(31, 45, 61, 0.14),
    0 0 0 2px rgba(147, 79, 6, 0.28),
    0 0 24px rgba(147, 79, 6, 0.42);
}

.unit-card.offline {
  border-color: rgba(104, 117, 132, 0.32);
  background: linear-gradient(180deg, #f8fafc, #ffffff);
}

.unit-head {
  grid-area: head;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.unit-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.home-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: #e8eef8;
  color: var(--blue);
  font-size: 14px;
}

.unit-card.present .home-icon {
  background: #dcfce7;
  color: #15803d;
}

.unit-card.alert .home-icon {
  background: var(--red-bg);
  color: var(--red);
}

.unit-card.offline .home-icon {
  background: #edf1f5;
  color: var(--muted);
}

.unit-title h3 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  letter-spacing: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--green-bg);
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.alert {
  background: var(--red-bg);
  color: var(--red);
}

.badge.present {
  background: #dff7e8;
  color: #166534;
}

.badge.offline {
  background: #edf1f5;
  color: var(--muted);
}

.sensor-line {
  grid-area: sensors;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 0;
}

.sensor-pill {
  min-height: 46px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.heart-history-trigger {
  cursor: pointer;
}

.heart-history-trigger:focus-visible {
  outline: 2px solid rgba(22, 128, 90, 0.6);
  outline-offset: 1px;
}

.fall-settings-trigger {
  cursor: pointer;
}

.fall-settings-trigger:focus-visible {
  outline: 2px solid rgba(36, 87, 167, 0.55);
  outline-offset: 1px;
}

.sensor-pill.heart-bpm-pill {
  border-color: rgba(22, 128, 90, 0.28);
  background: #ffffff;
  color: #121212;
}

.sensor-pill.heart-bpm-pill span,
.sensor-pill.heart-bpm-pill strong,
.sensor-pill.heart-bpm-pill .sub-status {
  color: #121212;
}

.sensor-pill.heart-bpm-pill .heart-icon {
  color: #121212;
}

.sensor-pill span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.sensor-pill strong {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 5px;
  min-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
}

.fall-icon,
.heart-icon {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.fall-icon::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 6px;
  width: 3px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
}

.fall-icon::after {
  content: "";
  position: absolute;
  bottom: 1px;
  left: 6px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--green);
}

.fall-icon.active::before,
.fall-icon.active::after {
  background: var(--red);
}

.heart-icon::before {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: 6px;
  height: 2px;
  background: currentColor;
}

.heart-icon::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 10px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: skewX(-28deg);
}

.heart-icon.active {
  color: var(--red);
}

.sub-status {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.sub-status.alert {
  color: var(--red);
}

.unit-meta-row {
  grid-area: meta;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.unit-meta {
  margin-top: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.sensor-summary {
  grid-area: summary;
  margin-top: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.sensor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.sensor-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.sensor-chip.online {
  background: var(--green-bg);
  color: var(--green);
  border-color: rgba(22, 128, 90, 0.25);
}

.sensor-chip.offline {
  background: #edf1f5;
  color: var(--muted);
  border-color: rgba(104, 117, 132, 0.35);
}

.high-risk-panel,
.alerts-panel {
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(31, 45, 61, 0.08);
}

.high-risk-panel {
  background: #606873;
  border-color: #4f5762;
  min-height: 320px;
  height: max(320px, var(--unit-rail-height));
}

.high-risk-panel .section-heading {
  margin-bottom: 10px;
  color: #e5ebf3;
}

.high-risk-panel .section-heading h2,
.high-risk-panel .section-heading span {
  color: #f3f7fc;
}

.high-risk-panel .empty-state {
  border-color: rgba(231, 238, 247, 0.42);
  background: rgba(255, 255, 255, 0.05);
  color: #dce4ee;
}

.alerts-panel {
  min-height: 0;
  max-height: none;
}

.right-alerts-panel {
  max-height: calc((5 * 74px) + (4 * 8px) + 64px);
}

.right-alerts-panel .event-list {
  max-height: calc((5 * 74px) + (4 * 8px));
  overflow: auto;
}

.right-alerts-panel .empty-state {
  min-height: calc((5 * 74px) + (4 * 8px));
}

.risk-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.risk-grid .unit-card {
  min-height: 110px;
}

.unit-grid .empty-state,
.risk-grid .empty-state {
  grid-column: 1 / -1;
}

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

.event {
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.event.alert {
  border-color: rgba(180, 35, 24, 0.28);
  background: var(--red-bg);
}

.event-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.event strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.event time,
.event p {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.history-modal[hidden] {
  display: none;
}

.history-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.history-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 11, 16, 0.72);
}

.history-modal-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(920px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  transform: translate(-50%, -50%);
  overflow: auto;
  padding: 14px;
  border: 1px solid #2b3443;
  border-radius: 8px;
  background: #12161d;
  color: #edf3ff;
  box-shadow: 0 28px 70px rgba(6, 10, 16, 0.6);
}

.history-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-modal-header h2 {
  color: #f5f8ff;
}

.history-close-btn {
  min-height: 30px;
  min-width: 30px;
  padding: 0;
  border: 1px solid #3a4351;
  border-radius: 8px;
  background: #181e27;
  color: #d0daeb;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.history-modal-subtitle {
  margin-top: 4px;
  color: #aab6ca;
  font-size: 12px;
  font-weight: 700;
}

.history-live-row {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #2e3746;
  border-radius: 8px;
  background: #181e27;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-live-title {
  margin: 0;
  color: #dde5f4;
  font-size: 18px;
  font-weight: 800;
}

.history-live-time {
  margin: 2px 0 0;
  color: #95a4ba;
  font-size: 12px;
  font-weight: 700;
}

#historyLiveValue {
  color: #f4f8ff;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0;
}

.history-section-head {
  margin-top: 12px;
  margin-bottom: 6px;
}

.history-section-head h3 {
  margin: 0;
  color: #f5f8ff;
  font-size: 18px;
}

.history-section-head p {
  margin: 2px 0 0;
  color: #95a4ba;
  font-size: 12px;
  font-weight: 700;
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.history-stat {
  min-height: 56px;
  padding: 8px;
  border: 1px solid #2f3948;
  border-radius: 8px;
  background: #181f2a;
}

.history-stat small {
  display: block;
  color: #9ba9bf;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.history-stat strong {
  display: block;
  margin-top: 4px;
  color: #f2f7ff;
  font-size: 16px;
  font-weight: 900;
}

.history-chart {
  width: 100%;
  height: 280px;
  margin-top: 6px;
  border: 1px solid #2e3746;
  border-radius: 8px;
  background: #10151d;
}

.history-axis-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  color: #9aa9bf;
  font-size: 11px;
  font-weight: 700;
}

.history-empty {
  fill: #aebbd0;
  font-size: 14px;
  font-weight: 700;
}

.fall-settings-modal[hidden] {
  display: none;
}

.fall-settings-modal {
  position: fixed;
  inset: 0;
  z-index: 85;
}

.fall-settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 22, 33, 0.52);
}

.fall-settings-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(560px, calc(100vw - 28px));
  transform: translate(-50%, -50%);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(13, 22, 33, 0.24);
}

.fall-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.fall-settings-close-btn {
  min-height: 30px;
  min-width: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.fall-settings-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.fall-settings-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.fall-settings-form label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.fall-settings-form select {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.radar-preview {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7fb;
}

.radar-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.radar-preview-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 850;
  color: #1e2b3d;
}

#radarPointCloudUpdated {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.radar-point-chart {
  width: 100%;
  height: 220px;
  margin-top: 8px;
  border: 1px solid #ccd7e5;
  border-radius: 8px;
  background: #ffffff;
}

#radarPointCloudMeta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.fall-settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.fall-settings-save-btn {
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid rgba(22, 128, 90, 0.3);
  border-radius: 8px;
  background: var(--green-bg);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.fall-settings-save-btn:disabled {
  border-color: var(--line);
  background: #edf1f5;
  color: var(--muted);
  cursor: default;
}

#fallSettingsStatus {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.empty-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 750;
  text-align: center;
  padding: 20px;
}

@media (max-width: 1200px) {
  .units-panel,
  .high-risk-panel,
  .alerts-panel {
    height: auto;
    min-height: 0;
  }

  .right-alerts-panel .event-list {
    max-height: none;
  }

  .unit-grid,
  .risk-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .shell {
    padding: 16px;
  }

  .brand-logo {
    width: min(40vw, 245px);
    margin: -10px -16px -12px -8px;
  }

  .brand-lockup {
    width: min(30vw, 185px);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .header-metrics {
    flex-wrap: wrap;
  }

  .header-metric-weather {
    min-width: 168px;
  }

  .unit-grid,
  .risk-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .unit-card {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "sensors"
      "summary"
      "meta";
  }

  .sensor-line {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #historyLiveValue {
    font-size: 28px;
  }
}

@media (max-width: 560px) {
  body {
    padding-bottom: 88px;
  }

  .brand-logo {
    width: min(82vw, 340px);
    margin: -8px 0 -8px 0;
  }

  .brand-lockup {
    width: min(88vw, 360px);
    overflow: visible;
  }

  .shell {
    padding: 14px 12px 24px;
  }

  .alert-band {
    grid-template-columns: 1fr;
  }

  .topbar-right,
  .header-metrics {
    width: 100%;
  }

  .topbar {
    gap: 12px;
  }

  .header-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .header-metric {
    min-width: 0;
  }

  .header-metric-weather {
    grid-column: 1 / -1;
  }

  .api-status {
    width: 100%;
    justify-content: center;
  }

  .install-app-btn {
    width: 100%;
    justify-content: center;
  }

  .alarm-actions {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .clear-alarm-btn,
  .sound-alarm-btn {
    flex: 1 1 calc(50% - 6px);
    min-height: 38px;
    font-size: 13px;
  }

  #alarmLatchState {
    width: 100%;
    text-align: center;
  }

  .content-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .left-column,
  .right-rail {
    display: contents;
  }

  .mobile-nav {
    position: sticky;
    bottom: 8px;
    z-index: 15;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 2px 0 2px;
    padding: 8px;
    border: 1px solid rgba(197, 207, 218, 0.95);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    box-shadow: 0 12px 32px rgba(31, 45, 61, 0.12);
  }

  .mobile-panel {
    display: none;
  }

  body[data-mobile-tab="units"] [data-mobile-panel="units"],
  body[data-mobile-tab="high-risk"] [data-mobile-panel="high-risk"],
  body[data-mobile-tab="alerts"] [data-mobile-panel="alerts"],
  body[data-mobile-tab="notes"] [data-mobile-panel="notes"] {
    display: block;
  }

  .units-panel,
  .high-risk-panel,
  .notes-panel,
  .alerts-panel {
    min-height: 0;
    height: auto;
  }

  .sensor-line {
    grid-template-columns: 1fr;
  }

  .history-modal-panel {
    padding: 12px;
  }

  .history-live-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  #historyLiveValue {
    font-size: 24px;
  }

  .unit-grid {
    grid-template-columns: 1fr;
  }

  .risk-grid {
    grid-template-columns: 1fr;
  }

  .right-rail {
    gap: 8px;
  }

  .unit-card {
    min-height: 0;
  }

  .notes-input {
    min-height: 120px;
  }

  .right-alerts-panel .event-list,
  .notes-list {
    max-height: none;
  }
}
