/* ============================================================
   心肺健康智能监测系统 - 主样式表
   Cardiopulmonary Health Intelligent Monitoring System
   ============================================================ */

/* --- CSS Variables / Theme --- */
:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --primary-bg: #eff6ff;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #6366f1;
  --info-bg: #eef2ff;

  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: #1e3a5f;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-sidebar: #cbd5e1;
  --text-sidebar-active: #ffffff;

  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,.05);
  --shadow: 0 1px 3px 0 rgba(0,0,0,.1), 0 1px 2px -1px rgba(0,0,0,.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --sidebar-width: 260px;
  --header-height: 0px;

  --transition: 200ms ease;
  --transition-slow: 300ms ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
svg { flex-shrink: 0; }

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-slow);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-icon { color: var(--primary-light); }

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
}

.brand-sub {
  font-size: .68rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-sidebar);
  transition: all var(--transition);
  position: relative;
  font-size: .92rem;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
}

.nav-item svg {
  opacity: .8;
}

.nav-item.active svg {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  font-size: .65rem;
  padding: 2px 6px;
  border-radius: 10px;
}

.badge-warning {
  background: rgba(245,158,11,.2);
  color: #fbbf24;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--text-muted); }

.status-text { color: var(--text-muted); }

/* --- Mobile Header --- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 90;
}

.menu-toggle {
  background: none; border: none;
  color: var(--text);
  padding: 4px;
  display: flex;
}

.mobile-title {
  font-weight: 600;
  font-size: 1rem;
}

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 28px 32px 40px;
  min-height: 100vh;
  max-width: 1400px;
  width: 100%;
}

/* --- Page --- */
.page {
  display: none;
  animation: fadeSlideIn .35s ease;
}

.page.active {
  display: block;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.page-desc {
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: .92rem;
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.heart-icon { background: #fef2f2; color: var(--danger); }
.spo2-icon { background: #eef2ff; color: var(--info); }
.bp-icon { background: #ecfdf5; color: var(--success); }
.resp-icon { background: #fffbeb; color: var(--warning); }

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 500;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-value small {
  font-size: .7rem;
  color: var(--text-muted);
  font-weight: normal;
}

.stat-trend {
  font-size: .75rem;
  margin-top: 2px;
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }
.stat-trend.warn { color: var(--warning); }

/* --- Charts --- */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.chart-card-wide {
  grid-column: span 2;
}

.chart-card-full {
  grid-column: span 2;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
}

.chart-header h3 {
  font-size: .95rem;
  font-weight: 600;
}

.chart-badge {
  font-size: .75rem;
  color: var(--text-muted);
  background: var(--border-light);
  padding: 2px 8px;
  border-radius: 10px;
}

.chart-body {
  padding: 16px;
  position: relative;
  min-height: 250px;
}

.chart-body canvas {
  width: 100% !important;
}

.chart-body-tall {
  min-height: 320px;
}

/* --- AI Tip Card --- */
.ai-tip-card {
  background: linear-gradient(135deg, #eff6ff, #eef2ff);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
}

.ai-tip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.ai-tip-header h3 {
  font-size: .95rem;
  font-weight: 600;
}

.ai-icon { font-size: 1.2rem; }

.ai-tip-card p {
  color: var(--text-secondary);
  font-size: .88rem;
  line-height: 1.7;
}

.ai-tip-time {
  display: block;
  margin-top: 10px;
  font-size: .75rem;
  color: var(--text-muted);
}

/* --- Development Notice (Hardware Page) --- */
.dev-notice {
  background: var(--warning-bg);
  border: 2px dashed #fcd34d;
  border-radius: var(--radius-xl);
  padding: 32px;
  text-align: center;
  margin-bottom: 24px;
}

.dev-notice-icon {
  color: var(--warning);
  margin-bottom: 12px;
}

.dev-notice h2 {
  font-size: 1.2rem;
  color: #92400e;
  margin-bottom: 8px;
}

.dev-notice p {
  color: #a16207;
  font-size: .9rem;
  max-width: 500px;
  margin: 0 auto 16px;
}

.dev-progress {
  height: 6px;
  background: #fde68a;
  border-radius: 3px;
  max-width: 300px;
  margin: 0 auto 8px;
  overflow: hidden;
}

.dev-progress-bar {
  height: 100%;
  background: var(--warning);
  border-radius: 3px;
  transition: width 1s ease;
}

.dev-progress-label {
  font-size: .78rem;
  color: #a16207;
}

/* --- Hardware Panels --- */
.hardware-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.hardware-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.hardware-panel.disabled-panel {
  opacity: .6;
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  font-size: .92rem;
  font-weight: 600;
}

.panel-badge {
  font-size: .72rem;
  padding: 2px 10px;
  border-radius: 10px;
}

.panel-badge.inactive {
  background: var(--border-light);
  color: var(--text-muted);
}

.panel-badge.active {
  background: var(--success-bg);
  color: var(--success);
}

.panel-body {
  padding: 16px 20px;
}

/* Device List */
.device-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.device-item:last-child { border: none; }

.device-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.device-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.device-name {
  font-size: .85rem;
  font-weight: 500;
}

.device-status {
  font-size: .72rem;
  color: var(--text-muted);
}

/* Waveform Placeholder */
.waveform-placeholder {
  position: relative;
  background: #0a0a0a;
  border-radius: var(--radius);
  height: 200px;
  overflow: hidden;
}

.waveform-placeholder canvas {
  width: 100%;
  height: 100%;
}

.placeholder-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255,255,255,.3);
  background: rgba(10,10,10,.7);
  font-size: .82rem;
}

/* Vitals Grid */
.vitals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.vital-item {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.vital-label {
  display: block;
  font-size: .72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.vital-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-muted);
}

.vital-value small {
  font-size: .6rem;
  font-weight: normal;
}

/* Multimodal Panel */
.signal-channels {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.signal-channel {
  display: flex;
  align-items: center;
  gap: 10px;
}

.channel-label {
  width: 70px;
  font-size: .75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.channel-bar {
  flex: 1;
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}

.channel-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width .5s ease;
}

.channel-value {
  width: 56px;
  font-size: .72rem;
  color: var(--text-muted);
  text-align: right;
}

.fusion-output {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 14px;
}

.fusion-label {
  font-size: .72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.fusion-text {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Import / OCR Page --- */
.import-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.import-upload-card, .import-result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.import-upload-card h3, .import-result-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.import-upload-card > p {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.upload-placeholder svg { opacity: .5; }

.upload-hint {
  font-size: .72rem;
  color: var(--text-muted);
}

.preview-image {
  max-height: 300px;
  border-radius: var(--radius);
  margin: 0 auto;
}

.upload-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  justify-content: center;
}

/* OCR Progress */
.ocr-progress {
  margin-top: 16px;
  text-align: center;
}

.progress-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  width: 0%;
  transition: width .3s ease;
}

.progress-text {
  font-size: .78rem;
  color: var(--text-secondary);
}

/* Result Table */
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.result-confidence {
  font-size: .75rem;
  padding: 3px 10px;
  border-radius: 10px;
  background: var(--success-bg);
  color: var(--success);
  font-weight: 500;
}

.result-table-wrap {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.result-table th, .result-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.result-table th {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.result-actions {
  display: flex;
  gap: 10px;
}

/* Manual Entry */
.manual-entry-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  overflow: hidden;
}

.manual-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  cursor: pointer;
  user-select: none;
}

.manual-entry-header h3 {
  font-size: .95rem;
  font-weight: 600;
}

.manual-entry-body {
  padding: 0 24px 24px;
  border-top: 1px solid var(--border-light);
}

.manual-form { margin-top: 16px; }

/* Import History */
.import-history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.import-history-card h3 {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.history-table-wrap {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.history-table th, .history-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.history-table th {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.empty-row {
  text-align: center;
  color: var(--text-muted);
  padding: 32px !important;
}

/* --- Analysis Page --- */
.data-source-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.source-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.source-icon { font-size: 1.5rem; }

.source-label {
  font-size: .82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.source-count {
  font-size: .9rem;
  color: var(--text-muted);
}

/* Analysis Controls */
.analysis-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
}

.time-filter {
  display: flex;
  gap: 6px;
}

.metric-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  color: var(--text-secondary);
}

.metric-selector select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  min-height: 60px;
  min-width: 140px;
}

/* AI Analysis */
.ai-analysis-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  overflow: hidden;
}

.ai-analysis-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--info-bg), var(--primary-bg));
  border-bottom: 1px solid var(--border);
}

.ai-icon-lg { font-size: 2rem; }

.ai-analysis-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.ai-analysis-header p {
  font-size: .78rem;
  color: var(--text-muted);
}

.ai-analysis-body {
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.analysis-section {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
}

.analysis-section h4 {
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.analysis-section p {
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Data Table */
.data-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.data-table-header h3 {
  font-size: .95rem;
  font-weight: 600;
}

.data-table-actions {
  display: flex;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.data-table th {
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  background: var(--bg);
  position: sticky;
  top: 0;
}

.data-table tbody tr:hover {
  background: var(--primary-bg);
}

/* --- Reports Page --- */
.reports-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.report-generate-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.report-generate-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.report-generate-card > p {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.report-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.report-preview-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.report-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.report-preview-header h3 {
  font-size: .95rem;
  font-weight: 600;
}

.report-actions {
  display: flex;
  gap: 8px;
}

.report-body {
  padding: 24px;
  max-height: 500px;
  overflow-y: auto;
  font-size: .85rem;
  line-height: 1.8;
}

.report-body h4 {
  font-size: .92rem;
  margin: 16px 0 8px;
  color: var(--primary);
}

.report-body h4:first-child { margin-top: 0; }

.report-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: .82rem;
}

.report-body table th, .report-body table td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.report-body table th {
  background: var(--bg);
  font-weight: 600;
}

.past-reports-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.past-reports-card h3 {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.report-list { }

.report-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: background var(--transition);
}

.report-item:hover {
  background: var(--bg);
}

.report-item-info { display: flex; flex-direction: column; }

.report-item-title {
  font-weight: 500;
  font-size: .88rem;
}

.report-item-meta {
  font-size: .75rem;
  color: var(--text-muted);
}

.report-item-actions {
  display: flex;
  gap: 6px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px;
  color: var(--text-muted);
  font-size: .85rem;
}

/* --- About Page --- */
.about-content {
  max-width: 900px;
}

.about-hero {
  text-align: center;
  margin-bottom: 32px;
  padding: 40px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.about-hero-icon {
  color: var(--danger);
  margin-bottom: 16px;
}

.about-hero h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.about-subtitle {
  font-size: .82rem;
  color: var(--text-muted);
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.about-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.about-card h3 {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.about-card p, .about-card li {
  font-size: .85rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.about-card ul {
  padding-left: 18px;
}

.about-card li {
  margin-bottom: 4px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: .85rem;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 5px 12px;
  font-size: .78rem;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #dc2626;
}

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* --- Forms --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input, .form-group select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  transition: border-color var(--transition);
}

.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  box-shadow: var(--shadow-lg);
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn .3s ease;
  max-width: 360px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }

.toast.removing {
  animation: toastOut .3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Extra: Status tags in tables --- */
.status-tag {
  display: inline-block;
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.status-tag.normal { background: var(--success-bg); color: var(--success); }
.status-tag.warning { background: var(--warning-bg); color: var(--warning); }
.status-tag.alert { background: var(--danger-bg); color: var(--danger); }

.source-tag {
  display: inline-block;
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.source-tag.hardware { background: var(--info-bg); color: var(--info); }
.source-tag.watch { background: var(--warning-bg); color: var(--warning); }
.source-tag.manual { background: var(--border-light); color: var(--text-muted); }

/* --- Auth Section (Sidebar) --- */
.sidebar-auth {
  margin-bottom: 12px;
}

.auth-login-btn {
  background: var(--primary);
  color: #fff !important;
  border: none;
  font-size: .82rem;
  gap: 6px;
}

.auth-login-btn:hover {
  background: var(--primary-dark);
}

.auth-user-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.auth-user-name {
  font-size: .82rem;
  color: #fff;
  font-weight: 500;
}

.auth-logout-btn {
  font-size: .72rem;
  color: var(--text-muted) !important;
  border-color: rgba(255,255,255,.15) !important;
}

/* --- Auth Modal --- */
.auth-modal-header {
  text-align: center;
  margin-bottom: 20px;
}

.auth-modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.auth-modal-header p {
  font-size: .82rem;
  color: var(--text-muted);
}

.auth-error {
  background: var(--danger-bg);
  color: var(--danger);
  font-size: .8rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  display: none;
}

.auth-switch {
  text-align: center;
  margin-top: 14px;
  font-size: .82rem;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* --- Mobile Auth Indicator --- */
.mobile-auth-indicator {
  margin-left: auto;
  font-size: .75rem;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .auth-login-btn {
    width: auto !important;
    padding: 4px 10px;
    font-size: .75rem;
  }
}

/* --- Responsive --- */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .chart-card-wide, .chart-card-full { grid-column: span 1; }
  .hardware-grid { grid-template-columns: 1fr; }
  .import-layout { grid-template-columns: 1fr; }
  .reports-layout { grid-template-columns: 1fr; }
  .ai-analysis-body { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    margin-top: 56px;
    padding: 20px 16px 32px;
  }

  .stats-grid { grid-template-columns: 1fr; }
  .data-source-summary { grid-template-columns: 1fr; }
  .analysis-controls { flex-direction: column; align-items: stretch; }
  .vitals-grid { grid-template-columns: repeat(2, 1fr); }

  .form-row {
    flex-direction: column;
  }

  .page-header h1 {
    font-size: 1.35rem;
  }
}

@media (max-width: 480px) {
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.2rem; }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.4);
  z-index: 95;
}

@media (max-width: 768px) {
  .sidebar-overlay.show { display: block; }
}

/* ============================================================
   Breath Sound Analysis
   ============================================================ */
.breath-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.breath-file-info {
  font-size: 14px;
  color: var(--text-secondary);
}

.breath-prob-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.breath-prob-label {
  width: 70px;
  font-size: 13px;
  text-align: right;
  flex-shrink: 0;
}

.breath-prob-bar {
  flex: 1;
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.breath-prob-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
}

.breath-prob-val {
  width: 50px;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light, #e8f4fd);
}

.badge-success {
  background: #4caf50;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: auto;
}
