/*
 * FerretFHIR 設計系統（docs/design/phase2-parity-plan.md §4）
 * 海軍藍品牌底色、亮藍互動色、火焰橘少量強調。亮色為主，支援暗色（html[data-bs-theme="dark"]）。
 * 不使用 inline style（CSP style-src 'self'）；所有頁面共用這份 tokens 與元件。
 */

/* ---------- Tokens ---------- */
:root,
[data-bs-theme="light"] {
  --gh-brand-900: #001a4d;
  --gh-brand: #002060;
  --gh-brand-700: #0b3a8c;
  --gh-primary: #1f56d6;
  --gh-primary-rgb: 31, 86, 214;
  --gh-primary-hover: #1947b5;
  --gh-primary-subtle: #dde7fb;
  /* 選取中的文字、作用中的分頁（在 primary-subtle 上 ≥ 7:1）；primary 本身留給按鈕底色、選取色條與焦點框。 */
  --gh-primary-strong: #1742a9;
  /* 文字連結（Bootstrap --bs-link-color）：比 primary 深，在頁面底色上 ≥ 7:1。 */
  --gh-link: #1a49b8;
  /* 滑鼠移過的底色：中性灰，不用藍色，才不會跟「已選取」混淆。 */
  --gh-hover: #eef2f8;
  --gh-accent: #f26b1d;
  --gh-accent-subtle: #fff1e8;
  /* 強調色當圖示用（統計卡片）：在 accent-subtle 上 ≥ 3:1。 */
  --gh-accent-icon: #d4570f;
  /* 語意色當文字用（徽章、提示、錯誤訊息）：在自己的 *-subtle 底色與頁面底色上都 ≥ 7:1。
     底色、圖示仍用 --gh-success 等原色。CssLegibilityTests 檢查這些對比。 */
  --gh-accent-text: #8d3808;
  --gh-info-text: #085098;
  --gh-warning-text: #7d4505;
  --gh-danger-text: #972620;
  --gh-success-text: #0c5d41;
  --gh-bg: #f4f6fa;
  --gh-surface: #fff;
  --gh-surface-2: #f8fafc;
  /* 兩級線條：border 是裝飾用的分隔線（刻意 < 3:1），border-strong 是控制項的外框與樹狀導引線（≥ 3:1）。 */
  --gh-border: #cbd3df;
  --gh-border-strong: #7d8799;
  --gh-text: #18212f;
  /* 次要文字在所有亮色底色（含選取底色）上 ≥ 7:1。 */
  --gh-text-muted: #424a57;
  --gh-text-subtle: #475060;
  /* 輸入框提示文字刻意比內文淡（≥ 4.5:1），免得被當成已填的值。 */
  --gh-placeholder: #66707f;
  --gh-success: #0f7552;
  --gh-success-subtle: #e7f6ef;
  --gh-warning: #a35a06;
  --gh-warning-subtle: #fff4e0;
  --gh-danger: #c8322b;
  --gh-danger-subtle: #fdecea;
  --gh-info: #0b6bcb;
  --gh-info-subtle: #e6f1fb;
  --gh-sidebar-bg: #002060;
  --gh-sidebar-bg-2: #001a4d;
  --gh-sidebar-text: rgba(255, 255, 255, 0.88);
  --gh-sidebar-text-strong: #fff;
  --gh-sidebar-hover: rgba(255, 255, 255, 0.08);
  --gh-sidebar-active: rgba(255, 255, 255, 0.18);
  --gh-sidebar-heading: rgba(255, 255, 255, 0.74);
  /* 側欄頁尾連結、收合按鈕、品牌副標 */
  --gh-sidebar-muted: rgba(255, 255, 255, 0.8);
  /* 深藍漸層（登入頁、首頁橫幅）上的次要文字：在漸層最亮的一端仍 ≥ 7:1。首頁橫幅的漸層終點用 --gh-hero-end。 */
  --gh-on-brand-muted: rgba(255, 255, 255, 0.9);
  --gh-hero-end: #1742a9;
  --gh-code-bg: #f1f4f9;
  /* REST Dashboard 病歷時間軸的種類色（沿用舊版的色相）：只用在圖示底色、左側色條與篩選的色塊，文字一律用 --gh-text 系列。
     在頁面底色上 ≥ 3:1，圖示（--gh-tl-icon-fg）在色塊上 ≥ 3:1；種類一定另有文字標籤，不只靠顏色。CssLegibilityTests 檢查。 */
  --gh-tl-patient: #6d45c4;
  --gh-tl-encounter: #5d6878;
  --gh-tl-observation: #1f5fc4;
  --gh-tl-medication: #c0332b;
  --gh-tl-procedure: #b02f74;
  --gh-tl-condition: #a8530a;
  --gh-tl-composition: #257336;
  --gh-tl-report: #0d6f7a;
  --gh-tl-other: #3d4654;
  --gh-tl-icon-fg: #fff;
  /* 伺服器產生的 SVG 圖表（Charts/SvgLineChart）：折線與圓點、目前這一筆（≥ 3:1）、參考範圍的淺色帶。 */
  --gh-chart-1: #1f5fc4;
  --gh-chart-current: #c0332b;
  --gh-chart-band: #e7f6ef;

  /* 字級（根字級 16px；「大字」時 18px，全部跟著放大）。任何文字不小於 --gh-fs-xs（13px），
     由 CssLegibilityTests.Font_sizes_respect_the_floor 檢查。 */
  --gh-fs-xs: 0.8125rem;
  --gh-fs-sm: 0.875rem;
  --gh-fs-md: 0.9375rem;
  --gh-fs-base: 1rem;

  --gh-font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", "Heiti TC", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gh-font-mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --gh-radius-sm: 6px;
  --gh-radius: 10px;
  --gh-radius-lg: 14px;
  --gh-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --gh-shadow-md: 0 2px 8px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --gh-shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
  --gh-sidebar-width: 248px;
  --gh-sidebar-collapsed: 72px;
  --gh-topbar-height: 56px;
  --gh-input-height: 40px;
  --gh-transition: 150ms ease;
  --gh-page-pad: 24px;

  /* Bootstrap 對應 */
  --bs-body-font-family: var(--gh-font);
  --bs-font-monospace: var(--gh-font-mono);
  --bs-body-font-size: var(--gh-fs-base);
  --bs-body-line-height: 1.6;
  --bs-body-color: var(--gh-text);
  --bs-body-color-rgb: 24, 33, 47;
  --bs-body-bg: var(--gh-bg);
  --bs-secondary-color: var(--gh-text-muted);
  --bs-tertiary-color: var(--gh-text-subtle);
  --bs-border-color: var(--gh-border);
  --bs-border-color-translucent: var(--gh-border);
  --bs-border-radius: var(--gh-radius-sm);
  --bs-border-radius-lg: var(--gh-radius);
  --bs-border-radius-xl: var(--gh-radius-lg);
  --bs-primary: var(--gh-primary);
  --bs-primary-rgb: var(--gh-primary-rgb);
  --bs-primary-bg-subtle: var(--gh-primary-subtle);
  --bs-primary-text-emphasis: var(--gh-primary-hover);
  --bs-success-rgb: 18, 128, 92;
  --bs-warning-rgb: 245, 159, 0;
  --bs-danger-rgb: 200, 50, 43;
  --bs-info-rgb: 11, 107, 203;
  --bs-link-color: var(--gh-link);
  --bs-link-color-rgb: 26, 73, 184;
  --bs-link-hover-color: var(--gh-primary-strong);
  --bs-link-hover-color-rgb: 23, 66, 169;
  --bs-focus-ring-color: rgba(31, 86, 214, 0.25);
  --bs-emphasis-color: var(--gh-text);
  --bs-heading-color: var(--gh-text);
  --bs-tertiary-bg: var(--gh-surface-2);
  --bs-secondary-bg: var(--gh-surface-2);
  --bs-code-color: #33415c;
  color-scheme: light;
}

