/**
 * public/styles.css
 * 画面用レスポンシブUI・トリアージ一覧・フォーム・3段グラフ・エラー診断モーダル ＆ A4縦1枚固定印刷CSS
 */

:root {
  --bg-page: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --ink-primary: #0f172a;
  --ink-secondary: #334155;
  --ink-muted: #64748b;
  --border-light: #e2e8f0;
  --border-std: #cbd5e1;
  --border-strong: #1e293b;

  --brand-primary: #1d4ed8;
  --brand-primary-hover: #1e40af;
  --brand-soft: #eff6ff;

  --sev-low-bg: #ecfdf5;
  --sev-low-ink: #065f46;
  --sev-low-bar: #10b981;

  --sev-mod-bg: #fffbeb;
  --sev-mod-ink: #92400e;
  --sev-mod-bar: #f59e0b;

  --sev-high-bg: #fff7ed;
  --sev-high-ink: #9a3412;
  --sev-high-bar: #ea580c;

  --sev-crit-bg: #fff1f2;
  --sev-crit-ink: #9f1239;
  --sev-crit-border: #be123c;
  --sev-crit-bar: #e11d48;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.07);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.09);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo", sans-serif;
  background-color: var(--bg-page);
  color: var(--ink-primary);
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-danger {
  color: var(--sev-crit-border) !important;
}

/* =========================================================
   1. トップヘッダー ＆ 共通ボタン
   ========================================================= */
.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 16px 40px;
}

.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-md);
}

.brand-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.18);
  color: #bae6fd;
  border: 1px solid rgba(125, 211, 252, 0.4);
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.app-title {
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.app-subtitle {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-top: 2px;
}

.app-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.active-patient-pill {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: #f8fafc;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  text-decoration: none;
  line-height: 1.25;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--brand-primary-hover);
}

.btn-secondary {
  background-color: #0f172a;
  color: #ffffff;
}

.btn-secondary:hover {
  background-color: #334155;
}

.btn-outline {
  background-color: #ffffff;
  color: var(--ink-primary);
  border-color: var(--border-std);
}

.btn-outline:hover {
  background-color: var(--bg-subtle);
  border-color: #94a3b8;
}

.btn-ghost {
  background-color: transparent;
  color: var(--ink-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background-color: #e2e8f0;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 7px 12px;
}

.btn-xs {
  font-size: 0.75rem;
  padding: 5px 9px;
}

.btn-block {
  width: 100%;
}

.btn-link-xs {
  background: none;
  border: none;
  color: var(--brand-primary);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

.file-upload-label {
  cursor: pointer;
  margin: 0;
}

/* =========================================================
   2. グローバル緊急レッドフラッグ ＆ 安全ロック常時表示バー
   ========================================================= */
.global-alert-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.global-alert-item {
  border-radius: var(--radius-md);
  padding: 11px 15px;
  box-shadow: var(--shadow-sm);
}

.global-alert-item.is-redflag {
  background-color: var(--sev-crit-bg);
  border: 2px solid var(--sev-crit-border);
  color: var(--sev-crit-ink);
}

.global-alert-item.is-safetylock {
  background-color: #fffbeb;
  border: 2px solid #d97706;
  color: #78350f;
}

.global-alert-title {
  font-size: 0.92rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.global-alert-body {
  font-size: 0.82rem;
  margin-top: 3px;
  font-weight: 600;
}

/* =========================================================
   3. 4タブ切り替えナビゲーション
   ========================================================= */
.tab-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
  background: #e2e8f0;
  padding: 5px;
  border-radius: var(--radius-md);
}

.tab-btn {
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-secondary);
  background: transparent;
  border: none;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.55);
}

.tab-btn.is-active {
  background: #ffffff;
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 999px;
  background: #cbd5e1;
  color: var(--ink-primary);
}

.tab-btn.is-active .tab-badge {
  background: var(--brand-primary);
  color: #ffffff;
}

/* =========================================================
   4. カード共通・CSVハブ・ステータストースト
   ========================================================= */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.card-header-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--ink-primary);
}

.card-desc {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: 3px;
}

.csv-hub-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.csv-action-grid,
.json-backup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.csv-box-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink-primary);
}

