/* ==========================================================================
   醫點通 MedPoint - 個人與家庭健康存摺視覺化管理輔助工具
   設計理念：精準、洗練、人體工學、高資訊密度、WCAG AA 級對比度。
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Noto+Sans+TC:wght@400;500;600;700;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* 品牌中性基調 (Clinical Slate / Zinc) */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* 醫療專業主色調 */
  --primary-700: #0369a1;
  --primary-600: #0284c7;
  --primary-500: #0ea5e9;
  --primary-50: #f0f9ff;
  --teal-900: #134e4a;
  --teal-700: #0f766e;
  --teal-600: #0d9488;
  --teal-300: #5eead4;
  --teal-50: #f0fdfa;

  /* 其他顏色層次補全 */
  --rose-400: #fb7185;
  --rose-500: #f43f5e;
  --emerald-500: #10b981;

  /* 臨床狀態警示色 (低飽和高辨識) */
  --rose-600: #e11d48;
  --rose-50: #fff1f2;
  --amber-600: #d97706;
  --amber-50: #fffbeb;
  --emerald-600: #059669;
  --emerald-50: #ecfdf5;
  --indigo-600: #4f46e5;
  --indigo-50: #eef2ff;

  /* 系統語意變數 (淺色模式) */
  --bg-app: #f4f6f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-sidebar: #090e17;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;

  /* 陰影與圓角 */
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.02);
  --shadow-elevation: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;
  --radius-full: 9999px;

  /* 語意別名 (便於在 JS 行內樣式使用) */
  --border-color: #e2e8f0;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Material Symbols 單色向量圖示通用類別 */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
  color: inherit;
  user-select: none;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.icon-inline {
  font-size: 1.15em;
  margin-right: 6px;
  vertical-align: -2px;
}

.nav-item .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 20px;
  color: var(--slate-400);
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.nav-item:hover .icon {
  color: #ffffff;
  transform: scale(1.08);
}

.nav-item.active .icon {
  color: #2dd4bf !important;
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

[data-theme="dark"] {
  --bg-app: #080c14;
  --bg-surface: #0f172a;
  --bg-subtle: #141f36;
  --bg-sidebar: #04070d;
  --border-subtle: #1e293b;
  --border-strong: #334155;
  --border-color: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  --primary-50: rgba(14, 165, 233, 0.12);
  --teal-50: rgba(13, 148, 136, 0.12);
  --rose-50: rgba(225, 29, 72, 0.15);
  --amber-50: rgba(217, 119, 6, 0.15);
  --emerald-50: rgba(5, 150, 105, 0.15);
  --indigo-50: rgba(79, 70, 229, 0.15);
}

/* 全局重設與視窗捲軸消除（單一主滾動條架構） */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden; /* 徹底消除外層 window 雙重滾動條 */
}

body {
  font-family: 'Plus Jakarta Sans', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
}

/* 自訂精緻滾動條 (Slim Professional Scrollbars) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.6);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 主佈局架構 */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* 側邊導航 (極簡深黑專業風，內部獨立捲動) */
.sidebar {
  width: 260px;
  height: 100vh;
  background: var(--bg-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 50;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--teal-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #fff;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-menu {
  flex: 1;
  padding: 12px 10px 24px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* 側邊欄分類小標題 (Category Header) */
.nav-category-header {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--slate-500);
  padding: 12px 14px 4px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--slate-400);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 600;
  border-left: 3px solid var(--teal-600);
}

.nav-item .icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.nav-item .badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  display: none;
}

.nav-item .badge.badge-abnormal {
  display: inline-block;
  background: var(--rose-600);
  color: #fff;
}

.nav-item .badge.badge-normal {
  display: inline-block;
  background: var(--emerald-600);
  color: #fff;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.2);
}

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