[data-bs-theme="dark"] {
  --gh-bg: #0d1320;
  --gh-surface: #141c2b;
  --gh-surface-2: #1a2435;
  --gh-border: #34425b;
  --gh-border-strong: #68778f;
  --gh-text: #e6eaf2;
  --gh-text-muted: #c7cdd8;
  --gh-text-subtle: #b1bac9;
  --gh-placeholder: #8692aa;
  --gh-primary: #6f9bff;
  --gh-primary-rgb: 111, 155, 255;
  --gh-primary-hover: #8fb1ff;
  --gh-primary-subtle: rgba(111, 155, 255, 0.22);
  --gh-primary-strong: #b1c9ff;
  --gh-link: #8fb1ff;
  --gh-hover: #202c41;
  --gh-accent-subtle: rgba(242, 107, 29, 0.16);
  --gh-accent-icon: #f26b1d;
  --gh-accent-text: #ffba8f;
  --gh-info-text: #9cceff;
  --gh-warning-text: #f5c06d;
  --gh-danger-text: #ffb7b2;
  --gh-success-text: #85d9ba;
  --gh-success: #4cc79a;
  --gh-success-subtle: rgba(76, 199, 154, 0.14);
  --gh-warning: #f2b049;
  --gh-warning-subtle: rgba(242, 176, 73, 0.14);
  --gh-danger: #ff7a72;
  --gh-danger-subtle: rgba(255, 122, 114, 0.14);
  --gh-info: #66b3ff;
  --gh-info-subtle: rgba(102, 179, 255, 0.14);
  --gh-sidebar-bg: #0a1530;
  --gh-sidebar-bg-2: #081026;
  --gh-code-bg: #1e2a3e;
  --gh-tl-patient: #b9a3ff;
  --gh-tl-encounter: #aab4c3;
  --gh-tl-observation: #80b1ff;
  --gh-tl-medication: #ff9189;
  --gh-tl-procedure: #f590c6;
  --gh-tl-condition: #f2a54c;
  --gh-tl-composition: #72cf8a;
  --gh-tl-report: #52cfd8;
  --gh-tl-other: #c2c9d4;
  --gh-tl-icon-fg: #0d1320;
  --gh-chart-1: #80b1ff;
  --gh-chart-current: #ff9189;
  --gh-chart-band: rgba(76, 199, 154, 0.16);
  --gh-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --gh-shadow-md: 0 2px 8px rgba(0, 0, 0, 0.35);
  --gh-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);

  --bs-body-color: var(--gh-text);
  --bs-body-color-rgb: 230, 234, 242;
  --bs-body-bg: var(--gh-bg);
  --bs-secondary-color: var(--gh-text-muted);
  --bs-tertiary-color: var(--gh-text-subtle);
  --bs-border-color: var(--gh-border);
  --bs-border-color-translucent: var(--gh-border);
  --bs-emphasis-color: var(--gh-text);
  --bs-heading-color: var(--gh-text);
  --bs-tertiary-bg: var(--gh-surface-2);
  --bs-secondary-bg: var(--gh-surface-2);
  --bs-link-color: var(--gh-link);
  --bs-link-color-rgb: 143, 177, 255;
  --bs-link-hover-color: var(--gh-primary-strong);
  --bs-link-hover-color-rgb: 177, 201, 255;
  --bs-focus-ring-color: rgba(111, 155, 255, 0.3);
  --bs-code-color: #c3cde0;
  color-scheme: dark;
}

/* ---------- Base ---------- */
/* 根字級：全站字級都用 rem，改這裡就會整體放大或縮小。「大字」模式由 theme-init.js 在 <html> 設 data-text-size="large"。 */
html {
  font-size: 16px;
}

html[data-text-size="large"] {
  font-size: 18px;
  --gh-input-height: 44px;
}

body {
  font-family: var(--gh-font);
  background: var(--gh-bg);
  color: var(--gh-text);
  -webkit-font-smoothing: antialiased;
}

code,
kbd,
pre,
.font-monospace,
.gh-mono {
  font-family: var(--gh-font-mono);
}

code {
  font-size: max(0.9em, var(--gh-fs-xs));
  overflow-wrap: anywhere;
}

/* Bootstrap 以 em 縮小的元素：放在 .small、.form-text 裡面時會再縮一次（例如 pre 在 14px 的說明裡只剩 12.25px），一律加上 13px 的下限。
   CssLegibilityTests.Bootstrap_shrinking_rules_are_overridden 從 bootstrap.min.css 找出這類規則，檢查這裡都有覆寫。 */
pre,
kbd,
samp,
.initialism,
.blockquote-footer,
.figure-caption,
.valid-feedback,
.invalid-feedback {
  font-size: max(0.875em, var(--gh-fs-xs));
}

sub,
sup {
  font-size: max(0.75em, var(--gh-fs-xs));
}

.badge {
  --bs-badge-font-size: max(0.75em, var(--gh-fs-xs));
}

.progress,
.progress-stacked {
  --bs-progress-font-size: var(--gh-fs-xs);
}

a {
  text-underline-offset: 2px;
}

::selection {
  background: rgba(var(--gh-primary-rgb), 0.18);
}

.text-muted,
.text-secondary {
  color: var(--gh-text-muted) !important;
}

.text-subtle {
  color: var(--gh-text-subtle);
}

.small,
small {
  font-size: var(--gh-fs-sm);
}

.gh-skip:focus {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 2000;
  background: var(--gh-surface);
  padding: 8px 12px;
  border-radius: var(--gh-radius-sm);
  box-shadow: var(--gh-shadow-lg);
}

/* ---------- Bootstrap 元件換色 ---------- */
.btn {
  --bs-btn-padding-y: 0.4rem;
  --bs-btn-padding-x: 0.9rem;
  --bs-btn-font-size: var(--gh-fs-md);
  --bs-btn-font-weight: 500;
  --bs-btn-border-radius: var(--gh-radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: color var(--gh-transition), background-color var(--gh-transition), border-color var(--gh-transition), box-shadow var(--gh-transition);
}

/* 鍵盤焦點：按鈕與可以操作的元件一律有 2px 的外框。Bootstrap 的 .btn 只畫 box-shadow，而 .btn-ghost 等沒有設定
   --bs-btn-focus-shadow-rgb 的按鈕會完全看不到焦點（例如「主題與字級」）。CssLegibilityTests.Focus_is_visible 檢查這份清單。 */
.btn:focus-visible,
.btn-check:focus-visible + .btn,
.btn-close:focus-visible,
.gh-user-btn:focus-visible,
.gh-step:focus-visible,
.gh-segmented button:focus-visible,
.page-link:focus-visible,
.nav-link:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--gh-primary);
  outline-offset: 2px;
}

.dropdown-item:focus-visible,
.list-group-item-action:focus-visible {
  outline: 2px solid var(--gh-primary);
  outline-offset: -2px;
}

/* 深藍側欄與首頁橫幅上的焦點外框用白色（藍色在深藍底上看不清楚）。 */
.gh-sidebar a:focus-visible,
.gh-sidebar button:focus-visible,
.gh-hero .btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

.btn-sm {
  --bs-btn-padding-y: 0.25rem;
  --bs-btn-padding-x: 0.6rem;
  --bs-btn-font-size: var(--gh-fs-sm);
  gap: 0.3rem;
}

.btn-lg {
  --bs-btn-padding-y: 0.6rem;
  --bs-btn-padding-x: 1.2rem;
  --bs-btn-font-size: 1.0625rem;
}

.btn-primary {
  --bs-btn-bg: var(--gh-primary);
  --bs-btn-border-color: var(--gh-primary);
  --bs-btn-hover-bg: var(--gh-primary-hover);
  --bs-btn-hover-border-color: var(--gh-primary-hover);
  --bs-btn-active-bg: var(--gh-primary-hover);
  --bs-btn-active-border-color: var(--gh-primary-hover);
  --bs-btn-disabled-bg: var(--gh-primary);
  --bs-btn-disabled-border-color: var(--gh-primary);
  --bs-btn-focus-shadow-rgb: var(--gh-primary-rgb);
  box-shadow: var(--gh-shadow-sm);
}

[data-bs-theme="dark"] .btn-primary {
  --bs-btn-color: #0d1320;
  --bs-btn-hover-color: #0d1320;
  --bs-btn-active-color: #0d1320;
  --bs-btn-disabled-color: #0d1320;
}

/* 外框按鈕的文字用 primary-strong（≥ 7:1）；外框仍是品牌藍。 */
.btn-outline-primary {
  --bs-btn-color: var(--gh-primary-strong);
  --bs-btn-border-color: rgba(var(--gh-primary-rgb), 0.45);
  --bs-btn-hover-bg: var(--gh-primary-subtle);
  --bs-btn-hover-color: var(--gh-primary-strong);
  --bs-btn-hover-border-color: var(--gh-primary);
  --bs-btn-active-bg: var(--gh-primary-subtle);
  --bs-btn-active-color: var(--gh-primary-strong);
  --bs-btn-active-border-color: var(--gh-primary);
  --bs-btn-focus-shadow-rgb: var(--gh-primary-rgb);
}

.btn-outline-secondary,
.btn-light {
  --bs-btn-color: var(--gh-text);
  --bs-btn-bg: var(--gh-surface);
  --bs-btn-border-color: var(--gh-border-strong);
  --bs-btn-hover-color: var(--gh-text);
  --bs-btn-hover-bg: var(--gh-surface-2);
  --bs-btn-hover-border-color: var(--gh-border-strong);
  --bs-btn-active-color: var(--gh-text);
  --bs-btn-active-bg: var(--gh-surface-2);
  --bs-btn-active-border-color: var(--gh-text-subtle);
  --bs-btn-disabled-color: var(--gh-text-subtle);
  --bs-btn-disabled-bg: var(--gh-surface);
  --bs-btn-disabled-border-color: var(--gh-border);
  --bs-btn-focus-shadow-rgb: var(--gh-primary-rgb);
}

/* 外框按鈕的文字用 danger-text（≥ 7:1）；外框與實心的刪除按鈕仍是原本的紅色。 */
.btn-outline-danger {
  --bs-btn-color: var(--gh-danger-text);
  --bs-btn-border-color: rgba(200, 50, 43, 0.4);
  --bs-btn-hover-bg: var(--gh-danger-subtle);
  --bs-btn-hover-color: var(--gh-danger-text);
  --bs-btn-hover-border-color: var(--gh-danger);
  --bs-btn-active-bg: var(--gh-danger-subtle);
  --bs-btn-active-color: var(--gh-danger-text);
  --bs-btn-active-border-color: var(--gh-danger);
}

.btn-danger {
  --bs-btn-bg: var(--gh-danger);
  --bs-btn-border-color: var(--gh-danger);
  --bs-btn-hover-bg: #ac2a24;
  --bs-btn-hover-border-color: #ac2a24;
  --bs-btn-active-bg: #ac2a24;
  --bs-btn-active-border-color: #ac2a24;
}