.csv-box-note {
  font-size: 0.77rem;
  color: var(--ink-muted);
  margin: 4px 0 10px;
}

.csv-btn-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.status-toast {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--brand-soft);
  border: 1px solid #93c5fd;
  color: #1e3a8a;
}

.status-toast.is-error {
  background: var(--sev-crit-bg);
  border-color: #fda4af;
  color: var(--sev-crit-ink);
}

/* =========================================================
   5. 緊急トリアージ一覧テーブル ＆ 3段階フィルタボタン
   ========================================================= */
.triage-panel-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.file-source-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  background: #e2e8f0;
  color: var(--ink-secondary);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

.triage-header-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.triage-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.triage-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-pill {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border-std);
  background: #ffffff;
  color: var(--ink-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-pill:hover {
  border-color: #64748b;
}

.filter-pill.is-active {
  background: var(--ink-primary);
  border-color: var(--ink-primary);
  color: #ffffff;
}

.filter-pill-critical.is-active {
  background: var(--sev-crit-border);
  border-color: var(--sev-crit-border);
  color: #ffffff;
}

.filter-pill-high.is-active {
  background: var(--sev-high-bar);
  border-color: var(--sev-high-bar);
  color: #ffffff;
}

.pill-count {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(15, 23, 42, 0.09);
}

.filter-pill.is-active .pill-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.triage-search-sort {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.table-scroll-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border-std);
  border-radius: var(--radius-sm);
}

.triage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 940px;
}

.triage-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f1f5f9;
  color: var(--ink-secondary);
  font-weight: 800;
  text-align: left;
  padding: 8px 9px;
  border-bottom: 2px solid var(--border-std);
  white-space: nowrap;
}

.triage-table tbody td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.triage-table tbody tr {
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.triage-table tbody tr:hover {
  background-color: #f8fafc;
}

.triage-table tbody tr.row-sev-critical {
  border-left: 4px solid var(--sev-crit-border);
  background-color: #fff5f7;
}

.triage-table tbody tr.row-sev-high {
  border-left: 4px solid var(--sev-high-bar);
  background-color: #fffaf5;
}

.triage-table tbody tr.is-selected-row {
  outline: 2px solid var(--brand-primary);
  outline-offset: -2px;
  background-color: #eff6ff !important;
}

.sev-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.73rem;
  font-weight: 800;
  white-space: nowrap;
}

.sev-pill.critical {
  background: var(--sev-crit-border);
  color: #ffffff;
}

.sev-pill.high {
  background: var(--sev-high-bar);
  color: #ffffff;
}

.sev-pill.moderate {
  background: #fef3c7;
  color: var(--sev-mod-ink);
  border: 1px solid #f59e0b;
}

.sev-pill.low {
  background: var(--sev-low-bg);
  color: var(--sev-low-ink);
  border: 1px solid #6ee7b7;
}

.rf-mini-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  margin: 1px 2px 1px 0;
  background: #ffe4e6;
  color: var(--sev-crit-ink);
  border: 1px solid #fda4af;
}

.lock-mini-tag {
  display: inline-block;
  font-size: 0.69rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin: 1px 2px 1px 0;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

/* =========================================================
   6. 2カラム入力ワークスペース・アコーディオン・フォーム要素
   ========================================================= */
.workspace-2col {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(350px, 1fr);
  gap: 16px;
  align-items: start;
}

.record-meta-bar {
  background: #f8fafc;
  border-color: var(--border-std);
}

.form-accordion {
  padding: 0;
  overflow: hidden;
}

.accordion-summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 18px;
  background: #f8fafc;
  border-bottom: 1px solid transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.accordion-summary::-webkit-details-marker {
  display: none;
}

.form-accordion[open] .accordion-summary {
  border-bottom-color: var(--border-light);
}

.section-step-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  background: var(--ink-primary);
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}

.accordion-title {
  font-size: 0.96rem;
  font-weight: 800;
  vertical-align: middle;
}

