/* 血压监测 — clinical instrument UI
   Tokens:
   ink #1A2E33 | paper #F2F6F5 | surface #fff | accent #0F7B6C | haze #7D918F
   severity: normal/highNormal/elevated/high1/high2/crisis/low
*/

:root {
  --ink: #1a2e33;
  --paper: #f2f6f5;
  --surface: #ffffff;
  --accent: #0f7b6c;
  --accent-soft: #e6f3f0;
  --haze: #7d918f;
  --line: #d7e2df;
  --danger: #a33a3a;

  --bp-normal: #2f7d4f;
  --bp-highNormal: #6f9a3a;
  --bp-elevated: #b8860b;
  --bp-high1: #d4762a;
  --bp-high2: #c23b3b;
  --bp-crisis: #7a1f3d;
  --bp-low: #3b7ea1;

  --tone: var(--haze);

  --radius: 12px;
  --shadow: 0 8px 28px rgba(26, 46, 51, 0.07);
  --font-body: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-display: Georgia, "Times New Roman", "Songti SC", serif;
  --font-mono: "Cascadia Code", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #dceee9 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #e8eef5 0%, transparent 45%),
    var(--paper);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--haze); }
[hidden] { display: none !important; }

/* Tones */
.tone-normal, .tone.tone-normal { color: var(--bp-normal) !important; }
.tone-highNormal, .tone.tone-highNormal { color: var(--bp-highNormal) !important; }
.tone-elevated, .tone.tone-elevated { color: var(--bp-elevated) !important; }
.tone-high1, .tone.tone-high1 { color: var(--bp-high1) !important; }
.tone-high2, .tone.tone-high2 { color: var(--bp-high2) !important; }
.tone-crisis, .tone.tone-crisis { color: var(--bp-crisis) !important; }
.tone-low, .tone.tone-low { color: var(--bp-low) !important; }
.tone-muted { color: var(--haze) !important; }

