:root {
  /* Brand tokens (達成 logo / 眠りCONNECT style) */
  --color-brand-primary: #0F4C81;
  --color-brand-deep: #0B3F6E;
  --color-brand-accent: #F0A500;
  --color-status-sleep-deep: #1D4E89;
  --color-status-sleep-light: #0E8FA0;
  --color-status-away: #E07B00;
  --color-status-offline: #64748B;
  --color-status-alert: #D9534F;
  --color-data-vital: #4C9A6E;
  --color-bg-page: #F5F7FA;
  --color-card-border: #EBEEF5;
  --color-text-primary: #1F2A3A;
  --color-text-secondary: #667085;

  /* Compatible aliases used by existing rules */
  --navy: var(--color-brand-primary);
  --navy-2: #133C6B;
  --bg: var(--color-bg-page);
  --panel: #ffffff;
  --ink: var(--color-text-primary);
  --muted: var(--color-text-secondary);
  --line: var(--color-card-border);
  --line-soft: #F0F3F8;
  --teal: var(--color-brand-primary);
  --teal-deep: var(--color-brand-deep);
  --teal-soft: #EAF1FA;
  --teal-bright: var(--color-status-sleep-light);
  --amber: var(--color-brand-accent);
  --amber-soft: #FEF5E0;
  --coral: var(--color-status-alert);
  --coral-soft: #FBEAE9;
  --green: var(--color-data-vital);
  --green-soft: #E9F4EE;
  --violet: #4A90C4;
  --violet-soft: #EAF1FA;
  --radius: 10px;
  --radius-control: 7px;
  --sidebar-w: 236px;
  --shadow: 0 1px 2px rgba(15, 76, 129, 0.05), 0 10px 28px -22px rgba(15, 76, 129, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid rgba(240, 165, 0, 0.55);
  outline-offset: 2px;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: default;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #ffffff;
  border-right: 1px solid var(--line);
  color: var(--navy);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  min-height: 52px;
}

.brand img {
  height: 32px;
  width: auto;
  display: block;
}

.brand-caption {
  margin-top: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #4A5D70;
  text-align: left;
  font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item.active {
  background: #E7F3F0;
  color: var(--navy);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--teal);
}

.nav-item:not(.active):hover {
  background: #F2F7F6;
  color: var(--navy);
}

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.demo-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #EFF4F2;
  color: #4A5D70;
  font-size: 12px;
}

.demo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #F0A500;
  box-shadow: 0 0 0 3px rgba(240, 165, 0, 0.2);
}

.site-link {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.site-link:hover {
  color: var(--navy);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: rgba(245, 247, 250, 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-title h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  color: var(--navy);
}

.topbar-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--navy);
  background: #F6F8FB;
  border: 1px solid #C8DCF2;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
}

.pause-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #8FB8D9;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.pause-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.view-stack {
  padding: 22px 24px 30px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeUp 0.24s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.module-card {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-height: 82px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.module-card:hover {
  border-color: var(--teal-bright);
  transform: translateY(-1px);
}

.module-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  display: grid;
  place-items: center;
  flex: 0 0 40px;
}

.module-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.module-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.module-body strong {
  font-size: 15px;
}

.module-body small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.module-arrow {
  margin-left: auto;
  color: var(--teal);
  font-weight: 600;
  flex: 0 0 auto;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.kpi-card.warn {
  border-color: #E8C877;
  background: #FFF9ED;
}

.kpi-label {
  width: 100%;
  color: var(--muted);
  font-size: 12.5px;
  margin-bottom: 2px;
}

.kpi-card strong {
  font-size: 27px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.kpi-unit {
  color: var(--muted);
  font-size: 12px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

.overview-grid .panel:nth-child(1) {
  grid-column: span 7;
}

.overview-grid .panel:nth-child(2) {
  grid-column: span 5;
}

.overview-grid .panel:nth-child(3) {
  grid-column: span 5;
}

.overview-grid .panel:nth-child(4) {
  grid-column: span 7;
}

.panel {
  background: var(--panel);
  border: 1px solid #EBEEF5;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
}

.panel-note {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pdf-btn {
  font: inherit;
  font-size: 12px;
  line-height: 1;
  color: #ffffff;
  background: var(--teal);
  border: 1px solid var(--teal);
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.pdf-btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pdf-btn:hover {
  background: var(--teal-deep);
}

.pdf-btn:disabled {
  opacity: 0.65;
  cursor: default;
}

.mini-vitals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.mini-vital {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #F6F8FB;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px;
}

.mini-label {
  width: 100%;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

.mini-vital strong {
  font-size: 24px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.mini-unit {
  color: var(--muted);
  font-size: 12px;
}

.mini-vital canvas {
  display: block;
  width: 100%;
  height: 34px;
  margin-top: 4px;
}

.chart-canvas {
  display: block;
  width: 100%;
  height: 210px;
}

.chart-canvas.tall {
  height: 250px;
}

/* Toolbars */
.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
}

.segmented button {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.segmented button.active {
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-weight: 600;
}

.toolbar-meta {
  color: var(--muted);
  font-size: 13px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.demo-btn {
  border: 1px solid #8FB8D9;
  background: #ffffff;
  color: var(--teal-deep);
  padding: 8px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.demo-btn:hover {
  background: var(--teal-soft);
}

/* Vital cards */
.vital-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}

.vital-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
}

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

.vital-label {
  color: var(--muted);
  font-size: 12.5px;
}

.vital-state {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
  white-space: nowrap;
}

.vital-state.good {
  background: var(--green-soft);
  color: var(--green);
}

.vital-state.info {
  background: var(--teal-soft);
  color: var(--teal-deep);
}

.vital-state.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.vital-state.bad {
  background: var(--coral-soft);
  color: var(--coral);
}

.vital-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.vital-value strong {
  font-size: 28px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.vital-value span {
  color: var(--muted);
  font-size: 12px;
}

.vital-card canvas {
  display: block;
  width: 100%;
  height: 38px;
  margin-top: auto;
}

/* Mattress */
.mattress-main {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  gap: 14px;
}

.mattress-bottom {
  display: grid;
  grid-template-columns: 1.1fr 0.85fr 1.05fr;
  gap: 14px;
  margin-top: 14px;
}

.rr-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.rr-stats div,
.hrv-grid div,
.voice-stats div {
  border: 1px solid var(--line);
  background: #F6F8FB;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
  overflow-wrap: anywhere;
}

.rr-stats span,
.hrv-grid span,
.voice-stats span {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 2px;
}

.rr-stats strong,
.hrv-grid strong,
.voice-stats strong {
  font-size: 22px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.rr-stats small,
.hrv-grid small,
.voice-stats small {
  color: var(--muted);
  font-size: 11.5px;
}

.hrv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.hrv-group + .hrv-group {
  margin-top: 14px;
}

.hrv-group-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 8px;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
}

.summary-table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12.5px;
  padding: 10px 0;
  width: 46%;
}

.summary-table td {
  text-align: right;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 0;
}

.summary-table tr + tr {
  border-top: 1px solid var(--line-soft);
}

.alert-list,
.event-list,
.schedule-list,
.record-list,
.follow-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.alert-list li,
.event-list li,
.schedule-list li,
.record-list li,
.follow-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
}

.alert-list li + li,
.event-list li + li,
.schedule-list li + li,
.record-list li + li,
.follow-list li + li {
  border-top: 1px solid var(--line-soft);
}

.event-time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 44px;
}

.event-text {
  font-size: 13px;
  line-height: 1.5;
  min-width: 0;
}

.event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex: 0 0 8px;
}

.dot-teal {
  background: var(--teal-bright);
}

.dot-amber {
  background: var(--amber);
}

.dot-coral {
  background: var(--coral);
}

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

.dot-violet {
  background: var(--violet);
}

/* Overview widgets */
.bed-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.bed-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #F6F8FB;
  padding: 10px 11px;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bed-tile strong {
  font-size: 13.5px;
  color: var(--navy);
}

.bed-tile small {
  color: var(--muted);
  font-size: 11.5px;
}

.bed-state {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--teal-deep);
}

.bed-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.bed-tile.good {
  border-color: #BBD8EA;
}

.bed-tile.away {
  background: #FFF9ED;
  border-color: #E8C877;
}

.bed-tile.away .bed-state {
  color: var(--amber);
}

.bed-tile.empty {
  background: #F0F3F8;
}

.bed-tile.empty .bed-state {
  color: var(--muted);
}

.device-health-list {
  display: grid;
  gap: 2px;
}

.health-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
  font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
}

.health-row:last-child {
  border-bottom: 0;
}

.health-row span:first-child {
  color: var(--muted);
}

.health-row strong {
  margin-left: auto;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.status-on {
  background: var(--green-soft);
  color: var(--green);
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
}

.scenario-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.scenario-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.scenario-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.scenario-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.scenario-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.scenario-tags span {
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 99px;
  font-weight: 600;
}

/* Radar */
.radar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 14px;
}

.radar-side {
  display: grid;
  gap: 14px;
}

#roomCanvas {
  height: 300px;
}

.radar-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-weight: 600;
  font-size: 13px;
}