.patient-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--slate-800);
  color: var(--teal-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

/* 主工作台 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  background-color: var(--bg-app);
}

.content-body {
  padding: 24px 28px 48px;
  flex: 1;
}

/* 視圖分頁切換控制 (SPA View Switcher) */
.view-section {
  display: none;
}

.view-section.active {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 頂部操作列 */
.topbar {
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 40;
}

.topbar-meta h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.topbar-meta p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 按鈕元件 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-primary {
  background: var(--teal-600);
  border-color: var(--teal-600);
  color: #fff;
}
.btn-primary:hover {
  background: var(--teal-700);
  border-color: var(--teal-700);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
}

/* 內容主區 */
.content-body {
  padding: 24px 28px 60px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.view-section {
  display: none;
}
.view-section.active {
  display: block;
  animation: viewFade 0.2s ease-out;
}

@keyframes viewFade {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 專業臨床卡片 */
.card-grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.card-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-header h3 {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header .caption {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* 數據指標卡 (KPI Metric) */
.metric-box {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 4px 0 2px;
  letter-spacing: -0.5px;
}

.metric-footer {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* 臨床提示橫條 (Notice Bar) */
.clinical-notice {
  background: var(--amber-50);
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-left: 4px solid var(--amber-600);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.clinical-notice.info {
  background: var(--primary-50);
  border-color: rgba(2, 132, 199, 0.25);
  border-left-color: var(--primary-600);
}

.clinical-notice-icon {
  font-size: 1.2rem;
  line-height: 1.2;
}

.clinical-notice-content h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.clinical-notice-content p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* 標籤過濾組 (Segmented Controls & Tabs) */
.segment-group {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  gap: 2px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.segment-btn {
  padding: 6px 14px;
  border-radius: var(--radius-xs);
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.segment-btn:hover {
  color: var(--text-primary);
}

.segment-btn.active {
  background: var(--bg-surface);
  color: var(--teal-600);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* 狀態標籤 (Pill Badges) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.pill.high { background: var(--rose-50); color: var(--rose-600); border: 1px solid rgba(225, 29, 72, 0.2); }
.pill.low { background: var(--indigo-50); color: var(--indigo-600); border: 1px solid rgba(79, 70, 229, 0.2); }
.pill.normal { background: var(--emerald-50); color: var(--emerald-600); border: 1px solid rgba(5, 150, 105, 0.2); }
.pill.subtle { background: var(--bg-subtle); color: var(--text-secondary); border: 1px solid var(--border-subtle); }

/* 專業臨床表格 */
.table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.clinical-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
}

.clinical-table th {
  background: var(--bg-subtle);
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.clinical-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.clinical-table tr:last-child td {
  border-bottom: none;
}

.clinical-table tr:hover td {
  background: rgba(15, 118, 110, 0.03);
}

/* 圖表容器 */
.chart-box {
  position: relative;
  width: 100%;
  height: 320px;
}

/* 藥物安全指南卡 (Drug Safety Card) */
.safety-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--teal-600);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 14px;
}

.safety-card h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.safety-card .dosage-guide {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  margin: 8px 0;
  border-left: 2px solid var(--teal-600);
}

.safety-card ul {
  margin-left: 18px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* 醫學名詞小字典 (Glossary Grid) */
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.glossary-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.glossary-item .term {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--teal-600);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 4px;
}

.glossary-item .definition {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* 看診前摘要單 (A4 醫療單據排版) */
.prep-document {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 36px;
  max-width: 920px;
  margin: 0 auto;
  box-shadow: var(--shadow-elevation);
}

.prep-doc-header {
  border-bottom: 2px solid var(--slate-800);
  padding-bottom: 16px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.prep-doc-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.prep-doc-header .doc-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
}

.prep-block {
  margin-bottom: 24px;
}

.prep-block-title {
  font-size: 0.95rem;
  font-weight: 700;
  background: var(--bg-subtle);
  padding: 6px 10px;
  border-left: 3px solid var(--teal-600);
  margin-bottom: 10px;
}

.q-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  margin-bottom: 8px;
  display: flex;
  gap: 10px;
}

.q-num {
  font-weight: 700;
  color: var(--teal-600);
  font-family: 'JetBrains Mono', monospace;
}

.q-content {
  font-size: 0.88rem;
  color: var(--text-primary);
  flex: 1;
}

/* 列印樣式 */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .sidebar, .topbar, .btn, .no-print, .segment-group {
    display: none !important;
  }
  .main-wrapper {
    height: auto !important;
    overflow: visible !important;
  }
  .content-body {
    padding: 0 !important;
  }
  .view-section {
    display: none !important;
  }
  #view-prep {
    display: block !important;
  }
  .prep-document {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
}

/* 漢堡按鈕 (預設在桌面版隱藏) */
.btn-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-xs);
  padding: 6px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-hamburger:hover {
  background: var(--bg-subtle);
}

/* 行動端側邊欄遮罩 (Mobile Backdrop) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* 響應式與行動端抽屜適配 (Mobile / PWA Responsive) */
@media (max-width: 960px) {
  .btn-hamburger {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content-body {
    padding: 16px 16px 36px;
  }

  .card-grid-2, .card-grid-3, .card-grid-4 {
    grid-template-columns: 1fr;
  }
}

/* 示範模式頂部醒目橫幅 (高對比強化) */
.demo-banner-wrapper {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
  border: 1.5px solid #f59e0b !important;
  border-left: 6px solid #f59e0b !important;
  color: #ffffff !important;
  padding: 14px 20px !important;
  border-radius: var(--radius-md) !important;
  margin-bottom: 20px !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.demo-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.demo-banner-badge {
  background: #f59e0b !important;
  color: #0f172a !important;
  font-weight: 800 !important;
  font-size: 0.78rem !important;
  padding: 3px 10px !important;
  border-radius: var(--radius-full) !important;
  letter-spacing: 0.5px;
}

.demo-banner-text {
  font-size: 0.92rem !important;
  color: #f8fafc !important;
  line-height: 1.5;
}

.demo-banner-text strong {
  color: #38bdf8 !important;
  font-weight: 700 !important;
}

.demo-banner-btn {
  background: #f59e0b !important;
  color: #0f172a !important;
  font-weight: 800 !important;
  font-size: 0.86rem !important;
  border: none !important;
  padding: 8px 18px !important;
  border-radius: var(--radius-pill) !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
  transition: all 0.2s ease-in-out !important;
  white-space: nowrap !important;
  text-decoration: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.demo-banner-btn:hover {
  background: #fbbf24 !important;
  color: #020617 !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4) !important;
}

/* 高對比標籤增強 (使用明確顏色值確保無變數缺失) */
.pill.normal {
  background: #f0fdfa;
  color: #134e4a;
  border: 1px solid #5eead4;
  font-weight: 700;
}

[data-theme="dark"] .pill.normal {
  background: rgba(13, 148, 136, 0.2);
  color: #5eead4;
  border: 1px solid rgba(94, 234, 212, 0.5);
  font-weight: 700;
}

/* ==========================================================================
   通用 Modal 彈窗與即時抽血比對工具 (Lab Comparator)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 35px -5px rgba(0, 0, 0, 0.2), 0 10px 15px -5px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  animation: modalScaleUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleUp {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

/* 比對結果狀態徽章與卡片 */
.compare-diff-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 800;
}

.compare-diff-badge.improved {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.compare-diff-badge.warning {
  background: #fff1f2;
  color: #9f1239;
  border: 1px solid #fecdd3;
}

.compare-diff-badge.neutral {
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

[data-theme="dark"] .compare-diff-badge.improved {
  background: rgba(5, 150, 105, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

[data-theme="dark"] .compare-diff-badge.warning {
  background: rgba(225, 29, 72, 0.2);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.4);
}

[data-theme="dark"] .compare-diff-badge.neutral {
  background: rgba(14, 165, 233, 0.2);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