.severity-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: #eef3f2;
  color: var(--haze);
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--line);
}
.severity-pill.tone-normal { background: #e7f5ec; border-color: #b9dfc7; color: var(--bp-normal); }
.severity-pill.tone-highNormal { background: #f1f5e4; border-color: #d0dfb0; color: var(--bp-highNormal); }
.severity-pill.tone-elevated { background: #fbf3df; border-color: #ead59a; color: var(--bp-elevated); }
.severity-pill.tone-high1 { background: #fceee2; border-color: #f0c49d; color: var(--bp-high1); }
.severity-pill.tone-high2 { background: #fbe4e4; border-color: #efb0b0; color: var(--bp-high2); }
.severity-pill.tone-crisis { background: #f6e4ea; border-color: #d9a3b4; color: var(--bp-crisis); }
.severity-pill.tone-low { background: #e5f1f7; border-color: #b5d4e5; color: var(--bp-low); }

/* Auth */
.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.75rem;
}
.auth-brand { text-align: center; margin-bottom: 1.25rem; }
.auth-brand h1 { font-family: var(--font-display); font-size: 1.75rem; margin-top: 0.75rem; }
.auth-brand .muted { margin-top: 0.35rem; font-size: 0.92rem; }

.brand-mark {
  width: 88px;
  height: 88px;
  margin: 0 auto;
  border-radius: 22px;
  background: linear-gradient(160deg, #0f7b6c, #1a4f55);
  color: #f4fbf9;
  display: grid;
  place-content: center;
  font-family: var(--font-display);
  line-height: 1;
  gap: 2px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.brand-mark .brand-sys { font-size: 1.35rem; font-weight: 700; }
.brand-mark .brand-slash { opacity: 0.7; font-size: 0.9rem; }
.brand-mark .brand-dia { font-size: 1.15rem; font-weight: 600; }
.brand-mark.sm {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  margin: 0;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.85rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  background: #eef3f2;
  border-radius: 10px;
  padding: 0.3rem;
  margin-bottom: 1.1rem;
}
.tab {
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 0.55rem;
  color: var(--haze);
  font-weight: 600;
}
.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(26,46,51,0.08);
}

.auth-meta {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--haze);
}

/* Forms */
.form { display: grid; gap: 0.85rem; }
.field { display: grid; gap: 0.35rem; }
.field > span { font-size: 0.88rem; color: var(--haze); font-weight: 600; }
.field input,
.field select,
.profile-switch select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfdfc;
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  outline: none;
  min-height: 44px;
}
.field input:focus,
.field select:focus,
.profile-switch select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 108, 0.15);
  background: #fff;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.row-inline { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; }
.check {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  font-size: 0.9rem;
  color: var(--ink);
}
.check input { margin-top: 0.2rem; width: 1rem; height: 1rem; accent-color: var(--accent); }
.form-hint { font-size: 0.85rem; }
.form-actions { display: flex; gap: 0.5rem; }

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  min-height: 44px;
  font-weight: 650;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: #f4fffb; }
.btn.primary:hover { background: #0c6a5d; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); border-color: #c5e2db; }
.btn.secondary:hover { background: #d7ece7; }
.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn.ghost:hover { background: rgba(15, 123, 108, 0.06); border-color: #b9d0cb; }
.btn.danger { background: #b4232a; color: #fff; }
.btn.danger:hover { background: #961c23; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0.4rem 0.7rem; font-size: 0.88rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* App shell */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.topbar-right { justify-content: flex-end; }
.topbar-title { display: grid; line-height: 1.2; }
.topbar-title strong { font-size: 0.98rem; }
.topbar-title span { font-size: 0.75rem; }
.profile-switch { display: flex; align-items: center; gap: 0.5rem; }
.profile-switch span { font-size: 0.85rem; white-space: nowrap; }
.profile-switch select { min-width: 140px; width: auto; }
.user-chip {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.sync-chip {
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f4f7f6;
  color: var(--haze);
  white-space: nowrap;
}
.sync-chip.ok {
  background: #e7f5ec;
  border-color: #b9dfc7;
  color: var(--bp-normal);
}
.sync-chip.error {
  background: #fbe4e4;
  border-color: #efb0b0;
  color: var(--bp-high2);
}
.sync-chip.idle {
  background: var(--accent-soft);
  border-color: #c5e2db;
  color: var(--accent);
}

.filter-bar {
  display: grid;
  grid-template-columns: 160px 160px 1fr auto;
  gap: 0.75rem 0.85rem;
  align-items: end;
  margin-bottom: 0.85rem;
}
.filter-bar .tone-filter-field {
  grid-column: auto;
  min-width: 0;
}
.tone-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.5rem;
  align-items: center;
  min-height: 44px;
}
.tone-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  min-height: 40px;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.tone-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.tone-chip .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tone, var(--haze));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  flex: 0 0 auto;
}
.tone-chip .txt { color: inherit; }
.tone-chip[data-tone='normal'] { --tone: var(--bp-normal); }
.tone-chip[data-tone='highNormal'] { --tone: var(--bp-highNormal); }
.tone-chip[data-tone='elevated'] { --tone: var(--bp-elevated); }
.tone-chip[data-tone='high1'] { --tone: var(--bp-high1); }
.tone-chip[data-tone='high2'] { --tone: var(--bp-high2); }
.tone-chip[data-tone='crisis'] { --tone: var(--bp-crisis); }
.tone-chip[data-tone='low'] { --tone: var(--bp-low); }

.tone-chip:hover {
  border-color: #c5d5d1;
  background: #f8fbfa;
}
.tone-chip:has(input:checked),
.tone-chip.is-on {
  border-color: var(--tone);
  background: #f4faf8;
  color: var(--tone);
  box-shadow: inset 0 0 0 1px var(--tone);
}
.tone-chip:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.tone-chip:has(input:checked) .dot,
.tone-chip.is-on .dot {
  box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--tone);
}
.filter-actions { display: flex; gap: 0.4rem; }
.history-meta { margin-bottom: 0.6rem; font-size: 0.9rem; }

.webdav-panel { margin-top: 0.25rem; }
.field-row.two { grid-template-columns: 1fr 1fr; }
.form-actions.wrap { flex-wrap: wrap; }
.sync-log {
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: #f4f8f7;
  border: 1px dashed var(--line);
  font-size: 0.88rem;
  color: var(--ink);
  white-space: pre-wrap;
}
.sync-log.error {
  background: #fbeaea;
  border-color: #efb8b8;
  color: var(--bp-high2);
}
.sync-log.ok {
  background: #eaf6ef;
  border-color: #b9dfc7;
  color: var(--bp-normal);
}

.main-nav {
  display: flex;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem 0;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}
.nav-btn {
  border: 0;
  background: transparent;
  color: var(--haze);
  font-weight: 650;
  padding: 0.7rem 1rem;
  border-radius: 10px 10px 0 0;
  border-bottom: 2px solid transparent;
  min-height: 44px;
}
.nav-btn:hover { color: var(--ink); background: rgba(255,255,255,0.55); }
.nav-btn.active {
  color: var(--accent);
  background: var(--surface);
  border-bottom-color: var(--accent);
  box-shadow: 0 -1px 0 var(--line);
}
.nav-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.main {
  flex: 1;
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
}
.view { display: none; }
.view.active { display: grid; gap: 1rem; }

/* Instrument — signature */
.instrument {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem 1rem;
  position: relative;
  overflow: hidden;
}
.instrument::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: var(--tone, var(--haze));
  transition: background 0.2s ease;
}
.instrument.tone-normal { --tone: var(--bp-normal); }
.instrument.tone-highNormal { --tone: var(--bp-highNormal); }
.instrument.tone-elevated { --tone: var(--bp-elevated); }
.instrument.tone-high1 { --tone: var(--bp-high1); }
.instrument.tone-high2 { --tone: var(--bp-high2); }
.instrument.tone-crisis { --tone: var(--bp-crisis); }
.instrument.tone-low { --tone: var(--bp-low); }

.instrument-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--haze);
  font-weight: 700;
}
.instrument-time { margin-top: 0.2rem; font-family: var(--font-mono); font-size: 0.9rem; }
.instrument-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.reading {
  background: linear-gradient(180deg, #f7fbfa, #eef5f3);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem 0.85rem;
}
.reading-label { font-size: 0.82rem; color: var(--haze); font-weight: 600; }
.reading-value {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  line-height: 1;
  margin-top: 0.35rem;
  font-weight: 700;
  color: var(--haze);
}
.reading-unit { font-size: 0.8rem; color: var(--haze); margin-top: 0.25rem; font-family: var(--font-mono); }
.instrument-foot {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 1rem;
  align-items: center;
}
.stat { display: grid; gap: 0.15rem; }
.stat strong { font-family: var(--font-mono); font-size: 0.98rem; }
.severity-legend {
  justify-self: end;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  font-size: 0.75rem;
  color: var(--haze);
  align-items: center;
}
.lg {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 0.25rem;
}
.lg.normal { background: var(--bp-normal); }
.lg.highNormal { background: var(--bp-highNormal); }
.lg.elevated { background: var(--bp-elevated); }
.lg.high1 { background: var(--bp-high1); }
.lg.high2 { background: var(--bp-high2); }
.lg.crisis { background: var(--bp-crisis); }
.lg.low { background: var(--bp-low); }

/* Panels */
.panel-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1rem;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem 1.15rem;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.panel-head h2 { font-size: 1.05rem; }
.panel-tools { display: flex; gap: 0.4rem; }

.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 640px;
}
.data-table th {
  text-align: left;
  color: var(--haze);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid #eaf1ef;
  vertical-align: middle;
}
.data-table tbody tr { background: transparent; }
.data-table tbody tr:hover { background: #f6faf8; }
.data-table td.num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
}
.data-table td.time { font-family: var(--font-mono); font-size: 0.86rem; white-space: nowrap; }
.data-table td.actions { white-space: nowrap; }
.data-table .btn { margin-right: 0.25rem; }
.empty-cell {
  text-align: center;
  color: var(--haze);
  padding: 1.5rem 0.75rem !important;
}
.row-sev {
  width: 4px;
  padding: 0 !important;
  border-bottom: 1px solid #eaf1ef;
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.legend-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}
.legend-card h3 { font-size: 0.98rem; margin-bottom: 0.75rem; }
.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
}
.legend-item {
  border-left: 4px solid var(--haze);
  background: #f7faf9;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  display: grid;
  gap: 0.15rem;
}
.legend-item strong { font-size: 0.9rem; }
.legend-item span { font-size: 0.8rem; color: var(--haze); }
.legend-item.tone-normal { border-left-color: var(--bp-normal); }
.legend-item.tone-highNormal { border-left-color: var(--bp-highNormal); }
.legend-item.tone-elevated { border-left-color: var(--bp-elevated); }
.legend-item.tone-high1 { border-left-color: var(--bp-high1); }
.legend-item.tone-high2 { border-left-color: var(--bp-high2); }
.legend-item.tone-crisis { border-left-color: var(--bp-crisis); }
.legend-item.tone-low { border-left-color: var(--bp-low); }

/* Profiles */
.profile-list { display: grid; gap: 0.65rem; }
.profile-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  background: #fbfdfc;
}
.profile-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(15,123,108,0.15);
}
.profile-item h4 { margin: 0; font-size: 1rem; }
.profile-meta { margin-top: 0.2rem; font-size: 0.84rem; color: var(--haze); }
.profile-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: flex-end; }
.badge-active {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: #fff;
  border: 1px solid #b7ddd4;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  vertical-align: middle;
}