.btn-ghost {
  --bs-btn-color: var(--gh-text-muted);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: transparent;
  --bs-btn-hover-color: var(--gh-text);
  --bs-btn-hover-bg: var(--gh-surface-2);
  --bs-btn-hover-border-color: transparent;
  --bs-btn-active-color: var(--gh-text);
  --bs-btn-active-bg: var(--gh-surface-2);
  --bs-btn-active-border-color: transparent;
}

.btn-icon {
  --bs-btn-padding-x: 0.5rem;
  min-width: 34px;
}

.btn-icon.btn-sm {
  --bs-btn-padding-x: 0.35rem;
  min-width: 28px;
}

.form-control,
.form-select {
  border-color: var(--gh-border-strong);
  background-color: var(--gh-surface);
  color: var(--gh-text);
  min-height: var(--gh-input-height);
  font-size: var(--gh-fs-base);
  transition: border-color var(--gh-transition), box-shadow var(--gh-transition);
}

.form-control-sm,
.form-select-sm {
  min-height: 34px;
  font-size: var(--gh-fs-sm);
}

textarea.form-control {
  min-height: auto;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--gh-primary);
  box-shadow: 0 0 0 3px rgba(var(--gh-primary-rgb), 0.18);
}

.form-control::placeholder {
  color: var(--gh-placeholder);
}

.form-control:disabled,
.form-control[readonly] {
  background-color: var(--gh-surface-2);
}

/* 核取方塊、選項、開關的外框是控制項唯一的輪廓，用 border-strong（≥ 3:1）。 */
.form-check-input {
  border-color: var(--gh-border-strong);
}

.form-check-input:checked {
  background-color: var(--gh-primary);
  border-color: var(--gh-primary);
}

.form-switch .form-check-input:focus {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%2831, 86, 214, 0.5%29'/%3e%3c/svg%3e");
}

.form-label {
  font-weight: 500;
  font-size: var(--gh-fs-sm);
  color: var(--gh-text);
  margin-bottom: 0.35rem;
}

.form-text {
  color: var(--gh-text-muted);
  font-size: var(--gh-fs-sm);
}

.gh-required::after {
  content: " *";
  color: var(--gh-danger-text);
}

.input-group-text {
  background: var(--gh-surface-2);
  border-color: var(--gh-border-strong);
  color: var(--gh-text-muted);
}

.dropdown-menu {
  --bs-dropdown-bg: var(--gh-surface);
  --bs-dropdown-border-color: var(--gh-border);
  --bs-dropdown-border-radius: var(--gh-radius);
  --bs-dropdown-link-color: var(--gh-text);
  --bs-dropdown-link-hover-bg: var(--gh-hover);
  --bs-dropdown-link-hover-color: var(--gh-text);
  --bs-dropdown-link-active-bg: var(--gh-primary-subtle);
  --bs-dropdown-link-active-color: var(--gh-primary-strong);
  --bs-dropdown-font-size: var(--gh-fs-md);
  --bs-dropdown-padding-y: 0.375rem;
  --bs-dropdown-item-padding-y: 0.45rem;
  box-shadow: var(--gh-shadow-lg);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.dropdown-item .bi {
  color: var(--gh-text-muted);
}

/* 已選取的選單項目（例如主題、字級）：底色 + 左側色條 + 粗體，不只靠顏色。 */
.dropdown-item.active {
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--gh-primary);
}

.dropdown-item.active .bi {
  color: inherit;
}

.dropdown-item.text-danger .bi {
  color: inherit;
}

.dropdown-header {
  font-size: var(--gh-fs-xs);
  color: var(--gh-text-subtle);
}

.modal {
  --bs-modal-bg: var(--gh-surface);
  --bs-modal-border-color: var(--gh-border);
  --bs-modal-border-radius: var(--gh-radius-lg);
  --bs-modal-header-border-color: var(--gh-border);
  --bs-modal-footer-border-color: var(--gh-border);
  --bs-modal-box-shadow: var(--gh-shadow-lg);
}

.modal-title {
  font-size: 1.0625rem;
  font-weight: 600;
}

.modal-footer {
  background: var(--gh-surface-2);
  border-bottom-left-radius: var(--gh-radius-lg);
  border-bottom-right-radius: var(--gh-radius-lg);
}

.offcanvas {
  --bs-offcanvas-bg: var(--gh-surface);
  --bs-offcanvas-border-color: var(--gh-border);
  --bs-offcanvas-width: 480px;
  box-shadow: var(--gh-shadow-lg);
}

.offcanvas-title {
  font-size: 1.0625rem;
  font-weight: 600;
}

.offcanvas-header {
  border-bottom: 1px solid var(--gh-border);
}

.nav-tabs {
  --bs-nav-tabs-border-color: var(--gh-border);
  --bs-nav-tabs-link-active-color: var(--gh-primary-strong);
  --bs-nav-tabs-link-active-bg: transparent;
  --bs-nav-tabs-link-active-border-color: transparent transparent var(--gh-primary);
  --bs-nav-tabs-link-hover-border-color: transparent;
  --bs-nav-link-color: var(--gh-text-muted);
  --bs-nav-link-hover-color: var(--gh-text);
  gap: 0.25rem;
}

.nav-tabs .nav-link {
  border-width: 0 0 3px;
  font-weight: 500;
}

.nav-tabs .nav-link.active {
  font-weight: 600;
}

.nav-pills {
  --bs-nav-pills-link-active-bg: var(--gh-primary-subtle);
  --bs-nav-pills-link-active-color: var(--gh-primary-strong);
  --bs-nav-link-color: var(--gh-text-muted);
}

.nav-pills .nav-link.active {
  font-weight: 600;
}

.pagination {
  --bs-pagination-color: var(--gh-text);
  --bs-pagination-bg: var(--gh-surface);
  --bs-pagination-border-color: var(--gh-border);
  --bs-pagination-hover-color: var(--gh-text);
  --bs-pagination-hover-bg: var(--gh-surface-2);
  --bs-pagination-hover-border-color: var(--gh-border);
  --bs-pagination-active-bg: var(--gh-primary);
  --bs-pagination-active-border-color: var(--gh-primary);
  --bs-pagination-disabled-bg: var(--gh-surface);
  --bs-pagination-disabled-color: var(--gh-text-subtle);
  --bs-pagination-disabled-border-color: var(--gh-border);
  --bs-pagination-focus-box-shadow: 0 0 0 3px rgba(var(--gh-primary-rgb), 0.18);
  --bs-pagination-font-size: var(--gh-fs-sm);
  margin: 0;
}

.alert {
  --bs-alert-border-radius: var(--gh-radius);
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  font-size: var(--gh-fs-md);
}

.alert > .bi:first-child {
  font-size: 1.1rem;
  line-height: 1.4;
}

.alert-dismissible {
  padding-right: 3rem;
}

.alert-info {
  --bs-alert-color: var(--gh-info-text);
  --bs-alert-bg: var(--gh-info-subtle);
  --bs-alert-border-color: rgba(11, 107, 203, 0.2);
}

.alert-warning {
  --bs-alert-color: var(--gh-warning-text);
  --bs-alert-bg: var(--gh-warning-subtle);
  --bs-alert-border-color: rgba(163, 90, 6, 0.2);
}

.alert-danger {
  --bs-alert-color: var(--gh-danger-text);
  --bs-alert-bg: var(--gh-danger-subtle);
  --bs-alert-border-color: rgba(200, 50, 43, 0.2);
}

.alert-success {
  --bs-alert-color: var(--gh-success-text);
  --bs-alert-bg: var(--gh-success-subtle);
  --bs-alert-border-color: rgba(18, 128, 92, 0.2);
}

/* 提示框裡的連結：用提示框自己的文字色（在淺色底上 ≥ 7:1）加底線，不用一般連結的藍色。 */
.alert {
  --bs-alert-link-color: var(--bs-alert-color);
}

.alert a:not(.btn) {
  color: var(--bs-alert-color);
  text-decoration: underline;
}

.alert ul {
  padding-left: 1.1rem;
}

.validation-summary-valid {
  display: none !important;
}

.validation-summary-errors ul {
  margin-bottom: 0;
  padding-left: 1.1rem;
}

.field-validation-error,
.text-danger {
  color: var(--gh-danger-text) !important;
}

.tooltip {
  --bs-tooltip-font-size: var(--gh-fs-sm);
}

.list-group {
  --bs-list-group-bg: var(--gh-surface);
  --bs-list-group-border-color: var(--gh-border);
  --bs-list-group-action-hover-bg: var(--gh-hover);
  --bs-list-group-action-active-bg: var(--gh-primary-subtle);
  --bs-list-group-active-bg: var(--gh-primary-subtle);
  --bs-list-group-active-color: var(--gh-primary-strong);
  --bs-list-group-active-border-color: var(--gh-border);
}

.list-group-item.active {
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--gh-primary);
}

.progress {
  --bs-progress-bar-bg: var(--gh-primary);
}

.toast {
  --bs-toast-bg: var(--gh-surface);
  --bs-toast-border-color: var(--gh-border);
  --bs-toast-border-radius: var(--gh-radius);
  --bs-toast-box-shadow: var(--gh-shadow-lg);
  --bs-toast-max-width: 380px;
  --bs-toast-font-size: var(--gh-fs-md);
}

/* ---------- App shell ---------- */
.gh-app {
  min-height: 100vh;
}

