:root {
      --bg: #f5f7fb;
      --card: #ffffff;
      --text: #172033;
      --muted: #667085;
      --border: #e5e7eb;

      --good: #0f766e;
      --warn: #b45309;
      --bad: #b91c1c;

      --soft-good: #d1fae5;
      --soft-warn: #fef3c7;
      --soft-bad: #fee2e2;
      --soft-blue: #dbeafe;
      --soft-gray: #f3f4f6;

      --shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
      background: var(--bg);
      color: var(--text);
    }

    .page {
      max-width: 860px;
      margin: 0 auto;
      padding: 16px;
    }

    .topbar {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 12px;
      margin-bottom: 16px;
    }

    .title {
      font-size: 25px;
      font-weight: 850;
      margin: 0;
    }

    .subtitle {
      color: var(--muted);
      margin-top: 5px;
      font-size: 14px;
    }

    button {
      border: 1px solid var(--border);
      background: white;
      border-radius: 999px;
      padding: 9px 13px;
      font-weight: 750;
      cursor: pointer;
      box-shadow: 0 2px 8px rgba(16, 24, 40, 0.06);
    }

    button:active { transform: scale(0.98); }

    .error {
      background: var(--soft-bad);
      color: var(--bad);
      border: 1px solid #fecaca;
      border-radius: 15px;
      padding: 12px;
      margin-bottom: 12px;
      display: none;
      white-space: pre-wrap;
      font-weight: 700;
    }

    .card {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 22px;
      padding: 17px;
      box-shadow: var(--shadow);
      margin-bottom: 14px;
    }

    .hero {
      padding: 20px;
      border-width: 2px;
    }

    .hero.alert {
      border-color: #fca5a5;
      background: linear-gradient(180deg, #fff, #fff7f7);
    }

    .hero.warning {
      border-color: #fcd34d;
      background: linear-gradient(180deg, #fff, #fffbeb);
    }

    .hero.normal {
      border-color: #99f6e4;
      background: linear-gradient(180deg, #fff, #f0fdfa);
    }

    .hero-row {
      display: flex;
      justify-content: space-between;
      gap: 14px;
      align-items: flex-start;
    }

    .hero-main {
      display: flex;
      gap: 14px;
      align-items: flex-start;
    }

    .icon {
      width: 58px;
      height: 58px;
      border-radius: 20px;
      display: grid;
      place-items: center;
      font-size: 30px;
      background: var(--soft-blue);
      flex: 0 0 auto;
    }

    .icon.alert { background: var(--soft-bad); }
    .icon.warning { background: var(--soft-warn); }
    .icon.normal { background: var(--soft-good); }

    .status-title {
      font-size: 23px;
      font-weight: 850;
      margin: 0 0 6px;
    }

    .message {
      color: var(--muted);
      line-height: 1.45;
      font-size: 15px;
      margin: 0;
    }

    .pill {
      display: inline-flex;
      align-items: center;
      padding: 8px 12px;
      border-radius: 999px;
      font-size: 13px;
      font-weight: 850;
      border: 1px solid var(--border);
      background: white;
      white-space: nowrap;
    }

    .risk-normal {
      background: var(--soft-good);
      color: var(--good);
      border-color: #99f6e4;
    }

    .risk-warning {
      background: var(--soft-warn);
      color: var(--warn);
      border-color: #fde68a;
    }

    .risk-alert {
      background: var(--soft-bad);
      color: var(--bad);
      border-color: #fecaca;
    }

    .section-title {
      font-size: 17px;
      font-weight: 850;
      margin: 0 0 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }

    .section-note {
      color: var(--muted);
      font-size: 12px;
      font-weight: 650;
    }

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

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

    .metric {
      background: #fbfdff;
      border: 1px solid var(--border);
      border-radius: 18px;
      padding: 14px;
      min-height: 88px;
    }

    .metric-label {
      color: var(--muted);
      font-size: 13px;
      margin-bottom: 6px;
      font-weight: 650;
    }

    .metric-value {
      font-size: 22px;
      font-weight: 850;
      line-height: 1.2;
    }

    .metric-small {
      font-size: 13px;
      color: var(--muted);
      margin-top: 5px;
      line-height: 1.35;
    }

    .alert-box {
      display: none;
      background: var(--soft-bad);
      color: var(--bad);
      border: 1px solid #fecaca;
      border-radius: 18px;
      padding: 14px;
      margin-top: 14px;
    }

    .alert-box strong {
      display: block;
      margin-bottom: 5px;
      font-size: 15px;
    }

    .timeline {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .event-row {
      display: grid;
      grid-template-columns: 142px 1fr;
      gap: 10px;
      padding: 11px 12px;
      border: 1px solid var(--border);
      background: #fbfdff;
      border-radius: 16px;
      align-items: center;
    }

    .event-time {
      font-size: 12px;
      color: var(--muted);
      font-weight: 700;
      line-height: 1.35;
    }

    .event-name {
      font-size: 13px;
      font-weight: 850;
      word-break: break-word;
    }

    .event-alert {
      border-color: #fecaca;
      background: #fff7f7;
      color: var(--bad);
    }

    .footer {
      color: var(--muted);
      font-size: 12px;
      text-align: center;
      padding: 14px 0 4px;
      line-height: 1.5;
    }

    @media (max-width: 650px) {
      .page { padding: 13px; }
      .hero-row { flex-direction: column; }
      .grid, .grid3 { grid-template-columns: 1fr; }
      .event-row { grid-template-columns: 1fr; }
      .title { font-size: 23px; }
      .status-title { font-size: 21px; }
    }

/* C-034: Family trends section */
.range-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.range-tab {
  border: 1px solid var(--border);
  background: white;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: none;
}

.range-tab.active {
  background: var(--text);
  color: white;
  border-color: var(--text);
}

.trend-grid {
  margin-bottom: 14px;
}

.mini-trend-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin: 4px 0 10px;
}

.mini-trend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trend-row {
  display: grid;
  grid-template-columns: 86px 1fr 64px;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: var(--muted);
}

.trend-date {
  font-weight: 800;
  color: var(--muted);
}

.trend-bar-track {
  height: 9px;
  background: var(--soft-gray);
  border-radius: 999px;
  overflow: hidden;
}

.trend-bar-fill {
  height: 100%;
  background: var(--good);
  border-radius: 999px;
}

.trend-value {
  text-align: right;
  font-weight: 800;
  color: var(--text);
}

@media (max-width: 650px) {
  .trend-row {
    grid-template-columns: 74px 1fr 54px;
  }
}

/* C-035: Mobile tab layout */
.mobile-tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 12px;
  margin-bottom: 8px;
  background: var(--bg);
}

.mobile-tab {
  border: 1px solid var(--border);
  background: white;
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.05);
}

.mobile-tab.active {
  background: var(--text);
  color: white;
  border-color: var(--text);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.home-map {
  position: relative;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 12px;
  min-height: 230px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  padding: 14px;
  overflow: hidden;
}

.zone-box {
  border: 2px solid var(--border);
  background: white;
  border-radius: 20px;
  padding: 16px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.zone-box.active {
  border-color: #99f6e4;
  background: #f0fdfa;
}

.zone-box.warning {
  border-color: #fcd34d;
  background: #fffbeb;
}

.zone-box.alert {
  border-color: #fca5a5;
  background: #fff7f7;
}

.zone-title {
  font-size: 18px;
  font-weight: 900;
}

.zone-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.zone-person {
  position: absolute;
  left: 22px;
  bottom: 18px;
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--text);
  color: white;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.16);
  transition: all 0.25s ease;
}

.zone-person.in-bed {
  left: calc(55% + 18px);
  bottom: 18px;
}

.zone-person.in-room {
  left: 22px;
  bottom: 18px;
}

.zone-person.unknown {
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  background: var(--muted);
}

.location-note {
  margin-top: 10px;
}

@media (max-width: 650px) {
  .mobile-tabs {
    margin-left: -3px;
    margin-right: -3px;
  }

  .home-map {
    grid-template-columns: 1fr;
    min-height: 360px;
  }

  .zone-person.in-bed,
  .zone-person.in-room,
  .zone-person.unknown {
    left: 22px;
    bottom: 18px;
    transform: none;
  }
}

/* C-036: Interactive trend charts */
.trend-chart-card {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #ffffff;
  padding: 14px;
  margin: 14px 0;
}

.trend-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.chart-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 12px;
}

.chart-tab {
  border: 1px solid var(--border);
  background: var(--soft-gray);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.chart-tab.active {
  background: var(--good);
  color: white;
  border-color: var(--good);
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  min-height: 160px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border-radius: 18px;
  padding: 14px 10px 28px;
  overflow-x: auto;
}

.chart-bar-wrap {
  min-width: 18px;
  flex: 1;
  height: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  position: relative;
}

.chart-bar {
  width: 100%;
  max-width: 24px;
  min-height: 3px;
  border-radius: 999px 999px 4px 4px;
  background: var(--good);
}

.chart-bar.empty {
  background: #e5e7eb;
}

.chart-day-label {
  position: absolute;
  bottom: -22px;
  font-size: 10px;
  color: var(--muted);
  transform: rotate(-35deg);
  transform-origin: center;
  white-space: nowrap;
}

.chart-value-label {
  font-size: 10px;
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 650px) {
  .bar-chart {
    gap: 4px;
  }

  .chart-bar-wrap {
    min-width: 16px;
  }
}

/* C-037: Multi-zone apartment map */
.layout-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.layout-tab {
  border: 1px solid var(--border);
  background: white;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 850;
}

.layout-tab.active {
  background: var(--text);
  color: white;
  border-color: var(--text);
}

.apartment-map {
  position: relative;
  display: grid;
  gap: 10px;
  min-height: 430px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  padding: 14px;
  overflow: hidden;
}

.apartment-map.layout-studio {
  grid-template-columns: 0.75fr 1.25fr 1fr;
  grid-template-rows: 0.8fr 1.2fr 1fr;
  grid-template-areas:
    "entrance living restroom"
    "room     living kitchen"
    "room     bed    bed";
}

.apartment-map.layout-two_room {
  grid-template-columns: 0.7fr 1.1fr 1fr 1fr;
  grid-template-rows: 0.75fr 1.15fr 1.1fr;
  grid-template-areas:
    "entrance living living restroom"
    "room     living kitchen kitchen"
    "room     bed    bed     bed";
}

.apartment-map.layout-three_room {
  grid-template-columns: 0.75fr 1fr 1fr 1fr;
  grid-template-rows: 0.8fr 1fr 1fr 1fr;
  grid-template-areas:
    "entrance living living restroom"
    "room     living kitchen kitchen"
    "room     bed    bed     kitchen"
    "room     bed    bed     kitchen";
}

.apt-zone {
  border: 2px solid var(--border);
  background: white;
  border-radius: 20px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 92px;
}

.apt-zone.active {
  border-color: #99f6e4;
  background: #f0fdfa;
}

.apt-zone.warning {
  border-color: #fcd34d;
  background: #fffbeb;
}

.apt-zone.alert {
  border-color: #fca5a5;
  background: #fff7f7;
}

.apt-zone.inactive {
  opacity: 0.62;
}

.entrance-zone { grid-area: entrance; }
.living-zone { grid-area: living; }
.room-zone { grid-area: room; }
.bed-zone { grid-area: bed; }
.restroom-zone { grid-area: restroom; }
.kitchen-zone { grid-area: kitchen; }

.location-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px;
  margin-top: 14px;
}

.zone-person.at-entrance {
  left: 22px;
  top: 70px;
  bottom: auto;
}

.zone-person.at-living {
  left: 42%;
  top: 125px;
  bottom: auto;
}

.zone-person.at-room {
  left: 22px;
  bottom: 86px;
}

.zone-person.at-bed {
  left: 52%;
  bottom: 30px;
}

.zone-person.at-restroom {
  right: 28px;
  top: 70px;
  left: auto;
  bottom: auto;
}

.zone-person.at-kitchen {
  right: 35px;
  bottom: 110px;
  left: auto;
}

.zone-person.unknown {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  bottom: 20px;
  background: var(--muted);
}

@media (max-width: 750px) {
  .apartment-map,
  .apartment-map.layout-studio,
  .apartment-map.layout-two_room,
  .apartment-map.layout-three_room {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
    grid-template-areas:
      "entrance restroom"
      "living living"
      "room room"
      "bed bed"
      "kitchen kitchen";
    min-height: 620px;
  }

  .location-summary-grid {
    grid-template-columns: 1fr;
  }

  .zone-person.at-entrance,
  .zone-person.at-living,
  .zone-person.at-room,
  .zone-person.at-bed,
  .zone-person.at-restroom,
  .zone-person.at-kitchen,
  .zone-person.unknown {
    left: 22px;
    right: auto;
    top: auto;
    bottom: 18px;
    transform: none;
  }
}

/* C-038: Stable apartment layout override
   Use explicit grid positions instead of relying only on grid-template-areas. */

.apartment-map {
  display: grid;
  gap: 12px;
}

/* 1-room / studio layout */
.apartment-map.layout-studio {
  grid-template-columns: 0.8fr 1.35fr 0.95fr;
  grid-template-rows: 0.8fr 1.15fr 1fr;
}

.apartment-map.layout-studio .entrance-zone {
  grid-column: 1;
  grid-row: 1;
}

.apartment-map.layout-studio .room-zone {
  grid-column: 1;
  grid-row: 2 / 4;
}

.apartment-map.layout-studio .living-zone {
  grid-column: 2;
  grid-row: 1 / 3;
}

.apartment-map.layout-studio .bed-zone {
  grid-column: 2 / 4;
  grid-row: 3;
}

