:root {
  --canvas: #eef3f1;
  --surface: #ffffff;
  --surface-muted: #f5f8f7;
  --ink: #16231f;
  --muted: #697c76;
  --line: #dce6e2;
  --primary: #087f72;
  --primary-dark: #05675d;
  --primary-soft: #dff3ef;
  --blue: #356f95;
  --blue-soft: #e3eef5;
  --amber: #c9861b;
  --amber-soft: #fff2d7;
  --danger: #c84242;
  --danger-soft: #fde9e6;
  --shadow: 0 14px 36px rgba(27, 53, 46, 0.09);
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(16, 78, 68, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 78, 68, 0.035) 1px, transparent 1px),
    var(--canvas);
  background-size: 24px 24px;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(8, 127, 114, 0.25);
  outline-offset: 2px;
}

button,
label,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.app-shell {
  position: relative;
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface-muted);
  box-shadow: 0 0 60px rgba(32, 58, 52, 0.08);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 12px 18px 10px;
  border-bottom: 1px solid rgba(220, 230, 226, 0.8);
  background: rgba(245, 248, 247, 0.94);
  backdrop-filter: blur(16px);
}

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

.brand-mark {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px 10px 10px 3px;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(8, 127, 114, 0.2);
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  position: absolute;
  content: "";
  background: #fff;
}

.brand-mark::before {
  width: 19px;
  height: 3px;
  border-radius: 2px;
  transform: translateY(-5px);
}

.brand-mark::after {
  width: 3px;
  height: 17px;
  border-radius: 2px;
}

.brand-mark span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b9e8df;
  transform: translate(8px, 8px);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0;
}

.icon-button {
  position: relative;
  display: inline-grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

.icon-button:active,
.action-button:active,
.mode-option:active,
.primary-button:active,
.outline-button:active {
  transform: translateY(1px);
}

.icon-button.small {
  width: 34px;
  height: 34px;
}

.device-indicator {
  color: var(--primary);
}

.online-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: #2daf75;
}

.content {
  padding: 20px 16px calc(104px + var(--safe-bottom));
}

.view {
  display: none;
  animation: view-in 220ms ease both;
}

.view.is-active {
  display: block;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading.compact {
  margin: 4px 0 10px;
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
  letter-spacing: 0;
}

.section-heading h2 {
  font-size: 22px;
}

.section-heading h3 {
  font-size: 16px;
}

.patient-button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 5px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
}

.patient-button svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.work-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border-radius: var(--radius);
  color: #fff;
  background: #183c35;
  box-shadow: 0 12px 28px rgba(22, 57, 49, 0.16);
}

.work-summary > div {
  position: relative;
  padding: 14px 12px;
}

.work-summary > div + div::before {
  position: absolute;
  top: 13px;
  bottom: 13px;
  left: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.14);
  content: "";
}

.work-summary span,
.work-summary strong {
  display: block;
}

.work-summary span {
  color: rgba(255, 255, 255, 0.64);
  font-size: 9px;
}

.work-summary strong {
  margin-top: 4px;
  font-family: "DIN Alternate", "Arial Narrow", sans-serif;
  font-size: 23px;
  line-height: 1;
}

.tone-danger-text {
  color: #ff9d8a;
}

.tone-warning-text {
  color: #f5c663;
}