.gh-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--gh-sidebar-width);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--gh-sidebar-bg) 0%, var(--gh-sidebar-bg-2) 100%);
  color: var(--gh-sidebar-text);
  z-index: 1040;
  transition: width var(--gh-transition), transform 200ms ease;
}

.gh-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 72px;
  padding: 0 1.1rem;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  overflow: hidden;
}

.gh-brand:hover {
  color: #fff;
}

/* 側欄的吉祥物：透明背景、不加底框（白色的身體就是輪廓，深淺色主題的側欄都是深藍） */
.gh-brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 0;
  background: none;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: visible;
}

.gh-brand-mark img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.gh-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
  white-space: nowrap;
}

.gh-brand-text strong {
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.gh-brand-text small {
  font-size: var(--gh-fs-xs);
  color: var(--gh-sidebar-muted);
}

/* 組織標誌（_OrgMark.cshtml）：目前是文字，之後換成標誌圖檔時沿用同一個 class */
.gh-org-mark {
  display: inline-block;
  align-self: flex-start;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1;
}

img.gh-org-mark {
  width: auto;
}

.gh-brand-org {
  font-size: var(--gh-fs-xs);
  margin-top: 3px;
  opacity: 0.9;
}

img.gh-brand-org {
  height: 18px;
  font-size: 0;
}

.gh-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.75rem 0.65rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.gh-nav-group + .gh-nav-group {
  margin-top: 0.9rem;
}

.gh-nav-heading {
  font-size: var(--gh-fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gh-sidebar-heading);
  padding: 0.25rem 0.75rem 0.35rem;
  white-space: nowrap;
}

.gh-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  margin: 1px 0;
  border-radius: 8px;
  color: var(--gh-sidebar-text);
  text-decoration: none;
  font-size: var(--gh-fs-md);
  white-space: nowrap;
  transition: background-color var(--gh-transition), color var(--gh-transition);
}

.gh-nav-link .bi {
  font-size: 1.1rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

.gh-nav-link:hover {
  background: var(--gh-sidebar-hover);
  color: var(--gh-sidebar-text-strong);
}

.gh-nav-link.active {
  background: var(--gh-sidebar-active);
  color: var(--gh-sidebar-text-strong);
  font-weight: 600;
}

.gh-nav-link.active::before {
  content: "";
  position: absolute;
  left: -0.65rem;
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: 0 3px 3px 0;
  background: var(--gh-accent);
}

.gh-nav-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gh-sidebar-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--gh-fs-sm);
}

.gh-sidebar-footer a {
  color: var(--gh-sidebar-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.gh-sidebar-footer a:hover {
  color: #fff;
}

.gh-collapse-btn {
  border: 0;
  background: transparent;
  color: var(--gh-sidebar-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.gh-collapse-btn:hover {
  background: var(--gh-sidebar-hover);
  color: #fff;
}

.gh-main {
  margin-left: var(--gh-sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--gh-transition);
  min-width: 0;
}

/* 收合（≥992px）：只顯示 icon */
@media (min-width: 992px) {
  [data-sidebar="collapsed"] .gh-sidebar {
    width: var(--gh-sidebar-collapsed);
  }

  [data-sidebar="collapsed"] .gh-main {
    margin-left: var(--gh-sidebar-collapsed);
  }

  [data-sidebar="collapsed"] .gh-brand {
    padding: 0 14px;
  }

  [data-sidebar="collapsed"] .gh-brand-text,
  [data-sidebar="collapsed"] .gh-nav-label,
  [data-sidebar="collapsed"] .gh-sidebar-footer a span {
    display: none;
  }

  [data-sidebar="collapsed"] .gh-nav-heading {
    font-size: 0;
    padding: 0;
    margin: 0.5rem 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  [data-sidebar="collapsed"] .gh-nav-link {
    justify-content: center;
    padding: 0.6rem 0;
  }

  [data-sidebar="collapsed"] .gh-sidebar-footer {
    flex-direction: column;
    padding: 0.65rem 0;
  }

  [data-sidebar="collapsed"] .gh-collapse-btn .bi {
    transform: rotate(180deg);
  }
}

/* <992px：側欄改為抽屜 */
.gh-sidebar-backdrop {
  display: none;
}

@media (max-width: 991.98px) {
  .gh-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--gh-shadow-lg);
  }

  .gh-main {
    margin-left: 0;
  }

  .gh-sidebar-open .gh-sidebar {
    transform: none;
  }

  .gh-sidebar-open .gh-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(8, 16, 38, 0.45);
    z-index: 1035;
  }

  .gh-collapse-btn {
    display: none;
  }
}

.gh-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  height: var(--gh-topbar-height);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 var(--gh-page-pad);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--gh-border);
}

[data-bs-theme="dark"] .gh-topbar {
  background: rgba(20, 28, 43, 0.86);
}

.gh-menu-btn {
  display: none;
}

@media (max-width: 991.98px) {
  .gh-menu-btn {
    display: inline-flex;
  }
}

.gh-breadcrumb {
  min-width: 0;
  flex: 1 1 auto;
}

.gh-breadcrumb .breadcrumb {
  margin: 0;
  flex-wrap: nowrap;
  font-size: var(--gh-fs-sm);
  --bs-breadcrumb-divider-color: var(--gh-text-subtle);
  --bs-breadcrumb-item-active-color: var(--gh-text);
  --bs-breadcrumb-divider: "›";
}

.gh-breadcrumb .breadcrumb-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 22rem;
}

.gh-breadcrumb .breadcrumb-item a {
  color: var(--gh-text-muted);
  text-decoration: none;
}

.gh-breadcrumb .breadcrumb-item a:hover {
  color: var(--gh-link);
}

.gh-breadcrumb .breadcrumb-item.active {
  font-weight: 500;
}

.gh-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.gh-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gh-brand-700), var(--gh-primary));
  color: #fff;
  font-weight: 600;
  font-size: var(--gh-fs-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.gh-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 0;
  background: transparent;
  padding: 0.2rem 0.35rem 0.2rem 0.2rem;
  border-radius: 999px;
  color: var(--gh-text);
}

.gh-user-btn:hover,
.gh-user-btn[aria-expanded="true"] {
  background: var(--gh-surface-2);
}

.gh-user-name {
  font-size: var(--gh-fs-sm);
  font-weight: 500;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 575.98px) {
  .gh-user-name {
    display: none;
  }
}

.gh-user-menu-head {
  padding: 0.5rem 1rem 0.6rem;
  border-bottom: 1px solid var(--gh-border);
  margin-bottom: 0.3rem;
  min-width: 14rem;
}

.gh-user-menu-head strong {
  display: block;
  font-size: var(--gh-fs-md);
}

.gh-user-menu-head span {
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

.gh-content {
  flex: 1 1 auto;
  padding: var(--gh-page-pad);
  min-width: 0;
}

.gh-content > .gh-content-inner {
  max-width: 1440px;
  margin: 0 auto;
}

.gh-footer {
  padding: 1rem var(--gh-page-pad);
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  justify-content: space-between;
  border-top: 1px solid var(--gh-border);
}

.gh-footer a {
  color: var(--gh-text-muted);
  text-decoration: none;
}

.gh-footer a:hover {
  color: var(--gh-link);
}

@media (max-width: 767.98px) {
  :root {
    --gh-page-pad: 16px;
  }
}

/* ---------- Page header ---------- */
.gh-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.gh-page-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.gh-page-subtitle {
  margin: 0.35rem 0 0;
  color: var(--gh-text-muted);
  max-width: 52rem;
}

.gh-page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-top: 0.45rem;
  color: var(--gh-text-muted);
  font-size: var(--gh-fs-sm);
}

.gh-page-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.gh-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.gh-section-title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---------- Cards ---------- */
.card,
.gh-card {
  --bs-card-bg: var(--gh-surface);
  --bs-card-border-color: var(--gh-border);
  --bs-card-border-radius: var(--gh-radius);
  --bs-card-inner-border-radius: calc(var(--gh-radius) - 1px);
  --bs-card-cap-bg: transparent;
  --bs-card-cap-padding-y: 0.9rem;
  --bs-card-cap-padding-x: 1.25rem;
  --bs-card-spacer-y: 1.25rem;
  --bs-card-spacer-x: 1.25rem;
  box-shadow: var(--gh-shadow-sm);
}

.gh-card .card-header {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gh-card .card-header .bi {
  color: var(--gh-text-muted);
}

.gh-card-hover {
  transition: box-shadow var(--gh-transition), border-color var(--gh-transition), transform var(--gh-transition);
}

.gh-card-hover:hover {
  box-shadow: var(--gh-shadow-md);
  border-color: var(--gh-border-strong);
}

.gh-stat {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  height: 100%;
}

.gh-stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  background: var(--gh-primary-subtle);
  color: var(--gh-primary);
  flex-shrink: 0;
}

.gh-stat-icon.is-accent {
  background: var(--gh-accent-subtle);
  color: var(--gh-accent-icon);
}

.gh-stat-icon.is-success {
  background: var(--gh-success-subtle);
  color: var(--gh-success);
}

.gh-stat-icon.is-info {
  background: var(--gh-info-subtle);
  color: var(--gh-info);
}

.gh-stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.gh-stat-label {
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

/* ---------- Badges ---------- */
.gh-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: var(--gh-fs-xs);
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--gh-surface-2);
  color: var(--gh-text-muted);
  border: 1px solid var(--gh-border);
  vertical-align: middle;
}

.gh-badge-primary,
.gh-badge-bundle {
  background: var(--gh-primary-subtle);
  color: var(--gh-primary-strong);
  border-color: transparent;
}