.apartment-map.layout-studio .restroom-zone {
  grid-column: 3;
  grid-row: 1;
}

.apartment-map.layout-studio .kitchen-zone {
  grid-column: 3;
  grid-row: 2;
}

/* 2-room layout */
.apartment-map.layout-two_room {
  grid-template-columns: 0.8fr 1.05fr 1.05fr 0.95fr;
  grid-template-rows: 0.8fr 1fr 1.05fr;
}

.apartment-map.layout-two_room .entrance-zone {
  grid-column: 1;
  grid-row: 1;
}

.apartment-map.layout-two_room .room-zone {
  grid-column: 1;
  grid-row: 2 / 4;
}

.apartment-map.layout-two_room .living-zone {
  grid-column: 2 / 4;
  grid-row: 1 / 3;
}

.apartment-map.layout-two_room .bed-zone {
  grid-column: 2 / 4;
  grid-row: 3;
}

.apartment-map.layout-two_room .restroom-zone {
  grid-column: 4;
  grid-row: 1;
}

.apartment-map.layout-two_room .kitchen-zone {
  grid-column: 4;
  grid-row: 2 / 4;
}

/* 3-room layout */
.apartment-map.layout-three_room {
  grid-template-columns: 0.85fr 1fr 1fr 0.95fr;
  grid-template-rows: 0.75fr 0.95fr 0.95fr 0.95fr;
}

.apartment-map.layout-three_room .entrance-zone {
  grid-column: 1;
  grid-row: 1;
}

.apartment-map.layout-three_room .room-zone {
  grid-column: 1;
  grid-row: 2 / 5;
}

.apartment-map.layout-three_room .living-zone {
  grid-column: 2 / 4;
  grid-row: 1 / 3;
}

.apartment-map.layout-three_room .bed-zone {
  grid-column: 2 / 4;
  grid-row: 3 / 5;
}

.apartment-map.layout-three_room .restroom-zone {
  grid-column: 4;
  grid-row: 1;
}

.apartment-map.layout-three_room .kitchen-zone {
  grid-column: 4;
  grid-row: 2 / 5;
}

/* Keep every zone visible and readable */
.apartment-map .apt-zone {
  min-height: 105px;
  box-sizing: border-box;
}

.apartment-map .zone-title {
  line-height: 1.1;
}

.apartment-map .zone-status {
  min-height: 20px;
}

/* Better resident marker positions */
.apartment-map.layout-studio .zone-person.at-room,
.apartment-map.layout-two_room .zone-person.at-room,
.apartment-map.layout-three_room .zone-person.at-room {
  left: 28px;
  bottom: 34px;
}

.apartment-map.layout-studio .zone-person.at-bed,
.apartment-map.layout-two_room .zone-person.at-bed,
.apartment-map.layout-three_room .zone-person.at-bed {
  left: 48%;
  bottom: 34px;
}

.apartment-map.layout-studio .zone-person.at-restroom,
.apartment-map.layout-two_room .zone-person.at-restroom,
.apartment-map.layout-three_room .zone-person.at-restroom {
  right: 34px;
  top: 90px;
  left: auto;
  bottom: auto;
}

.apartment-map.layout-studio .zone-person.at-kitchen,
.apartment-map.layout-two_room .zone-person.at-kitchen,
.apartment-map.layout-three_room .zone-person.at-kitchen {
  right: 38px;
  bottom: 125px;
  left: auto;
}

.apartment-map.layout-studio .zone-person.at-living,
.apartment-map.layout-two_room .zone-person.at-living,
.apartment-map.layout-three_room .zone-person.at-living {
  left: 42%;
  top: 145px;
  bottom: auto;
}

.apartment-map.layout-studio .zone-person.at-entrance,
.apartment-map.layout-two_room .zone-person.at-entrance,
.apartment-map.layout-three_room .zone-person.at-entrance {
  left: 28px;
  top: 88px;
  bottom: auto;
}

/* Mobile fallback: readable stacked floor plan */
@media (max-width: 750px) {
  .apartment-map.layout-studio,
  .apartment-map.layout-two_room,
  .apartment-map.layout-three_room {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }

  .apartment-map.layout-studio .entrance-zone,
  .apartment-map.layout-two_room .entrance-zone,
  .apartment-map.layout-three_room .entrance-zone {
    grid-column: 1;
    grid-row: 1;
  }

  .apartment-map.layout-studio .restroom-zone,
  .apartment-map.layout-two_room .restroom-zone,
  .apartment-map.layout-three_room .restroom-zone {
    grid-column: 2;
    grid-row: 1;
  }

  .apartment-map.layout-studio .living-zone,
  .apartment-map.layout-two_room .living-zone,
  .apartment-map.layout-three_room .living-zone {
    grid-column: 1 / 3;
    grid-row: 2;
  }

  .apartment-map.layout-studio .room-zone,
  .apartment-map.layout-two_room .room-zone,
  .apartment-map.layout-three_room .room-zone {
    grid-column: 1 / 3;
    grid-row: 3;
  }

  .apartment-map.layout-studio .bed-zone,
  .apartment-map.layout-two_room .bed-zone,
  .apartment-map.layout-three_room .bed-zone {
    grid-column: 1 / 3;
    grid-row: 4;
  }

  .apartment-map.layout-studio .kitchen-zone,
  .apartment-map.layout-two_room .kitchen-zone,
  .apartment-map.layout-three_room .kitchen-zone {
    grid-column: 1 / 3;
    grid-row: 5;
  }
}

/* C-039: Health-app active location styling */
.apt-zone.active {
  border-color: #14b8a6;
  background:
    radial-gradient(circle at 20% 20%, rgba(20, 184, 166, 0.18), transparent 38%),
    linear-gradient(135deg, #ecfdf5, #ffffff);
  box-shadow: 0 10px 28px rgba(20, 184, 166, 0.16);
}

.apt-zone.primary-location {
  border-color: #0f766e;
  background:
    radial-gradient(circle at 18% 18%, rgba(20, 184, 166, 0.28), transparent 42%),
    linear-gradient(135deg, #ccfbf1, #ffffff);
  box-shadow:
    0 14px 34px rgba(20, 184, 166, 0.24),
    inset 0 0 0 1px rgba(15, 118, 110, 0.18);
  position: relative;
}

.apt-zone.primary-location::after {
  content: "Active now";
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: #0f766e;
  color: white;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.22);
}

.apt-zone.alert.primary-location::after {
  content: "Check now";
  background: #dc2626;
}

.apt-zone.inactive {
  opacity: 1;
  background: white;
}

.apt-zone.inactive .zone-status {
  color: var(--muted);
}

.apt-zone.primary-location .zone-title {
  color: #0f172a;
}

.apt-zone.primary-location .zone-status {
  color: #0f766e;
  font-weight: 850;
}

.zone-person {
  z-index: 10;
  background: #0f172a;
  color: white;
}

.zone-person.at-bed,
.zone-person.at-room,
.zone-person.at-restroom,
.zone-person.at-living,
.zone-person.at-kitchen,
.zone-person.at-entrance {
  background: #0f766e;
}

.zone-person.unknown {
  background: #64748b;
}

.location-summary-grid .metric-value {
  color: #0f172a;
}

#estimatedLocation:not(:empty),
#restroomState:not(:empty),
#locationConfidence:not(:empty) {
  font-weight: 950;
}

/* C-042: Health-app mobile polish */
.page {
  max-width: 980px;
}

.card {
  border-radius: 26px;
}

.topbar {
  align-items: center;
}

.title {
  letter-spacing: -0.04em;
}

.subtitle {
  margin-top: 4px;
}

.mobile-tabs {
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  backdrop-filter: blur(10px);
}

.mobile-tab {
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.mobile-tab:active {
  transform: scale(0.96);
}

.metric {
  border-radius: 22px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.metric-value {
  letter-spacing: -0.03em;
}

.section-title {
  letter-spacing: -0.02em;
}

.zone-icon {
  display: inline-flex;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.06);
  font-size: 15px;
}

.apt-zone {
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}

.apt-zone.primary-location {
  transform: translateY(-2px);
}

.apt-zone.primary-location .zone-icon {
  background: rgba(20, 184, 166, 0.18);
}

.apt-zone.alert .zone-icon {
  background: rgba(239, 68, 68, 0.16);
}

.zone-status {
  margin-top: 8px;
}

.zone-person {
  border: 2px solid rgba(255, 255, 255, 0.8);
  letter-spacing: -0.01em;
}

.location-summary-grid .metric {
  background:
    radial-gradient(circle at 20% 10%, rgba(20, 184, 166, 0.08), transparent 40%),
    white;
}

.location-note {
  padding: 11px 12px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.risk-alert {
  animation: softPulse 1.8s ease-in-out infinite;
}

@keyframes softPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.20);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* Health-style active ring for selected location */
.apt-zone.primary-location::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 16px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  pointer-events: none;
}

/* Better app feeling on small phones */
@media (max-width: 650px) {
  body {
    background: #f8fafc;
  }

  .page {
    padding: 14px;
  }

  .card {
    border-radius: 24px;
    padding: 16px;
  }

  .topbar {
    gap: 12px;
  }

  .topbar button {
    padding: 9px 12px;
  }

  .mobile-tab,
  .range-tab,
  .chart-tab,
  .layout-tab {
    min-height: 38px;
  }

  .title {
    font-size: 24px;
  }

  .metric-value {
    font-size: 25px;
  }

  .apt-zone {
    min-height: 112px;
  }

  .apt-zone.primary-location::after {
    right: 10px;
    bottom: 10px;
  }
}

/* C-043: Mobile-app bottom navigation */
body {
  padding-bottom: 92px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(940px, calc(100% - 24px));
  z-index: 80;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 18px 45px rgba(15, 23, 42, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(14px);
}

.bottom-nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 22px;
  padding: 9px 4px 8px;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 850;
  box-shadow: none;
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.bottom-nav-item:active {
  transform: scale(0.94);
}

.bottom-nav-item.active {
  background:
    radial-gradient(circle at 50% 0%, rgba(20, 184, 166, 0.22), transparent 55%),
    #ecfdf5;
  color: #0f766e;
}

.bottom-nav-icon {
  font-size: 18px;
  line-height: 1;
}

/* On app-like mobile layout, bottom nav is primary. Top tab row becomes secondary/hidden. */
@media (max-width: 760px) {
  .mobile-tabs {
    display: none;
  }

  body {
    padding-bottom: 104px;
  }

  .bottom-nav {
    bottom: 10px;
    width: calc(100% - 18px);
    border-radius: 24px;
  }

  .bottom-nav-item {
    min-height: 56px;
    font-size: 10.5px;
  }

  .bottom-nav-icon {
    font-size: 17px;
  }
}

/* On wider desktop/tablet, keep both available but make bottom nav compact. */
@media (min-width: 761px) {
  .bottom-nav {
    max-width: 760px;
  }
}

/* C-044: App-style alert banner and notification center */
.app-alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 26px;
  padding: 15px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: white;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.app-alert-banner.normal {
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, 0.14), transparent 42%),
    #ffffff;
  border-color: rgba(20, 184, 166, 0.28);
}

.app-alert-banner.warning {
  background:
    radial-gradient(circle at 12% 10%, rgba(245, 158, 11, 0.18), transparent 42%),
    #fffdf5;
  border-color: rgba(245, 158, 11, 0.38);
}

.app-alert-banner.alert {
  background:
    radial-gradient(circle at 12% 10%, rgba(239, 68, 68, 0.18), transparent 42%),
    #fff7f7;
  border-color: rgba(239, 68, 68, 0.40);
  animation: softPulse 1.8s ease-in-out infinite;
}

.app-alert-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  font-size: 22px;
  font-weight: 950;
  background: #ecfdf5;
  color: #0f766e;
}

.app-alert-banner.warning .app-alert-icon {
  background: #fffbeb;
  color: #b45309;
}

.app-alert-banner.alert .app-alert-icon {
  background: #fee2e2;
  color: #dc2626;
}

.app-alert-text {
  flex: 1;
  min-width: 0;
}

.app-alert-title {
  font-size: 16px;
  font-weight: 950;
  color: var(--text);
  letter-spacing: -0.02em;
}

.app-alert-message {
  margin-top: 3px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.app-alert-action {
  border: 0;
  background: #0f172a;
  color: white;
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 900;
  box-shadow: none;
}

.notification-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notification-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 11px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px;
  background: white;
}

.notification-item.normal {
  background: #ffffff;
}

.notification-item.warning {
  background: #fffbeb;
  border-color: rgba(245, 158, 11, 0.34);
}

.notification-item.alert {
  background: #fff7f7;
  border-color: rgba(239, 68, 68, 0.38);
}

.notification-icon {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  font-size: 20px;
}

.notification-item.normal .notification-icon {
  background: #ecfdf5;
}

.notification-item.warning .notification-icon {
  background: #fffbeb;
}

.notification-item.alert .notification-icon {
  background: #fee2e2;
}

.notification-title {
  font-weight: 950;
  color: var(--text);
  letter-spacing: -0.01em;
}

.notification-message {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
}

.notification-time {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

@media (max-width: 650px) {
  .app-alert-banner {
    border-radius: 24px;
    padding: 13px;
  }

  .app-alert-icon {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    font-size: 20px;
  }

  .app-alert-action {
    padding: 8px 10px;
  }

  .notification-item {
    border-radius: 18px;
  }
}

/* C-045: Home layout onboarding/configuration */
.setup-card {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 10% 10%, rgba(20, 184, 166, 0.08), transparent 36%),
    white;
  border-radius: 20px;
  padding: 14px;
  margin-top: 12px;
}

.setup-title {
  font-size: 15px;
  font-weight: 950;
  color: var(--text);
  letter-spacing: -0.01em;
}