.radar-status.alert {
  background: var(--coral-soft);
  color: var(--coral);
}

.radar-raw-block {
  margin-top: 6px;
  font-family: Consolas, "Microsoft JhengHei", monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  max-height: 130px;
  overflow-y: auto;
}

.detect-row,
.metric-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}

.detect-row:last-child,
.metric-row:last-child {
  border-bottom: 0;
}

.detect-row span,
.metric-row span {
  color: var(--muted);
}

.detect-row strong,
.metric-row strong {
  margin-left: auto;
  font-weight: 600;
  color: var(--navy);
}

.detect-row strong.ok {
  color: var(--green);
}

.detect-row strong.warn {
  color: var(--amber);
}

.detect-row strong.bad {
  color: var(--coral);
}

#radarSignal {
  height: 130px;
  margin-top: 10px;
}

.event-panel {
  margin-top: 14px;
}

.event-list.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 22px;
}

.event-list.two-col li {
  border-top: 1px solid var(--line-soft);
}

/* Voice */
.voice-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 14px;
  align-items: start;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 560px;
}

.chat-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding: 2px 0 12px;
  max-height: 460px;
}

.chat-msg {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.55;
}

.chat-msg.ai {
  align-self: flex-start;
  background: var(--teal-soft);
  color: var(--ink);
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--navy-2);
  color: #ffffff;
}

.chat-msg small {
  display: block;
  margin-top: 4px;
  opacity: 0.65;
  font-size: 11px;
}

.chat-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.mic-btn {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 50%;
  border: 0;
  background: var(--teal);
  color: #ffffff;
  display: grid;
  place-items: center;
}

.mic-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mic-btn:active {
  background: var(--coral);
}

.quick-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.quick-chips button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
}

.quick-chips button:hover {
  border-color: var(--teal-bright);
  background: var(--teal-soft);
}

.voice-side {
  display: grid;
  gap: 14px;
}

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

.voice-stats div {
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.voice-stats span {
  margin-bottom: 0;
}

.device-grid {
  display: grid;
  gap: 8px;
}

.device-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  background: #F6F8FB;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.device-row span {
  color: var(--muted);
  font-size: 13px;
}

.device-row strong {
  margin-left: auto;
  color: var(--navy);
  font-size: 13.5px;
  font-weight: 600;
}

.device-row:hover {
  border-color: var(--teal-bright);
  background: var(--teal-soft);
}

/* Cognition */
.cognition-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.35fr);
  gap: 14px;
}

.score-panel {
  text-align: center;
}

#scoreGauge {
  height: 230px;
}

.score-label {
  font-size: 30px;
  font-weight: 700;
  color: var(--navy);
  margin: 2px 0 10px;
  font-variant-numeric: tabular-nums;
}

.risk-badge {
  display: inline-flex;
  padding: 7px 14px;
  border-radius: 99px;
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 600;
  font-size: 13px;
}

.risk-badge.high {
  background: var(--coral-soft);
  color: var(--coral);
}

.risk-badge.good {
  background: var(--green-soft);
  color: var(--green);
}

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

#cogBars {
  height: 150px;
}

#cogTrend {
  height: 230px;
}

.record-list .event-time {
  min-width: 74px;
}