.gh-badge-method {
  background: var(--gh-surface-2);
  color: var(--gh-text);
  font-family: var(--gh-font-mono);
  font-size: var(--gh-fs-xs);
}

.gh-badge-success {
  background: var(--gh-success-subtle);
  color: var(--gh-success-text);
  border-color: transparent;
}

.gh-badge-warning,
.gh-badge-inactive {
  background: var(--gh-warning-subtle);
  color: var(--gh-warning-text);
  border-color: transparent;
}

.gh-badge-danger {
  background: var(--gh-danger-subtle);
  color: var(--gh-danger-text);
  border-color: transparent;
}

.gh-badge-info {
  background: var(--gh-info-subtle);
  color: var(--gh-info-text);
  border-color: transparent;
}

/* 表單的 FHIR 版本（只標示 R4 以外的版本，docs/adr/0012 第 3 階段）。 */
.gh-badge-release {
  background: var(--gh-info-subtle);
  color: var(--gh-info-text);
  border-color: var(--gh-info);
  font-family: var(--gh-font-mono);
  font-weight: 600;
}

.gh-badge-accent,
.gh-badge-readonly {
  background: var(--gh-accent-subtle);
  color: var(--gh-accent-text);
  border-color: transparent;
}

/* 頂端列的資料庫種類標籤（MySQL／SQLite（開發））：中性色，不搶唯讀標籤的注意力。 */
.gh-badge-db {
  background: var(--gh-surface-2);
  color: var(--gh-text-muted);
  border-color: var(--gh-border);
}

.gh-badge-count {
  min-width: 1.6rem;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tables ---------- */
.gh-table-card {
  overflow: hidden;
}

.gh-table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--gh-border);
}

.gh-search {
  position: relative;
  flex: 0 1 18rem;
  min-width: 12rem;
}

.gh-search .bi {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gh-text-subtle);
  pointer-events: none;
}

.gh-search .form-control {
  padding-left: 2.1rem;
}

.gh-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--gh-text);
  --bs-table-border-color: var(--gh-border);
  --bs-table-hover-bg: var(--gh-hover);
  --bs-table-hover-color: var(--gh-text);
  --bs-table-striped-bg: var(--gh-surface-2);
  margin: 0;
  font-size: var(--gh-fs-sm);
}

.gh-table > :not(caption) > * > * {
  padding: 10px 12px;
}

.gh-table > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--gh-surface-2);
  color: var(--gh-text-muted);
  font-size: var(--gh-fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border-bottom-width: 1px;
}

.gh-table > tbody > tr:last-child > * {
  border-bottom-width: 0;
}

.gh-table td.gh-actions,
.gh-table th.gh-actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

.gh-table .gh-cell-title {
  font-weight: 500;
  color: var(--gh-text);
  text-decoration: none;
}

.gh-table a.gh-cell-title:hover {
  color: var(--gh-link);
}

.gh-table .gh-cell-sub {
  display: block;
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

.gh-table th[data-sortable] {
  cursor: pointer;
  user-select: none;
}

.gh-table th[data-sortable]::after {
  content: "\F127";
  font-family: bootstrap-icons;
  font-size: var(--gh-fs-xs);
  margin-left: 0.3rem;
  opacity: 0.35;
  vertical-align: 0;
}

.gh-table th[data-sort-dir="asc"]::after {
  content: "\F235";
  opacity: 0.9;
}

.gh-table th[data-sort-dir="desc"]::after {
  content: "\F229";
  opacity: 0.9;
}

.gh-table-scroll {
  max-height: 70vh;
  overflow: auto;
}

.gh-table-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--gh-border);
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

.gh-table-footer:empty {
  display: none;
}

.gh-table-empty td {
  text-align: center;
  color: var(--gh-text-muted);
  padding: 2rem 1rem !important;
}

/* ---------- Empty state ---------- */
.gh-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--gh-text-muted);
}

.gh-empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  margin: 0 auto 1rem;
  display: grid;
  place-items: center;
  font-size: 1.75rem;
  background: var(--gh-primary-subtle);
  color: var(--gh-primary);
}

.gh-empty h2,
.gh-empty h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--gh-text);
  margin-bottom: 0.35rem;
}

.gh-empty p {
  max-width: 32rem;
  margin: 0 auto 1.1rem;
}

.gh-empty-sm {
  padding: 1.5rem 1rem;
}

.gh-empty-sm .gh-empty-icon {
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  border-radius: 12px;
  margin-bottom: 0.6rem;
}

/* ---------- Forms ---------- */
.gh-form-section {
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--gh-border);
}

.gh-form-section:last-of-type {
  border-bottom: 0;
  margin-bottom: 0;
}

.gh-form-section-title {
  font-size: var(--gh-fs-md);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.gh-form-section-desc {
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
  margin-bottom: 0.9rem;
}

.gh-form-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.9rem 1.25rem;
  background: var(--gh-surface-2);
  border-top: 1px solid var(--gh-border);
  border-bottom-left-radius: var(--gh-radius);
  border-bottom-right-radius: var(--gh-radius);
}

.gh-segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 8px;
  background: var(--gh-surface-2);
  border: 1px solid var(--gh-border-strong);
  gap: 2px;
  flex-wrap: wrap;
}

.gh-segmented .btn-check + label,
.gh-segmented button {
  border: 0;
  background: transparent;
  color: var(--gh-text-muted);
  font-size: var(--gh-fs-sm);
  font-weight: 500;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  line-height: 1.4;
}

.gh-segmented .btn-check:checked + label,
.gh-segmented button.active {
  background: var(--gh-surface);
  color: var(--gh-primary-strong);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--gh-primary), var(--gh-shadow-sm);
}

.gh-segmented .btn-check:focus-visible + label {
  outline: 2px solid var(--gh-primary);
}

.gh-segmented-sm button {
  padding: 0.15rem 0.5rem;
  font-size: var(--gh-fs-xs);
}

.gh-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 1.75rem 1rem;
  border: 1.5px dashed var(--gh-border-strong);
  border-radius: var(--gh-radius);
  background: var(--gh-surface-2);
  text-align: center;
  color: var(--gh-text-muted);
  cursor: pointer;
  transition: border-color var(--gh-transition), background-color var(--gh-transition);
}

.gh-dropzone:hover,
.gh-dropzone.is-dragover {
  border-color: var(--gh-primary);
  background: var(--gh-primary-subtle);
}

.gh-dropzone .bi {
  font-size: 1.75rem;
  color: var(--gh-primary);
}

.gh-dropzone strong {
  color: var(--gh-text);
  font-weight: 600;
}

.gh-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}

.gh-dropzone-file {
  font-size: var(--gh-fs-sm);
  color: var(--gh-text);
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 0.35rem;
}

.gh-dropzone.has-file .gh-dropzone-file {
  display: inline-flex;
}

.gh-dropzone.has-file .gh-dropzone-hint {
  display: none;
}

/* ---------- Stepper（表單流程：表頭 → 分類 → Mapping → 轉換） ---------- */
.gh-stepper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 1.5rem;
  padding: 0.4rem;
  background: var(--gh-surface);
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius);
  box-shadow: var(--gh-shadow-sm);
  overflow-x: auto;
  scrollbar-width: thin;
}

.gh-step {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.85rem 0.45rem 0.5rem;
  border-radius: 8px;
  color: var(--gh-text-muted);
  text-decoration: none;
  white-space: nowrap;
  font-size: var(--gh-fs-sm);
  font-weight: 500;
  transition: background-color var(--gh-transition), color var(--gh-transition);
}

.gh-step:hover {
  background: var(--gh-hover);
  color: var(--gh-text);
}

.gh-step-num {
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--gh-fs-xs);
  font-weight: 600;
  background: var(--gh-surface-2);
  border: 1px solid var(--gh-border-strong);
  color: var(--gh-text-muted);
  flex-shrink: 0;
}

.gh-step-count {
  font-size: var(--gh-fs-xs);
  color: var(--gh-text-subtle);
  font-weight: 500;
}

.gh-step.is-active {
  background: var(--gh-primary-subtle);
  color: var(--gh-primary-strong);
  font-weight: 600;
  box-shadow: inset 0 -3px 0 var(--gh-primary);
}

/* 選取底色上的次要文字用 muted（subtle 在淺藍底上不到 7:1）。 */
.gh-step.is-active .gh-step-count {
  color: var(--gh-text-muted);
}

.gh-step.is-active .gh-step-num {
  background: var(--gh-primary);
  border-color: var(--gh-primary);
  color: #fff;
}

.gh-step.is-done .gh-step-num {
  background: var(--gh-success-subtle);
  border-color: transparent;
  color: var(--gh-success);
}

.gh-step-sep {
  color: var(--gh-text-subtle);
  font-size: var(--gh-fs-xs);
  flex-shrink: 0;
}

.gh-stepper-end {
  margin-left: auto;
  padding-left: 0.5rem;
  border-left: 1px solid var(--gh-border);
  display: flex;
  gap: 0.25rem;
}

/* ---------- Code ---------- */
.gh-code {
  position: relative;
  background: var(--gh-code-bg);
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius-sm);
  font-family: var(--gh-font-mono);
  font-size: var(--gh-fs-sm);
  margin: 0;
}

.gh-code pre {
  margin: 0;
  padding: 0.9rem 2.75rem 0.9rem 1rem;
  overflow: auto;
  max-height: 28rem;
  color: var(--gh-text);
  white-space: pre;
}