.setup-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
}

.setup-select-row {
  flex: 0 0 190px;
}

#homeLayoutSelect {
  width: 100%;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  border-radius: 16px;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 850;
}

@media (max-width: 650px) {
  .setup-card {
    flex-direction: column;
    align-items: stretch;
  }

  .setup-select-row {
    flex: 1 1 auto;
  }
}

/* C-047: Activity statistics cards */
.activity-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 11px;
  margin-top: 12px;
}

.activity-stat-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 11px;
  align-items: center;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, 0.08), transparent 38%),
    white;
  border-radius: 22px;
  padding: 13px;
}

.activity-stat-card.primary {
  border-color: rgba(20, 184, 166, 0.34);
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, 0.14), transparent 42%),
    #ffffff;
}

.activity-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.activity-stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.activity-stat-value {
  margin-top: 2px;
  color: var(--text);
  font-size: 22px;
  font-weight: 950;
  letter-spacing: -0.04em;
}

.activity-stat-note {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.3;
}

.activity-insight-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px;
  margin-top: 12px;
}

.activity-insight {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px;
  background: #f8fafc;
}

.activity-insight-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.activity-insight-value {
  margin-top: 4px;
  color: var(--text);
  font-size: 22px;
  font-weight: 950;
}

@media (max-width: 650px) {
  .activity-summary-grid {
    grid-template-columns: 1fr;
  }

  .activity-insight-row {
    grid-template-columns: 1fr;
  }
}

/* C-048: Clear horizontal trend chart */
.bar-chart {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-height: 220px;
  max-height: 430px;
  overflow-y: auto;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border-radius: 18px;
  padding: 14px;
}

.horizontal-chart-row {
  display: grid;
  grid-template-columns: 58px 1fr 64px;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}

.horizontal-chart-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.horizontal-chart-track {
  position: relative;
  height: 12px;
  background: #edf2f7;
  border-radius: 999px;
  overflow: hidden;
}

.horizontal-chart-fill {
  height: 100%;
  min-width: 4px;
  border-radius: 999px;
  background: #0f766e;
}

.horizontal-chart-fill.empty {
  background: #cbd5e1;
  min-width: 4px;
  opacity: 0.55;
}

.horizontal-chart-value {
  color: var(--text);
  font-size: 12px;
  font-weight: 950;
  text-align: right;
  white-space: nowrap;
}

.horizontal-chart-row.today {
  background: #ecfdf5;
  border-radius: 14px;
  padding: 6px;
  margin-left: -6px;
  margin-right: -6px;
}

.horizontal-chart-row.today .horizontal-chart-date {
  color: #0f766e;
}

.horizontal-chart-row.today .horizontal-chart-fill {
  background: #0f766e;
}

.chart-empty-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  padding: 18px;
  text-align: center;
}

@media (max-width: 650px) {
  .horizontal-chart-row {
    grid-template-columns: 52px 1fr 56px;
    gap: 8px;
  }

  .bar-chart {
    max-height: 360px;
  }
}

/* C-049: Compact monthly summary replacing long 30-day overview */
.monthly-summary-card {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 15px;
  background:
    radial-gradient(circle at 10% 8%, rgba(20, 184, 166, 0.10), transparent 42%),
    #ffffff;
}

.monthly-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.monthly-summary-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 950;
  letter-spacing: -0.02em;
}

.monthly-summary-note {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.monthly-summary-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 10px;
  background: #ecfdf5;
  color: #0f766e;
  font-size: 12px;
  font-weight: 950;
}

.monthly-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.monthly-summary-item {
  border: 1px solid rgba(226, 232, 240, 0.92);
  background: #f8fafc;
  border-radius: 18px;
  padding: 12px;
  min-height: 74px;
}

.monthly-summary-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.monthly-summary-value {
  margin-top: 5px;
  color: var(--text);
  font-size: 20px;
  font-weight: 950;
  letter-spacing: -0.03em;
}

@media (max-width: 760px) {
  .monthly-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 430px) {
  .monthly-summary-grid {
    grid-template-columns: 1fr;
  }
}

/* C-050: Interactive vertical bar trend dashboard */
.trend-chart-dashboard {
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    radial-gradient(circle at 8% 8%, rgba(20, 184, 166, 0.08), transparent 38%),
    linear-gradient(180deg, #ffffff, #f8fafc);
  padding: 16px;
  margin-top: 12px;
}

.trend-chart-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.trend-chart-main-title {
  font-size: 15px;
  font-weight: 950;
  color: var(--text);
  letter-spacing: -0.02em;
}

.trend-chart-main-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}

.trend-chart-selected-value {
  min-width: 120px;
  text-align: right;
  color: var(--text);
}

.trend-chart-selected-value .selected-main {
  font-size: 24px;
  font-weight: 950;
  letter-spacing: -0.04em;
}

.trend-chart-selected-value .selected-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.vertical-chart-wrap {
  position: relative;
  height: 280px;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
}

.vertical-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  padding: 8px 0 32px;
  text-align: right;
}

.vertical-chart-plot {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 100%;
  padding: 8px 4px 32px;
  border-left: 1px solid rgba(148, 163, 184, 0.22);
  border-bottom: 1px solid rgba(148, 163, 184, 0.26);
  overflow-x: auto;
  overflow-y: hidden;
}

.vertical-chart-plot::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 8px;
  bottom: 32px;
  background:
    linear-gradient(to bottom,
      rgba(148, 163, 184, 0.14) 1px,
      transparent 1px
    );
  background-size: 100% 25%;
  pointer-events: none;
}

.vertical-bar-group {
  position: relative;
  flex: 0 0 28px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  cursor: pointer;
}

.vertical-bar {
  position: relative;
  z-index: 2;
  width: 18px;
  min-height: 3px;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, #14b8a6, #0f766e);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
  transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}

.vertical-bar.empty {
  background: #cbd5e1;
  box-shadow: none;
  opacity: 0.55;
}

.vertical-bar-group:hover .vertical-bar,
.vertical-bar-group.selected .vertical-bar {
  transform: translateY(-4px);
  filter: brightness(1.05);
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.28);
}

.vertical-bar-group.selected .vertical-bar {
  background: linear-gradient(180deg, #0ea5e9, #2563eb);
}

.vertical-bar-label {
  position: absolute;
  z-index: 3;
  bottom: -26px;
  left: 50%;
  transform: translateX(-50%) rotate(-38deg);
  transform-origin: center;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.vertical-bar-tooltip {
  position: absolute;
  z-index: 5;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: none;
  min-width: 82px;
  border-radius: 12px;
  padding: 7px 8px;
  background: #0f172a;
  color: white;
  font-size: 11px;
  font-weight: 850;
  text-align: center;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.22);
}

.vertical-bar-group:hover .vertical-bar-tooltip,
.vertical-bar-group.selected .vertical-bar-tooltip {
  display: block;
}

.trend-chart-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.trend-chart-legend-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.trend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #0f766e;
}

.trend-chart-empty {
  display: flex;
  height: 100%;
  min-height: 210px;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.45;
  padding: 20px;
}

.mini-trend-title,
.mini-trend-list {
  display: none !important;
}

@media (max-width: 650px) {
  .trend-chart-header-row {
    flex-direction: column;
  }

  .trend-chart-selected-value {
    text-align: left;
  }

  .vertical-chart-wrap {
    height: 250px;
    grid-template-columns: 36px 1fr;
  }

  .vertical-chart-plot {
    gap: 6px;
  }

  .vertical-bar-group {
    flex-basis: 24px;
  }

  .vertical-bar {
    width: 16px;
  }
}

/* C-051: Day / Week / Month trend aggregation controls */
.trend-group-tabs {
  display: inline-flex;
  gap: 7px;
  margin-top: 10px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
}

.trend-group-tab {
  border: 0;
  border-radius: 999px;
  padding: 7px 11px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  box-shadow: none;
  min-height: auto;
}

.trend-group-tab.active {
  background: #0f766e;
  color: white;
}

.vertical-chart-plot.group-week .vertical-bar-group {
  flex-basis: 56px;
}

.vertical-chart-plot.group-week .vertical-bar {
  width: 28px;
}

.vertical-chart-plot.group-month .vertical-bar-group {
  flex-basis: 86px;
}

.vertical-chart-plot.group-month .vertical-bar {
  width: 34px;
}

.vertical-chart-plot.group-month .vertical-bar-label,
.vertical-chart-plot.group-week .vertical-bar-label {
  transform: translateX(-50%) rotate(0deg);
}

@media (max-width: 650px) {
  .trend-group-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .trend-group-tab {
    flex: 1;
  }

  .vertical-chart-plot.group-week .vertical-bar-group {
    flex-basis: 50px;
  }

  .vertical-chart-plot.group-month .vertical-bar-group {
    flex-basis: 70px;
  }
}

/* C-052: KPI cards above trend chart */
.trend-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 11px;
  margin: 12px 0 12px;
}

.trend-kpi-card {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 13px;
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, 0.07), transparent 40%),
    #ffffff;
  min-height: 92px;
}

.trend-kpi-card.primary {
  border-color: rgba(20, 184, 166, 0.38);
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, 0.16), transparent 42%),
    #ffffff;
}

.trend-kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.trend-kpi-value {
  margin-top: 5px;
  color: var(--text);
  font-size: 25px;
  font-weight: 950;
  letter-spacing: -0.045em;
}

.trend-kpi-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.3;
}

.trend-kpi-value.positive {
  color: #0f766e;
}

.trend-kpi-value.negative {
  color: #dc2626;
}

.trend-kpi-value.neutral {
  color: var(--text);
}