.search-field {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.search-field svg {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
}

.search-field input::placeholder {
  color: #97a6a1;
}

.patient-filter {
  display: flex;
  gap: 7px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.patient-filter::-webkit-scrollbar {
  display: none;
}

.patient-filter button {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.patient-filter button.is-selected {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.patient-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.patient-card {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 92px;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  padding: 13px 12px 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  box-shadow: 0 7px 18px rgba(27, 53, 46, 0.05);
  cursor: pointer;
}

.patient-card.is-active {
  border-color: var(--primary);
  background: #f3fbf8;
  box-shadow: 0 10px 24px rgba(8, 127, 114, 0.1);
}

.patient-risk-line {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
}

.risk-high {
  color: var(--danger);
}

.risk-medium {
  color: var(--amber);
}

.risk-low {
  color: var(--primary);
}

.patient-risk-line.risk-high,
.risk-dot.risk-high {
  background: var(--danger);
}

.patient-risk-line.risk-medium,
.risk-dot.risk-medium {
  background: var(--amber);
}

.patient-risk-line.risk-low,
.risk-dot.risk-low {
  background: #3d9b72;
}

.patient-card .avatar {
  width: 34px;
  height: 34px;
  background: #5b7d91;
}

.patient-card.is-active .avatar {
  background: var(--primary);
}

.patient-card-main {
  min-width: 0;
}

.patient-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.patient-name-row strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.risk-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.patient-card-main > small {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patient-tags {
  display: flex;
  gap: 5px;
  margin-top: 8px;
}

.patient-tags em {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 8px;
  font-style: normal;
  font-weight: 700;
}

.patient-tags .risk-high {
  background: var(--danger-soft);
}

.patient-tags .risk-medium {
  background: var(--amber-soft);
}

.patient-tags .risk-low {
  background: var(--primary-soft);
}

.patient-tags .status-attention {
  color: #9b5313;
  background: #fce6d1;
}

.patient-tags .status-due {
  color: #7a5a1a;
  background: var(--amber-soft);
}

.patient-tags .status-stable {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.patient-card-stats {
  min-width: 70px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  text-align: right;
}

.patient-card-stats strong,
.patient-card-stats span,
.patient-card-stats i {
  display: block;
}

.patient-card-stats strong {
  font-family: "DIN Alternate", "Arial Narrow", sans-serif;
  font-size: 16px;
}

.patient-card-stats strong small {
  color: var(--muted);
  font-size: 7px;
}

.patient-card-stats span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 8px;
}

.patient-card-stats i {
  margin-top: 5px;
  color: var(--danger);
  font-size: 8px;
  font-style: normal;
  font-weight: 700;
}

.empty-state {
  display: grid;
  min-height: 190px;
  place-items: center;
  align-content: center;
  gap: 7px;
  border: 1px dashed #cbd8d3;
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  text-align: center;
}

.empty-state svg {
  width: 28px;
  height: 28px;
  color: #91a29c;
}

.empty-state strong {
  color: var(--ink);
  font-size: 12px;
}

.empty-state p {
  margin: 0;
  font-size: 9px;
}

.avatar {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.monitor-panel,
.settings-panel,
.record-summary,
.device-card,
.profile-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.monitor-panel {
  padding: 16px;
}

.monitor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.label-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(8, 127, 114, 0.32);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 7px rgba(8, 127, 114, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(8, 127, 114, 0);
  }
}

.pressure-readout {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 2px;
}

.pressure-readout strong {
  font-family: "DIN Alternate", "Arial Narrow", sans-serif;
  font-size: 42px;
  font-weight: 760;
  line-height: 1;
  letter-spacing: 0;
}

.pressure-readout > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.monitor-status {
  text-align: right;
}

.monitor-status p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.status-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge svg {
  width: 14px;
  height: 14px;
}

.status-badge.is-soft {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.status-badge.is-paused {
  color: #7a5a1a;
  background: var(--amber-soft);
}

.status-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2daf75;
}

.monitor-body {
  display: grid;
  grid-template-columns: 1.06fr 0.94fr;
  gap: 16px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #e7eeeb;
  border-radius: var(--radius);
  background: #f8faf9;
}

.body-figure {
  position: relative;
  width: 100%;
  min-height: 250px;
  overflow: hidden;
  border-radius: 7px;
  background:
    radial-gradient(circle at center, rgba(8, 127, 114, 0.075), transparent 68%),
    repeating-linear-gradient(0deg, transparent 0 24px, rgba(8, 127, 114, 0.045) 24px 25px);
}

.body-zone {
  position: absolute;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.8);
  color: #18352f;
  background: var(--zone-color, #8cc9b8);
  transition: background 500ms ease, box-shadow 500ms ease;
  transform: translateX(-50%);
}

.body-zone::after {
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: inherit;
  content: "";
}

.body-zone span {
  display: none;
}

.body-zone strong {
  position: relative;
  z-index: 1;
  font-size: 11px;
}

.zone-head {
  top: 10px;
  width: 54px;
  height: 54px;
  border-radius: 50% 50% 45% 45%;
}

.zone-torso {
  top: 72px;
  width: 88px;
  height: 82px;
  border-radius: 30px 30px 19px 19px;
}

.zone-hip {
  top: 162px;
  width: 82px;
  height: 42px;
  border-radius: 19px 19px 28px 28px;
}

.zone-legs {
  top: 212px;
  width: 68px;
  height: 32px;
  border-radius: 12px 12px 28px 28px;
}

.zone-summary {
  min-width: 0;
}

.zone-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  font-size: 12px;
  font-weight: 700;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.text-button svg {
  width: 14px;
  height: 14px;
}

.pressure-legend {
  display: grid;
  grid-template-columns: 8px auto 8px auto 8px auto;
  align-items: center;
  justify-content: start;
  gap: 4px;
  margin: 9px 0 10px;
  color: var(--muted);
  font-size: 9px;
}

.pressure-legend span:not([class]) {
  margin-right: 2px;
}

.legend-low,
.legend-mid,
.legend-high {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend-low {
  background: #7ac6af;
}

.legend-mid {
  background: #e2b457;
}

.legend-high {
  background: #e47c61;
}

.zone-list {
  margin: 0;
}

.zone-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #e6eeeb;
}

.zone-list > div:last-child {
  border-bottom: 0;
}

.zone-list dt {
  color: var(--muted);
  font-size: 11px;
}

.zone-list dd {
  margin: 0;
  font-family: "DIN Alternate", "Arial Narrow", sans-serif;
  font-size: 16px;
  font-weight: 760;
}

.zone-list dd small {
  color: var(--muted);
  font-size: 8px;
  font-weight: 600;
}

.zone-list .is-warning dd {
  color: var(--danger);
}

.device-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.device-meta > span {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.device-meta svg {
  width: 13px;
  height: 13px;
  color: var(--primary);
}

.device-meta b {
  color: var(--ink);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 12px;
}

.action-button {
  display: flex;
  min-width: 0;
  min-height: 80px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.action-button.is-primary {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.action-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  color: var(--primary);
  background: var(--primary-soft);
}

.is-primary .action-icon {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.action-icon svg {
  width: 16px;
  height: 16px;
}

.action-button strong,
.action-button small {
  display: block;
}

.action-button strong {
  font-size: 12px;
  line-height: 1.2;
}

.action-button small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-button.is-primary small {
  color: rgba(255, 255, 255, 0.76);
}

.alert-section {
  margin-top: 22px;
}

.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 23px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #e8eeeb;
  font-size: 10px;
  font-weight: 700;
}

.alert-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 13px;
  border: 1px solid #f1d6a2;
  border-radius: var(--radius);
  background: var(--amber-soft);
}

.alert-card.is-danger {
  border-color: #f1c2bb;
  background: var(--danger-soft);
}

.alert-card.is-success {
  border-color: #c9e7dd;
  background: var(--primary-soft);
}

.alert-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius);
  color: #7a5514;
  background: rgba(255, 255, 255, 0.64);
}

.alert-card.is-danger .alert-icon {
  color: var(--danger);
}

.alert-card.is-success .alert-icon {
  color: var(--primary);
}

.alert-icon svg {
  width: 18px;
  height: 18px;
}

.alert-copy {
  min-width: 0;
}

.alert-copy strong {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
}

.alert-copy p {
  margin: 0;
  color: #6d5b35;
  font-size: 10px;
  line-height: 1.5;
}

.alert-card.is-danger .alert-copy p {
  color: #7e4a45;
}

.alert-card.is-success .alert-copy p {
  color: #407168;
}

.alert-action {
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: #9b6813;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.alert-card.is-danger .alert-action {
  background: var(--danger);
}

.metrics-section {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 12px;
}

.metric {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-icon {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
}

.metric-icon svg {
  width: 15px;
  height: 15px;
}

.tone-teal {
  color: var(--primary);
  background: var(--primary-soft);
}

.tone-blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.tone-amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.metric div {
  min-width: 0;
}

.metric strong,
.metric span:not(.metric-icon) {
  display: block;
}

.metric strong {
  font-family: "DIN Alternate", "Arial Narrow", sans-serif;
  font-size: 17px;
  line-height: 1.1;
}

.metric div > span {
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.mode-option {
  display: flex;
  min-width: 0;
  min-height: 130px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.mode-option.is-selected {
  border: 2px solid var(--primary);
  padding: 11px 9px;
  background: #eefaf7;
  box-shadow: 0 8px 22px rgba(8, 127, 114, 0.1);
}

.mode-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius);
  color: var(--primary);
  background: var(--primary-soft);
}

.mode-option.is-selected .mode-icon {
  color: #fff;
  background: var(--primary);
}

.mode-icon svg {
  width: 18px;
  height: 18px;
}

.mode-option strong {
  display: block;
  margin-top: 8px;
  font-size: 12px;
}

.mode-option small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.settings-panel {
  margin-top: 14px;
  padding: 0 14px;
}

.settings-row,
.toggle-row {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.settings-row.is-stacked {
  display: block;
  padding: 14px 0;
}

.toggle-row:last-child,
.settings-row:last-child {
  border-bottom: 0;
}

.setting-copy {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.setting-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  color: var(--primary);
  background: var(--primary-soft);
}

.setting-icon svg {
  width: 17px;
  height: 17px;
}

.setting-copy strong,
.setting-copy small {
  display: block;
}

.setting-copy strong {
  font-size: 12px;
}

.setting-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.setting-copy small b {
  color: var(--ink);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 7px;
}

.stepper > span {
  min-width: 52px;
  text-align: center;
}

.stepper strong {
  font-family: "DIN Alternate", "Arial Narrow", sans-serif;
  font-size: 20px;
}

.stepper small {
  margin-left: 2px;
  color: var(--muted);
  font-size: 8px;
}

.range-wrap {
  margin-top: 15px;
}

input[type="range"] {
  width: 100%;
  height: 5px;
  margin: 0;
  border-radius: 5px;
  accent-color: var(--primary);
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--muted);
  font-size: 9px;
}

.toggle-row > div:first-child {
  min-width: 0;
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row strong {
  font-size: 12px;
}

.toggle-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd6d2;
  transition: background 180ms ease;
  cursor: pointer;
}

.switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(22, 35, 31, 0.2);
  content: "";
  transition: transform 180ms ease;
}

.switch input:checked + span {
  background: var(--primary);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.primary-button,
.outline-button,
.danger-outline-button,
.text-danger-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  margin-top: 14px;
  border: 1px solid var(--primary);
  color: #fff;
  background: var(--primary);
  box-shadow: 0 10px 22px rgba(8, 127, 114, 0.17);
}

.primary-button.compact {
  width: auto;
  min-width: 120px;
  margin: 0;
  padding: 0 16px;
}

.outline-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.danger-outline-button {
  width: 100%;
  margin-top: 14px;
  border: 1px solid #ebc0ba;
  color: var(--danger);
  background: var(--danger-soft);
}

.text-danger-button {
  width: 100%;
  min-height: 42px;
  margin-top: 6px;
  border: 0;
  color: var(--danger);
  background: transparent;
}

.period-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #e8eeeb;
}

.period-control button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.period-control button.is-selected {
  color: var(--primary-dark);
  background: var(--surface);
  box-shadow: 0 3px 9px rgba(27, 53, 46, 0.08);
}

.record-summary {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  margin-top: 12px;
  padding: 16px;
  overflow: hidden;
}

.task-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.task-overview > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.task-overview-icon {
  display: grid;
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
}

.task-overview-icon svg {
  width: 15px;
  height: 15px;
}

.task-overview strong,
.task-overview div > div > span {
  display: block;
}

.task-overview strong {
  font-family: "DIN Alternate", "Arial Narrow", sans-serif;
  font-size: 17px;
  line-height: 1;
}

.task-overview div > div > span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
  white-space: nowrap;
}

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

.task-item {
  position: relative;
  display: grid;
  grid-template-columns: 39px 1px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 82px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 7px 18px rgba(27, 53, 46, 0.05);
}

.task-item.is-overdue {
  border-color: #efc3bc;
  background: #fffafa;
}

.task-item > time {
  color: var(--muted);
  font-family: "DIN Alternate", "Arial Narrow", sans-serif;
  font-size: 11px;
  font-weight: 750;
}

.task-line {
  width: 1px;
  height: 38px;
  border-radius: 1px;
  background: var(--amber);
}

.task-item.is-overdue .task-line {
  background: var(--danger);
}

.task-copy {
  min-width: 0;
}

.task-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.task-title-row strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-title-row span {
  flex: 0 0 auto;
  padding: 2px 5px;
  border-radius: 4px;
  color: #7a5a1a;
  background: var(--amber-soft);
  font-size: 8px;
  font-weight: 700;
}

.task-item.is-overdue .task-title-row span {
  color: var(--danger);
  background: var(--danger-soft);
}

.task-copy p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.task-copy small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #8b9995;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-item > button {
  min-width: 44px;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 9px;
  font-weight: 750;
  cursor: pointer;
}

.task-item.is-overdue > button {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.empty-task {
  display: flex;
  min-height: 82px;
  align-items: center;
  gap: 11px;
  padding: 14px;
  border: 1px solid #cce5dc;
  border-radius: var(--radius);
  color: var(--primary);
  background: var(--primary-soft);
}

.empty-task > span {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #fff;
}

.empty-task svg {
  width: 18px;
  height: 18px;
}

.empty-task strong,
.empty-task p {
  display: block;
}

.empty-task strong {
  color: var(--ink);
  font-size: 11px;
}

.empty-task p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.record-summary > div:first-child > span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.record-summary > div:first-child > strong {
  display: block;
  margin-top: 3px;
  font-family: "DIN Alternate", "Arial Narrow", sans-serif;
  font-size: 35px;
  line-height: 1;
}

.record-summary > div:first-child small {
  font-size: 15px;
}

.summary-ring {
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
}

.summary-ring svg {
  position: absolute;
  inset: 0;
  width: 58px;
  height: 58px;
  transform: rotate(-90deg);
}

.summary-ring circle {
  fill: none;
  stroke: #e4ece9;
  stroke-width: 3;
}

.summary-ring .ring-value {
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-dasharray: 100 100;
  stroke-dashoffset: 4;
}

.summary-ring > span {
  position: relative;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: var(--primary);
  background: var(--primary-soft);
}

.summary-ring svg + span svg {
  width: 14px;
  height: 14px;
}

.record-summary dl {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.record-summary dl > div {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.record-summary dl > div:first-child {
  padding-left: 0;
  border-left: 0;
}

.record-summary dt {
  color: var(--muted);
  font-size: 9px;
}

.record-summary dd {
  margin: 3px 0 0;
  font-size: 14px;
  font-weight: 750;
}

.timeline {
  margin: 0;
  padding: 4px 0 0;
  list-style: none;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 70px;
}

.timeline-item::before {
  position: absolute;
  top: 28px;
  bottom: 0;
  left: 13px;
  width: 1px;
  background: var(--line);
  content: "";
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-icon {
  z-index: 1;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--primary);
  background: var(--surface-muted);
}

.timeline-icon.is-alert {
  color: var(--amber);
  background: var(--amber-soft);
}

.timeline-icon svg {
  width: 14px;
  height: 14px;
}

.timeline-copy {
  padding-top: 4px;
}

.timeline-copy strong {
  display: block;
  font-size: 12px;
}

.timeline-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.timeline time {
  padding-top: 5px;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.device-card {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 16px;
}

.device-visual {
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 18px 18px 18px 7px;
  color: #fff;
  background: var(--primary);
}

.device-visual.small {
  width: 48px;
  height: 48px;
  border-radius: 15px 15px 15px 6px;
}

.device-visual svg {
  position: relative;
  z-index: 1;
  width: 24px;
  height: 24px;
}

.device-ring {
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: inherit;
}

.device-copy {
  min-width: 0;
}

.device-copy h3 {
  margin: 8px 0 3px;
  font-size: 13px;
}

.device-copy p {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-stats {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, 1fr);
  margin: 3px 0 0;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.device-stats > div {
  text-align: center;
}

.device-stats dt {
  color: var(--muted);
  font-size: 9px;
}

.device-stats dd {
  margin: 3px 0 0;
  font-size: 12px;
  font-weight: 700;
}

.profile-panel {
  margin-top: 12px;
  padding: 15px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}

.panel-heading h3 {
  margin: 0;
  font-size: 15px;
}

.profile-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 0;
}

.profile-list > div {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
}

.profile-list > div:nth-child(odd) {
  padding-left: 0;
  border-right: 1px solid var(--line);
}

.profile-list > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.profile-list dt {
  color: var(--muted);
  font-size: 9px;
}

.profile-list dd {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 700;
}

.risk-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  color: #8a5710;
  background: var(--amber-soft);
  font-size: 10px;
}

.risk-tag[data-risk="high"] {
  color: var(--danger);
  background: var(--danger-soft);
}

.risk-tag[data-risk="medium"] {
  color: #8a5710;
  background: var(--amber-soft);
}

.risk-tag[data-risk="low"] {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.profile-panel .toggle-row {
  min-height: 64px;
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  width: min(100%, 480px);
  grid-template-columns: repeat(5, 1fr);
  margin: 0 auto;
  padding: 7px 10px calc(7px + var(--safe-bottom));
  border-top: 1px solid rgba(220, 230, 226, 0.9);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  display: flex;
  min-height: 54px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: var(--radius);
  color: #83928d;
  background: transparent;
  font-size: 9px;
  font-weight: 650;
  cursor: pointer;
}

.bottom-nav button svg {
  width: 21px;
  height: 21px;
}

.bottom-nav button.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(94px + var(--safe-bottom));
  max-width: min(82vw, 360px);
  padding: 10px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: #1d302b;
  box-shadow: 0 12px 30px rgba(20, 38, 33, 0.24);
  font-size: 11px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  padding: 20px;
  place-items: center;
  background: rgba(13, 27, 23, 0.5);
  backdrop-filter: blur(4px);
}

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

.alert-modal {
  width: min(100%, 390px);
  padding: 24px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(10, 25, 21, 0.27);
}

.modal-icon {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 16px;
  place-items: center;
  border-radius: var(--radius);
  color: var(--danger);
  background: var(--danger-soft);
}

.modal-icon svg {
  width: 23px;
  height: 23px;
}

.alert-modal h2 {
  margin: 0;
  font-size: 21px;
}

.alert-modal > p:not(.eyebrow) {
  margin: 11px 0 22px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.modal-actions .outline-button,
.modal-actions .primary-button {
  width: 100%;
  margin: 0;
}

.device-modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.device-modal-head h2 {
  font-size: 16px;
}

.device-modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.modal-device-list {
  margin: 20px 0;
  border-top: 1px solid var(--line);
}

.modal-device-list > div {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.modal-device-list dt {
  color: var(--muted);
  font-size: 11px;
}

.modal-device-list dd {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
}

.device-modal .primary-button.compact {
  width: 100%;
}

.app-shell.is-paused .pulse-dot {
  background: var(--amber);
  animation: none;
}

.app-shell.is-turning .body-figure {
  animation: caring 1.5s ease-in-out infinite;
}

@keyframes caring {
  50% {
    box-shadow: inset 0 0 0 2px rgba(8, 127, 114, 0.18);
  }
}

@media (max-width: 370px) {
  .content {
    padding-right: 12px;
    padding-left: 12px;
  }

  .monitor-body {
    grid-template-columns: 0.95fr 1.05fr;
    gap: 10px;
    padding: 10px;
  }

  .pressure-readout strong {
    font-size: 37px;
  }

  .action-button {
    min-height: 76px;
    padding: 9px;
  }

  .metric {
    display: block;
    padding: 9px 8px;
  }

  .metric-icon {
    margin-bottom: 6px;
  }

  .mode-option {
    min-height: 122px;
    padding: 10px 8px;
  }
}

@media (min-width: 700px) {
  body {
    padding: 20px 0;
  }

  .app-shell {
    min-height: calc(100dvh - 40px);
    border: 1px solid #d8e2de;
    border-radius: 20px;
  }

  .topbar {
    border-radius: 20px 20px 0 0;
  }

  .bottom-nav {
    bottom: 20px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-left: 1px solid var(--line);
    border-radius: 0 0 20px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