.gh-code-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.45rem 0.45rem 0.75rem;
}

.gh-code-inline code {
  flex: 1 1 auto;
  color: var(--gh-text);
  font-size: var(--gh-fs-sm);
  overflow-wrap: anywhere;
}

.gh-copy {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
}

.gh-code-inline .gh-copy {
  position: static;
}

/* 程式碼框右上角的複製按鈕：有底色，外圍再用同色的陰影蓋到框的邊緣（程式碼較長、水平捲動時文字不會從按鈕旁邊露出來）；
   程式碼右側也留出按鈕的位置。 */
.gh-code > .gh-copy {
  --bs-btn-bg: var(--gh-code-bg);
  box-shadow: 0 0 0 0.4rem var(--gh-code-bg);
}

.gh-kv {
  display: grid;
  grid-template-columns: minmax(7rem, max-content) 1fr;
  gap: 0.5rem 1.25rem;
  margin: 0;
  font-size: var(--gh-fs-md);
}

.gh-kv dt {
  font-weight: 500;
  color: var(--gh-text-muted);
}

.gh-kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---------- Toasts ---------- */
.gh-toasts {
  position: fixed;
  top: calc(var(--gh-topbar-height) + 12px);
  right: 16px;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
}

.gh-toasts .toast {
  pointer-events: auto;
  border-left: 4px solid var(--gh-primary);
}

.gh-toasts .toast.is-success {
  border-left-color: var(--gh-success);
}

.gh-toasts .toast.is-danger {
  border-left-color: var(--gh-danger);
}

.gh-toasts .toast.is-warning {
  border-left-color: var(--gh-accent);
}

.gh-toast-body {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.8rem 0.9rem;
}

.gh-toast-body > .bi {
  font-size: 1.15rem;
  line-height: 1.3;
}

.toast.is-success .gh-toast-body > .bi {
  color: var(--gh-success);
}

.toast.is-danger .gh-toast-body > .bi {
  color: var(--gh-danger);
}

.toast.is-warning .gh-toast-body > .bi {
  color: var(--gh-accent);
}

.toast.is-info .gh-toast-body > .bi {
  color: var(--gh-info);
}

.gh-toast-text {
  flex: 1 1 auto;
  color: var(--gh-text);
  overflow-wrap: anywhere;
}

/* 伺服器端訊息（JS 會轉成 toast；沒有 JS 時直接顯示） */
.gh-flash-source {
  display: none;
}

.no-js .gh-flash-source {
  display: block;
}

/* ---------- Auth layout ---------- */
.gh-auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--gh-bg);
}

@media (min-width: 992px) {
  .gh-auth {
    grid-template-columns: 5fr 7fr;
  }
}

.gh-auth-hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(160deg, #001a4d, #0b3a8c);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 992px) {
  .gh-auth-hero {
    padding: 3rem 3rem 2.5rem;
    justify-content: space-between;
  }
}

.gh-auth-hero::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -120px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 107, 29, 0.35), transparent 65%);
  pointer-events: none;
}

.gh-auth-logo {
  font-size: 1.4rem;
}

img.gh-auth-logo {
  height: 30px;
}

.gh-auth-hero-body {
  position: relative;
  z-index: 1;
}

/* 登入頁的吉祥物：不加白色底框，白色的身體就是輪廓 */
.gh-auth-mascot {
  width: 128px;
  height: 128px;
  object-fit: contain;
  border-radius: 0;
  background: none;
  padding: 0;
  box-shadow: none;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
  margin-bottom: 1.25rem;
}

.gh-auth-title {
  color: #fff;
  font-size: 1.9rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  letter-spacing: 0.01em;
}

.gh-auth-title small {
  display: block;
  font-size: var(--gh-fs-md);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--gh-on-brand-muted);
  margin-top: 0.2rem;
}

.gh-auth-subtitle {
  color: var(--gh-on-brand-muted);
  margin-bottom: 1.5rem;
  max-width: 30rem;
}

.gh-auth-points {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.85rem;
}

.gh-auth-points li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  color: var(--gh-on-brand-muted);
}

.gh-auth-points .bi {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.gh-auth-points strong {
  display: block;
  color: #fff;
  font-weight: 600;
}

.gh-auth-points span {
  font-size: var(--gh-fs-sm);
  color: var(--gh-sidebar-muted);
}

.gh-auth-hero-foot {
  position: relative;
  z-index: 1;
  font-size: var(--gh-fs-sm);
  color: var(--gh-sidebar-muted);
}

@media (max-width: 991.98px) {
  .gh-auth-points,
  .gh-auth-hero-foot {
    display: none;
  }

  .gh-auth-mascot {
    width: 72px;
    height: 72px;
    margin-bottom: 0.75rem;
  }

  .gh-auth-title {
    font-size: 1.4rem;
  }

  .gh-auth-subtitle {
    margin-bottom: 0;
  }
}

.gh-auth-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.gh-auth-card {
  width: 100%;
  max-width: 400px;
}

.gh-auth-card h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.gh-auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--gh-text-subtle);
  font-size: var(--gh-fs-sm);
  margin: 1.25rem 0;
}

.gh-auth-divider::before,
.gh-auth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--gh-border);
}

.gh-auth-links {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: var(--gh-fs-sm);
  margin-top: 1.25rem;
  color: var(--gh-text-muted);
}

.gh-auth-footer {
  margin-top: 2rem;
  font-size: var(--gh-fs-xs);
  color: var(--gh-text-subtle);
  text-align: center;
}

.gh-auth-footer a {
  color: var(--gh-text-muted);
}

.gh-password {
  position: relative;
}

.gh-password .form-control {
  padding-right: 2.75rem;
}

/* Edge 會在密碼欄自己加一個「顯示密碼」眼睛（::-ms-reveal），與我們的切換鈕重疊成兩個；有切換鈕的欄位隱藏內建的。
   沒有切換鈕的密碼欄（例如「確認密碼」）保留 Edge 內建的顯示功能。 */
.gh-password .form-control::-ms-reveal,
.gh-password .form-control::-ms-clear {
  display: none;
}

.gh-password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--gh-text-muted);
  width: 34px;
  height: 30px;
  border-radius: 6px;
}

.gh-password-toggle:hover {
  color: var(--gh-text);
  background: var(--gh-surface-2);
}

/* ---------- Misc ---------- */
.gh-feature {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
}

.gh-feature-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  background: var(--gh-primary-subtle);
  color: var(--gh-primary);
  flex-shrink: 0;
}

.gh-feature h3 {
  font-size: 0.975rem;
  font-weight: 600;
  margin: 0 0 0.2rem;
}

.gh-feature p {
  margin: 0;
  color: var(--gh-text-muted);
  font-size: var(--gh-fs-sm);
}

.gh-steps-list {
  counter-reset: gh-step;
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.9rem;
}

.gh-steps-list > li {
  counter-increment: gh-step;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.gh-steps-list > li::before {
  content: counter(gh-step);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: var(--gh-fs-sm);
  font-weight: 600;
  background: var(--gh-primary);
  color: #fff;
}

.gh-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--gh-radius-lg);
  padding: 1.75rem;
  color: #fff;
  background: linear-gradient(135deg, #001a4d 0%, #0b3a8c 60%, var(--gh-hero-end) 100%);
  box-shadow: var(--gh-shadow-md);
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.gh-hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -80px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 107, 29, 0.4), transparent 65%);
}

.gh-hero-mascot {
  width: 104px;
  height: 104px;
  border-radius: 0;
  background: none;
  padding: 0;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.3));
  object-fit: contain;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.gh-hero-body {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.gh-hero h1 {
  color: #fff;
  font-size: 1.55rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.gh-hero p {
  margin: 0 0 1rem;
  color: var(--gh-on-brand-muted);
  max-width: 46rem;
}

.gh-hero .btn-light {
  --bs-btn-bg: #fff;
  --bs-btn-color: var(--gh-brand);
  --bs-btn-border-color: #fff;
  --bs-btn-hover-bg: #eef2fb;
  --bs-btn-hover-color: var(--gh-brand);
  --bs-btn-hover-border-color: #eef2fb;
}

.gh-hero .btn-outline-light {
  --bs-btn-color: #fff;
  --bs-btn-border-color: rgba(255, 255, 255, 0.5);
  --bs-btn-hover-bg: rgba(255, 255, 255, 0.12);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-border-color: #fff;
}

@media (max-width: 575.98px) {
  .gh-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .gh-hero-mascot {
    width: 64px;
    height: 64px;
  }
}

.gh-link-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: var(--gh-text);
  height: 100%;
}

.gh-link-card:hover {
  color: var(--gh-text);
}

.gh-link-card .gh-link-arrow {
  margin-left: auto;
  color: var(--gh-text-subtle);
  transition: transform var(--gh-transition), color var(--gh-transition);
}

.gh-link-card:hover .gh-link-arrow {
  transform: translateX(3px);
  color: var(--gh-primary);
}

.gh-link-card strong {
  display: block;
  font-weight: 600;
}

.gh-link-card span {
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

.gh-divider {
  border-top: 1px solid var(--gh-border);
  margin: 1.25rem 0;
}

.gh-prose {
  max-width: 54rem;
}

.gh-prose h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.75rem 0 0.6rem;
}

.gh-prose h2:first-child {
  margin-top: 0;
}

.gh-prose h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
}

.gh-prose ol,
.gh-prose ul {
  padding-left: 1.25rem;
}