@media (max-width: 850px) {
  .trend-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 430px) {
  .trend-kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* C-053: Metric color themes for trend dashboard */
.trend-chart-dashboard.metric-sleep {
  --metric-main: #2563eb;
  --metric-dark: #1d4ed8;
  --metric-soft: rgba(37, 99, 235, 0.14);
  --metric-border: rgba(37, 99, 235, 0.35);
}

.trend-chart-dashboard.metric-wake {
  --metric-main: #7c3aed;
  --metric-dark: #6d28d9;
  --metric-soft: rgba(124, 58, 237, 0.14);
  --metric-border: rgba(124, 58, 237, 0.35);
}

.trend-chart-dashboard.metric-restroom {
  --metric-main: #0f766e;
  --metric-dark: #115e59;
  --metric-soft: rgba(15, 118, 110, 0.15);
  --metric-border: rgba(15, 118, 110, 0.36);
}

.trend-chart-dashboard.metric-alert {
  --metric-main: #dc2626;
  --metric-dark: #b91c1c;
  --metric-soft: rgba(220, 38, 38, 0.14);
  --metric-border: rgba(220, 38, 38, 0.36);
}

.trend-chart-dashboard.metric-heart {
  --metric-main: #e11d48;
  --metric-dark: #be123c;
  --metric-soft: rgba(225, 29, 72, 0.14);
  --metric-border: rgba(225, 29, 72, 0.34);
}

.trend-chart-dashboard.metric-breathing {
  --metric-main: #16a34a;
  --metric-dark: #15803d;
  --metric-soft: rgba(22, 163, 74, 0.14);
  --metric-border: rgba(22, 163, 74, 0.34);
}

.trend-chart-dashboard {
  border-color: var(--metric-border, var(--border));
  background:
    radial-gradient(circle at 8% 8%, var(--metric-soft, rgba(20, 184, 166, 0.08)), transparent 38%),
    linear-gradient(180deg, #ffffff, #f8fafc);
}

.trend-chart-dashboard .vertical-bar {
  background: linear-gradient(180deg, var(--metric-main, #14b8a6), var(--metric-dark, #0f766e));
  box-shadow: 0 8px 18px var(--metric-soft, rgba(15, 118, 110, 0.18));
}

.trend-chart-dashboard .vertical-bar-group.selected .vertical-bar {
  background: linear-gradient(180deg, var(--metric-dark, #2563eb), var(--metric-main, #0ea5e9));
  box-shadow: 0 12px 26px var(--metric-soft, rgba(15, 118, 110, 0.30));
}

.trend-chart-dashboard .trend-dot {
  background: var(--metric-main, #0f766e);
}

.trend-chart-dashboard .trend-group-tab.active {
  background: var(--metric-main, #0f766e);
}

.trend-chart-dashboard .trend-chart-selected-value .selected-main {
  color: var(--metric-dark, var(--text));
}

.trend-kpi-grid.metric-sleep {
  --metric-main: #2563eb;
  --metric-soft: rgba(37, 99, 235, 0.13);
  --metric-border: rgba(37, 99, 235, 0.34);
}

.trend-kpi-grid.metric-wake {
  --metric-main: #7c3aed;
  --metric-soft: rgba(124, 58, 237, 0.13);
  --metric-border: rgba(124, 58, 237, 0.34);
}

.trend-kpi-grid.metric-restroom {
  --metric-main: #0f766e;
  --metric-soft: rgba(15, 118, 110, 0.14);
  --metric-border: rgba(15, 118, 110, 0.35);
}

.trend-kpi-grid.metric-alert {
  --metric-main: #dc2626;
  --metric-soft: rgba(220, 38, 38, 0.13);
  --metric-border: rgba(220, 38, 38, 0.35);
}

.trend-kpi-grid.metric-heart {
  --metric-main: #e11d48;
  --metric-soft: rgba(225, 29, 72, 0.13);
  --metric-border: rgba(225, 29, 72, 0.34);
}

.trend-kpi-grid.metric-breathing {
  --metric-main: #16a34a;
  --metric-soft: rgba(22, 163, 74, 0.13);
  --metric-border: rgba(22, 163, 74, 0.34);
}

.trend-kpi-grid .trend-kpi-card.primary {
  border-color: var(--metric-border, rgba(20, 184, 166, 0.38));
  background:
    radial-gradient(circle at 12% 10%, var(--metric-soft, rgba(20, 184, 166, 0.16)), transparent 42%),
    #ffffff;
}

.trend-kpi-grid .trend-kpi-card.primary .trend-kpi-value {
  color: var(--metric-main, var(--text));
}

.chart-tab.metric-active {
  background: var(--metric-main, #0f766e) !important;
  color: white !important;
  border-color: var(--metric-main, #0f766e) !important;
}

/* C-054: Combined care trend chart */
.trend-chart-dashboard.metric-combined {
  --metric-main: #0f172a;
  --metric-dark: #020617;
  --metric-soft: rgba(15, 23, 42, 0.10);
  --metric-border: rgba(15, 23, 42, 0.22);
}

.trend-kpi-grid.metric-combined {
  --metric-main: #0f172a;
  --metric-soft: rgba(15, 23, 42, 0.10);
  --metric-border: rgba(15, 23, 42, 0.22);
}

.combined-chart-plot {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 100%;
  padding: 8px 4px 36px;
  border-left: 1px solid rgba(148, 163, 184, 0.22);
  border-bottom: 1px solid rgba(148, 163, 184, 0.26);
  overflow-x: auto;
  overflow-y: hidden;
}

.combined-chart-plot::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 8px;
  bottom: 36px;
  background:
    linear-gradient(to bottom,
      rgba(148, 163, 184, 0.14) 1px,
      transparent 1px
    );
  background-size: 100% 25%;
  pointer-events: none;
}

.combined-day-group {
  position: relative;
  flex: 0 0 38px;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 3px;
  cursor: pointer;
}

.combined-mini-bar {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 3px;
  border-radius: 8px 8px 3px 3px;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.combined-mini-bar.sleep {
  background: linear-gradient(180deg, #60a5fa, #2563eb);
}

.combined-mini-bar.wake {
  background: linear-gradient(180deg, #a78bfa, #7c3aed);
}

.combined-mini-bar.restroom {
  background: linear-gradient(180deg, #2dd4bf, #0f766e);
}

.combined-day-group:hover .combined-mini-bar,
.combined-day-group.selected .combined-mini-bar {
  transform: translateY(-4px);
  filter: brightness(1.05);
}

.combined-date-label {
  position: absolute;
  z-index: 3;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%) rotate(-38deg);
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.combined-tooltip {
  position: absolute;
  z-index: 8;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: none;
  min-width: 145px;
  border-radius: 13px;
  padding: 8px 9px;
  background: #0f172a;
  color: white;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.4;
  text-align: left;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.24);
}

.combined-day-group:hover .combined-tooltip,
.combined-day-group.selected .combined-tooltip {
  display: block;
}

.combined-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.combined-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.combined-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.combined-legend-dot.sleep {
  background: #2563eb;
}

.combined-legend-dot.wake {
  background: #7c3aed;
}

.combined-legend-dot.restroom {
  background: #0f766e;
}

@media (max-width: 650px) {
  .combined-day-group {
    flex-basis: 34px;
  }

  .combined-chart-plot {
    gap: 8px;
  }
}

/* C-055: Care Insights section */
.care-insight-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.care-insight-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 11px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px;
  background: white;
}

.care-insight-item.normal {
  background:
    radial-gradient(circle at 8% 8%, rgba(20, 184, 166, 0.08), transparent 38%),
    #ffffff;
  border-color: rgba(20, 184, 166, 0.22);
}

.care-insight-item.notice {
  background:
    radial-gradient(circle at 8% 8%, rgba(59, 130, 246, 0.10), transparent 38%),
    #ffffff;
  border-color: rgba(59, 130, 246, 0.25);
}

.care-insight-item.warning {
  background:
    radial-gradient(circle at 8% 8%, rgba(245, 158, 11, 0.13), transparent 38%),
    #fffdf5;
  border-color: rgba(245, 158, 11, 0.34);
}

.care-insight-item.alert {
  background:
    radial-gradient(circle at 8% 8%, rgba(239, 68, 68, 0.14), transparent 38%),
    #fff7f7;
  border-color: rgba(239, 68, 68, 0.38);
}

.care-insight-icon {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  font-size: 20px;
}

.care-insight-item.normal .care-insight-icon {
  background: #ecfdf5;
}

.care-insight-item.notice .care-insight-icon {
  background: #eff6ff;
}

.care-insight-item.warning .care-insight-icon {
  background: #fffbeb;
}

.care-insight-item.alert .care-insight-icon {
  background: #fee2e2;
}

.care-insight-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 950;
  letter-spacing: -0.01em;
}

.care-insight-message {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.4;
}

.care-insight-meta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

@media (max-width: 650px) {
  .care-insight-item {
    border-radius: 18px;
  }
}

/* C-057: Zone/session details */
.zone-session-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 11px;
  margin-top: 12px;
}

.zone-session-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 11px;
  align-items: center;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, 0.08), transparent 38%),
    white;
  border-radius: 22px;
  padding: 13px;
}

.zone-session-card.primary {
  border-color: rgba(20, 184, 166, 0.34);
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, 0.15), transparent 42%),
    #ffffff;
}

.zone-session-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.zone-session-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.zone-session-value {
  margin-top: 2px;
  color: var(--text);
  font-size: 22px;
  font-weight: 950;
  letter-spacing: -0.04em;
}

.zone-session-note {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.3;
}

.session-detail-card {
  margin-top: 13px;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 14px;
  background: #f8fafc;
}

.session-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.session-detail-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 950;
}

.session-detail-note {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.session-detail-badge {
  border-radius: 999px;
  padding: 7px 10px;
  background: #ecfdf5;
  color: #0f766e;
  font-size: 12px;
  font-weight: 950;
  white-space: nowrap;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.session-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(226, 232, 240, 0.92);
  background: white;
  border-radius: 17px;
  padding: 10px;
}

.session-row.open {
  border-color: rgba(20, 184, 166, 0.34);
  background: #ecfdf5;
}

.session-row-icon {
  width: 36px;
  height: 36px;
  border-radius: 13px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.session-row-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 950;
}

.session-row-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.session-row-duration {
  color: var(--text);
  font-size: 13px;
  font-weight: 950;
  white-space: nowrap;
}

@media (max-width: 650px) {
  .zone-session-grid {
    grid-template-columns: 1fr;
  }

  .session-row {
    grid-template-columns: 34px 1fr;
  }

  .session-row-duration {
    grid-column: 2;
  }
}

/* C-061 backend-driven registered location map */
.c061-backend-location-card {
  margin-bottom: 16px;
}

.c061-location-summary {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
  color: #334155;
  font-weight: 800;
}

.c061-map-wrap {
  width: 100%;
  overflow: hidden;
}

.c061-map {
  position: relative;
  min-height: 300px;
  border-radius: 22px;
  border: 1px solid #dbe4ef;
  background:
    linear-gradient(90deg, rgba(148, 163, 184, 0.12) 1px, transparent 1px),
    linear-gradient(0deg, rgba(148, 163, 184, 0.12) 1px, transparent 1px),
    #f8fafc;
  background-size: 10% 10%;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.65);
}

.c061-zone {
  position: absolute;
  border: 2px solid #cbd5e1;
  background: rgba(255,255,255,0.82);
  border-radius: 16px;
  padding: 10px;
  min-width: 80px;
  min-height: 52px;
  box-sizing: border-box;
  color: #0f172a;
  transition: 0.2s ease;
  overflow: hidden;
}

.c061-zone-title {
  font-weight: 950;
  font-size: 13px;
}

.c061-zone-type {
  color: #64748b;
  font-size: 11px;
  margin-top: 3px;
}

.c061-zone.active {
  border-color: #0f766e;
  background: #ecfdf5;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.18);
}

.c061-zone.soft-active {
  border-color: #38bdf8;
  background: #f0f9ff;
}

.c061-zone.unmapped {
  position: relative;
  display: inline-block;
  left: auto !important;
  top: auto !important;
  width: auto !important;
  height: auto !important;
  margin: 6px;
}

.c061-unmapped-list {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.c061-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: #64748b;
  font-size: 12px;
}

.c061-legend-pill {
  border-radius: 999px;
  padding: 5px 9px;
  background: #f1f5f9;
  font-weight: 800;
}

.c061-legend-pill.active {
  background: #ccfbf1;
  color: #0f766e;
}

@media (max-width: 700px) {
  .c061-map {
    min-height: 250px;
  }

  .c061-zone {
    padding: 8px;
    border-radius: 12px;
  }

  .c061-zone-title {
    font-size: 12px;
  }
}

/* C-070 cloud/edge mobile mode switch */
.c070-cloud-mode-card {
  border: 1px solid #dbeafe;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.c070-mode-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.c070-mode-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.c070-mode-buttons button {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: #334155;
  font-weight: 900;
  padding: 8px 13px;
  cursor: pointer;
}

.c070-mode-buttons button.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.c070-mode-status {
  margin-top: 12px;
  border-radius: 14px;
  padding: 11px 12px;
  background: #f1f5f9;
  color: #334155;
  font-weight: 850;
}

.c070-mode-status.cloud {
  background: #eff6ff;
  color: #1d4ed8;
}

.c070-mode-status.edge {
  background: #ecfdf5;
  color: #047857;
}

.c070-cloud-snapshot {
  margin-top: 14px;
}

.c070-snapshot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
}

.c070-snapshot-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 11px;
}

.c070-snapshot-item .label {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
}

.c070-snapshot-item strong {
  color: #0f172a;
  font-size: 15px;
}

.c070-cloud-events {
  margin-top: 14px;
}

.c070-cloud-events h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #0f172a;
}

.c070-cloud-event {
  border-left: 3px solid #bfdbfe;
  padding: 7px 10px;
  margin: 7px 0;
  background: #f8fafc;
  border-radius: 10px;
}

.c070-cloud-event strong {
  display: block;
  color: #0f172a;
  font-size: 13px;
}

.c070-cloud-event span {
  color: #64748b;
  font-size: 12px;
}

@media (max-width: 700px) {
  .c070-mode-header {
    flex-direction: column;
  }

  .c070-snapshot-grid {
    grid-template-columns: repeat(2, minmax(110px, 1fr));
  }
}

/* USERDATA-004F-FIX: styled Details-only family report */
.family-report-details-card {
  margin-top: 16px;
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.family-report-grid {
  margin-top: 14px;
}

.family-report-summary-box {
  display: grid;
  gap: 14px;
}

.family-report-summary-main {
  padding: 14px 16px;
  border: 1px solid rgba(16, 185, 129, 0.18);
  border-radius: 18px;
  background: linear-gradient(90deg, rgba(236, 253, 245, 0.95), rgba(255, 255, 255, 0.95));
}

.family-report-summary-title {
  font-weight: 800;
  color: #0f172a;
}

.family-report-summary-subtitle {
  margin-top: 4px;
  font-size: 0.92rem;
  color: #64748b;
}

.family-report-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.family-report-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(226, 232, 240, 1);
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.9);
}

.family-report-icon {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(209, 250, 229, 0.8);
}

.family-report-item-title {
  font-weight: 800;
  color: #0f172a;
}

.family-report-item-subtitle {
  margin-top: 2px;
  font-size: 0.82rem;
  color: #64748b;
}


/* MOBILE_LOCATION_UI_001: semantic location-state frontend */
#c061BackendLocationCard {
  display: none !important;
}

#zonePerson {
  display: none !important;
}

.bedroom-zone {
  grid-area: bedroom;
}

.loc-main {
  font-size: 14px;
  font-weight: 950;
  color: #0f172a;
}

.loc-vitals {
  margin-top: 7px;
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 9px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 900;
}

.loc-sub {
  margin-top: 6px;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.apartment-map.layout-studio,
.apartment-map.layout-two_room,
.apartment-map.layout-three_room {
  grid-template-columns: 0.82fr 1.05fr 1.05fr 0.95fr !important;
  grid-template-rows: 0.75fr 0.95fr 0.95fr 1fr !important;
}

.apartment-map.layout-studio .bedroom-zone,
.apartment-map.layout-two_room .bedroom-zone,
.apartment-map.layout-three_room .bedroom-zone {
  grid-column: 2 / 5 !important;
  grid-row: 3 / 5 !important;
  min-height: 245px !important;
  padding-bottom: 118px !important;
  z-index: 1 !important;
}

.apartment-map.layout-studio .bed-zone,
.apartment-map.layout-two_room .bed-zone,
.apartment-map.layout-three_room .bed-zone {
  grid-column: 3 / 5 !important;
  grid-row: 4 !important;
  align-self: end !important;
  justify-self: end !important;
  width: 92% !important;
  min-height: 110px !important;
  z-index: 3 !important;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.10) !important;
}