.footer {
  text-align: center;
  font-size: 0.82rem;
  padding: 0.5rem 1rem 1.5rem;
}

/* Toast / Modal */
.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #f4fbf9;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  z-index: 100;
  box-shadow: var(--shadow);
  max-width: min(90vw, 420px);
  font-weight: 600;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--accent); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 46, 51, 0.45);
}
.modal-card {
  position: relative;
  width: min(400px, 100%);
  background: var(--surface);
  border-radius: 14px;
  padding: 1.2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.modal-card h3 { margin-bottom: 0.5rem; }
.modal-card p { color: var(--ink); margin-bottom: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* Responsive */
@media (max-width: 900px) {
  .panel-grid { grid-template-columns: 1fr; }
  .instrument-foot { grid-template-columns: 1fr 1fr; }
  .severity-legend { grid-column: 1 / -1; justify-self: start; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-bar .tone-filter-field { grid-column: 1 / -1; }
  .filter-actions { grid-column: 1 / -1; }
  .field-row.two { grid-template-columns: 1fr; }
  .tone-chip { min-height: 38px; padding: 0.4rem 0.7rem 0.4rem 0.55rem; font-size: 0.85rem; }
}

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "left right"
      "center center";
    gap: 0.65rem;
  }
  .topbar-left { grid-area: left; }
  .topbar-right { grid-area: right; }
  .topbar-center { grid-area: center; justify-self: stretch; }
  .profile-switch { width: 100%; }
  .profile-switch select { flex: 1; width: 100%; }
  .field-row { grid-template-columns: 1fr; }
  .instrument-grid { grid-template-columns: 1fr; }
  .reading-value { font-size: 2.4rem; }
  .main-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    border-radius: 0;
    z-index: 30;
    max-width: none;
    box-shadow: 0 -4px 16px rgba(26, 46, 51, 0.06);
    display: flex;
  }
  .nav-btn {
    flex: 1;
    text-align: center;
    border-radius: 10px;
    border-bottom: 0;
    min-height: 48px;
    font-size: 0.92rem;
  }
  .nav-btn.active {
    box-shadow: none;
    background: var(--accent-soft);
  }
  .main {
    padding: 0 0.75rem calc(5.5rem + env(safe-area-inset-bottom));
  }
  .footer {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
  }
  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }
  .btn, .nav-btn, input, select {
    font-size: 16px; /* 防 iOS 聚焦缩放 */
  }
  .btn { min-height: 44px; }
  .form-actions .btn { flex: 1; }
  .webdav-panel .form-actions .btn { flex: 1 1 42%; }
}

@media (max-width: 420px) {
  .auth-card { padding: 1.2rem; }
  .topbar { padding: 0.7rem 0.75rem; }
  .user-chip { display: none; }
  .sync-chip { font-size: 0.72rem; padding: 0.25rem 0.45rem; }
  .instrument { padding: 1rem; }
  .filter-bar { grid-template-columns: 1fr; }
  .severity-legend { font-size: 0.7rem; }
}

@media (min-width: 1100px) {
  .panel-grid { grid-template-columns: minmax(300px, 380px) 1fr; }
  .instrument-grid .reading-value { font-size: 3.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---- A4 打印（历史报表） ---- */
#print-root { display: none; }

@media print {
  body.printing-history {
    background: #fff;
  }
  body.printing-history > *:not(#print-root) {
    display: none !important;
  }
  body.printing-history #print-root {
    display: block !important;
  }
  body.printing-history #print-root .toolbar {
    display: none !important;
  }
  body.printing-history #print-root .report {
    box-shadow: none;
    margin: 0;
    padding: 0;
    max-width: none;
    border-radius: 0;
  }
  body.printing-history #toast,
  body.printing-history #modal {
    display: none !important;
  }
}