.gh-prose li + li {
  margin-top: 0.3rem;
}

.gh-toc {
  position: sticky;
  top: calc(var(--gh-topbar-height) + 24px);
  font-size: var(--gh-fs-sm);
}

.gh-toc a {
  display: block;
  padding: 0.3rem 0.75rem;
  color: var(--gh-text-muted);
  text-decoration: none;
  border-left: 2px solid var(--gh-border);
}

.gh-toc a:hover {
  color: var(--gh-link);
  border-left-color: var(--gh-primary);
}

.gh-soon-illustration {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 28px;
  background: var(--gh-surface);
  border: 1px solid var(--gh-border);
  padding: 10px;
  box-shadow: var(--gh-shadow-md);
}

.gh-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.gh-w-sm {
  max-width: 34rem;
}

.gh-w-md {
  max-width: 46rem;
}

.cursor-pointer {
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Confirm modal ---------- */
.gh-confirm-body {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.5rem;
}

.gh-confirm-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 1.3rem;
  background: var(--gh-danger-subtle);
  color: var(--gh-danger);
}

.gh-confirm-icon.is-primary {
  background: var(--gh-primary-subtle);
  color: var(--gh-primary);
}

.gh-confirm-body .modal-title {
  margin-bottom: 0.35rem;
}

.min-w-0 {
  min-width: 0;
}

/* ---------- REST Dashboard：病歷時間軸與檢驗趨勢（Pages/Explorer/Detail.cshtml、explorer-timeline.js） ---------- */
.gh-tl-k-patient { --gh-tl-color: var(--gh-tl-patient); }
.gh-tl-k-encounter { --gh-tl-color: var(--gh-tl-encounter); }
.gh-tl-k-observation { --gh-tl-color: var(--gh-tl-observation); }
.gh-tl-k-medication { --gh-tl-color: var(--gh-tl-medication); }
.gh-tl-k-procedure { --gh-tl-color: var(--gh-tl-procedure); }
.gh-tl-k-condition { --gh-tl-color: var(--gh-tl-condition); }
.gh-tl-k-composition { --gh-tl-color: var(--gh-tl-composition); }
.gh-tl-k-report { --gh-tl-color: var(--gh-tl-report); }
.gh-tl-k-other { --gh-tl-color: var(--gh-tl-other); }

/* 寬螢幕（xl）左右並排：時間軸在左（5/12）、固定位置並自己捲動；右側是頁籤與目前的頁籤內容（7/12）。
   .tab-content 用 display: contents，裡面的頁籤內容直接排進格線（Bootstrap 的 .tab-content > .tab-pane 規則照常）。較窄時時間軸是一般的頁籤。 */
@media (min-width: 1200px) {
  .gh-detail-split {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    grid-template-rows: auto 1fr;
    column-gap: 1.5rem;
    align-items: start;
  }

  .gh-detail-split > .nav-tabs {
    grid-column: 2;
    grid-row: 1;
  }

  .gh-detail-split > .tab-content {
    display: contents;
  }

  .gh-detail-split > .tab-content > .tab-pane {
    grid-column: 2;
    grid-row: 2;
  }

  .gh-detail-split > .tab-content > .tab-pane.gh-timeline-pane {
    display: flex;
    flex-direction: column;
    opacity: 1;
    grid-column: 1;
    grid-row: 1 / span 2;
    position: sticky;
    top: calc(var(--gh-topbar-height) + 1rem);
    max-height: calc(100vh - var(--gh-topbar-height) - 2rem);
  }

  .gh-detail-split .gh-timeline {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .gh-detail-split .gh-timeline-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  /* 捲動時目前這一天的日期標記固定在時間軸上方（被下一天的標記推走）。 */
  .gh-detail-split .gh-tl-date {
    position: sticky;
    top: 0;
    padding: 0.25rem 0;
    margin-top: -0.25rem;
    background: var(--gh-surface);
  }

  /* 固定的日期標記有底色（蓋住捲到下面的列），線在底色上照樣畫過去。 */
  .gh-detail-split .gh-tl-date::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: 0;
    bottom: 0;
    left: calc(var(--gh-tl-x) - 1px);
    width: 2px;
    background: var(--gh-border-strong);
  }

  .gh-detail-split .gh-tl-days > .gh-tl-day:first-child .gh-tl-date::before {
    top: 50%;
  }
}

.gh-timeline-head {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--gh-border);
}

.gh-timeline-title {
  font-size: var(--gh-fs-base);
  font-weight: 600;
  margin: 0;
}

.gh-timeline-count {
  font-size: var(--gh-fs-sm);
  font-weight: 400;
  color: var(--gh-text-muted);
}

.gh-timeline-note {
  display: flex;
  gap: 0.4rem;
  margin: 0.5rem 0 0;
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

/* 篩選：每個種類一個可切換的標籤（真正的勾選框用 Bootstrap 的 .btn-check 藏起來，點標籤切換；鍵盤焦點畫在標籤上）。
   勾選 = 選取的樣式（primary-subtle 底、primary 外框、primary-strong 粗體）＋實心色點；沒勾選 = 淡色文字＋空心色點（不只靠顏色）。 */
.gh-tl-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.5rem;
  margin: 0.625rem 0 0;
}

.gh-tl-filter-legend {
  float: none;
  width: auto;
  margin: 0 0.25rem 0 0;
  padding: 0;
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

.gh-tl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.gh-tl-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.625rem 0.125rem 0.5rem;
  border: 1px solid var(--gh-border-strong);
  border-radius: 999px;
  font-size: var(--gh-fs-sm);
  line-height: 1.5;
  color: var(--gh-text-muted);
  background: transparent;
  cursor: pointer;
  user-select: none;
}

.gh-tl-chip:hover {
  background: var(--gh-hover);
}

.btn-check:checked + .gh-tl-chip {
  border-color: var(--gh-primary);
  background: var(--gh-primary-subtle);
  color: var(--gh-primary-strong);
  font-weight: 600;
}

.btn-check:focus-visible + .gh-tl-chip {
  outline: 2px solid var(--gh-primary);
  outline-offset: 2px;
}

.gh-tl-chip-count {
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.gh-tl-swatch {
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  border: 2px solid var(--gh-tl-color);
  background: transparent;
}

.btn-check:checked + .gh-tl-chip .gh-tl-swatch {
  background: var(--gh-tl-color);
}

.gh-tl-filter-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.gh-tl-filter-actions .btn {
  padding: 0 0.25rem;
  font-size: var(--gh-fs-sm);
}

.gh-timeline-scroll {
  padding: 0.25rem 1rem 1rem;
}

/* 可以捲動的區塊要能用鍵盤聚焦（方向鍵捲動），焦點外框畫在內側。 */
.gh-timeline-scroll:focus-visible,
.gh-chart:focus-visible {
  outline: 2px solid var(--gh-primary);
  outline-offset: -2px;
}

/* 時間軸的格線：時刻欄（--gh-tl-when）、線與圓點（--gh-tl-rail）、內容。線畫在每一天（.gh-tl-day::before），一天接一天連成一條；
   圓點與日期標記蓋在線上。線用 --gh-border-strong（導引線 ≥ 3:1）；種類色只用在圓點與篩選的色點，文字一律 --gh-text 系列。 */
.gh-tl-days {
  --gh-tl-when: 2.75rem;
  --gh-tl-rail: 1.75rem;
  --gh-tl-gap: 0.5rem;
  --gh-tl-x: calc(var(--gh-tl-when) + var(--gh-tl-gap) + var(--gh-tl-rail) / 2);
}

.gh-tl-days,
.gh-tl-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.gh-tl-day {
  position: relative;
  padding-top: 0.75rem;
}

.gh-tl-day::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  left: calc(var(--gh-tl-x) - 1px);
  width: 2px;
  background: var(--gh-border-strong);
  pointer-events: none;
}

/* 線從第一個日期標記開始，不往上超出。 */
.gh-tl-days > .gh-tl-day:first-child::before {
  top: 1.5rem;
}

/* 日期標記：線上的一個膠囊（日期一天只寫一次），各筆只寫時刻。 */
.gh-tl-date {
  position: relative;
  z-index: 3;
  margin: 0 0 0.25rem;
  font-size: var(--gh-fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--gh-text);
}

.gh-tl-date-pill {
  display: inline-block;
  padding: 0.125rem 0.625rem;
  border: 1px solid var(--gh-border-strong);
  border-radius: 999px;
  background: var(--gh-surface);
}

/* 每一筆：時刻｜圓點｜內容。沒有外框與底色；可以點的列整列都是連結（標題的 ::after 蓋住整列），滑過時 --gh-hover。 */
.gh-tl-item {
  position: relative;
  display: grid;
  grid-template-columns: var(--gh-tl-when) var(--gh-tl-rail) minmax(0, 1fr);
  column-gap: var(--gh-tl-gap);
  align-items: start;
  padding: 0.375rem 0.5rem 0.375rem 0;
  border-radius: var(--gh-radius-sm);
}

.gh-tl-item:has(.gh-tl-link):hover {
  background: var(--gh-hover);
}

.gh-tl-item:has(.gh-tl-link):hover .gh-tl-dot {
  box-shadow: 0 0 0 3px var(--gh-hover);
}

.gh-tl-when {
  padding-top: 0.125rem;
  text-align: right;
  font-size: var(--gh-fs-sm);
  font-variant-numeric: tabular-nums;
  color: var(--gh-text-muted);
  white-space: nowrap;
}