.accordion-sub {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

.accordion-chevron {
  font-size: 0.8rem;
  color: var(--ink-muted);
  transition: transform 0.15s ease;
}

.form-accordion[open] .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-body {
  padding: 15px 18px 18px;
}

.sub-heading {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink-secondary);
  border-left: 3px solid var(--brand-primary);
  padding-left: 8px;
  margin: 14px 0 9px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.accordion-body .sub-heading:first-child {
  margin-top: 0;
}

.form-grid {
  display: grid;
  gap: 11px;
  margin-bottom: 11px;
}

.form-grid:last-child {
  margin-bottom: 0;
}

.form-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-grid-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field-inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.form-input,
.form-select {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid var(--border-std);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--ink-primary);
}

.form-input:focus,
.form-select:focus {
  outline: 2px solid var(--brand-primary);
  border-color: var(--brand-primary);
}

.form-input-sm,
.form-select-sm {
  font-size: 0.82rem;
  padding: 6px 9px;
  width: auto;
}

.input-with-btn {
  display: flex;
  gap: 5px;
  align-items: stretch;
}

.input-with-btn .form-input {
  flex: 1;
  min-width: 0;
}

.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1px solid #94a3b8;
  background: #f1f5f9;
  color: var(--ink-secondary);
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}

.help-btn:hover {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}

.field-hint {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

/* 基礎疾患・薬剤チェックチップ */
.check-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.check-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--border-std);
  border-radius: var(--radius-sm);
  background: #ffffff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.check-chip:hover {
  background: var(--bg-subtle);
}

.check-chip input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-primary);
  flex-shrink: 0;
}

.profile-footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.profile-save-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ふくらはぎ周囲径ボックス ＆ 採血基準値パネル */
.calf-measure-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-std);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 12px;
}

.calf-measure-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  margin-bottom: 8px;
}

.calf-diff-badge {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  background: #e2e8f0;
  color: var(--ink-primary);
}

.calf-diff-badge.is-warn {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
}

.calf-diff-badge.is-danger {
  background: var(--sev-crit-bg);
  color: var(--sev-crit-ink);
  border: 1px solid var(--sev-crit-border);
}

.lab-panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 12px;
}

.lab-guide-note {
  font-size: 0.78rem;
  color: #0c4a6e;
  flex: 1;
  min-width: 240px;
}

.lab-field {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.lab-ref-text {
  font-size: 0.7rem;
  color: var(--ink-muted);
  line-height: 1.3;
}

/* =========================================================
   7. 右カラム：追従型7軸リスク結果パネル ＆ SBAR電話連絡メモ
   ========================================================= */
.result-sticky-card {
  position: sticky;
  top: 12px;
  border: 1.5px solid var(--border-std);
}

.result-top-banner {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--sev-low-bg);
  border: 1.5px solid #6ee7b7;
  color: var(--sev-low-ink);
}

.result-top-banner.level-moderate {
  background: var(--sev-mod-bg);
  border-color: #fbbf24;
  color: var(--sev-mod-ink);
}

.result-top-banner.level-high {
  background: var(--sev-high-bg);
  border-color: #fb923c;
  color: var(--sev-high-ink);
}

.result-top-banner.level-critical {
  background: var(--sev-crit-bg);
  border: 2px solid var(--sev-crit-border);
  color: var(--sev-crit-ink);
}

.result-severity-tag {
  font-size: 0.96rem;
  font-weight: 800;
}

.result-completeness {
  font-size: 0.74rem;
  margin-top: 2px;
  opacity: 0.9;
}

.result-primary-actions {
  display: grid;
  gap: 7px;
  margin-bottom: 10px;
}

.save-feedback-msg {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--sev-low-ink);
  background: var(--sev-low-bg);
  border: 1px solid #6ee7b7;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  text-align: center;
}

.kpi-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.kpi-mini-card {
  border: 1px solid var(--border-std);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  background: var(--bg-subtle);
}

.kpi-mini-card.is-alert {
  background: var(--sev-crit-bg);
  border-color: var(--sev-crit-border);
}

.kpi-mini-label {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-weight: 700;
}

.kpi-mini-val {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink-primary);
}

.kpi-mini-sub {
  display: block;
  font-size: 0.69rem;
  color: var(--ink-muted);
}

.derived-clinical-notes {
  font-size: 0.76rem;
  color: var(--ink-secondary);
  background: #f8fafc;
  border: 1px dashed var(--border-std);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  margin-bottom: 12px;
}

