/* GroundHog — main.css  */
.practitioner-removal-backdrop {
  position: fixed; inset: 0; z-index: 1300;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: rgba(15, 23, 42, .45);
}
.practitioner-removal-dialog {
  background: var(--bg-card, #fff); color: var(--text-main, #1A1A2E);
  border-radius: 10px; padding: 1.5rem; width: min(760px, 100%);
  max-height: calc(85dvh / var(--ui-zoom, 1)); overflow-y: auto;
  box-shadow: 0 18px 45px rgba(15, 23, 42, .28);
}
.practitioner-removal-dialog h2 { margin: 0 0 .75rem; font-size: 1.2rem; }
.practitioner-removal-dialog p { margin: .75rem 0; }
.practitioner-reference-hit { outline: 3px solid var(--primary, #0066CC); outline-offset: 3px; }
.related-practitioner-summary {
  margin: 12px 0;
  padding: 12px 16px;
  border: 1px solid var(--border, #d2dbea);
  border-radius: 10px;
  background: var(--bg-card, #fff);
  min-width: 0;
}
.related-practitioner-summary-scroll { overflow-x: auto; margin-top: 8px; }
.related-practitioner-summary-table { width: 100%; border-collapse: collapse; text-align: left; }
.related-practitioner-summary-table th,
.related-practitioner-summary-table td { padding: 6px 12px; vertical-align: top; text-align: left; }
.related-practitioner-summary-table th { color: var(--text-muted, #6b7280); font-weight: 600; }
.related-practitioner-summary-table td { border-top: 1px solid var(--border, #d2dbea); }
.related-practitioner-summary-table th:first-child,
.related-practitioner-summary-table td:first-child { padding-left: 0; white-space: nowrap; }
.related-practitioner-summary-table td:nth-child(2) { min-width: 10em; overflow-wrap: anywhere; }
.related-practitioner-summary-table td:nth-child(3),
.related-practitioner-summary-table td:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Global reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif);
  font-size: var(--font-size, 15px);
  color: var(--text-main, #1A1A2E);
  background: var(--surface, #F4F7FB);
  line-height: 1.6;
}

/* ── 顯示設定:字型與字級 ──────────────────────────────────────────────
   每台電腦各自記住,由 _display_prefs_head.html 在 <html> 掛 data-font / data-font-size。
   沒掛 = 預設:系統字型、字級「標準」。

   字型:只換內文字型。表單元件(按鈕、輸入框)瀏覽器預設不繼承字型,換了字型才讓它們跟著;
   用 :where() 把權重壓到 0,程式碼欄位自己指定的等寬字仍然優先。

   字級:用 zoom 整頁等比放大。只改根字級的話,頁面裡上百處寫死 px 的字不會變,
   大小參差。zoom 會把 vh/vw 也一起放大 —— 所以凡是用 vh/vw 決定高寬的地方
   都除以 --ui-zoom,否則側邊欄、彈出視窗會比螢幕還高。

   **2026-10-08 整體上調一級**(醫院 demo 回饋:字太小):標準 = 原本的「大」(1.125),
   小 = 原本的標準(1,不縮放),大 1.25,特大 1.375。標準寫在 :root 的預設值,
   不靠 JS —— 登入頁、讀不到設定(無痕模式)時也是這個大小。 */
:root[data-font="jhenghei"] { --font-body: "Microsoft JhengHei", "微軟正黑體", sans-serif; }
:root[data-font="noto"]     { --font-body: "Noto Sans TC", "Source Han Sans TC", "思源黑體", "Microsoft JhengHei", sans-serif; }
:where(:root[data-font]) :where(button, input, select, textarea) { font-family: inherit; }
:root { --ui-zoom: 1.125; }                       /* 標準 */
:root[data-font-size="sm"] { --ui-zoom: 1; }
:root[data-font-size="lg"] { --ui-zoom: 1.25; }
:root[data-font-size="xl"] { --ui-zoom: 1.375; }
body { zoom: var(--ui-zoom); }

/* ── Layout ── */
.layout { display: flex; min-height: calc(100vh / var(--ui-zoom, 1)); }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg, #fff);
  border-right: 1px solid var(--border, #D0D9E8);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: calc(100vh / var(--ui-zoom, 1));
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border, #D0D9E8);
}
.brand-icon { font-size: 1.5rem; }
.brand-name { font-size: 1.1rem; font-weight: 700; color: var(--primary, #0066CC); }

.nav-list { list-style: none; padding: .5rem 0; flex: 1; }
.nav-section {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted, #888);
  padding: 1rem 1rem .25rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1rem;
  color: var(--text-main, #1A1A2E);
  text-decoration: none;
  border-radius: var(--radius, 8px);
  margin: .15rem .5rem;
  font-size: .92rem;
  transition: background .15s;
}
.nav-link:hover, .nav-link.active {
  background: var(--primary-light, #E8F0FB);
  color: var(--primary, #0066CC);
}
.nav-icon { font-size: 1rem; width: 1.2rem; }
.sidebar-footer { padding: .75rem 1rem; font-size: .75rem; color: var(--text-muted, #888); }
.version-tag {}

.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--sidebar-bg, #fff);
  border-bottom: 1px solid var(--border, #D0D9E8);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: .5rem; }
/* 桌機上等於不存在(子頁的麵包屑照舊直接排在 topbar-left 裡);窄螢幕時負責截斷 */
.topbar-crumbs { display: contents; }
.breadcrumb-current { font-size: .9rem; color: var(--text-muted, #888); }
.topbar-right { display: flex; align-items: center; gap: .75rem; }

.content { padding: 1.5rem; max-width: 1400px; }

/* ── 窄螢幕:側邊欄改成抽屜 ──
   以前沒有任何 @media:手機上側邊欄照樣佔 220px,內容只剩一百多 px。
   ≤ 900px 時側邊欄移出畫面,由頂列的 ☰ 打開;收起時 visibility:hidden,
   鍵盤 Tab 不會跑進看不見的選單。 */
/* ☰ 一律顯示(2026-10-08):桌機按了收合/展開側邊欄,窄螢幕開抽屜。抽屜裡的 ✕ 只在窄螢幕。 */
.nav-toggle, .sidebar-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: 1px solid var(--border, #D0D9E8);
  border-radius: var(--radius, 8px);
  background: transparent;
  color: var(--text-main, #1A1A2E);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle:focus-visible, .sidebar-close:focus-visible {
  outline: 2px solid var(--primary, #0066CC);
  outline-offset: 2px;
}
.sidebar-close { display: none; }
.sidebar-backdrop { display: none; }

/* ── 桌機收合側邊欄 ──
   收合時整個不佔位置,內容用滿寬度;狀態記在這個瀏覽器(base.html 在畫面畫出來前就套上
   `nav-collapsed`,不會先閃一下)。窄螢幕不看這個 class,照舊是抽屜。 */
@media screen and (min-width: 901px) {
  :root.nav-collapsed { --sidebar-width: 0px; }
  .nav-collapsed .sidebar { display: none; }
}

@media screen and (max-width: 900px) {
  /* 表單頁底部固定的儲存列用這個變數決定左邊留多少(fill.html 的 .save-bar);
     側邊欄不佔版面了,就不用留。 */
  :root { --sidebar-width: 0px; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    height: calc(100vh / var(--ui-zoom, 1));
    height: calc(100dvh / var(--ui-zoom, 1));
    width: min(280px, calc(85vw / var(--ui-zoom, 1)));
    z-index: 1100;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .2s ease, visibility 0s linear .2s;
  }
  .nav-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform .2s ease;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .25);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1090;
    background: rgba(15, 23, 42, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  /* 只鎖 html:連 body 一起設 overflow:hidden,body 會變成捲動容器,
     頂列和各頁的 sticky 標頭會跟著跑掉 */
  html.nav-open { overflow: hidden; }

  .sidebar-close { display: inline-flex; margin-left: auto; border-color: transparent; }

  .topbar { padding: .5rem 1rem; gap: .5rem; }
  /* 「Aa」在頂列中間,靠它右對齊的話彈出框會超出左邊 —— 窄螢幕改成貼齊畫面左右 */
  .topbar .dp-menu { position: static; }
  .topbar .dp-pop { position: fixed; left: 1rem; right: 1rem; top: 3.6rem; width: auto; }
  /* 至少留得下 ☰,帳號名稱再長也不能把它擠掉 */
  .topbar-left { min-width: 40px; flex: 1 1 auto; }
  .topbar-crumbs {
    display: block;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .topbar-right { flex-shrink: 1; min-width: 0; gap: .5rem; }
  .user-badge { min-width: 0; }
  .user-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .content { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar-backdrop { transition: none !important; }
}

/* ── 字型與字級的選項(頂列「Aa」與系統設定頁)── */
.dp-menu { position: relative; }
.dp-toggle { font-weight: 600; min-width: 2.4rem; justify-content: center; }
.dp-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 300;
  width: min(340px, calc(100vw / var(--ui-zoom, 1) - 32px));
  background: var(--sidebar-bg, #fff); color: var(--text-main, #1A1A2E);
  border: 1px solid var(--border, #D0D9E8); border-radius: var(--radius, 8px);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .18); padding: .85rem;
}
.dp-controls { display: flex; flex-direction: column; gap: .85rem; }
.dp-label { font-size: .82rem; font-weight: 600; color: var(--text-muted, #6B7280); margin-bottom: .35rem; }
.dp-options { display: flex; flex-wrap: wrap; gap: .4rem; }
.dp-option {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  padding: .4rem .7rem; border: 1px solid var(--border, #D0D9E8); border-radius: var(--radius, 8px);
  background: transparent; color: var(--text-main, #1A1A2E); cursor: pointer; font-size: .92rem;
}
.dp-option:hover:not(:disabled) { border-color: var(--primary, #0066CC); }
.dp-option--on { border-color: var(--primary, #0066CC); background: var(--primary-light, #E8F0FB);
                 color: var(--primary, #0066CC); font-weight: 600; }
.dp-option:disabled { opacity: .5; cursor: not-allowed; }
.dp-option-note { font-size: .72rem; color: var(--text-muted, #6B7280); font-weight: 400; }
.dp-options--seg .dp-option { align-items: center; min-width: 3.2rem; }
.dp-note { font-size: .78rem; color: var(--text-muted, #6B7280); margin: 0; }
.dp-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.dp-preview { margin-top: 1rem; padding: .75rem .9rem; border-radius: var(--radius, 8px);
              background: var(--surface, #F4F7FB); border: 1px solid var(--border, #D0D9E8); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem 1rem;
  border-radius: var(--radius, 8px);
  border: 1px solid transparent;
  font-size: .9rem;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  font-weight: 500;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary, #0066CC); color: #fff; border-color: var(--primary, #0066CC); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--text-main); border-color: var(--border, #D0D9E8); }
.btn-ghost:hover:not(:disabled) { background: var(--surface, #F4F7FB); }
.btn-outline { background: transparent; color: var(--primary, #0066CC); border-color: var(--primary, #0066CC); }
.btn-outline:hover:not(:disabled) { background: var(--primary-light, #E8F0FB); }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger-ghost { background: transparent; color: #dc2626; border-color: #dc2626; }
.btn-danger-ghost:hover:not(:disabled) { background: #fef2f2; }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-xs { padding: .2rem .5rem; font-size: .78rem; }
.btn-close { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: var(--text-muted, #888); }

/* ── Cards ── */
.card {
  background: var(--sidebar-bg, #fff);
  border: 1px solid var(--border, #D0D9E8);
  border-radius: var(--radius, 8px);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border, #D0D9E8);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}
.page-heading { font-size: 1.4rem; font-weight: 700; }
.header-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ── Forms ── */
.form-card {
  background: var(--sidebar-bg, #fff);
  border: 1px solid var(--border, #D0D9E8);
  border-radius: var(--radius, 8px);
  padding: 1.5rem;
}
.section-block { margin-bottom: 1.5rem; }
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border, #D0D9E8); }
.section-desc { font-size: .88rem; color: var(--text-muted, #888); margin-bottom: 1rem; }

.field-group { margin-bottom: 1rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.field-label { display: block; font-size: .88rem; font-weight: 500; margin-bottom: .35rem; }
.field-input {
  display: block;
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border, #D0D9E8);
  border-radius: calc(var(--radius, 8px) - 2px);
  background: var(--surface, #F4F7FB);
  color: var(--text-main, #1A1A2E);
  font-size: .92rem;
  transition: border-color .15s;
}
.field-input:focus { outline: none; border-color: var(--primary, #0066CC); }
.field-hint { font-size: .8rem; color: var(--text-muted, #888); margin-top: .25rem; }
.req-star, .required, .req-mark { color: #dc2626; font-weight: 800; font-size: 1.1em; }
.field-required > .field-label::after { content: ' *'; color: #dc2626; font-weight: 800; font-size: 1.1em; }
.field-widget-hint { font-size: .72rem; color: var(--text-muted, #888); font-weight: normal; margin-left: .3rem; }
.hidden { display: none !important; }
.radio-group, .checkbox-group { display: flex; flex-wrap: wrap; gap: .75rem; padding: .25rem 0; }
.radio-label, .checkbox-label { display: flex; align-items: center; gap: .35rem; font-size: .9rem; cursor: pointer; }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border, #D0D9E8); }

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border, #D0D9E8);
  border-radius: var(--radius, 8px);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drag-active { border-color: var(--primary, #0066CC); background: var(--primary-light, #E8F0FB); }
.drop-icon { font-size: 2rem; margin-bottom: .5rem; }
.drop-text { font-size: .95rem; margin-bottom: .25rem; }
.drop-hint { font-size: .8rem; color: var(--text-muted, #888); }
.file-list { margin-top: .75rem; display: flex; flex-direction: column; gap: .35rem; }
.file-item { display: flex; align-items: center; gap: .5rem; padding: .4rem .75rem; background: var(--surface, #F4F7FB); border-radius: calc(var(--radius, 8px) - 2px); font-size: .88rem; }
.file-name { flex: 1; }
.file-size { color: var(--text-muted, #888); font-size: .8rem; }
.btn-remove { background: none; border: none; cursor: pointer; color: #dc2626; font-size: .85rem; }
.file-badge { display: inline-block; background: var(--surface, #F4F7FB); border: 1px solid var(--border, #D0D9E8); border-radius: 4px; padding: .1rem .4rem; font-size: .78rem; margin: .1rem; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th { padding: .6rem 1rem; text-align: left; font-weight: 600; font-size: .8rem; background: var(--surface, #F4F7FB); border-bottom: 2px solid var(--border, #D0D9E8); white-space: nowrap; }
.data-table td { padding: .6rem 1rem; border-bottom: 1px solid var(--border, #D0D9E8); vertical-align: top; }
.data-table tr:hover td { background: var(--surface, #F4F7FB); }
.row-active td { background: #f0fdf4 !important; }
.row-hidden td { opacity: .6; }
.row-required td:first-child { border-left: 3px solid var(--primary, #0066CC); }
.row-sub td { background: var(--surface, #F4F7FB) !important; }

/* ── Badges ── */
.badge-active { background: #dcfce7; color: #166534; padding: .15rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.badge-inactive { background: var(--surface, #F4F7FB); color: var(--text-muted, #888); padding: .15rem .5rem; border-radius: 99px; font-size: .78rem; }
.badge-pending { background: #fef9c3; color: #713f12; padding: .15rem .5rem; border-radius: 99px; font-size: .78rem; }
.badge-parsing { background: #dbeafe; color: #1e40af; padding: .15rem .5rem; border-radius: 99px; font-size: .78rem; animation: pulse 1.5s infinite; }
.badge-repeatable { background: #fce7f3; color: #9d174d; padding: .15rem .5rem; border-radius: 99px; font-size: .78rem; }
.badge-error { background: #fee2e2; color: #991b1b; padding: .15rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; cursor: help; }
.status-badge { padding: .15rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.status-draft { background: #fef9c3; color: #713f12; }
.status-completed { background: #dcfce7; color: #166534; }
.status-exported { background: #dbeafe; color: #1e40af; }
.meta-tag { display: inline-block; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: .1rem .5rem; font-size: .8rem; margin-left: .35rem; }
.project-id-badge { display: inline-block; background: var(--primary-light, #E8F0FB); color: var(--primary, #0066CC); border-radius: 4px; padding: .1rem .5rem; font-size: .8rem; font-family: monospace; }
.user-badge { display: flex; align-items: center; gap: .35rem; font-size: .85rem; }
.user-role { padding: .1rem .4rem; border-radius: 4px; font-size: .75rem; font-weight: 600; }
.role-admin { background: #fee2e2; color: #991b1b; }
.role-editor { background: #dbeafe; color: #1e40af; }
.role-viewer { background: var(--surface); color: var(--text-muted); }

/* ── Widget badges ── */
.widget-badge { padding: .1rem .4rem; border-radius: 4px; font-size: .75rem; font-family: monospace; }
.widget-text { background: #f3f4f6; }
.widget-select { background: #dbeafe; }
.widget-date { background: #fce7f3; }
.widget-radio { background: #dcfce7; }
.widget-checkbox { background: #fef9c3; }
.widget-textarea { background: #f3f4f6; }
.widget-number { background: #e0e7ff; }
.widget-file { background: #fef3c7; }
.widget-repeatable-group { background: #ede9fe; }
.widget-group { background: #f3f4f6; }

/* ── Tabs ── */
.tab-bar { display: flex; gap: .25rem; border-bottom: 2px solid var(--border, #D0D9E8); margin-bottom: 1rem; overflow-x: auto; }
.tab-btn { background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; padding: .5rem .9rem; font-size: .88rem; cursor: pointer; color: var(--text-muted, #888); white-space: nowrap; transition: all .15s; }
.tab-btn:hover { color: var(--primary, #0066CC); }
.tab-btn.active { color: var(--primary, #0066CC); border-bottom-color: var(--primary, #0066CC); font-weight: 600; }
.tab-count { background: var(--surface, #F4F7FB); border-radius: 99px; padding: .05rem .4rem; font-size: .75rem; margin-left: .3rem; }

/* ── Dashboard cards ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.project-card { background: #fff; border: 1px solid var(--border, #D0D9E8); border-radius: var(--radius, 8px); padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; transition: box-shadow .15s; }
.project-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.project-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.project-name { font-size: 1rem; font-weight: 600; }
.project-name a { color: var(--text-main); text-decoration: none; }
.project-name a:hover { color: var(--primary, #0066CC); }
.project-desc { font-size: .85rem; color: var(--text-muted, #888); }
.project-stats { display: flex; gap: 1rem; }
.stat-item { text-align: center; }
.stat-num { display: block; font-size: 1.4rem; font-weight: 700; color: var(--primary, #0066CC); }
.stat-label { font-size: .75rem; color: var(--text-muted, #888); }
.project-card-actions { display: flex; gap: .5rem; margin-top: .25rem; }

/* ── Repeatable ── */
.repeatable-container { display: flex; flex-direction: column; gap: .75rem; }
.repeatable-row { border: 1px solid var(--border, #D0D9E8); border-radius: var(--radius, 8px); padding: 1rem; background: var(--surface, #F4F7FB); }
.repeatable-row-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.repeatable-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-card { background: #fff; border-radius: var(--radius, 8px); width: 520px; max-width: calc(95vw / var(--ui-zoom, 1)); max-height: calc(90vh / var(--ui-zoom, 1)); display: flex; flex-direction: column; }
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .75rem; }

/* ── Alerts ── */
.alert { padding: .75rem 1rem; border-radius: var(--radius, 8px); margin-bottom: 1rem; font-size: .9rem; }
.alert-warning { background: #fef9c3; color: #713f12; border: 1px solid #fde047; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.error-msg { color: #dc2626; font-size: .88rem; padding: .5rem .75rem; background: #fee2e2; border-radius: 4px; margin: .5rem 0; }
.success-msg { color: #166534; font-size: .88rem; padding: .5rem .75rem; background: #dcfce7; border-radius: 4px; margin: .5rem 0; }
.validation-errors { background: #fee2e2; border: 1px solid #fca5a5; border-radius: var(--radius, 8px); padding: .75rem 1rem; margin: 1rem 0; color: #991b1b; font-size: .88rem; }
.validation-errors ul { margin-top: .5rem; padding-left: 1.25rem; }

/* ── Schema-specific ── */
.schema-section-header { display: flex; align-items: center; gap: .75rem; padding: .75rem 0; margin-bottom: .75rem; }
.schema-section-header h3 { font-size: 1rem; }
.fhir-path { font-size: .75rem; color: var(--text-muted, #888); }
code { font-family: "Fira Code", "Consolas", monospace; font-size: .85em; background: var(--surface, #F4F7FB); padding: .1rem .3rem; border-radius: 3px; }

/* ── Misc ── */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: .5rem; }
.empty-state p { color: var(--text-muted, #888); margin-bottom: 1.25rem; }
.empty-state-inline { padding: 1.5rem; text-align: center; color: var(--text-muted, #888); font-size: .9rem; }
.loading-state { text-align: center; padding: 3rem; color: var(--text-muted, #888); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto 1rem; }

.json-viewer { background: #1e1e2e; color: #cdd6f4; padding: 1.25rem; border-radius: var(--radius, 8px); font-family: "Fira Code", monospace; font-size: .82rem; overflow-x: auto; white-space: pre; line-height: 1.6; max-height: 60vh; overflow-y: auto; }
.project-description { color: var(--text-muted); font-size: .9rem; margin-bottom: 1rem; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.meta-item { display: flex; flex-direction: column; gap: .2rem; }
.meta-label { font-size: .75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: calc(100vh / var(--ui-zoom, 1)); background: var(--surface, #F4F7FB); }
.login-container { width: 100%; max-width: 400px; padding: 1rem; }
.login-card { background: #fff; border: 1px solid var(--border, #D0D9E8); border-radius: var(--radius, 8px); padding: 2rem; }
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-icon { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.login-title { font-size: 1.5rem; font-weight: 700; color: var(--primary, #0066CC); }
.login-subtitle { color: var(--text-muted, #888); font-size: .9rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.btn-keycloak { margin-bottom: 1rem; border: 1px solid #376fd0; background: #fff; color: #2558a8; text-decoration: none; }
.btn-keycloak:hover { background: #eef5ff; }
.keycloak-mark { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 22px; padding: 0 6px; border-radius: 5px; background: #376fd0; color: #fff; font-size: .68rem; font-weight: 700; letter-spacing: .04em; }
.login-divider { display: flex; align-items: center; gap: .75rem; margin: .25rem 0 1.25rem; color: var(--text-muted, #888); font-size: .78rem; }
.login-divider::before,.login-divider::after { content: ""; height: 1px; flex: 1; background: var(--border, #D0D9E8); }
.sso-error { margin-bottom: 1rem; }

/* Theme grid */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 1rem; padding: .5rem 0; }
.theme-card { border: 2px solid var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; cursor: pointer; transition: all .15s; }
.theme-card:hover { border-color: var(--primary); }
.theme-selected { border-color: var(--primary, #0066CC); background: var(--primary-light, #E8F0FB); }
.theme-swatch { width: 48px; height: 48px; border-radius: 50%; border: 3px solid; margin: 0 auto .5rem; }
.theme-name { display: block; font-size: .85rem; font-weight: 500; }
.theme-check { display: block; color: var(--primary); font-size: 1.1rem; }

/* Form container */
.form-container { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.form-body { min-height: 400px; }
.section-panel { padding: .25rem 0; }

/* Animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.5; } }

.reference-card-detail { margin-top: 6px; color: var(--text-muted, #687386); white-space: pre-line; }
.fc-personal-text { margin: 8px 0; padding: 10px 0; border-bottom: 1px solid var(--border, #d7deeb); }
.fc-personal-text > label { display: inline-flex; align-items: center; gap: 6px; margin-right: 10px; }