.gh-tl-dot {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  justify-self: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--gh-tl-color);
  color: var(--gh-tl-icon-fg);
  font-size: var(--gh-fs-xs);
  box-shadow: 0 0 0 3px var(--gh-surface);
}

.gh-tl-body {
  min-width: 0;
  padding-top: 0.0625rem;
}

.gh-tl-line {
  overflow-wrap: break-word;
}

.gh-tl-kind {
  margin-right: 0.375rem;
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

.gh-tl-title {
  color: var(--gh-text);
}

.gh-tl-link {
  text-decoration: none;
}

.gh-tl-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.gh-tl-link:hover {
  color: var(--gh-text);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.gh-tl-link:focus-visible {
  outline: 2px solid var(--gh-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

.gh-tl-line .gh-badge {
  margin-left: 0.375rem;
  vertical-align: 0.0625rem;
}

.gh-tl-sub {
  margin-top: 0.0625rem;
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
  overflow-wrap: anywhere;
}

/* 目前查看的這一筆：選取的樣式（primary-subtle 底、左側色條、primary-strong 粗體），另有「目前查看」的文字徽章。 */
.gh-tl-item.is-current {
  background: var(--gh-primary-subtle);
  box-shadow: inset 3px 0 0 var(--gh-primary);
}

.gh-tl-item.is-current .gh-tl-title {
  color: var(--gh-primary-strong);
  font-weight: 600;
}

.gh-tl-item.is-current .gh-tl-dot {
  box-shadow: 0 0 0 3px var(--gh-surface), 0 0 0 5px var(--gh-primary);
}

.gh-tl-more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.gh-tl-status {
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

.gh-trend-intro {
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

.gh-trend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 36rem), 1fr));
  gap: 1rem;
}

.gh-trend-title {
  margin: 0 0 0.25rem;
  font-size: var(--gh-fs-base);
  font-weight: 600;
}

.gh-trend-code,
.gh-trend-note {
  margin: 0.25rem 0 0;
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

/* SVG 的寬度不小於 viewBox（560），字級（rem）才不會被縮到下限以下；較窄時在框內左右捲動。 */
.gh-chart {
  margin-top: 0.5rem;
  overflow-x: auto;
}

.gh-chart-svg {
  display: block;
  width: 100%;
  min-width: 35rem;
  max-width: 48rem;
  height: auto;
}

.gh-chart-grid {
  stroke: var(--gh-border);
  stroke-width: 1;
}

.gh-chart-axis {
  stroke: var(--gh-border-strong);
  stroke-width: 1;
}

.gh-chart-tick {
  fill: var(--gh-text-muted);
  font-family: var(--gh-font);
  font-size: var(--gh-fs-xs);
}

.gh-chart-line {
  fill: none;
  stroke: var(--gh-chart-1);
  stroke-width: 2;
  stroke-linejoin: round;
}

.gh-chart-point {
  fill: var(--gh-surface);
  stroke: var(--gh-chart-1);
  stroke-width: 2;
}

.gh-chart-point.is-current {
  fill: var(--gh-chart-current);
  stroke: var(--gh-text);
}

.gh-chart-current-label {
  fill: var(--gh-text);
  font-family: var(--gh-font);
  font-size: var(--gh-fs-xs);
  font-weight: 600;
}

.gh-chart-band {
  fill: var(--gh-chart-band);
}

.gh-chart-legend-band {
  display: inline-block;
  width: 1rem;
  height: 0.75rem;
  margin-right: 0.35rem;
  border: 1px solid var(--gh-border-strong);
  background: var(--gh-chart-band);
  vertical-align: -0.1rem;
}

.gh-trend-table {
  margin-top: 0.5rem;
}

.gh-trend-table > summary {
  font-size: var(--gh-fs-sm);
}

.gh-tl-empty {
  margin: 0.5rem 0 0;
  color: var(--gh-text-muted);
}

/* 列印：時間軸與檢驗趨勢不是作用中的頁籤時也印出來（左右並排取消、由上往下排；固定位置、高度上限、自己捲動都取消），
   圖表依紙張寬度縮放；趨勢的資料表由 explorer-timeline.js 在列印前展開。 */
@media print {
  .gh-detail-split,
  .gh-detail-split > .tab-content {
    display: block;
  }

  .tab-content > .tab-pane.gh-trends-pane {
    display: block !important;
    opacity: 1;
    margin-bottom: 1rem;
  }

  .gh-detail-split > .tab-content > .tab-pane.gh-timeline-pane {
    display: block !important;
    opacity: 1;
    position: static;
    max-height: none;
    margin-bottom: 1rem;
  }

  .gh-timeline-pane .gh-timeline-scroll {
    max-height: none;
    overflow: visible;
  }

  .gh-chart-svg {
    min-width: 0;
  }
}

/* 表單的網頁填寫（Forms/Fill）：分類是 <details>（沒有 JS 也能收合，有問題的由伺服器展開），重複的一組是 fieldset。
   字級一律 var(--gh-fs-*)；錯誤用 --gh-danger-text（≥ 7:1）＋左邊色條；摘要列的焦點外框沿用 summary:focus-visible。 */
.gh-fill-lead {
  max-width: 60rem;
}

.gh-fill-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: var(--gh-fs-sm);
}

.gh-fill-section {
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius);
  background: var(--gh-surface);
  margin-bottom: 1rem;
}

.gh-fill-section > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
}

.gh-fill-section > summary:hover {
  background: var(--gh-hover);
}

.gh-fill-section[open] > summary {
  border-bottom: 1px solid var(--gh-border);
}

.gh-fill-section.is-invalid {
  border-left: 4px solid var(--gh-danger);
}

.gh-fill-section-title {
  font-weight: 600;
}

.gh-fill-section-meta {
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

.gh-fill-section-body {
  padding: 1rem;
}

.gh-fill-field,
.gh-fill-list,
.gh-fill-group,
.gh-fill-items {
  margin-bottom: 1rem;
}

.gh-fill-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.5rem;
  font-weight: 600;
  font-size: var(--gh-fs-base);
}

.gh-fill-sub {
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
  margin-bottom: 0.25rem;
}

.gh-fill-datetime {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.gh-fill-date,
.gh-fill-time {
  max-width: 14rem;
}

.gh-fill-number {
  max-width: 16rem;
}

.gh-fill-group,
.gh-fill-list {
  border-left: 2px solid var(--gh-border-strong);
  padding-left: 0.75rem;
}

.gh-fill-group > legend,
.gh-fill-list > legend,
fieldset.gh-fill-field > legend {
  float: none;
  width: auto;
  margin-bottom: 0.5rem;
}

.gh-fill-value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.gh-fill-value .gh-fill-sub {
  min-width: 4rem;
  margin-bottom: 0;
}

.gh-fill-value-input {
  flex: 1 1 14rem;
  min-width: 0;
}

.gh-fill-item {
  position: relative;
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius-sm);
  padding: 0.75rem 1rem 0.25rem;
  margin-bottom: 0.75rem;
}

.gh-fill-item > legend.gh-fill-item-title {
  float: none;
  width: auto;
  padding: 0 0.25rem;
  margin-bottom: 0;
  font-size: var(--gh-fs-base);
  font-weight: 600;
}

.gh-fill-item-remove {
  float: right;
  margin: -0.25rem 0 0.5rem 0.5rem;
}

.gh-fill-item.is-invalid,
.gh-fill-field.is-invalid,
.gh-fill-value.is-invalid {
  border-left: 4px solid var(--gh-danger);
  padding-left: 0.75rem;
}

.gh-fill-error {
  flex-basis: 100%;
  margin-top: 0.25rem;
  font-size: var(--gh-fs-sm);
  color: var(--gh-danger-text);
}

.gh-fill-add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.gh-fill-pair {
  color: var(--gh-text-muted);
}

/* 代碼很多的欄位的搜尋清單（form-fill.js 加上的 ARIA combobox）：目前的選項（aria-selected）＝ --gh-primary-subtle 底＋左邊色條＋ --gh-primary-strong 粗體；
   滑鼠移過只用 --gh-hover。選項不會取得焦點（aria-activedescendant），焦點外框在文字框。 */
.gh-fill-combo {
  position: relative;
}

.gh-fill-combo [role="combobox"]:focus-visible {
  outline: 2px solid var(--gh-primary);
  outline-offset: 2px;
}

.gh-fill-combo-list {
  position: absolute;
  z-index: 1030;
  left: 0;
  right: 0;
  max-height: 18rem;
  overflow-y: auto;
  margin: 0.25rem 0 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--gh-surface);
  border: 1px solid var(--gh-border-strong);
  border-radius: var(--gh-radius-sm);
  box-shadow: var(--gh-shadow-lg);
}

.gh-fill-combo-option {
  padding: 0.375rem 0.75rem;
  border-left: 3px solid transparent;
  font-size: var(--gh-fs-base);
  color: var(--gh-text);
  cursor: pointer;
}

.gh-fill-combo-option:hover {
  background: var(--gh-hover);
}

.gh-fill-combo-option[aria-selected="true"] {
  background: var(--gh-primary-subtle);
  border-left-color: var(--gh-primary);
  color: var(--gh-primary-strong);
  font-weight: 600;
}

.gh-fill-combo-status {
  margin-top: 0.25rem;
  font-size: var(--gh-fs-sm);
  color: var(--gh-text-muted);
}

.gh-fill-combo-status:empty {
  display: none;
}