.domain-bars-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.domain-bars-title {
  font-size: 0.86rem;
  font-weight: 800;
}

.domain-bars-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.domain-bar-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.domain-bar-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.domain-bar-track {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.domain-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--sev-low-bar);
  transition: width 0.25s ease;
}

.domain-bar-fill.band-moderate {
  background: var(--sev-mod-bar);
}

.domain-bar-fill.band-high {
  background: var(--sev-high-bar);
}

.domain-bar-fill.band-critical {
  background: var(--sev-crit-bar);
}

.sbar-script-box {
  background: #f8fafc;
  border: 1px solid var(--border-std);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.sbar-script-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.sbar-script-hint {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.sbar-script-content {
  font-size: 0.8rem;
  line-height: 1.55;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 8px 10px;
  white-space: pre-wrap;
}

/* =========================================================
   8. タブ2：3段シンクロ熱型表グラフ ＆ 追従ツールチップ
   ========================================================= */
.trend-quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trend-controls-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.trend-period-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.trend-series-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.series-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--border-std);
  cursor: pointer;
  user-select: none;
}

.series-check input[type="checkbox"] {
  accent-color: var(--ink-primary);
}

.series-sepsis { border-left: 4px solid #e11d48; }
.series-uti { border-left: 4px solid #2563eb; }
.series-oral { border-left: 4px solid #059669; }
.series-hidden { border-left: 4px solid #d97706; }
.series-dvt { border-left: 4px solid #7c3aed; }
.series-noninf { border-left: 4px solid #0d9488; }

.trend-canvas-container {
  position: relative;
  width: 100%;
  height: 540px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 4px;
}

#trend-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-floating-tooltip {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  max-width: 280px;
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  font-size: 0.76rem;
  line-height: 1.45;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

/* =========================================================
   9. タブ3・タブ4：A4プレビュー操作バー ＆ 参考文献一覧カード
   ========================================================= */
.handoff-control-card {
  border-left: 4px solid var(--brand-primary);
}

.handoff-btn-group,
.ref-export-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ref-filter-bar {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ref-category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ref-search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ref-matched-toggle {
  padding: 6px 11px;
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e3a8a;
}

.ref-search-row .form-input-sm {
  flex: 1;
  min-width: 240px;
}

.ref-count-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink-secondary);
  white-space: nowrap;
}

.references-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.ref-card {
  border: 1px solid var(--border-std);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.ref-card.is-matched {
  border: 2px solid var(--brand-primary);
  background: #f8fbff;
  box-shadow: var(--shadow-sm);
}

.ref-card-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.ref-cat-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: var(--ink-secondary);
}

.ref-matched-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-primary);
  color: #ffffff;
}

.ref-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink-primary);
  line-height: 1.38;
  margin-top: 4px;
}

.ref-authors-journal {
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin-top: 3px;
}

.ref-summary {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  line-height: 1.5;
  margin-top: 6px;
}

.ref-rule-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.ref-rule-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border-std);
}

.ref-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-light);
  font-size: 0.76rem;
}

.ref-ext-link {
  color: var(--brand-primary);
  font-weight: 800;
  text-decoration: underline;
  word-break: break-all;
}

/* =========================================================
   10. 介護者支援モーダル3種（おむつ電卓・30秒呼吸・ヘルプ）
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-dialog {
  width: 100%;
  max-width: 520px;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 13px 16px;
  background: #0f172a;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-title {
  font-size: 0.96rem;
  font-weight: 800;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}

.modal-close-btn:hover {
  color: #ffffff;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
}

.modal-desc {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.calc-preview-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--brand-soft);
  border: 1.5px solid #93c5fd;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: #1e3a8a;
}

.calc-preview-sub {
  font-size: 0.8rem;
  margin-top: 4px;
  font-weight: 700;
}

.timer-display-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-std);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.timer-clock {
  font-size: 1.05rem;
  color: var(--ink-primary);
}

.timer-clock strong {
  font-size: 1.35rem;
  color: var(--brand-primary);
}

.timer-count-box {
  font-size: 0.86rem;
}

.btn-breath-tap {
  width: 100%;
  min-height: 82px;
  border-radius: var(--radius-md);
  border: 2px solid var(--brand-primary);
  background: #eff6ff;
  color: #1e3a8a;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 800;
  cursor: pointer;
  margin-bottom: 12px;
  transition: background-color 0.08s ease, transform 0.05s ease;
}

.btn-breath-tap:active {
  background: #dbeafe;
  transform: scale(0.99);
}

.timer-sub-btns {
  display: flex;
  gap: 8px;
}

.help-modal-text {
  font-size: 0.88rem;
  color: var(--ink-primary);
  line-height: 1.65;
  white-space: pre-wrap;
}

.modal-footer {
  padding: 11px 16px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* =========================================================
   11. 医師・救急共有シート（画面A4プレビュー ＆ 印刷共通構造）
   ※画面上ではタブ3（body.tab-handoff-active）のときのみ実寸表示
   ========================================================= */