.record-score {
  margin-left: auto;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.record-note {
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
}

.follow-index {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 50%;
  background: var(--violet-soft);
  color: var(--violet);
  font-size: 11.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.follow-list p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

/* Footer and responsive */
.app-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

.app-footer a {
  color: var(--teal);
  text-decoration: none;
  margin-left: auto;
}

@media (max-width: 1220px) {
  .module-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .vital-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .overview-grid .panel:nth-child(1),
  .overview-grid .panel:nth-child(2),
  .overview-grid .panel:nth-child(3),
  .overview-grid .panel:nth-child(4) {
    grid-column: span 12;
  }
  .mattress-main,
  .radar-layout,
  .voice-layout,
  .cognition-layout {
    grid-template-columns: 1fr;
  }
  .mattress-bottom,
  .cognition-bottom,
  .scenario-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
  }
  .brand {
    min-height: 0;
    padding: 6px 8px;
  }
  .brand img {
    height: 24px;
  }
  .brand-caption,
  .sidebar-bottom {
    display: none;
  }
  .nav-list {
    flex: 1;
    display: flex;
    gap: 6px;
    margin: 0;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .nav-item {
    width: auto;
    white-space: nowrap;
    padding: 9px 11px;
  }
  .topbar {
    padding: 12px 14px;
  }
  .topbar-title h1 {
    font-size: 17px;
  }
  .view-stack {
    padding: 14px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .module-grid {
    grid-template-columns: 1fr;
  }
  .vital-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .mini-vitals {
    grid-template-columns: 1fr;
  }
  .bed-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .event-list.two-col {
    grid-template-columns: 1fr;
  }
  .rr-stats,
  .voice-stats {
    grid-template-columns: 1fr;
  }
  .hrv-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .chat-panel {
    min-height: 480px;
  }
  .chat-log {
    max-height: 380px;
  }
  .panel-head {
    flex-wrap: wrap;
  }
  .panel-note {
    white-space: normal;
  }
}

@media (max-width: 480px) {
  .clock {
    display: none;
  }
  .vital-grid {
    grid-template-columns: 1fr;
  }
  .hrv-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .app-footer {
    flex-wrap: wrap;
  }
  .app-footer a {
    margin-left: 0;
  }
}
/* ---- Resident card ---- */
.resident-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(120deg, #0F4C81 0%, #123A68 56%, #1E5F9E 100%);
  color: #DDE8F4;
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 2px 4px rgba(15, 76, 129, 0.08), 0 14px 34px -22px rgba(15, 76, 129, 0.4);
}
.resident-info {
  min-width: 0;
}
.resident-info .kicker {
  color: var(--teal-bright);
  font-size: 12px;
  font-weight: 600;
}
.resident-switch-label {
  display: block;
  color: var(--teal-bright);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.resident-switch {
  display: block;
  width: 100%;
  max-width: 240px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--navy);
  background: #ffffff;
  border: 1px solid rgba(143, 184, 217, 0.45);
  border-radius: 7px;
  padding: 8px 10px;
  min-height: 40px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.resident-switch:hover {
  border-color: var(--teal-bright);
}
.resident-switch:focus {
  outline: none;
  border-color: var(--teal-bright);
  box-shadow: 0 0 0 2px rgba(143, 184, 217, 0.2);
}
.resident-info h2 {
  margin: 4px 0 2px;
  font-size: 24px;
  color: #ffffff;
}
.resident-info p {
  margin: 0;
  color: #BFD3E8;
  font-size: 13px;
}
.resident-specs {
  margin-left: auto;
  display: grid;
  gap: 8px;
  min-width: 260px;
}
.resident-specs > div {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}
.resident-specs span {
  color: #B8CCE0;
  min-width: 66px;
}
.resident-specs strong {
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Live band ---- */
.live-band {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
}
.live-head {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.live-head h2 {
  margin: 0;
  font-size: 15px;
}
.live-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.live-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.live-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  grid-column: 1 / -1;
}
.info-dot-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  color: var(--navy);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.info-dot-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.info-dot-btn:hover {
  border-color: var(--teal);
  color: var(--teal-deep);
  background: var(--teal-soft);
}
.demo-tag {
  background: var(--teal-soft);
  color: var(--teal-deep);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.live-metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #F6F8FB;
  padding: 12px 13px;
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
  min-height: 86px;
  grid-column: span 3;
  align-self: stretch;
}
.live-label {
  width: 100%;
  color: var(--muted);
  font-size: 12.5px;
}
.live-metric strong {
  font-size: 30px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.live-metric small {
  color: var(--muted);
  font-size: 12px;
}
.live-status-hero {
  grid-column: span 6;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #F6F8FB;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  min-height: 88px;
}
.live-status-icon {
  width: 128px;
  height: 128px;
  flex: 0 0 128px;
  border-radius: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 10px 22px -14px rgba(15, 76, 129, 0.55);
}
.live-status-icon.deep {
  background: linear-gradient(145deg, #E9EEFC, #FFFFFF);
  border-color: #4241BE;
}
.live-status-icon.light {
  background: linear-gradient(145deg, #FFF3DF, #FFFFFF);
  border-color: #EAA522;
}
.live-status-icon.out {
  background: linear-gradient(145deg, #EFF1F3, #FFFFFF);
  border-color: #7B7A7A;
}
.live-status-icon.offline {
  background: linear-gradient(145deg, #526173, #7B8CA0);
}
.live-status-icon .sleep-state-svg,
.room-state-icon .sleep-state-svg {
  display: inline-flex;
}
.sleep-state-svg {
  line-height: 0;
}
.sleep-state-svg svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sleep-state-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.live-status-icon .sleep-state-img {
  width: 94px;
  height: 94px;
}
.room-state-icon .sleep-state-img {
  width: 78px;
  height: 78px;
}
.live-status-icon svg {
  width: 86px;
  height: 86px;
}
.live-status-copy {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.live-status-copy strong {
  font-size: 25px;
  line-height: 1.15;
  color: var(--navy);
}
.live-status-copy small {
  color: var(--muted);
  font-size: 12.5px;
}
.live-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  padding: 6px 11px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: #F0F3F8;
  color: var(--muted);
  border: 1px solid var(--line);
}
.live-status-pill .live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.live-status-pill.online {
  background: var(--green-soft);
  color: var(--green);
  border-color: #C6E0D1;
}
.live-status-pill.offline {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: #F5E2B8;
}
.live-battery-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: #ffffff;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  white-space: nowrap;
}
.live-battery-badge::before {
  content: "";
  width: 8px;
  height: 14px;
  border: 1.5px solid #8FA3B8;
  border-radius: 2px;
  box-sizing: border-box;
  position: relative;
}
.live-battery-badge::after {
  content: "";
  width: 2px;
  height: 5px;
  border-radius: 1px;
  background: #8FA3B8;
  margin-left: -5px;
}
.wave-panel {
  grid-column: span 6;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #F6F8FB;
  padding: 11px 12px;
}
.wave-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.sample-note {
  color: var(--amber);
  font-size: 11.5px;
  font-weight: 600;
}
.wave-panel canvas {
  display: block;
  width: 100%;
  height: 76px;
}
.live-alert-panel {
  grid-column: 1 / -1;
  align-self: start;
}
.live-alert-panel .panel-head {
  margin-bottom: 6px;
}
.live-alert-list {
  max-height: 218px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.event-text strong {
  display: block;
  color: var(--navy);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.4;
}
.event-text small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 2px;
}

/* ---- Report toolbar and date picker ---- */
.report-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.report-toolbar h2 {
  margin: 0;
  font-size: 16px;
}
.report-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}
.report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
#view-mattress .report-header {
  margin-top: 24px;
}
.report-header h2 {
  margin: 0;
  font-size: 16px;
}
.report-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}
.report-date {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid #EBEEF5;
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 5px 7px;
}
.date-field {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 4px;
}
.date-input {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #F6F8FB;
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.date-input:focus {
  outline: 2px solid rgba(15, 76, 129, 0.25);
  border-color: var(--teal-bright);
}
.date-weekday {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.date-total {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  background: #EEF2F8;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 3px 8px;
}
.date-nav {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 0;
  background: #EEF2F8;
  border-radius: 8px;
  color: var(--teal-deep);
  display: grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.date-nav:hover:not(:disabled) {
  background: var(--teal-soft);
  color: var(--teal-deep);
}
.date-nav:disabled {
  opacity: 0.4;
  cursor: default;
}
.date-nav svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Report layout ---- */
.report-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}
.report-layout .score-card {
  grid-column: span 3;
}
.report-layout .summary-card {
  grid-column: span 9;
}
.report-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.score-card {
  min-height: 150px;
}
.score-ring {
  --score: 0deg;
  width: 108px;
  height: 108px;
  flex: 0 0 108px;
  border-radius: 50%;
  border: 12px solid var(--line);
  background:
    radial-gradient(circle at center, var(--panel) 60%, transparent 62%),
    conic-gradient(var(--green) var(--score), rgba(15, 76, 129, 0.14) 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.score-ring strong {
  font-size: 30px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.score-ring span {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 4px;
}
.score-copy h3 {
  margin: 0 0 6px;
  font-size: 17px;
}
.score-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.summary-card {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  padding: 8px 16px;
  min-height: 150px;
}
.summary-stat {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
}
.summary-stat:nth-child(n+5) {
  border-bottom: 0;
}
.summary-stat span {
  color: var(--muted);
  font-size: 12px;
}
.summary-stat strong {
  font-size: 18px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
/* ---- 過去一週睡眠狀態 ---- */
.week-sleep-panel {
  margin: 14px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.week-sleep-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.week-sleep-head h2 {
  margin: 0;
  font-size: 15px;
  color: var(--navy);
}
.week-sleep-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.week-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.week-sleep-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.week-sleep-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 12px 14px;
  background: #FBFCFE;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.week-sleep-row.is-selected {
  background: #FFFBF0;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(240, 165, 0, 0.12);
}
.week-row-date {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.week-row-date strong {
  font-size: 17px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.week-row-date span {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}
.week-row-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.week-stage-grid {
  display: grid;
  grid-template-columns: repeat(64, minmax(0, 1fr));
  gap: 1px;
  min-width: 0;
}
.stage-chip {
  min-height: 12px;
  border-radius: 2px;
  background: #EEF2F8;
}
.stage-chip.deep {
  background: var(--color-status-sleep-deep);
}
.stage-chip.light {
  background: var(--color-status-sleep-light);
}
.stage-chip.awake {
  background: var(--color-status-away);
}
.week-row-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  min-width: 0;
}
.week-row-stats span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}
.week-row-score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  min-width: 0;
}
.week-row-score span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.week-row-score strong {
  color: var(--navy);
  font-size: 22px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
/* ---- Shared grids and demo pages ---- */
.section-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
  align-items: stretch;
}
.section-grid .panel {
  min-width: 0;
}
.section-grid .sleep-stage-card {
  grid-column: span 5;
}
.section-grid .trend-card {
  grid-column: span 7;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  align-content: start;
}
.trend-card.is-clickable {
  cursor: pointer;
}
.icon-zoom-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid #DCE4EE;
  border-radius: 7px;
  background: #F6F8FB;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.icon-zoom-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-zoom-btn:hover {
  color: var(--teal-deep);
  border-color: #C8DCF2;
  background: #FFFFFF;
}
.section-grid .hrv-card {
  grid-column: span 12;
}
.section-grid .care-card {
  grid-column: span 6;
}
.section-grid .alerts-card {
  grid-column: span 6;
}
.section-grid .trend-card .panel-head {
  grid-column: 1 / -1;
  align-items: center;
}
.section-grid .trend-card .panel-head h2 {
  margin-right: auto;
}
.section-grid .trend-card .panel-subhead {
  margin: 0 0 8px;
  padding-top: 0;
  border-top: 0;
}
.section-grid .trend-card .trend-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.section-grid .hrv-card .hrv-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.section-grid .hrv-card .hrv-group:last-child .hrv-grid {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}
.section-grid canvas {
  display: block;
  width: 100%;
  height: 168px;
}
#stageCanvas {
  height: 150px;
}
.stage-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.stage-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.swatch.deep {
  background: var(--color-status-sleep-deep);
}
.swatch.light {
  background: var(--color-status-sleep-light);
}
.swatch.awake {
  background: var(--color-status-away);
}
.stage-minutes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.stage-minutes div {
  border: 1px solid var(--line);
  background: #F6F8FB;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stage-minutes span {
  color: var(--muted);
  font-size: 11.5px;
}
.stage-minutes strong {
  font-size: 17px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.panel-subhead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: 18px 0 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.panel-subhead h3 {
  margin: 0;
  font-size: 14px;
  color: var(--navy);
}
.recommend-list {
  margin: 0;
  padding: 0 0 0 22px;
  display: grid;
  gap: 8px;
}
.recommend-list li {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  padding: 2px 0;
}
.recommend-list li + li {
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
}
.empty-note {
  color: var(--muted);
  font-size: 13px;
  padding: 14px;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 168px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #F8FAFD;
  text-align: center;
}
.empty-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.empty-icon::before {
  content: "";
  width: 30px;
  height: 30px;
  background: var(--teal-soft);
  border-radius: 50%;
  border: 1px solid #BFD6EF;
}
.empty-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 7px;
  border-left: 2.2px solid var(--teal-deep);
  border-bottom: 2.2px solid var(--teal-deep);
  transform: translate(-50%, -50%) rotate(-45deg) translate(0.5px, -1px);
}
.alert-list li {
  align-items: center;
}

/* ---- Demo pages ---- */
.demo-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--navy);
  color: #DDE8F4;
  border-radius: var(--radius);
  padding: 20px 22px;
}
.demo-banner h2 {
  margin: 8px 0 6px;
  color: #ffffff;
  font-size: 18px;
}
.demo-banner p {
  margin: 0;
  color: #BFD3E8;
  font-size: 13px;
  line-height: 1.6;
  max-width: 680px;
}
.demo-banner img {
  height: 90px;
  width: auto;
  border-radius: 8px;
  flex: 0 0 auto;
  margin-left: auto;
}
.demo-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(143, 184, 217, 0.18);
  color: var(--teal-bright);
  border: 1px solid rgba(143, 184, 217, 0.32);
  border-radius: 99px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.env-switch-row,
.bp-switch-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 18px;
  margin-bottom: 14px;
}
.env-switch-row .resident-switch,
.bp-switch-row .resident-switch {
  margin-bottom: 0;
  min-width: 220px;
}
.env-room-copy,
.bp-room-copy {
  min-width: 0;
}
.env-room-copy h3,
.bp-room-copy h3 {
  margin: 0;
  font-size: 17px;
  color: var(--navy);
}
.env-room-copy p,
.bp-room-copy p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}
.env-metrics,
.bp-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.env-metric,
.bp-metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #F6F8FB;
  padding: 12px 14px;
  display: grid;
  gap: 6px;
}
.env-metric span,
.bp-metric span {
  color: var(--muted);
  font-size: 12px;
}
.env-metric strong,
.bp-metric strong {
  color: var(--navy);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.handoff-switch-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 18px;
  margin-bottom: 18px;
}
.handoff-switch-row .resident-switch {
  margin-bottom: 0;
  min-width: 220px;
}
.handoff-room-copy {
  min-width: 0;
}
.handoff-room-copy h3 {
  margin: 0;
  font-size: 17px;
  color: var(--navy);
}
.handoff-room-copy p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}
.handoff-input {
  display: grid;
  gap: 10px;
}
.handoff-field-label {
  color: var(--teal-bright);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.handoff-text {
  width: 100%;
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  resize: vertical;
  min-height: 96px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.handoff-text:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.12);
}
.handoff-text::placeholder {
  color: #98A5B6;
}
.handoff-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.handoff-mic-btn,
.handoff-generate-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  border-radius: 7px;
  padding: 11px 14px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.handoff-mic-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.handoff-mic-btn {
  color: var(--teal-deep);
  background: var(--teal-soft);
  border: 1px solid #C8DCF2;
}
.handoff-mic-btn:hover {
  background: #D9E8F6;
}
.handoff-generate-btn {
  color: #ffffff;
  background: var(--teal);
  border: 1px solid var(--teal);
}
.handoff-generate-btn:hover {
  background: var(--teal-deep);
}
.handoff-status {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.handoff-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 14px;
  align-items: start;
  margin-top: 2px;
}
.handoff-compose {
  min-width: 0;
  display: grid;
  gap: 12px;
}
.handoff-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
}
.handoff-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(76, 154, 110, 0.28);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.handoff-live-badge[hidden] {
  display: none;
}
.handoff-live-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}
.handoff-capture-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.handoff-chip {
  font: inherit;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.handoff-chip svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.handoff-chip:hover {
  transform: translateY(-1px);
}
.handoff-chip.amber {
  color: #8A5F00;
  background: var(--amber-soft);
  border-color: #F0DFBC;
}
.handoff-chip.amber:hover {
  background: #F9E8BD;
  border-color: var(--amber);
}
.handoff-chip.coral {
  color: #A93632;
  background: var(--coral-soft);
  border-color: #F2D3D1;
}
.handoff-chip.coral:hover {
  background: #F5D6D3;
  border-color: var(--coral);
}
.handoff-chip.navy {
  color: var(--teal-deep);
  background: var(--teal-soft);
  border-color: #C9D9EC;
}
.handoff-chip.navy:hover {
  background: #D6E4F4;
  border-color: var(--navy);
}
.handoff-chip.green {
  color: #34704D;
  background: var(--green-soft);
  border-color: #CEE3D6;
}
.handoff-chip.green:hover {
  background: #D8ECE1;
  border-color: var(--green);
}
.handoff-chip.violet {
  color: #32618D;
  background: var(--violet-soft);
  border-color: #C4D9EE;
}
.handoff-chip.violet:hover {
  background: #D3E2F3;
  border-color: var(--violet);
}
.handoff-guide {
  min-width: 0;
  background: #F6F8FB;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: grid;
  gap: 12px;
}
.handoff-guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.handoff-guide-head h3 {
  margin: 0;
  font-size: 15px;
  color: var(--navy);
}
.handoff-steps {
  display: grid;
  gap: 8px;
}
.handoff-step {
  display: grid;
  grid-template-columns: 32px minmax(44px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 44px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.step-no {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--teal);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.handoff-step strong {
  font-size: 13px;
  color: var(--navy);
}
.handoff-step em {
  font-style: normal;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
}
.handoff-guide h4 {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--navy);
}
.handoff-preview-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.handoff-group {
  list-style: none;
  margin: 0;
  display: grid;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
.handoff-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.handoff-group-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--navy);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.handoff-group-title {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.handoff-group-title strong {
  font-size: 13.5px;
  color: var(--navy);
}
.handoff-group-title small {
  color: var(--muted);
  font-size: 11.5px;
}
.handoff-group-count {
  margin-left: auto;
  color: var(--teal-deep);
  background: var(--teal-soft);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.handoff-preview-sublist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.handoff-empty {
  list-style: none;
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  background: #ffffff;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
.handoff-empty-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.handoff-empty-icon svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.handoff-row {
  list-style: none;
  margin: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: 8px;
  padding: 10px;
}
.handoff-row.amber {
  border-left-color: var(--amber);
}
.handoff-row.coral {
  border-left-color: var(--coral);
}
.handoff-row.navy {
  border-left-color: var(--navy);
}
.handoff-row.green {
  border-left-color: var(--green);
}
.handoff-row.violet {
  border-left-color: var(--violet);
}
.handoff-row-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.handoff-row.amber .handoff-row-icon {
  background: var(--amber-soft);
  color: #8A5F00;
}
.handoff-row.coral .handoff-row-icon {
  background: var(--coral-soft);
  color: #A93632;
}
.handoff-row.green .handoff-row-icon {
  background: var(--green-soft);
  color: #34704D;
}
.handoff-row.violet .handoff-row-icon {
  background: var(--violet-soft);
  color: #32618D;
}
.handoff-row-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.handoff-row-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.handoff-row-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.handoff-row-time {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.handoff-row-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  white-space: nowrap;
}
.handoff-row.amber .handoff-row-chip {
  background: var(--amber-soft);
  color: #8A5F00;
}
.handoff-row.coral .handoff-row-chip {
  background: var(--coral-soft);
  color: #A93632;
}
.handoff-row.green .handoff-row-chip {
  background: var(--green-soft);
  color: #34704D;
}
.handoff-row.violet .handoff-row-chip {
  background: var(--violet-soft);
  color: #32618D;
}
.handoff-row-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.handoff-row-source {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  align-self: center;
}
.handoff-row-compact {
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 10px;
}
.handoff-row-compact .handoff-row-source {
  display: none;
}
.handoff-row-action {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.handoff-row-action::before {
  content: "→ ";
  color: var(--navy);
  font-weight: 700;
}
.handoff-struct-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.handoff-report {
  display: grid;
  gap: 14px;
}
.handoff-report[hidden] {
  display: none;
}
.handoff-report-card .panel-head {
  margin-bottom: 12px;
}
.handoff-report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.handoff-report-section {
  min-width: 0;
}
.handoff-report-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--navy);
}
.handoff-note-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #F6F8FB;
  padding: 12px 14px;
  margin: 4px 0 14px;
}
.handoff-quote {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--navy);
}
.handoff-report-card .metric-row {
  padding: 8px 2px;
}
.handoff-report-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(270px, 0.75fr);
  gap: 18px;
  align-items: center;
  background: linear-gradient(120deg, var(--navy), var(--teal-bright));
  border-radius: 10px;
  padding: 18px 20px;
  color: #ffffff;
}
.handoff-report-hero-main {
  min-width: 0;
  display: grid;
  gap: 8px;
}
.handoff-report-hero-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.handoff-report-kicker {
  display: inline-flex;
  align-items: center;
  color: var(--amber);
  border: 1px solid rgba(240, 165, 0, 0.45);
  background: rgba(240, 165, 0, 0.12);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 700;
}
.handoff-report-time {
  color: #C6DCEE;
  font-size: 12px;
  white-space: nowrap;
}
.handoff-report-hero h2 {
  margin: 0;
  color: #ffffff;
  font-size: 20px;
  line-height: 1.3;
}
.handoff-report-hero h2 span {
  color: #C6DCEE;
  font-weight: 500;
}
.handoff-report-lead {
  margin: 0;
  color: #DDE8F4;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.handoff-next-action {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 9px 11px;
}
.handoff-next-action span {
  flex: 0 0 auto;
  color: var(--amber);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.5;
}
.handoff-next-action strong {
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
}
.handoff-report-vitals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.handoff-vital-tile {
  min-width: 0;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 9px 12px;
  display: grid;
  gap: 3px;
}
.handoff-vital-tile span {
  color: #C6DCEE;
  font-size: 11px;
}
.handoff-vital-tile strong {
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.handoff-report-main-grid {
  margin-top: 14px;
  grid-template-columns: minmax(0, 1.25fr) minmax(240px, 0.75fr);
  align-items: start;
}
.handoff-report-content {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #F6F8FB;
  padding: 12px 14px;
}
.handoff-report-content .handoff-struct-list {
  margin-top: 10px;
}
.handoff-resident-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 4px 12px;
}
.handoff-report-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.handoff-report-actions .handoff-report-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px 14px;
}
.handoff-report-residents {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}
.handoff-resident-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  padding: 14px;
  display: grid;
  gap: 12px;
}
.handoff-resident-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.handoff-resident-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--navy);
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.handoff-resident-card-title {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.handoff-resident-card-title h3 {
  margin: 0;
  font-size: 16px;
  color: var(--navy);
}
.handoff-resident-card-title h3 span {
  color: var(--muted);
  font-weight: 500;
}
.handoff-resident-card-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.handoff-resident-card-status {
  margin-left: auto;
  color: var(--teal-deep);
  background: var(--teal-soft);
  border: 1px solid #C9D9EC;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.handoff-resident-card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(240px, 0.75fr);
  gap: 14px;
  align-items: start;
}
.handoff-resident-card-grid .handoff-report-content {
  background: #F6F8FB;
}
.handoff-resident-card-tasks,
.handoff-resident-card-suggest .handoff-report-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px 14px;
}
.handoff-resident-card-suggest {
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}
.handoff-resident-card .record-list,
.handoff-resident-card .recommend-list {
  margin: 0;
}
.meal-all-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.meal-all-row h3 {
  margin: 0;
  font-size: 17px;
  color: var(--navy);
}
.meal-date-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 5px 7px;
}
.meal-date-picker .date-input {
  background: #F6F8FB;
}
.meal-date-picker .date-input:focus {
  outline: 2px solid rgba(15, 76, 129, 0.25);
  border-color: var(--teal-bright);
}
.meal-date-picker .date-nav {
  background: #EEF2F8;
  color: var(--teal-deep);
}
.meal-date-picker .date-nav:hover:not(:disabled) {
  background: var(--teal-soft);
  color: var(--teal-deep);
}
.meal-date-picker .date-total {
  background: #EEF2F8;
}
.meal-resident-grid {
  min-width: 0;
}
.meal-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.meal-table {
  min-width: 780px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}