.apt-zone.mobile-loc-active {
  border-color: #0f766e !important;
  background:
    radial-gradient(circle at 18% 18%, rgba(20, 184, 166, 0.22), transparent 42%),
    linear-gradient(135deg, #ecfdf5, #ffffff) !important;
}

.apt-zone.mobile-loc-active .loc-main {
  color: #0f766e;
}

.apt-zone.mobile-loc-recent {
  border-color: #f59e0b !important;
  background:
    radial-gradient(circle at 18% 18%, rgba(245, 158, 11, 0.12), transparent 42%),
    linear-gradient(135deg, #fffbeb, #ffffff) !important;
}


/* LOCATION_UI_COSMETIC_001: improve location-card readability */

/* 1) Remove floating badge that hides vitals */
.apt-zone.primary-location::after,
.apt-zone.alert.primary-location::after {
  display: none !important;
  content: none !important;
}

/* 2) Better vertical spacing inside each location box */
.apt-zone .zone-status {
  margin-top: 14px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 8px !important;
}

/* 3) Stronger main status text */
.loc-main {
  font-size: 17px !important;
  line-height: 1.25 !important;
  font-weight: 900 !important;
  color: #0f172a !important;
}

/* Active / recent text color */
.apt-zone.location005-active .loc-main {
  color: #0f766e !important;
}

.apt-zone.recent-location .loc-main {
  color: #b45309 !important;
}

/* 4) Vitals should be clearly visible and never hidden */
.loc-vitals {
  margin-top: 0 !important;
  display: inline-flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 6px !important;
  width: auto !important;
  max-width: 100% !important;
  border-radius: 12px !important;
  padding: 7px 10px !important;
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  font-size: 12px !important;
  line-height: 1.35 !important;
  font-weight: 900 !important;
  white-space: normal !important;
  box-sizing: border-box !important;
}

/* 5) Sub info row */
.loc-sub {
  margin-top: 0 !important;
  color: #64748b !important;
  font-size: 12px !important;
  line-height: 1.3 !important;
  font-weight: 800 !important;
}

/* 6) Slightly improve box breathing room */
.apt-zone {
  padding-bottom: 16px !important;
}

/* 7) Keep title area clean */
.apt-zone .zone-title {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  margin-bottom: 2px !important;
}

/* 8) Primary active zone should look nicer but not flashy */
.apt-zone.primary-location {
  box-shadow:
    0 12px 28px rgba(20, 184, 166, 0.18),
    inset 0 0 0 1px rgba(15, 118, 110, 0.15) !important;
}

/* 9) Small-screen safeguard */
@media (max-width: 900px) {
  .loc-main {
    font-size: 15px !important;
  }

  .loc-vitals,
  .loc-sub {
    font-size: 11px !important;
  }
}


/* LOCATION_UI_COSMETIC_002: keep text inside cards + enlarge kitchen */

/* 1) Keep all location-card text safely inside the box */
.apt-zone .zone-status {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.loc-main,
.loc-vitals,
.loc-sub {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.loc-vitals {
  display: inline-flex !important;
  flex-wrap: wrap !important;
  width: auto !important;
  max-width: 100% !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  font-size: 11px !important;
  line-height: 1.25 !important;
  padding: 6px 10px !important;
}

.loc-sub {
  display: block !important;
  width: 100% !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  font-size: 11px !important;
  line-height: 1.25 !important;
  margin-top: 6px !important;
}

/* 2) Give active cards more vertical room so text never escapes */
.apt-zone.primary-location,
.apt-zone.location005-active,
.apt-zone.active {
  min-height: 170px !important;
  padding-bottom: 18px !important;
}

/* 3) Restroom card specifically needs a bit more room */
.apt-zone.restroom-zone {
  min-height: 155px !important;
}

/* 4) Kitchen card should be larger and easier to see */
.apt-zone.kitchen-zone {
  min-height: 165px !important;
}

/* 5) In the 2-room layout, give the kitchen more space */
.apartment-map.layout-two_room .kitchen-zone,
.apartment-map.layout-2_room .kitchen-zone {
  min-height: 175px !important;
}

/* 6) Slightly reduce title crowding */
.apt-zone .zone-title {
  margin-bottom: 10px !important;
}



/* NOW_TAB_001: better Now tab current location + vitals */
.now-status-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.now-location-metric {
  border-color: rgba(20, 184, 166, 0.34) !important;
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, 0.16), transparent 42%),
    #ffffff !important;
}

#nowLocationValue {
  color: #0f766e;
}

#hrValue,
#brValue {
  color: #0f172a;
}

#vitalsStatus {
  color: #1d4ed8;
  font-weight: 850;
}

.app-alert-banner.normal {
  animation: none !important;
}

.hero.normal {
  border-color: #99f6e4 !important;
  background: linear-gradient(180deg, #ffffff, #f0fdfa) !important;
}

@media (max-width: 650px) {
  .now-status-grid {
    grid-template-columns: 1fr;
  }
}


/* NOW_TAB_ZONE_CHIPS_001: smart active-zone chips on Now tab */
.now-zone-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 14px;
}

.now-zone-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 11px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.now-zone-chip.active {
  border-color: rgba(15, 118, 110, 0.35);
  background: #ccfbf1;
  color: #0f766e;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.12);
}

.now-zone-chip.recent {
  border-color: rgba(245, 158, 11, 0.35);
  background: #fffbeb;
  color: #b45309;
}

.now-zone-chip.off {
  opacity: 0.55;
}

.now-location-metric {
  border-color: rgba(15, 118, 110, 0.35) !important;
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, 0.16), transparent 42%),
    #ffffff !important;
}


/* NOW_TAB_FINAL_AUTHORITATIVE_001 */
.now-zone-chips {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  margin: 4px 0 16px !important;
}

.now-zone-chip {
  display: inline-flex !important;
  align-items: center !important;
  border-radius: 999px !important;
  padding: 8px 12px !important;
  border: 1px solid #e2e8f0 !important;
  background: #f8fafc !important;
  color: #64748b !important;
  font-size: 12px !important;
  font-weight: 900 !important;
  line-height: 1 !important;
}

.now-zone-chip.active {
  border-color: rgba(15, 118, 110, 0.35) !important;
  background: #ccfbf1 !important;
  color: #0f766e !important;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.12) !important;
}

.now-zone-chip.recent {
  border-color: rgba(245, 158, 11, 0.35) !important;
  background: #fffbeb !important;
  color: #b45309 !important;
}

.now-zone-chip.quiet {
  background: #f8fafc !important;
  color: #64748b !important;
}

.now-zone-chip.off {
  opacity: 0.55 !important;
}

.now-location-metric {
  border-color: rgba(15, 118, 110, 0.35) !important;
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, 0.16), transparent 42%),
    #ffffff !important;
}


/* TRENDS_V2_UI_001: unified Trends tab; old repeated sections hidden until cleanup */
#trendsCard,
#activityStatsCard,
#zoneSessionsCard {
  display: none !important;
}

.trends-v2-card {
  border-color: rgba(15, 118, 110, 0.22);
  background:
    radial-gradient(circle at 10% 5%, rgba(20, 184, 166, 0.10), transparent 40%),
    #ffffff;
}

.trends-v2-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.trends-v2-tabs,
.trends-v2-zone-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.trends-v2-tab,
.trends-v2-zone {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: #475569;
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: none;
}

.trends-v2-tab.active,
.trends-v2-zone.active {
  background: #0f766e;
  color: white;
  border-color: #0f766e;
}

.trends-v2-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px;
  margin: 12px 0 14px;
}

.trends-v2-kpi {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: white;
  padding: 12px;
  min-height: 96px;
}

.trends-v2-kpi.primary {
  border-color: rgba(15, 118, 110, 0.35);
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, 0.16), transparent 42%),
    #ffffff;
}

.trends-v2-kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: #ecfdf5;
  color: #0f766e;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 950;
}

.trends-v2-kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.trends-v2-kpi-value {
  margin-top: 3px;
  color: var(--text);
  font-size: 23px;
  font-weight: 950;
  letter-spacing: -0.04em;
}

.trends-v2-kpi-note {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 750;
  line-height: 1.3;
}

.trends-v2-chart-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  padding: 14px;
}

.trends-v2-chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.trends-v2-chart-title {
  font-size: 15px;
  font-weight: 950;
  color: var(--text);
}

.trends-v2-chart-note {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}

.trends-v2-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 10px;
  background: #ecfdf5;
  color: #0f766e;
  font-size: 12px;
  font-weight: 950;
}

.trends-v2-chart {
  height: 270px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 6px 34px;
  border-left: 1px solid rgba(148, 163, 184, 0.22);
  border-bottom: 1px solid rgba(148, 163, 184, 0.26);
  overflow-x: auto;
  overflow-y: hidden;
  position: relative;
}

.trends-v2-chart::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: 12px;
  bottom: 34px;
  background:
    linear-gradient(to bottom, rgba(148, 163, 184, 0.13) 1px, transparent 1px);
  background-size: 100% 25%;
  pointer-events: none;
}

.trends-v2-bar-item {
  position: relative;
  flex: 0 0 28px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.trends-v2-bar {
  z-index: 2;
  width: 18px;
  min-height: 3px;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, #14b8a6, #0f766e);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
}

.trends-v2-bar-item.latest .trends-v2-bar {
  background: linear-gradient(180deg, #0ea5e9, #2563eb);
}

.trends-v2-bar-label {
  position: absolute;
  bottom: -26px;
  left: 50%;
  transform: translateX(-50%) rotate(-38deg);
  transform-origin: center;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.trends-v2-tooltip {
  display: none;
  position: absolute;
  z-index: 5;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 88px;
  border-radius: 12px;
  padding: 7px 8px;
  background: #0f172a;
  color: white;
  font-size: 11px;
  font-weight: 850;
  text-align: center;
  line-height: 1.35;
}

.trends-v2-bar-item:hover .trends-v2-tooltip,
.trends-v2-bar-item.latest .trends-v2-tooltip {
  display: block;
}

.trends-v2-details {
  margin-top: 13px;
}

.trends-v2-detail-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 11px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: white;
  padding: 12px;
}

.trends-v2-detail-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #f1f5f9;
  font-size: 20px;
}

.trends-v2-detail-title {
  font-weight: 950;
  color: var(--text);
}

.trends-v2-detail-text {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.4;
}

.trends-v2-detail-note {
  margin-top: 6px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 750;
}

@media (max-width: 850px) {
  .trends-v2-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .trends-v2-kpis {
    grid-template-columns: 1fr;
  }

  .trends-v2-chart {
    height: 245px;
  }

  .trends-v2-bar-item {
    flex-basis: 24px;
  }

  .trends-v2-bar {
    width: 16px;
  }
}


/* NOW_SIMPLE_SENSOR_ROWS_001 */
.simple-now-card {
  margin: 12px 0 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #ffffff;
  padding: 12px;
}

.simple-now-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 950;
  margin-bottom: 10px;
}

.simple-now-table {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.simple-now-row {
  display: grid;
  grid-template-columns: 1.35fr 0.8fr 0.8fr 0.6fr 0.6fr;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  font-size: 13px;
  font-weight: 850;
}

.simple-now-header {
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.simple-now-area {
  font-weight: 950;
  color: var(--text);
}

.simple-now-status {
  text-transform: capitalize;
}

.simple-now-active {
  border-color: rgba(15, 118, 110, 0.38);
  background: #ecfdf5;
  color: #0f766e;
}

.simple-now-recent {
  border-color: rgba(245, 158, 11, 0.40);
  background: #fffbeb;
  color: #92400e;
}

.simple-now-quiet {
  background: #ffffff;
  color: #475569;
}

.simple-now-offline {
  background: #f1f5f9;
  color: #94a3b8;
}

.simple-now-loading {
  padding: 12px;
  color: #64748b;
  font-weight: 800;
}

@media (max-width: 650px) {
  .simple-now-row {
    grid-template-columns: 1.2fr 0.75fr 0.75fr 0.5fr 0.5fr;
    gap: 6px;
    padding: 9px;
    font-size: 12px;
  }
}


/* NOW_AREA_CARDS_002: replace Now tab row-table with 5 live status cards, and hide hero banner */

#heroCard {
  display: none !important;
}

.simple-now-card {
  border-radius: 28px;
}

.simple-now-head {
  align-items: center;
}

.simple-now-table {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
}

.simple-now-header {
  display: none !important;
}

#simpleNowSensorRows {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.now-area-card {
  border: 2px solid #d8dee8;
  border-radius: 24px;
  background: #ffffff;
  padding: 18px;
  min-height: 190px;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.now-area-card--active {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.45);
}

.now-area-card--recent {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.45);
}

.now-area-card--quiet {
  background: #f8fafc;
  border-color: #d8dee8;
}

.now-area-card--offline {
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.28);
}

.now-area-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.now-area-card__title {
  font-size: 1.65rem;
  line-height: 1.2;
  font-weight: 800;
  color: #16213e;
  display: flex;
  align-items: center;
  gap: 8px;
}

.now-area-card__pill {
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
  border-radius: 999px;
  padding: 9px 12px;
  border: 1px solid #d8dee8;
  background: #ffffff;
  color: #475569;
  white-space: nowrap;
}

.now-area-card--active .now-area-card__pill {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.35);
  color: #0f766e;
}

.now-area-card--recent .now-area-card__pill {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.35);
  color: #9a3412;
}

.now-area-card--quiet .now-area-card__pill {
  background: #f1f5f9;
  color: #475569;
}

.now-area-card--offline .now-area-card__pill {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.24);
  color: #991b1b;
}

.now-area-card__subtitle {
  font-size: 1.02rem;
  color: #64748b;
  margin-bottom: 14px;
}

.now-area-card__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
}

.now-area-card__metric {
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  padding-top: 10px;
}

.now-area-card__label {
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 4px;
}

.now-area-card__value {
  font-size: 1.65rem;
  line-height: 1.1;
  font-weight: 800;
  color: #0f172a;
}

.now-area-card__value.small {
  font-size: 1.25rem;
}

.simple-now-loading {
  grid-column: 1 / -1;
  padding: 18px 20px;
  border-radius: 20px;
}

@media (max-width: 900px) {
  #simpleNowSensorRows {
    grid-template-columns: 1fr;
  }
}


/* NOW_REMOVE_DUPLICATE_STATUS_GRID_001
   Remove repeated Now-tab summary cards.
   The 5 live area cards are now the single source for:
   status, presence, BR, HR.
*/
#tab-now .now-status-grid {
  display: none !important;
}