.a4-sheet {
  display: none;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto 36px;
  padding: 8.5mm 9.5mm;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18);
  flex-direction: column;
  justify-content: space-between;
  gap: 2.2mm;
  font-size: 10px;
  line-height: 1.32;
}

body.tab-handoff-active .a4-sheet,
.a4-sheet.is-preview-visible {
  display: flex;
}

.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 1.6mm;
}

.doc-title {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.doc-subtitle {
  font-size: 8.8px;
  color: #475569;
  margin-top: 1px;
}

.doc-meta {
  text-align: right;
  font-size: 9px;
  line-height: 1.35;
  white-space: nowrap;
}

.triage-banner {
  border: 1.8px solid #1e293b;
  border-radius: 4px;
  padding: 2mm 2.8mm;
  background: #f8fafc;
}

.triage-banner.is-critical {
  border: 2.5px solid #be123c;
  background: #fff1f2;
}

.triage-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1mm;
}

.priority-badge {
  display: inline-block;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 800;
  border: 1.5px solid #0f172a;
  background: #ffffff;
}

.triage-banner.is-critical .priority-badge {
  background: #be123c;
  color: #ffffff;
  border-color: #be123c;
}

.triage-rf-codes {
  font-size: 9px;
  font-weight: 800;
}

.sbar-text {
  font-size: 9.4px;
  font-weight: 600;
}

.safety-lock-row {
  margin-top: 1.1mm;
  padding-top: 1.1mm;
  border-top: 1px dashed #be123c;
  font-size: 8.9px;
  font-weight: 700;
  color: #9f1239;
}

.grid-2col {
  display: grid;
  grid-template-columns: 49% 49.5%;
  justify-content: space-between;
  gap: 2mm;
}

.panel {
  border: 1px solid #94a3b8;
  border-radius: 4px;
  padding: 1.8mm 2.3mm;
}

.panel-title {
  font-size: 9.4px;
  font-weight: 800;
  background: #f1f5f9;
  margin: -1.8mm -2.3mm 1.5mm -2.3mm;
  padding: 1.1mm 2.3mm;
  border-bottom: 1px solid #94a3b8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.panel-title-sub {
  font-size: 8.4px;
  font-weight: 700;
  color: #334155;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5mm;
  margin-bottom: 1.5mm;
}

.kpi-box {
  border: 1px solid #cbd5e1;
  padding: 1mm 1.2mm;
  text-align: center;
  border-radius: 3px;
}

.kpi-box.alert {
  border: 1.8px solid #be123c;
  background: #fff1f2;
}

.kpi-label {
  font-size: 8px;
  color: #475569;
  display: block;
}

.kpi-val {
  font-size: 11.5px;
  font-weight: 800;
}

.kpi-sub {
  font-size: 7.5px;
  color: #475569;
  display: block;
}

.a4-meta-block {
  font-size: 8.6px;
  line-height: 1.35;
  border-top: 1px dotted #cbd5e1;
  padding-top: 1mm;
  margin-top: 1mm;
}

table.clinical-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 8.9px;
}

table.clinical-table th,
table.clinical-table td {
  border: 1px solid #cbd5e1;
  padding: 0.9mm 1.4mm;
  text-align: left;
}

table.clinical-table th {
  background: #f8fafc;
  font-weight: 800;
  color: #334155;
  font-size: 8.3px;
}