.meal-head-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: #F0F3F8;
}
.meal-head-cell {
  padding: 10px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  border-left: 1px solid var(--line-soft);
}
.meal-head-resident {
  border-left: 0;
  text-align: left;
}
.meal-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
}
.meal-row:last-child {
  border-bottom: 0;
}
.meal-resident-cell {
  display: grid;
  align-content: center;
  gap: 2px;
  min-width: 0;
  padding: 12px 14px;
  border-right: 1px solid var(--line-soft);
  background: #F6F8FB;
}
.meal-resident-bed {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}
.meal-resident-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meal-resident-sn {
  font-size: 11px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.meal-time-cell {
  display: grid;
  gap: 7px;
  align-content: center;
  min-width: 0;
  padding: 10px 12px;
  border-left: 1px solid var(--line-soft);
}
.meal-kind-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.meal-kind-label {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}
.meal-card-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.meal-card-icon svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.meal-card-icon.meal {
  background: var(--green-soft);
  color: var(--green);
}
.meal-card-icon.water {
  background: var(--teal-soft);
  color: var(--teal-deep);
}
.meal-card-icon.med {
  background: var(--amber-soft);
  color: var(--amber);
}
.meal-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  min-width: 0;
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.meal-status.ok {
  color: var(--green);
  background: var(--green-soft);
}
.meal-status.warn {
  color: var(--amber);
  background: var(--amber-soft);
}
.meal-status.bad {
  color: var(--coral);
  background: var(--coral-soft);
}
.meal-summary {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--teal);
  background: #F6F8FB;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}
.score-demo .score-big {
  font-size: 48px;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  margin: 8px 0 18px;
  text-align: center;
}
.score-big {
  font-variant-numeric: tabular-nums;
}
.record-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.record-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.record-list li:last-child {
  border-bottom: 0;
}

/* ---- Topbar live pill ---- */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  background: #F0F3F8;
  color: var(--muted);
  border: 1px solid var(--line);
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.live-pill.online {
  background: var(--green-soft);
  color: var(--green);
  border-color: #C6E0D1;
}
.live-pill.offline {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: #F5E2B8;
}
@media (max-width: 1220px) {
  .resident-specs {
    min-width: 220px;
  }
  .env-metrics,
  .bp-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .live-band {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .live-status-hero {
    grid-column: span 6;
  }
  .live-metric {
    grid-column: span 3;
  }
  .wave-panel {
    grid-column: span 3;
  }
  .report-layout .score-card {
    grid-column: span 4;
  }
  .report-layout .summary-card {
    grid-column: span 8;
  }
  .section-grid .sleep-stage-card {
    grid-column: span 4;
  }
  .section-grid .trend-card {
    grid-column: span 8;
  }
  .section-grid .hrv-card {
    grid-column: span 12;
  }
  .summary-card {
    grid-template-columns: repeat(2, 1fr);
  }
  .summary-stat:nth-child(-n+6) {
    border-bottom: 1px solid var(--line-soft);
  }
  .summary-stat:nth-child(n+7) {
    border-bottom: 0;
  }
}

@media (max-width: 900px) {
  .resident-card {
    flex-wrap: wrap;
  }
  .resident-switch {
    max-width: 100%;
  }
  .resident-specs {
    margin-left: 0;
    width: 100%;
    min-width: 0;
  }
  .report-layout,
  .section-grid,
  .demo-grid,
  .handoff-report-grid,
  .handoff-resident-card-grid {
    grid-template-columns: 1fr;
  }
  .handoff-report-hero,
  .handoff-report-actions {
    grid-template-columns: 1fr;
  }
  .handoff-workbench {
    grid-template-columns: 1fr;
  }
  .report-layout .score-card,
  .report-layout .summary-card,
  .section-grid .sleep-stage-card,
  .section-grid .trend-card,
  .section-grid .hrv-card,
  .section-grid .care-card,
  .section-grid .alerts-card {
    grid-column: span 1;
  }
  .section-grid .trend-card {
    display: block;
  }
  .section-grid .trend-card .panel-subhead {
    margin: 18px 0 8px;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
  }
  .section-grid .hrv-card .hrv-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .report-card {
    align-items: stretch;
  }
  .meal-table-scroll {
    margin-right: -4px;
    padding-right: 4px;
  }
}

@media (max-width: 760px) {
  .meal-all-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .meal-date-picker {
    max-width: 100%;
    flex-wrap: wrap;
  }
  .live-band {
    grid-template-columns: 1fr;
  }
  .live-status-hero {
    grid-column: span 1;
  }
  .live-metric {
    grid-column: span 1;
  }
  .week-sleep-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .week-row-score {
    align-items: flex-start;
    flex-direction: row;
    justify-content: space-between;
  }
  .env-switch-row,
  .bp-switch-row,
  .handoff-switch-row {
    flex-direction: column;
    align-items: stretch;
  }
  .handoff-actions .handoff-mic-btn,
  .handoff-actions .handoff-generate-btn {
    flex: 1 1 160px;
  }
  .handoff-row {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 8px;
  }
  .handoff-row-source {
    display: none;
  }
  .handoff-report-hero {
    padding: 14px;
  }
  .handoff-report-hero h2 {
    font-size: 18px;
  }
  .handoff-resident-card-head {
    flex-wrap: wrap;
  }
  .handoff-guide {
    padding: 12px;
  }
  .env-metrics,
  .bp-metrics {
    grid-template-columns: 1fr;
  }
  .wave-panel {
    grid-column: span 1;
  }
  .summary-card {
    grid-template-columns: 1fr 1fr;
  }
  .stage-minutes {
    grid-template-columns: repeat(2, 1fr);
  }
  .demo-banner img {
    display: none;
  }
  .score-ring {
    width: 92px;
    height: 92px;
    flex-basis: 92px;
    border-width: 10px;
  }
  .live-status-icon {
    width: 88px;
    height: 88px;
    flex-basis: 88px;
    border-radius: 22px;
  }
  .live-status-icon svg {
    width: 62px;
    height: 62px;
  }
  .live-status-icon .sleep-state-img {
    width: 66px;
    height: 66px;
  }
  .live-status-copy strong {
    font-size: 22px;
  }
}

@media (max-width: 480px) {
  .summary-card {
    grid-template-columns: 1fr;
  }
  .summary-stat,
  .summary-stat:nth-child(n+4) {
    border-bottom: 1px solid var(--line-soft);
  }
  .summary-stat:last-child {
    border-bottom: 0;
  }
  .stage-minutes {
    grid-template-columns: repeat(2, 1fr);
  }
  .report-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}
.trend-card svg {
  display: block;
  width: 100%;
  height: 190px;
}
/* ---- 實時動態房卡 ---- */
.room-panel {
  margin-bottom: 18px;
}
.live-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  margin: 4px 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 76, 129, 0.05);
  align-items: center;
}
.live-overview-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
  padding-right: 12px;
  border-right: 1px solid var(--line-soft);
}
.live-overview-item:last-of-type {
  border-right: 0;
}
.overview-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.live-overview-item strong {
  font-size: 26px;
  line-height: 1;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.live-overview-item small {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}
.live-overview-item.warn strong {
  color: var(--amber);
}
.live-overview-item.alert strong {
  color: var(--coral);
}
.live-overview-stamp {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}
.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 10px;
}
.legend-dot.deep {
  background: var(--color-status-sleep-deep);
}
.legend-dot.light {
  background: var(--color-status-sleep-light);
}
.legend-dot.out {
  background: var(--color-status-away);
}
.legend-dot.offline {
  background: var(--color-status-offline);
}
.legend-dot.online {
  background: var(--color-data-vital);
}
.legend-dot.alert {
  background: var(--color-status-alert);
}
.room-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: -2px 0 12px;
}
.legend-item,
.week-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.legend-note {
  margin-left: auto;
  color: var(--muted);
  font-size: 11.5px;
}
.room-panel-head {
  align-items: center;
}
.room-panel-head .panel-head-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.edit-btn {
  font: inherit;
  font-size: 12px;
  line-height: 1;
  color: var(--teal-deep);
  background: var(--teal-soft);
  border: 1px solid #C8DCF2;
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.edit-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.edit-btn:hover {
  background: #D9E8F6;
}
.room-search-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 0 12px;
  background: #ffffff;
  border: 1px solid #EBEEF5;
  border-radius: 8px;
  min-height: 36px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.room-search-box:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.12);
}
.room-search-box span {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}
.room-sn-search {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  width: 176px;
  min-height: 34px;
  padding: 0 6px 0 2px;
}
.room-sn-search::placeholder {
  color: #9AA5B1;
}
.room-live-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.room-live-card {
  position: relative;
  background: var(--panel);
  border: 1px solid #EBEEF5;
  border-radius: 8px;
  padding: 13px 14px 14px;
  min-width: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.room-live-card:hover {
  border-color: #8FB8D9;
  box-shadow: 0 6px 18px -14px rgba(15, 76, 129, 0.26);
}
.room-live-card.is-offline {
  background: #F0F3F8;
}
.room-card-top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.room-state {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  min-width: 0;
}
.room-state-icon {
  width: 104px;
  height: 104px;
  flex: 0 0 104px;
  border-radius: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 8px 20px -12px rgba(15, 76, 129, 0.5);
}
.room-state-icon svg {
  width: 72px;
  height: 72px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.room-state-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  white-space: normal;
}
.room-state-copy strong {
  font-size: 16px;
  line-height: 1.2;
  color: var(--navy);
}
.room-state-duration {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.3;
}
.room-state.deep {
  color: var(--color-status-sleep-deep);
}
.room-state.light {
  color: var(--teal-deep);
}
.room-state.out {
  color: var(--amber);
}
.room-state.offline {
  color: var(--muted);
}
.room-state.deep .room-state-icon {
  background: linear-gradient(145deg, #E9EEFC, #FFFFFF);
  border-color: #4241BE;
}
.room-state.light .room-state-icon {
  background: linear-gradient(145deg, #FFF3DF, #FFFFFF);
  border-color: #EAA522;
}
.room-state.out .room-state-icon {
  background: linear-gradient(145deg, #EFF1F3, #FFFFFF);
  border-color: #7B7A7A;
}
.room-state.offline .room-state-icon {
  background: linear-gradient(145deg, #526173, #7B8CA0);
}
.room-online {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 99px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.room-online.on {
  background: var(--green-soft);
  color: var(--green);
  border-color: #C6E0D1;
}
.room-online.off {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: #F5E2B8;
}
.room-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  column-gap: 8px;
}
.room-meta .room-bed {
  grid-column: 1;
}
.room-meta .room-name {
  grid-column: 2;
}
.room-meta .room-sn {
  grid-column: 1 / -1;
}
.room-bed {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.room-name {
  font-size: 18px;
  color: var(--navy);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-sn {
  font-size: 12.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.room-vitals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}
.room-vitals > div {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.room-vitals span {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
}
.room-vitals strong {
  font-size: 24px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.room-vitals small {
  color: var(--muted);
  font-size: 11.5px;
}
.room-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.room-card-footer span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  min-width: 0;
}
.signal-bars {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 11px;
  flex: 0 0 16px;
  opacity: 0.85;
}
.signal-bars::before,
.signal-bars::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 4px;
  border-radius: 1px;
  background: currentColor;
}
.signal-bars::before {
  left: 0;
  height: 6px;
}
.signal-bars::after {
  left: 6px;
  height: 9px;
}
.signal-bars.strong {
  background: linear-gradient(currentColor, currentColor) right bottom / 4px 11px no-repeat;
}
.signal-bars.mid {
  background: none;
}
.signal-bars.weak::before {
  opacity: 0.35;
}
.signal-bars.weak::after {
  opacity: 0.35;
}
.room-card-actions {
  display: flex;
  gap: 8px;
  border-top: 1px dashed var(--line-soft);
  padding-top: 10px;
}
.room-edit-btn,
.room-delete-btn {
  font: inherit;
  font-size: 12px;
  line-height: 1;
  border-radius: 6px;
  padding: 8px 10px;
  min-height: 32px;
  cursor: pointer;
}
.room-edit-btn {
  color: var(--teal-deep);
  background: var(--teal-soft);
  border: 1px solid #C8DCF2;
}
.room-delete-btn {
  color: var(--coral);
  background: var(--coral-soft);
  border: 1px solid #F2D2D0;
}
.room-add-card {
  min-height: 44px;
  border: 1px dashed #C8DCF2;
  border-radius: 8px;
  background: #F6F8FB;
  color: var(--teal-deep);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.room-add-card svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.room-add-card:hover {
  background: var(--teal-soft);
  border-color: var(--teal);
}
.room-empty {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  background: #F6F8FB;
  border: 1px dashed #EBEEF5;
  border-radius: 8px;
  padding: 22px 16px;
  text-align: center;
}

/* ---- 實時動態彈窗 ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
body:has(.modal-backdrop:not([hidden])) .sidebar,
body:has(.modal-backdrop:not([hidden])) .main {
  filter: blur(5px);
  transition: filter 0.2s ease;
}
.modal-backdrop[hidden] {
  display: none !important;
}
.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: min(88vh, 720px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid #EBEEF5;
  border-radius: 10px;
  box-shadow: 0 24px 60px -28px rgba(15, 76, 129, 0.5);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  background: var(--panel);
}
.modal-head h2 {
  margin: 0;
  font-size: 17px;
  color: var(--navy);
}
.modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}
.modal-close {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #F6F8FB;
  color: var(--muted);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.modal-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.modal-close:hover {
  color: var(--teal-deep);
  border-color: #C8DCF2;
}
.modal-body {
  padding: 16px 18px 18px;
  display: grid;
  gap: 14px;
}
.modal-card-wide {
  max-width: 940px;
}
.hrv-modal-body {
  padding: 18px 20px 22px;
  gap: 18px;
}
.hrv-modal-chart {
  min-width: 0;
}
.hrv-modal-chart .panel-subhead {
  margin: 0 0 10px;
  padding-top: 0;
  border-top: 0;
}
.hrv-modal-canvas {
  min-width: 0;
}
.hrv-modal-canvas svg {
  display: block;
  width: 100%;
  height: auto;
}
.room-detail-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--navy);
}
.room-detail-cat + .room-detail-cat {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.room-detail-cat-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--teal-deep);
  letter-spacing: 0.3px;
}
.room-detail-rows {
  display: grid;
  gap: 8px;
}
.room-detail-rows > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
}
.room-detail-rows > div:last-child {
  border-bottom: 0;
}
.room-detail-rows span {
  color: var(--muted);
  font-size: 12.5px;
}
.room-detail-rows strong {
  color: var(--navy);
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow-wrap: anywhere;
}
.detail-online {
  color: var(--green);
}
.detail-offline {
  color: var(--amber);
}
.room-detail-wave {
  display: block;
  width: 100%;
  height: 78px;
}
.room-wave-empty {
  color: var(--muted);
  font-size: 12.5px;
  background: #F6F8FB;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 26px 14px;
  text-align: center;
}

/* ---- 房卡表單 ---- */
.room-form {
  display: grid;
  gap: 12px;
}
.room-form label {
  display: grid;
  gap: 6px;
}
.room-form label > span {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}
.room-form input,
.room-form select {
  font: inherit;
  font-size: 14px;
  color: var(--navy);
  background: #F6F8FB;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  min-height: 40px;
  width: 100%;
}
.room-form input:focus,
.room-form select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(15, 76, 129, 0.14);
}
.form-error {
  margin: 0;
  color: var(--coral);
  font-size: 12.5px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.ghost-btn {
  font: inherit;
  font-size: 12px;
  line-height: 1;
  color: var(--navy);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.ghost-btn:hover {
  border-color: var(--teal);
  color: var(--teal-deep);
}

/* ---- 藍牙配網精靈 ---- */
.provision-step {
  display: grid;
  gap: 14px;
}
.provision-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.provision-title {
  margin: 0;
  font-size: 14px;
  color: var(--navy);
}
.provision-status {
  color: var(--teal-deep);
  font-size: 13px;
  background: var(--teal-soft);
  border: 1px solid #C8DCF2;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.provision-device-list {
  display: grid;
  gap: 10px;
}
.provision-device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #F6F8FB;
}
.provision-device-info {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.provision-device-info strong {
  color: var(--navy);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}
.provision-device-info span,
.provision-device-info small {
  color: var(--muted);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}
.provision-selected {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px 12px;
  background: #F6F8FB;
}
.provision-selected span {
  color: var(--muted);
  font-size: 11.5px;
}
.provision-selected strong {
  color: var(--navy);
  font-size: 13.5px;
}
.provision-selected small {
  color: var(--muted);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}
.provision-success {
  margin: 0;
  color: var(--green);
  font-size: 13px;
  line-height: 1.5;
  background: var(--green-soft);
  border: 1px solid #C6E0D1;
  border-radius: 8px;
  padding: 12px 14px;
}
.help-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: help-step;
}
.help-steps li {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: start;
  gap: 10px;
  counter-increment: help-step;
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.6;
}
.help-steps li::before {
  content: counter(help-step);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 12px;
  font-weight: 700;
}
.help-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--teal);
  background: #F6F8FB;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

@media (max-width: 1100px) {
  .room-live-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .week-sleep-row {
    grid-template-columns: 88px minmax(0, 1fr) auto;
    gap: 12px;
  }
  .week-row-stats {
    gap: 12px;
  }
}
@media (max-width: 760px) {
  .room-live-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .live-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 10px;
  }
  .live-overview-item:nth-child(2) {
    border-right: 0;
  }
  .live-overview-stamp {
    grid-column: 1 / -1;
    text-align: right;
  }
  .week-sleep-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
    padding: 12px;
  }
  .week-row-date {
    grid-column: 1;
    grid-row: 1;
  }
  .week-row-score {
    grid-column: 2;
    grid-row: 1;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .week-row-body {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .week-row-score strong {
    font-size: 18px;
  }
  .room-panel-head {
    flex-wrap: wrap;
  }
  .room-panel-head .head-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .room-search-box {
    flex: 1 1 auto;
    min-height: 44px;
  }
  .room-sn-search {
    width: 100%;
    min-height: 42px;
  }
  .modal-card {
    max-width: none;
  }
  .room-panel-head {
    align-items: flex-start;
  }
}
@media (max-width: 480px) {
  .room-live-grid {
    grid-template-columns: 1fr;
  }
  .live-overview {
    grid-template-columns: 1fr 1fr;
  }
  .week-sleep-row {
    gap: 8px 10px;
    padding: 10px;
  }
  .week-stage-grid {
    gap: 1px;
  }
  .week-row-stats {
    gap: 8px 12px;
  }
  .room-state-icon {
    width: 88px;
    height: 88px;
    flex-basis: 88px;
    border-radius: 20px;
  }
  .room-state-icon svg {
    width: 62px;
    height: 62px;
  }
  .room-state-icon .sleep-state-img {
    width: 62px;
    height: 62px;
  }
}

/* ---- SOS 緊急求助彈窗 ---- */
.sos-demo-btn {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: #B23A36;
  background: var(--coral-soft);
  border: 1px solid #F2D3D1;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.sos-demo-btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sos-demo-btn:hover {
  background: #F6DAD7;
  border-color: var(--coral);
}
.sos-modal-backdrop {
  z-index: 60;
  background: rgba(10, 22, 38, 0.52);
  backdrop-filter: blur(6px);
}
.sos-modal-card {
  max-width: 470px;
  border: 0;
  box-shadow: 0 30px 80px -28px rgba(122, 30, 28, 0.55);
  animation: sos-pop 0.18s ease-out;
}
@keyframes sos-pop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.sos-modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(120deg, #C23A36, #E4574F);
  color: #ffffff;
  border-bottom: 0;
}
.sos-modal-head h2 {
  margin: 0;
  color: #ffffff;
  font-size: 18px;
}
.sos-modal-head p {
  margin: 3px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}
.sos-bell {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}
.sos-bell svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sos-close {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}
.sos-close:hover {
  background: rgba(255, 255, 255, 0.26);
  border-color: rgba(255, 255, 255, 0.5);
  color: #ffffff;
}
.sos-modal-body {
  padding: 18px;
  display: grid;
  gap: 14px;
}
.sos-resident {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.sos-resident-avatar {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #C23A36, #E8803B);
  color: #ffffff;
  font-size: 22px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px -8px rgba(194, 58, 54, 0.6);
}
.sos-resident-copy {
  min-width: 0;
  flex: 1 1 150px;
  display: grid;
  gap: 3px;
}
.sos-resident-copy strong {
  font-size: 17px;
  color: var(--navy);
}
.sos-resident-copy span {
  font-size: 12.5px;
  color: var(--muted);
}
.sos-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #A93632;
  background: var(--coral-soft);
  border: 1px solid #F2D3D1;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.sos-live-badge .live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--coral);
  animation: sos-pulse 1.6s infinite;
}
@keyframes sos-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(217, 83, 79, 0.45);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(217, 83, 79, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(217, 83, 79, 0);
  }
}
.sos-vitals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.sos-vitals > div {
  border: 1px solid #F2D3D1;
  background: #FFF8F7;
  border-radius: 9px;
  padding: 12px 10px;
  display: grid;
  gap: 2px;
  text-align: center;
}
.sos-vitals span {
  color: var(--muted);
  font-size: 11.5px;
}
.sos-vitals strong {
  color: #B23A36;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}
.sos-vitals small {
  color: var(--muted);
  font-size: 10.5px;
}
.sos-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.sos-meta-grid > div {
  background: #F6F8FB;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  gap: 3px;
  min-width: 0;
}
.sos-meta-grid span {
  color: var(--muted);
  font-size: 11px;
}
.sos-meta-grid strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.sos-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.sos-view-btn,
.sos-dismiss-btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1;
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.sos-view-btn {
  color: #ffffff;
  background: linear-gradient(120deg, #C23A36, #E4574F);
  border: 1px solid #C23A36;
}
.sos-view-btn:hover {
  background: #A9322F;
}
.sos-dismiss-btn {
  color: #A93632;
  background: #ffffff;
  border: 1px solid #F2D3D1;
}
.sos-dismiss-btn:hover {
  background: var(--coral-soft);
}

/* ---- 上門簽到・拍照簽退 ---- */
.visit-panel {
  display: grid;
  gap: 14px;
}
.visit-action-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(240px, 0.7fr);
  gap: 14px;
  align-items: stretch;
}
.visit-action {
  background: #F8FAFC;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px;
  display: grid;
  gap: 12px;
  min-width: 0;
}
.visit-switch-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 18px;
  flex-wrap: wrap;
}
.visit-switch-row .resident-switch {
  margin-bottom: 0;
  min-width: 210px;
}
.visit-room-copy {
  min-width: 0;
}
.visit-room-copy h3 {
  margin: 0;
  font-size: 16px;
  color: var(--navy);
}
.visit-room-copy p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.visit-action-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}
.visit-photo-btn {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--teal-deep);
  background: var(--teal-soft);
  border: 1px solid #C8DCF2;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.visit-photo-btn svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.visit-photo-btn:hover {
  background: #D9E8F6;
  border-color: #9DC1E8;
}
.visit-photo-preview {
  position: relative;
  flex: 1 1 180px;
  max-width: 240px;
  min-height: 118px;
  border: 1px dashed #C7D5E4;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
}
.visit-photo-thumb {
  width: 100%;
  height: 100%;
  min-height: 118px;
  object-fit: cover;
  display: block;
}
.visit-photo-clear {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid #F2D3D1;
  background: #FFF8F7;
  color: #B23A36;
  cursor: pointer;
}
.visit-photo-clear svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.visit-photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 118px;
  color: #98A5B6;
  font-size: 12px;
}
.visit-check-btn {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  background: var(--teal);
  border: 1px solid var(--teal);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.visit-check-btn:hover {
  background: var(--teal-deep);
}
.visit-check-btn.checkout {
  color: #7A5200;
  background: var(--amber-soft);
  border-color: #F0DFBC;
}
.visit-check-btn.checkout:hover {
  background: #F9E8BD;
  border-color: var(--amber);
}
.visit-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.visit-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  background: var(--navy);
  color: #ffffff;
  border-radius: 9px;
  padding: 14px;
}
.visit-summary > div {
  display: grid;
  gap: 4px;
  text-align: center;
}
.visit-summary span {
  font-size: 11.5px;
  color: #BFD3E8;
}
.visit-summary strong {
  font-size: 22px;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}
.visit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.visit-record {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
}
.visit-record-photo {
  width: 88px;
  height: 88px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.visit-list-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.visit-list-photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 26px;
  font-weight: 700;
}
.visit-record-main {
  min-width: 0;
  display: grid;
  gap: 8px;
}
.visit-record-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.visit-record-title {
  display: grid;
  gap: 2px;
}
.visit-record-title strong {
  font-size: 15px;
  color: var(--navy);
}
.visit-record-title small {
  font-size: 11.5px;
  color: var(--muted);
}
.visit-status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.visit-status-chip.done {
  color: #34704D;
  background: var(--green-soft);
  border: 1px solid #CEE3D6;
}
.visit-status-chip.ongoing {
  color: #8A5F00;
  background: var(--amber-soft);
  border: 1px solid #F0DFBC;
}
.visit-record-address {
  background: #F6F8FB;
  border-radius: 6px;
  padding: 6px 9px;
  display: flex;
  gap: 8px;
  font-size: 12px;
}
.visit-record-address span {
  color: var(--muted);
  white-space: nowrap;
}
.visit-record-address strong {
  color: var(--ink);
  word-break: break-word;
}
.visit-record-times {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}
.visit-time {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}
.visit-time span {
  color: var(--muted);
  white-space: nowrap;
}
.visit-time strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.visit-record-note {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  background: #F6F8FB;
  padding: 7px 9px;
  border-left: 3px solid var(--teal-bright);
  border-radius: 0 6px 6px 0;
}
.visit-record-actions {
  display: flex;
  gap: 8px;
}
.visit-jump-btn {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--teal-deep);
  background: var(--teal-soft);
  border: 1px solid #C8DCF2;
  border-radius: 6px;
  padding: 8px 11px;
  cursor: pointer;
}
.visit-jump-btn:hover {
  background: #D9E8F6;
}
.visit-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  background: #F6F8FB;
  border: 1px dashed #D6DFEA;
  border-radius: 8px;
  padding: 26px 16px;
  font-size: 13px;
}
.visit-empty-icon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal-deep);
}
.visit-empty-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 760px) {
  .visit-action-grid {
    grid-template-columns: 1fr;
  }
  .visit-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 480px) {
  .sos-modal-head {
    flex-wrap: wrap;
  }
  .sos-meta-grid,
  .sos-actions {
    grid-template-columns: 1fr;
  }
  .visit-switch-row {
    flex-direction: column;
    align-items: stretch;
  }
  .visit-switch-row .resident-switch {
    min-width: 0;
    width: 100%;
  }
  .visit-action-row {
    flex-direction: column;
  }
  .visit-photo-btn {
    width: 100%;
  }
  .visit-photo-preview {
    max-width: none;
    flex-basis: auto;
  }
  .visit-record {
    grid-template-columns: 72px minmax(0, 1fr);
  }
  .visit-record-photo {
    width: 72px;
    height: 72px;
  }
  .visit-record-times {
    grid-template-columns: 1fr;
  }
}