#tab-now .now-zone-chips {
  display: none !important;
}

#simpleNowSensorRowsCard {
  margin-top: 0 !important;
}
/* DFWS_SAFE_HOME_SCOPE_BADGE_STYLE_042B */
.dfws-home-scope-badge {
  box-sizing: border-box;
  width: calc(100% - 24px);
  max-width: 760px;
  margin: 12px auto;
  padding: 10px 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  background: rgba(255, 255, 255, 0.92);
}

@media (prefers-color-scheme: dark) {
  .dfws-home-scope-badge {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(20, 20, 20, 0.92);
  }
}

/* DFWS_P2_STATUS_TRUTHFULNESS_CSS_V1 */
.c070-mode-status.p2-backend-online {
  border-style: solid;
}

.c070-mode-status.p2-backend-offline {
  border-style: dashed;
}

.c070-mode-status.p2-sensors-partial::after,
.c070-mode-status.p2-sensors-online::after,
.c070-mode-status.p2-sensors-offline::after {
  content: "";
}

/* DAILY_ROUTINE_EDGE_001
   Compact Today-tab routine card. Cloud parity will reuse this contract later.
*/
#tab-now {
  gap: 8px !important;
}

#tab-now > .card,
#tab-now > .app-alert-banner {
  margin-bottom: 8px !important;
}

#tab-now .card {
  padding: 11px 12px !important;
}

#tab-now .hero {
  padding: 12px !important;
}

#tab-now .hero-row,
#tab-now .c070-mode-header {
  gap: 8px !important;
}

#tab-now .section-title {
  margin-bottom: 3px !important;
}

#tab-now .now-zone-chips {
  margin: 7px 0 !important;
  gap: 5px !important;
}

#tab-now .now-zone-chip {
  padding: 5px 8px !important;
  font-size: 12px !important;
}

#tab-now .simple-now-card {
  padding: 8px !important;
  margin-top: 7px !important;
}

#tab-now .simple-now-row {
  padding: 7px 8px !important;
}

#tab-now .now-status-grid {
  gap: 7px !important;
  margin-top: 8px !important;
}

#tab-now .metric {
  padding: 9px 10px !important;
}

.today-routine-card {
  overflow: hidden;
}

.today-routine-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.today-routine-switch {
  display: inline-flex;
  flex-shrink: 0;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--soft-bg, #f1f5f9);
}

.today-routine-switch button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.today-routine-switch button.active {
  background: var(--card-bg, #ffffff);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.today-routine-content {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  margin-top: 10px;
}

.today-routine-chart-wrap {
  display: flex;
  justify-content: center;
}

.today-routine-chart {
  position: relative;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: conic-gradient(#cbd5e1 0deg 360deg);
}

.today-routine-chart::after {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: var(--card-bg, #ffffff);
}

.today-routine-chart-center {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.today-routine-chart-center strong {
  font-size: 17px;
  line-height: 1.1;
}

.today-routine-chart-center span {
  margin-top: 2px;
  font-size: 10px;
  color: var(--muted, #64748b);
}

.today-routine-date {
  font-size: 14px;
  font-weight: 800;
}

.today-routine-quality {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted, #64748b);
}

.today-routine-list {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.today-routine-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  font-size: 12px;
}

.today-routine-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.today-routine-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-routine-duration {
  font-weight: 700;
  white-space: nowrap;
}

.today-routine-footnote {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--border, #e2e8f0);
  font-size: 10px;
  line-height: 1.4;
  color: var(--muted, #64748b);
}

.today-routine-loading {
  font-size: 12px;
  color: var(--muted, #64748b);
}

@media (max-width: 520px) {
  .today-routine-content {
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 10px;
  }

  .today-routine-chart {
    width: 102px;
    height: 102px;
  }

  .today-routine-chart::after {
    inset: 19px;
  }

  .today-routine-switch button {
    padding: 5px 7px;
  }
}

/* DAILY_ROUTINE_LEGEND_FIX_001 */
.today-routine-summary {
  min-width: 0;
}

.today-routine-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 14px;
  row-gap: 6px;
}

.today-routine-row {
  min-width: 0;
  padding: 3px 0;
}

.today-routine-dot {
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.today-routine-duration {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.today-routine-duration small {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted, #64748b);
}

@media (max-width: 620px) {
  .today-routine-list {
    grid-template-columns: 1fr;
  }
}

/* DAILY_ROUTINE_7DAY_001 */
.today-routine-switch {
  flex-wrap: nowrap;
}

.today-routine-switch button {
  white-space: nowrap;
}

@media (max-width: 520px) {
  .today-routine-header {
    align-items: stretch;
    flex-direction: column;
  }

  .today-routine-switch {
    width: 100%;
  }

  .today-routine-switch button {
    flex: 1;
    padding: 6px 5px;
  }
}

/* TODAY_COMPACT_AREA_CARDS_001
   Compact family-facing area cards without removing offline sensors.
*/

/* Remove unnecessary space around the Area Status block. */
#tab-now #simpleNowSensorRowsCard {
  padding: 8px !important;
  margin-top: 6px !important;
}

#tab-now .simple-now-head {
  margin-bottom: 7px !important;
}

/* Wide desktop: show all five registered area cards in one row. */
#tab-now #simpleNowSensorRows {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  align-items: stretch !important;
  gap: 9px !important;
}

/* Compact individual cards. */
#tab-now .now-area-card {
  min-width: 0 !important;
  min-height: 154px !important;
  padding: 11px 12px !important;
  border-radius: 17px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 7px !important;
}

#tab-now .now-area-card__top {
  align-items: center !important;
  gap: 7px !important;
}

#tab-now .now-area-card__title {
  min-width: 0 !important;
  gap: 5px !important;
  font-size: 18px !important;
  line-height: 1.1 !important;
}

#tab-now .now-area-card__pill {
  flex-shrink: 0 !important;
  padding: 5px 8px !important;
  border-radius: 999px !important;
  font-size: 11px !important;
  line-height: 1.1 !important;
}

/* Keep the explanation, but prevent it from dominating the card. */
#tab-now .now-area-card__subtitle {
  min-height: 31px !important;
  margin: 0 !important;
  font-size: 11px !important;
  line-height: 1.35 !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
}

/* Presence, status, BR and HR become compact four-cell metrics. */
#tab-now .now-area-card__grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 5px 9px !important;
  margin-top: auto !important;
}

#tab-now .now-area-card__metric {
  min-width: 0 !important;
  padding-top: 6px !important;
}

#tab-now .now-area-card__label {
  margin-bottom: 2px !important;
  font-size: 9px !important;
  line-height: 1.1 !important;
  letter-spacing: 0.04em !important;
}

#tab-now .now-area-card__value {
  font-size: 17px !important;
  line-height: 1.05 !important;
}

#tab-now .now-area-card__value.small {
  font-size: 14px !important;
}

/* Medium desktop/tablet: preserve readability with three columns. */
@media (max-width: 1180px) {
  #tab-now #simpleNowSensorRows {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

/* Narrow tablet: two cards per row. */
@media (max-width: 760px) {
  #tab-now #simpleNowSensorRows {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  #tab-now .now-area-card {
    min-height: 145px !important;
    padding: 10px !important;
  }

  #tab-now .now-area-card__title {
    font-size: 16px !important;
  }
}

/* Small phone: retain two columns where possible, then one when necessary. */
@media (max-width: 430px) {
  #tab-now #simpleNowSensorRows {
    grid-template-columns: 1fr !important;
  }

  #tab-now .now-area-card {
    min-height: auto !important;
  }

  #tab-now .now-area-card__subtitle {
    min-height: 0 !important;
  }
}

/* TODAY_SIMPLE_AREA_CARDS_002
   Family-facing card layout replacing the overly compressed five-card row.
*/
#tab-now #simpleNowSensorRows {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 10px !important;
}

#tab-now .now-area-card[data-family-compact-v2="true"] {
  min-height: 116px !important;
  padding: 12px 13px !important;
  gap: 8px !important;
  border-radius: 17px !important;
}

#tab-now
  .now-area-card[data-family-compact-v2="true"]
  .now-area-card__top {
  gap: 9px !important;
}

#tab-now
  .now-area-card[data-family-compact-v2="true"]
  .now-area-card__title {
  font-size: 19px !important;
  line-height: 1.1 !important;
}

#tab-now
  .now-area-card[data-family-compact-v2="true"]
  .now-area-card__pill {
  padding: 6px 10px !important;
  font-size: 11px !important;
}

#tab-now
  .now-area-card[data-family-compact-v2="true"]
  .now-area-card__subtitle {
  min-height: 0 !important;
  margin: 0 !important;
  font-size: 13px !important;
  line-height: 1.3 !important;
  display: block !important;
  overflow: visible !important;
  -webkit-line-clamp: unset !important;
}

#tab-now
  .now-area-card[data-family-compact-v2="true"]
  .now-area-card__grid.now-area-card__vitals {
  display: flex !important;
  align-items: center !important;
  gap: 16px !important;
  margin-top: auto !important;
  padding-top: 7px !important;
  border-top: 1px solid rgba(100, 116, 139, 0.15);
}

#tab-now .now-area-card__vital {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

#tab-now .now-area-card__vital-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--muted, #64748b);
}

#tab-now .now-area-card__vital-value {
  font-size: 18px;
  line-height: 1;
}

@media (max-width: 900px) {
  #tab-now #simpleNowSensorRows {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 520px) {
  #tab-now #simpleNowSensorRows {
    grid-template-columns: 1fr !important;
  }

  #tab-now .now-area-card[data-family-compact-v2="true"] {
    min-height: 105px !important;
  }
}

/* TODAY_AREA_CARD_STABILITY_003
   Prevent refresh-time resizing and balance five cards without an empty slot.
*/

/* Six logical columns:
   first three cards span 2 each;
   final two cards span 3 each.
*/
#tab-now #simpleNowSensorRows {
  display: grid !important;
  grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  grid-auto-rows: 118px !important;
  gap: 10px !important;
}

#tab-now #simpleNowSensorRows > .now-area-card {
  grid-column: span 2 !important;
  width: 100% !important;
  height: 118px !important;
  min-height: 118px !important;
  max-height: 118px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;

  /* Apply compact dimensions before the JS simplifier runs.
     This prevents the large-card-to-small-card jump on refresh. */
  padding: 12px 13px !important;
  border-radius: 17px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
}

/* Balance the second row across the full width. */
#tab-now #simpleNowSensorRows > .now-area-card:nth-child(4),
#tab-now #simpleNowSensorRows > .now-area-card:nth-child(5) {
  grid-column: span 3 !important;
}

/* Stable typography from the first browser paint. */
#tab-now #simpleNowSensorRows .now-area-card__top {
  gap: 8px !important;
  min-height: 25px !important;
}

#tab-now #simpleNowSensorRows .now-area-card__title {
  min-width: 0 !important;
  font-size: 18px !important;
  line-height: 1.1 !important;
}

#tab-now #simpleNowSensorRows .now-area-card__pill {
  flex-shrink: 0 !important;
  padding: 5px 9px !important;
  font-size: 11px !important;
  line-height: 1.1 !important;
}

#tab-now #simpleNowSensorRows .now-area-card__subtitle {
  min-height: 18px !important;
  max-height: 35px !important;
  margin: 0 !important;
  font-size: 12px !important;
  line-height: 1.35 !important;
  overflow: hidden !important;
}

/* The original detailed metric grid must not enlarge the card while the
   compacting JavaScript is still processing it. */
#tab-now
  #simpleNowSensorRows
  .now-area-card:not([data-family-compact-v2="true"])
  .now-area-card__grid {
  max-height: 35px !important;
  overflow: hidden !important;
  opacity: 0 !important;
}

/* Compact vitals remain visible after simplification. */
#tab-now
  #simpleNowSensorRows
  .now-area-card[data-family-compact-v2="true"]
  .now-area-card__grid.now-area-card__vitals {
  opacity: 1 !important;
  max-height: none !important;
  display: flex !important;
  align-items: center !important;
  gap: 16px !important;
  margin-top: auto !important;
  padding-top: 7px !important;
}

/* Avoid animation or transition-driven movement during refresh. */
#tab-now #simpleNowSensorRows .now-area-card,
#tab-now #simpleNowSensorRows .now-area-card * {
  transition: none !important;
}

/* Tablet: regular two-column grid. */
@media (max-width: 900px) {
  #tab-now #simpleNowSensorRows {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-rows: 112px !important;
  }

  #tab-now #simpleNowSensorRows > .now-area-card,
  #tab-now #simpleNowSensorRows > .now-area-card:nth-child(4),
  #tab-now #simpleNowSensorRows > .now-area-card:nth-child(5) {
    grid-column: span 1 !important;
    height: 112px !important;
    min-height: 112px !important;
    max-height: 112px !important;
  }

  /* Center the final odd card rather than leaving it awkwardly aligned. */
  #tab-now #simpleNowSensorRows > .now-area-card:nth-child(5):last-child {
    grid-column: 1 / -1 !important;
    width: calc(50% - 5px) !important;
    justify-self: center !important;
  }
}

/* Small phone: one card per row. */
@media (max-width: 520px) {
  #tab-now #simpleNowSensorRows {
    grid-template-columns: 1fr !important;
    grid-auto-rows: auto !important;
  }

  #tab-now #simpleNowSensorRows > .now-area-card,
  #tab-now #simpleNowSensorRows > .now-area-card:nth-child(4),
  #tab-now #simpleNowSensorRows > .now-area-card:nth-child(5),
  #tab-now #simpleNowSensorRows > .now-area-card:nth-child(5):last-child {
    grid-column: 1 !important;
    width: 100% !important;
    height: 105px !important;
    min-height: 105px !important;
    max-height: 105px !important;
  }
}