table.clinical-table td.abn {
  font-weight: 800;
  background: #fff1f2;
  border-color: #9f1239;
}

/* 白黒レーザープリンターでも識別できる7軸スコアハッチングバー */
.score-row {
  display: grid;
  grid-template-columns: 38mm 1fr 11mm;
  align-items: center;
  gap: 1.8mm;
  margin-bottom: 1.2mm;
  font-size: 8.8px;
}

.bar-track {
  height: 3mm;
  border: 1px solid #475569;
  background: #f8fafc;
  position: relative;
}

.bar-fill {
  height: 100%;
  background: #475569;
}

.bar-fill.high {
  background: repeating-linear-gradient(
    45deg,
    #be123c,
    #be123c 3px,
    #fecdd3 3px,
    #fecdd3 5px
  );
}

.bar-fill.crit {
  background: repeating-linear-gradient(
    -45deg,
    #881337,
    #881337 4px,
    #e11d48 4px,
    #e11d48 7px
  );
}

.finding-list {
  list-style: none;
  font-size: 8.7px;
  line-height: 1.34;
}

.finding-list li {
  padding: 0.65mm 0;
  border-bottom: 1px dotted #cbd5e1;
}

.finding-list li:last-child {
  border-bottom: none;
}

.tag-pos {
  display: inline-block;
  font-weight: 800;
  border: 1px solid #0f172a;
  padding: 0 3px;
  font-size: 7.8px;
  margin-right: 3px;
  background: #f1f5f9;
}

.tag-neg {
  color: #64748b;
  font-size: 8.4px;
}

.chart-box {
  border: 1px solid #94a3b8;
  border-radius: 4px;
  padding: 1.5mm 2.2mm;
}

.chart-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 0.8mm;
  font-size: 8.8px;
}

.chart-canvas-wrap {
  width: 100%;
  height: 49mm;
  position: relative;
}

#summary-trend-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#summary-trend-print-img {
  display: none;
  width: 100%;
  height: 49mm;
  object-fit: contain;
}

.doc-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 7.6px;
  color: #475569;
  border-top: 1px solid #cbd5e1;
  padding-top: 0.8mm;
}

/* =========================================================
   12. エラーコード・診断テキスト出力モーダル用スタイル
   ========================================================= */
.header-err-btn {
  background: #fff1f2;
  color: #9f1239;
  border-color: #fda4af;
}

.header-err-btn:hover {
  background: #ffe4e6;
  border-color: #be123c;
}

.modal-dialog-wide {
  max-width: 680px;
}

.modal-header-error {
  background: #881337;
}

.error-log-textarea {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  resize: vertical;
  white-space: pre;
  overflow: auto;
}

.toast-err-inline-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* =========================================================
   13. タブレット・スマートフォン用レスポンシブ調整
   ========================================================= */
@media screen and (max-width: 1100px) {
  .workspace-2col {
    grid-template-columns: 1fr;
  }

  .result-sticky-card {
    position: static;
  }

  .form-grid-5 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .references-grid {
    grid-template-columns: 1fr;
  }
}

@media screen and (max-width: 760px) {
  .app-shell {
    padding: 10px 10px 32px;
  }

  .tab-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .csv-action-grid,
  .json-backup-grid,
  .form-grid-4,
  .form-grid-3,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  .form-grid-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trend-canvas-container {
    height: 460px;
  }

  body.tab-handoff-active .a4-sheet {
    max-width: 100%;
    overflow-x: auto;
  }
}

/* =========================================================
   14. A4縦1枚厳密固定 ＠media print ルール
   ========================================================= */
@page {
  size: A4 portrait;
  margin: 7.5mm 8.5mm;
}

@media print {
  html,
  body {
    width: 210mm;
    height: 297mm;
    background: #ffffff !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  #screen-app-shell,
  .modal-backdrop,
  .chart-floating-tooltip {
    display: none !important;
  }

  #clinical-handoff-sheet.a4-sheet {
    display: flex !important;
    width: 100% !important;
    min-height: 280mm !important;
    max-height: 280mm !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .panel,
  .triage-banner,
  .chart-box {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  #summary-trend-canvas {
    display: none !important;
  }

  #summary-trend-print-img {
    display: block !important;
  }
}