/* TRENDS_V3_FAMILY_001 */

#tab-trends .trends-v3-legacy-hidden {
  display: none !important;
}

.trends-family-v3 {
  display: grid;
  gap: 14px;
}

.trends-family-v3__intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.trends-family-v3__eyebrow {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0f766e;
}

.trends-family-v3__title {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.trends-family-v3__subtitle {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: #64748b;
}

.trends-family-v3__range {
  display: inline-flex;
  padding: 4px;
  border-radius: 14px;
  background: #eef2f7;
}

.trends-family-v3__range-btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 13px;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.trends-family-v3__range-btn.active {
  background: #ffffff;
  color: #0f766e;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.trends-family-v3__metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.trends-family-v3__metric {
  min-width: 0;
  border: 1px solid #dbe3ec;
  border-radius: 14px;
  padding: 10px 8px;
  background: #ffffff;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
}

.trends-family-v3__metric.active {
  border-color: #14b8a6;
  background: #ecfdf8;
  color: #0f766e;
}

.trends-family-v3__metric-icon {
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
}

.trends-family-v3__summary {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 17px;
  border: 1px solid #dbeafe;
  border-radius: 18px;
  background: #f8fbff;
}

.trends-family-v3__summary-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 14px;
  background: #ffffff;
  font-size: 22px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.trends-family-v3__summary-label {
  margin-bottom: 3px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.trends-family-v3__summary-text {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  color: #1e293b;
}

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

.trends-family-v3__kpi {
  min-width: 0;
  padding: 14px 15px;
  border: 1px solid #e2e8f0;
  border-radius: 17px;
  background: #ffffff;
}

.trends-family-v3__kpi-label {
  margin-bottom: 7px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.trends-family-v3__kpi-value {
  font-size: 26px;
  font-weight: 850;
  line-height: 1;
  color: #0f172a;
}

.trends-family-v3__kpi-note {
  margin-top: 7px;
  font-size: 11px;
  line-height: 1.35;
  color: #64748b;
}

.trends-family-v3__chart-card {
  padding: 17px;
  border: 1px solid #e2e8f0;
  border-radius: 19px;
  background: #ffffff;
}

.trends-family-v3__chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.trends-family-v3__chart-title {
  font-size: 17px;
  font-weight: 850;
  color: #0f172a;
}

.trends-family-v3__chart-subtitle {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: #64748b;
}

.trends-family-v3__updating {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 10px;
  font-weight: 800;
}

.trends-family-v3__chart {
  min-height: 260px;
}

.trends-family-v3__bars {
  height: 260px;
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.trends-family-v3__bar-item {
  min-width: 0;
  flex: 1 1 0;
  display: grid;
  grid-template-rows: 32px 1fr 28px;
  gap: 6px;
  text-align: center;
}

.trends-family-v3__bar-value {
  align-self: end;
  min-height: 28px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.15;
  color: #475569;
}

.trends-family-v3__bar-track {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 160px;
  border-radius: 10px;
  background:
    linear-gradient(
      to top,
      rgba(148, 163, 184, 0.08) 1px,
      transparent 1px
    );
  background-size: 100% 25%;
}

.trends-family-v3__bar {
  width: min(38px, 68%);
  min-height: 6px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(
    180deg,
    #14b8a6,
    #0f766e
  );
}

.trends-family-v3__bar-item.today .trends-family-v3__bar {
  background: linear-gradient(
    180deg,
    #fb923c,
    #ea580c
  );
}

.trends-family-v3__bar.missing {
  background: repeating-linear-gradient(
    135deg,
    #cbd5e1,
    #cbd5e1 4px,
    #e2e8f0 4px,
    #e2e8f0 8px
  );
}

.trends-family-v3__bar-date {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
}

.trends-family-v3__bar-item.today
.trends-family-v3__bar-date {
  color: #c2410c;
}

.trends-family-v3__empty,
.trends-family-v3__loading {
  min-height: 230px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  color: #64748b;
}

.trends-family-v3__empty strong {
  font-size: 16px;
  color: #334155;
}

.trends-family-v3__empty-icon {
  font-size: 34px;
}

.trends-family-v3__quality {
  padding: 10px 13px;
  border-radius: 13px;
  background: #f8fafc;
  font-size: 11px;
  line-height: 1.45;
  color: #64748b;
}

@media (max-width: 900px) {
  .trends-family-v3__metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .trends-family-v3__intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .trends-family-v3__kpis {
    grid-template-columns: 1fr;
  }

  .trends-family-v3__chart-head {
    flex-direction: column;
  }

  .trends-family-v3__bars {
    gap: 5px;
  }

  .trends-family-v3__bar-value {
    font-size: 9px;
  }
}

@media (max-width: 520px) {
  .trends-family-v3__metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trends-family-v3__chart {
    overflow-x: auto;
  }

  .trends-family-v3__bars {
    min-width: 560px;
  }
}

/* TRENDS_V31_VISUAL_001 */

/* Metric buttons get distinct visual identities. */
.trends-family-v3__metric {
  position: relative;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}

.trends-family-v3__metric:hover {
  transform: translateY(-1px);
  border-color: var(--trend-metric-color, #14b8a6);
}

.trends-family-v3__metric-icon {
  width: 32px;
  height: 32px;
  margin: 0 auto 6px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--trend-metric-color, #0f766e);
  background:
    color-mix(
      in srgb,
      var(--trend-metric-color, #0f766e) 11%,
      white
    );
  font-size: 17px;
  font-weight: 900;
}

.trends-family-v3__metric.trend-v31-active {
  border-color:
    var(--trend-metric-color, #14b8a6) !important;
  color:
    var(--trend-metric-color, #0f766e) !important;
  background:
    color-mix(
      in srgb,
      var(--trend-metric-color, #0f766e) 7%,
      white
    ) !important;
  box-shadow:
    0 8px 22px
    color-mix(
      in srgb,
      var(--trend-metric-color, #0f766e) 13%,
      transparent
    );
}

/* Summary follows the selected metric color. */
.trends-family-v3__summary {
  border-color:
    color-mix(
      in srgb,
      var(--trend-v31-color, #0f766e) 18%,
      white
    );
  background:
    color-mix(
      in srgb,
      var(--trend-v31-color, #0f766e) 4%,
      white
    );
}

.trends-family-v3__summary-icon {
  color:
    var(--trend-v31-color, #0f766e);
  background:
    color-mix(
      in srgb,
      var(--trend-v31-color, #0f766e) 9%,
      white
    );
}

/* Stable graph geometry for all available metrics. */
.trends-family-v3__chart-card {
  min-height: 380px;
}

.trends-family-v3__chart {
  min-height: 275px !important;
  height: 275px !important;
  overflow: visible !important;
}

.trends-family-v31__chart-host {
  min-height: 275px !important;
  height: 275px !important;
}

/* Line chart. */
.trends-family-v31__line-shell {
  height: 275px;
  display: grid;
  grid-template-rows: 235px 32px;
}

.trends-family-v31__line-svg {
  width: 100%;
  height: 235px;
  overflow: visible;
}

.trends-family-v31__grid-line {
  stroke: rgba(148, 163, 184, 0.16);
  stroke-width: 1;
}

.trends-family-v31__xlabels {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0;
}

.trends-family-v31__xlabel {
  min-width: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  white-space: nowrap;
}

.trends-family-v31__xlabel.today {
  color: #ea580c;
  font-weight: 900;
}

/* Bar chart. */
.trends-family-v31__bars {
  height: 275px;
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.trends-family-v31__bar-item {
  min-width: 0;
  flex: 1 1 0;
  display: grid;
  grid-template-rows: 34px 1fr 28px;
  gap: 5px;
}

.trends-family-v31__bar-value {
  align-self: end;
  min-height: 28px;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.15;
  color: #475569;
}

.trends-family-v31__bar-track {
  position: relative;
  min-height: 190px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.trends-family-v31__bar {
  width: min(38px, 72%);
  min-height: 4px;
  border-radius: 9px 9px 3px 3px;
  background:
    var(--trend-v31-color, #0f766e);
  transition:
    height 0.2s ease,
    opacity 0.2s ease;
}

.trends-family-v31__bar-item.today
.trends-family-v31__bar {
  background: #f97316;
}

.trends-family-v31__bar.zero {
  opacity: 0.22;
}

.trends-family-v31__bar.missing {
  width: 65%;
  border-radius: 999px;
  opacity: 0.4;
  background:
    repeating-linear-gradient(
      135deg,
      #cbd5e1,
      #cbd5e1 4px,
      #e2e8f0 4px,
      #e2e8f0 8px
    );
}

.trends-family-v31__bar-date {
  min-width: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  white-space: nowrap;
}

.trends-family-v31__bar-date.today {
  color: #ea580c;
  font-weight: 900;
}

.trends-family-v31__tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 10;
  transform:
    translateX(-50%)
    translateY(4px);
  padding: 6px 8px;
  border-radius: 8px;
  background: #0f172a;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

.trends-family-v31__bar-track:hover
.trends-family-v31__tooltip {
  opacity: 1;
  transform:
    translateX(-50%)
    translateY(0);
}

/* Compact sleep state. */
.trends-family-v3__chart-card:has(
  .trends-family-v31__sleep
) {
  min-height: 250px;
}

.trends-family-v3__chart:has(
  .trends-family-v31__sleep
) {
  min-height: 145px !important;
  height: 145px !important;
}

.trends-family-v31__sleep {
  min-height: 145px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  color: #64748b;
}

.trends-family-v31__sleep-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: #f3e8ff;
  font-size: 24px;
}

.trends-family-v31__sleep strong {
  color: #312e81;
  font-size: 16px;
}

/* Make units appear once in headings, not repeatedly over each point. */
.trends-family-v3__chart-subtitle {
  max-width: 640px;
}

/* Improve KPI visual hierarchy. */
.trends-family-v3__kpi {
  box-shadow:
    0 4px 16px rgba(15, 23, 42, 0.035);
}

.trends-family-v3__kpi-value {
  letter-spacing: -0.025em;
}

/* 30-day mode remains readable without forcing all labels. */
@media (max-width: 900px) {
  .trends-family-v31__bars {
    min-width: 720px;
  }

  .trends-family-v31__line-shell {
    min-width: 720px;
  }

  .trends-family-v3__chart {
    overflow-x: auto !important;
  }
}

@media (max-width: 600px) {
  .trends-family-v3__chart-card {
    min-height: 350px;
  }

  .trends-family-v3__chart,
  .trends-family-v31__chart-host {
    height: 250px !important;
    min-height: 250px !important;
  }

  .trends-family-v31__line-shell {
    height: 250px;
    grid-template-rows: 215px 28px;
  }

  .trends-family-v31__line-svg {
    height: 215px;
  }

  .trends-family-v31__bars {
    height: 250px;
  }
}

/* TRENDS_V32_FINAL_POLISH_001 */

.trends-family-v3__chart-head {
  position: relative;
}

.trends-family-v32__chart-latest {
  margin-left: auto;
  margin-right: 110px;
  align-self: center;
  padding: 7px 11px;
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

/* Make room for subtle y-axis context on line charts. */
.trends-family-v31__line-shell {
  position: relative;
  padding-left: 44px;
  box-sizing: border-box;
}

.trends-family-v31__line-svg {
  width: 100%;
}

.trends-family-v32__yaxis {
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 34px;
  width: 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.trends-family-v32__ylabel {
  padding-right: 5px;
  text-align: right;
  font-size: 9px;
  font-weight: 750;
  color: #94a3b8;
}

.trends-family-v32__yunit {
  position: absolute;
  left: 0;
  bottom: -27px;
  width: 40px;
  text-align: right;
  font-size: 8px;
  font-weight: 750;
  color: #94a3b8;
  white-space: nowrap;
}

/* Keep bar labels concise and legible. */
.trends-family-v31__bar-value {
  line-height: 1.1;
  white-space: nowrap;
}

/* Improve missing-data gaps visually without connecting them. */
.trends-family-v31__line-shell::after {
  content: "";
  position: absolute;
  left: 44px;
  right: 0;
  bottom: 34px;
  height: 1px;
  background:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent 9px,
      rgba(148, 163, 184, 0.18) 9px,
      rgba(148, 163, 184, 0.18) 11px
    );
  pointer-events: none;
}

/* Sleep has no live chart, so suppress the provisional badge. */
.trends-family-v3__chart-card:has(
  .trends-family-v31__sleep
)
.trends-family-v3__updating {
  display: none !important;
}

/* Slightly strengthen active metric appearance. */
.trends-family-v3__metric.trend-v31-active {
  box-shadow:
    0 8px 24px
    color-mix(
      in srgb,
      var(--trend-metric-color, #0f766e) 15%,
      transparent
    );
}

@media (max-width: 760px) {
  .trends-family-v32__chart-latest {
    margin-right: 0;
    order: 3;
  }

  .trends-family-v3__chart-head {
    flex-wrap: wrap;
  }
}

/* TRENDS_V33_DURATION_FORMAT_001 */

.trends-family-v31__bar-value {
  white-space: nowrap !important;
  font-size: 9px;
}

.trends-family-v32__chart-latest {
  white-space: nowrap !important;
}

/* TIMELINE_FAMILY_V1_001 */

#tab-timeline .timeline {
  gap: 0;
}

.family-timeline-group {
  margin-bottom: 18px;
}

.family-timeline-group:last-child {
  margin-bottom: 0;
}

.family-timeline-group__title {
  margin: 0 0 9px;
  padding-left: 2px;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.03em;
  color: #64748b;
}

.family-timeline-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.family-timeline-list::before {
  content: "";
  position: absolute;
  left: 21px;
  top: 22px;
  bottom: 22px;
  width: 2px;
  border-radius: 999px;
  background: #e2e8f0;
}

.family-timeline-item {
  --timeline-color: #64748b;
  --timeline-soft: #f8fafc;

  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  padding: 11px 13px 11px 9px;
  border: 1px solid #e2e8f0;
  border-radius: 17px;
  background: #ffffff;
  box-shadow:
    0 3px 12px rgba(15, 23, 42, 0.025);
}

.family-timeline-item__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: 4px;
  border-radius: 11px;
  background: var(--timeline-soft);
  color: var(--timeline-color);
  font-size: 17px;
  font-weight: 900;
  box-shadow:
    0 0 0 4px #ffffff;
}

.family-timeline-item__body {
  min-width: 0;
}

.family-timeline-item__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.family-timeline-item__title {
  min-width: 0;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.3;
  color: #0f172a;
}

.family-timeline-item__time {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
  white-space: nowrap;
}

.family-timeline-item__message {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
  color: #64748b;
}

.family-timeline-item__location {
  display: inline-flex;
  margin-top: 7px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f8fafc;
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}

.family-timeline-item--presence {
  --timeline-color: #0f766e;
  --timeline-soft: #ecfdf5;
}

.family-timeline-item--movement {
  --timeline-color: #2563eb;
  --timeline-soft: #eff6ff;
}

.family-timeline-item--vitals {
  --timeline-color: #e11d48;
  --timeline-soft: #fff1f2;
}

.family-timeline-item--bed {
  --timeline-color: #7c3aed;
  --timeline-soft: #f5f3ff;
}

.family-timeline-item--activity {
  --timeline-color: #475569;
  --timeline-soft: #f8fafc;
}

.family-timeline-item--alert {
  --timeline-color: #dc2626;
  --timeline-soft: #fef2f2;

  border-color: #fecaca;
  background: #fffafa;
}

.family-timeline-empty {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 20px;
  text-align: center;
  color: #64748b;
}

.family-timeline-empty__icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: #f1f5f9;
  font-size: 22px;
}

.family-timeline-empty strong {
  color: #334155;
  font-size: 15px;
}

@media (max-width: 650px) {
  .family-timeline-item {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 9px;
    padding-right: 10px;
  }

  .family-timeline-item__top {
    align-items: flex-start;
  }

  .family-timeline-item__title {
    font-size: 13px;
  }

  .family-timeline-item__time {
    font-size: 10px;
  }

  .family-timeline-list::before {
    left: 19px;
  }

  .family-timeline-item__icon {
    width: 32px;
    height: 32px;
  }
}

/* TIMELINE_NOTIFICATION_POLICY_V2_001 */

.family-notification-clear {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 13px 15px;
  border: 1px solid #d1fae5;
  border-radius: 17px;
  background: #f7fefb;
}

.family-notification-clear__icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #dcfce7;
  color: #15803d;
  font-size: 19px;
  font-weight: 900;
}

.family-notification-clear strong,
.family-notification-clear span {
  display: block;
}

.family-notification-clear strong {
  color: #14532d;
  font-size: 14px;
  font-weight: 850;
}

.family-notification-clear span {
  margin-top: 3px;
  color: #64748b;
  font-size: 12px;
}

.family-notification-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  padding: 13px;
  border: 1px solid #fecaca;
  border-radius: 17px;
  background: #fffafa;
}

.family-notification-item + .family-notification-item {
  margin-top: 8px;
}

.family-notification-item__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: #fee2e2;
  color: #dc2626;
  font-size: 19px;
  font-weight: 900;
}

.family-notification-item__body strong,
.family-notification-item__body span,
.family-notification-item__body time {
  display: block;
}

.family-notification-item__body strong {
  color: #991b1b;
  font-size: 14px;
  font-weight: 850;
}

.family-notification-item__body span {
  margin-top: 3px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.4;
}

.family-notification-item__body time {
  margin-top: 6px;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 750;
}

/* TIMELINE_COMPACT_ROUTINE_V1_001 */

.family-timeline-item--compact {
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 48px;
  padding: 7px 11px 7px 8px;
  border-radius: 14px;
}

.family-timeline-item--compact .family-timeline-item__icon {
  width: 28px;
  height: 28px;
  margin-left: 1px;
  border-radius: 9px;
  font-size: 14px;
  box-shadow:
    0 0 0 3px #ffffff;
}

.family-timeline-item--compact .family-timeline-item__body {
  display: block;
}

.family-timeline-item--compact .family-timeline-item__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.family-timeline-item--compact .family-timeline-item__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.25;
}

.family-timeline-item--compact .family-timeline-item__time {
  font-size: 10px;
}

.family-timeline-item--compact
.family-timeline-item__message,
.family-timeline-item--compact
.family-timeline-item__location {
  display: none;
}

.family-timeline-item--compact
.family-timeline-item__top {
  margin: 0;
}

@media (max-width: 650px) {
  .family-timeline-item--compact {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 7px;
    min-height: 44px;
    padding: 6px 9px 6px 7px;
  }

  .family-timeline-item--compact
  .family-timeline-item__title {
    font-size: 12px;
  }
}

/* DETAILS_FAMILY_STRUCTURE_V1_001 */

.details-family-intro {
  margin: 0 0 16px;
  padding: 4px 2px 2px;
}

.details-family-intro__eyebrow {
  color: #0f766e;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.details-family-intro__title {
  margin: 5px 0 4px;
  color: #0f172a;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 900;
}

.details-family-intro__subtitle {
  margin: 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

#tab-details #homeSetupCard {
  margin-top: 18px;
}

@media (max-width: 650px) {
  .details-family-intro__title {
    font-size: 24px;
  }
}

/* DETAILS_ACTIVE_OWNER_V1_001 */

#tab-details #careInsightsCard,
#tab-details #activityStatsCard,
#tab-details #zoneSessionsCard,
#tab-details #homeSetupCard,
#tab-details #family-report-card {
  display: block;
}

#tab-details .details-family-intro {
  margin-top: 2px;
}

#tab-details #family-report-card {
  margin-top: 16px;
}

#tab-details #careInsightsCard,
#tab-details #activityStatsCard,
#tab-details #zoneSessionsCard,
#tab-details #homeSetupCard {
  margin-top: 16px;
}

/* DETAILS_MOVED_SECTIONS_VISIBILITY_FIX_001
   Activity Stats and Area Sessions were historically hidden globally
   while they belonged to legacy Trends.
   They now belong to Details, so restore them only inside tab-details.
*/

#tab-details #activityStatsCard,
#tab-details #zoneSessionsCard {
  display: block !important;
}

/* ESTIMATED_HOME_MOVEMENT_MAP_V1_001 */
.estimated-movement-card {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #ffffff;
}

.estimated-movement-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.estimated-movement-card__title {
  font-size: 16px;
  font-weight: 950;
  color: var(--text);
}

.estimated-movement-card__subtitle {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.estimated-movement-card__badge {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  font-weight: 900;
}

.estimated-movement-edges {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.estimated-movement-edge {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f8fafc;
}

.estimated-movement-edge__route {
  font-weight: 850;
  color: #334155;
}

.estimated-movement-edge__distance {
  font-weight: 950;
  color: #0f766e;
  white-space: nowrap;
}

.estimated-movement-example {
  margin-top: 14px;
  padding: 13px;
  border-radius: 16px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.estimated-movement-example:empty {
  display: none;
}

.estimated-movement-example__label {
  font-size: 11px;
  font-weight: 900;
  color: #047857;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.estimated-movement-example__route {
  margin-top: 5px;
  font-weight: 950;
  color: #064e3b;
}

.estimated-movement-example__distance {
  margin-top: 4px;
  color: #065f46;
  font-weight: 850;
}

.estimated-movement-empty {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 650px) {
  .estimated-movement-card__header {
    align-items: flex-start;
  }

  .estimated-movement-edge {
    align-items: center;
  }
}

/* MOVEMENT_SUMMARY_V1_001 */
.movement-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
  margin-bottom: 12px;
}

.movement-summary-metric {
  padding: 13px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.movement-summary-metric__label {
  font-size: 11px;
  font-weight: 850;
  color: var(--muted);
}

.movement-summary-metric__value {
  margin-top: 5px;
  font-size: 18px;
  font-weight: 950;
  color: #0f766e;
}

.movement-summary-detail {
  margin-bottom: 14px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

@media (max-width: 650px) {
  .movement-summary-grid {
    grid-template-columns: 1fr;
  }
}

/* NOW_MOVEMENT_SUMMARY_V1_001 */

.now-movement-summary-card {
  overflow: hidden;
}

.now-movement-summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.now-movement-summary-head .section-title {
  margin-bottom: 4px;
}

.now-movement-summary-subtitle {
  max-width: 640px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.now-movement-summary-badge {
  flex: 0 0 auto;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.now-movement-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  background: #ffffff;
}

.now-movement-summary-item {
  min-width: 0;
  padding: 15px 16px;
}

.now-movement-summary-item + .now-movement-summary-item {
  border-left: 1px solid var(--border);
}

.now-movement-summary-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 7px;
}

.now-movement-summary-value {
  color: var(--text);
  font-size: 19px;
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.now-movement-summary-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.now-movement-details-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 4px 0;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.now-movement-details-button:hover {
  text-decoration: underline;
}

@media (max-width: 650px) {
  .now-movement-summary-head {
    gap: 10px;
  }

  .now-movement-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .now-movement-summary-item {
    padding: 12px 9px;
  }

  .now-movement-summary-value {
    font-size: 15px;
  }

  .now-movement-summary-label,
  .now-movement-summary-note {
    font-size: 10px;
  }
}

/* CLOUD_FAMILY_AUTH_GATE_V1 */
.dfws-auth-gate {
  min-height: 100vh;
  padding: 28px 16px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(
      circle at top left,
      #d1fae5,
      transparent 42%
    ),
    linear-gradient(
      180deg,
      #f8fafc,
      #eef2f7
    );
}

.dfws-auth-gate[hidden] {
  display: none;
}

.dfws-auth-card {
  width: min(100%, 460px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.dfws-auth-brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 24px;
}

.dfws-auth-logo {
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #0f766e;
  color: #ffffff;
  font-size: 16px;
  font-weight: 950;
  letter-spacing: 0.5px;
}

.dfws-auth-brand h1 {
  margin: 2px 0 7px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.15;
}

.dfws-auth-brand p,
.dfws-auth-homes p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.dfws-auth-mode-switch {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 18px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--soft-gray);
}

.dfws-auth-mode-switch button {
  min-height: 42px;
  padding: 9px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-size: 13px;
  font-weight: 850;
}

.dfws-auth-mode-switch button:hover {
  background: rgba(
    255,
    255,
    255,
    0.72
  );
  color: var(--text);
}

.dfws-auth-mode-switch button.active {
  background: #ffffff;
  color: #0f766e;
  box-shadow:
    0 1px 3px rgba(
      15,
      23,
      42,
      0.08
    );
}

.dfws-auth-form {
  display: grid;
  gap: 9px;
}

.dfws-auth-form[hidden] {
  display: none;
}

.dfws-auth-form label {
  margin-top: 5px;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.dfws-auth-form input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  outline: none;
}

.dfws-auth-form input:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.dfws-auth-primary {
  width: 100%;
  min-height: 46px;
  margin-top: 10px;
  border: 0;
  border-radius: 13px;
  background: #0f766e;
  color: #ffffff;
  box-shadow: none;
}

.dfws-auth-primary:disabled {
  cursor: wait;
  opacity: 0.7;
}

.dfws-auth-message {
  margin-top: 16px;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--soft-gray);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.45;
}

.dfws-auth-message.error-state {
  border: 1px solid #fecaca;
  background: var(--soft-bad);
  color: var(--bad);
}

.dfws-auth-homes {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.dfws-auth-homes[hidden] {
  display: none;
}

.dfws-auth-homes h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

#dfwsAuthHomeList {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.dfws-auth-home-button {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px;
  border-radius: 15px;
  text-align: left;
  box-shadow: none;
}

.dfws-auth-home-button strong {
  color: var(--text);
  font-size: 15px;
}

.dfws-auth-home-button span {
  color: var(--muted);
  font-size: 12px;
}

.dfws-auth-no-access {
  padding: 13px;
  border: 1px solid #fde68a;
  border-radius: 13px;
  background: var(--soft-warn);
  color: var(--warn);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 520px) {
  .dfws-auth-gate {
    padding: 18px 12px;
  }

  .dfws-auth-card {
    padding: 21px;
    border-radius: 22px;
  }

  .dfws-auth-brand {
    gap: 11px;
  }

  .dfws-auth-logo {
    width: 50px;
    height: 50px;
    border-radius: 15px;
  }

  .dfws-auth-brand h1 {
    font-size: 21px;
  }
}

/* CLOUD_FAMILY_ACCOUNT_CONTROLS_V1 */
.dfws-family-top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.dfws-family-account {
  min-width: 120px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #ffffff;
  text-align: right;
}

.dfws-family-account[hidden] {
  display: none;
}

.dfws-family-account-name {
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.3;
}

.dfws-family-account-home {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

#dfwsSwitchHomeButton,
#dfwsLogoutButton {
  box-shadow: none;
}

#dfwsLogoutButton {
  border-color: #fecaca;
  color: var(--bad);
}

@media (max-width: 650px) {
  .topbar {
    align-items: flex-start;
  }

  .dfws-family-top-actions {
    max-width: 54%;
  }

  .dfws-family-account {
    width: 100%;
  }
}
