/* =====================================================================
 * 口腔機能低下症 管理アプリ  style.css
 * iPad タッチ前提：最小16px、タップ領域44px以上
 * ===================================================================== */
:root {
  --primary: #0a7ea4;
  --primary-d: #086380;
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #e2e8ee;
  --text: #1f2d3a;
  --muted: #7a8a99;
  --ok: #18a558;
  --ok-bg: #e6f7ee;
  --warn: #e23b3b;
  --warn-bg: #fdeaea;
  --yellow: #e6a700;
  --empty-glow: #fff7d6;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 16px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---- ヘッダー ---- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 14px 8px;
  background: var(--primary); color: #fff;
  min-height: 52px;
}
.hdr-back { display: none; } /* ナビバーに集約したため非表示 */
.hdr-title { font-size: 19px; font-weight: 700; flex: 1; }
.hdr-actions { display: flex; gap: 8px; }
.hdr-btn {
  background: rgba(255,255,255,.18); color: #fff; border: none;
  padding: 9px 14px; border-radius: 10px; font-size: 15px; min-height: 40px;
}
.hdr-btn.primary { background: #fff; color: var(--primary); font-weight: 700; }
.hdr-btn:active { opacity: .8; }

/* ---- ナビゲーションバー ---- */
.navbar {
  position: sticky; top: var(--hdr-h, 52px); z-index: 45;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 8px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.nav-left, .nav-right { display: flex; gap: 8px; align-items: center; }
.nav-btn {
  background: #eef3f6; color: var(--primary-d); border: none;
  padding: 9px 14px; border-radius: 10px; font-size: 15px; font-weight: 700; min-height: 42px;
}
.nav-btn:active { background: #e0ebf0; }
.nav-btn.undo { background: var(--warn-bg); color: var(--warn); }
.nav-btn.undo:active { background: #f7d4d4; }

/* ---- メイン ---- */
.app-main { padding: 14px; padding-bottom: 80px; max-width: 980px; margin: 0 auto; }

/* ---- 検索バー ---- */
.searchbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 200px; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.seg { display: flex; background: #e7edf2; border-radius: 12px; padding: 3px; }
.seg-btn { border: none; background: none; padding: 9px 16px; border-radius: 10px; font-size: 15px; color: var(--muted); min-height: 40px; }
.seg-btn.active { background: #fff; color: var(--primary); font-weight: 700; box-shadow: var(--shadow); }

/* 検査入力：前回値と差の表示 */
.test-prev { margin-top: 6px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.test-prev-label { font-weight: 700; }
.test-prev-diff { font-weight: 800; padding: 2px 10px; border-radius: 999px; background: #eef1f4; }
.test-prev-diff.better { background: var(--ok-bg); color: var(--ok); }
.test-prev-diff.worse { background: var(--warn-bg); color: var(--warn); }
.test-prev-diff.same { background: #eef1f4; color: var(--muted); }
.dev-aux-prev { padding-left: 2px; margin-bottom: 4px; }

/* 検査日エディタ */
.examdate-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.examdate-input { max-width: 200px; min-height: 42px; }

/* 算定記録 */
.billing-sec { background: var(--card); border: 1.5px solid #b9a23a; border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; margin: 10px 0; }
.billing-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0; }
.billing-row + .billing-row { border-top: 1px dashed var(--line); }
.billing-name { font-weight: 800; font-size: 14px; }
.billing-state { font-weight: 800; font-size: 13px; padding: 3px 10px; border-radius: 999px; }
.billing-state.done { background: var(--ok-bg); color: var(--ok); }
.billing-state.not { background: var(--warn-bg); color: var(--warn); }
.billing-prev { font-size: 12px; color: var(--muted); }
.billing-row .btn.tiny { margin-left: auto; }
.billing-state.wait { background: #eef1f4; color: var(--muted); }
/* 算定項目の設定エディタ */
.billing-edit-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.billing-edit-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fafcfd; }
.billing-edit-name { flex: 1 1 180px; min-width: 160px; }
.billing-edit-target { flex: 0 0 auto; width: auto; min-width: 130px; }
.billing-edit-cyclewrap { display: flex; align-items: center; gap: 4px; }
.billing-edit-cycle { width: 70px; text-align: right; }

/* 要再検査ワークリスト */
.worklist-btn { white-space: nowrap; }
.recall-table th, .recall-table td { padding: 7px 8px; }
.recall-table .recall-check { width: 40px; text-align: center; font-size: 16px; }

/* ダッシュボード（簡易統計） */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.dash-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; text-align: center; }
.dash-card.warn { border-color: var(--warn); background: var(--warn-bg); }
.dash-num { font-size: 32px; font-weight: 900; color: var(--primary-d); line-height: 1.1; }
.dash-card.warn .dash-num { color: var(--warn); }
.dash-klabel { font-size: 14px; font-weight: 700; margin-top: 4px; }
.dash-ksub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dash-section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 14px; }
.dash-sec-title { font-weight: 800; color: var(--primary-d); font-size: 15px; margin: 6px 0 10px; }
.dash-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.dash-row-label { display: flex; align-items: center; gap: 6px; min-width: 130px; font-size: 14px; font-weight: 700; }
.dash-row-n { min-width: 48px; text-align: right; font-weight: 800; font-size: 14px; }
.dash-bar { flex: 1; height: 14px; background: #eef1f4; border-radius: 999px; overflow: hidden; }
.dash-bar-fill { height: 100%; background: var(--primary); border-radius: 999px; min-width: 2px; }
.dash-bar-fill.warn { background: var(--warn); } .dash-bar-fill.ok { background: var(--ok); }
.dash-bar-fill.recover { background: #2a7de1; } .dash-bar-fill.neutral { background: #9aa6b2; }
.dash-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); flex: none; }
.dash-dot.warn { background: var(--warn); } .dash-dot.ok { background: var(--ok); }
.dash-dot.recover { background: #2a7de1; } .dash-dot.neutral { background: #9aa6b2; }

/* データ保護のおすすめカード */
.protect-hint { border: 1.5px solid var(--primary); background: #eef5f8; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.protect-hint-head { font-weight: 800; color: var(--primary-d); margin-bottom: 4px; }
.protect-hint-msg { font-size: 14px; line-height: 1.6; margin-bottom: 10px; }
.protect-hint-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* 設定：ストレージ保護ステータス */
.storage-status { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fafcfd; }
.storage-state { font-weight: 700; padding: 6px 10px; border-radius: 8px; margin: 4px 0; }
.storage-state.ok { background: var(--ok-bg); color: var(--ok); }
.storage-state.warn { background: var(--warn-bg); color: var(--warn); }
.home-steps { margin: 8px 0 4px 1.2em; line-height: 1.8; font-size: 14px; }
.home-steps li { margin-bottom: 4px; }

/* 患者一覧：絞り込み＋並び替えコントロール */
.list-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.seg-filter { flex-wrap: wrap; }
.seg-filter .seg-btn { padding: 9px 14px; font-size: 14px; }
.sort-row { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.sort-label { font-size: 13px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.sort-select { min-height: 40px; padding: 8px 10px; max-width: 180px; }
@media (max-width: 520px) {
  .sort-row { margin-left: 0; width: 100%; }
  .sort-select { flex: 1; max-width: none; }
}

/* ---- バックアップバー（ホーム最上部） ---- */
.backup-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.backup-bar.warn { background: var(--warn-bg); border-color: var(--warn); }
.backup-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.backup-alert { font-size: 22px; color: var(--warn); }
.backup-when { font-size: 15px; font-weight: 700; }
.backup-msg { font-size: 13px; color: var(--warn); font-weight: 700; margin-top: 2px; }
.backup-btn { white-space: nowrap; min-height: 44px; padding: 11px 18px; }

/* ---- バックアップ警告バナー（全画面共通） ---- */
.backup-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 190; display: flex; align-items: center; gap: 10px; background: #fff4e5; border-top: 2px solid var(--warn); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 8px rgba(0,0,0,.08); }
.backup-banner .bb-icon { font-size: 20px; color: var(--warn); }
.backup-banner .bb-msg { flex: 1; font-size: 14px; font-weight: 700; color: #8a4b00; }
.backup-banner .bb-do { background: var(--warn); color: #fff; border: none; border-radius: 10px; padding: 9px 14px; font-weight: 700; min-height: 40px; }
.backup-banner .bb-close { background: none; border: none; font-size: 24px; color: var(--muted); width: 40px; height: 40px; }

/* ---- 患者カード ---- */
.patient-list { display: flex; flex-direction: column; gap: 10px; }
.p-card {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.p-card:active { background: #f0f6f9; }
.p-name { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.p-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.p-card-side { text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.p-last { font-size: 14px; color: var(--text); }
.p-last.muted { color: var(--muted); }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.badge-red { background: var(--warn-bg); color: var(--warn); }
.badge-yellow { background: #fdf3d6; color: var(--yellow); }
.tag { font-size: 13px; padding: 3px 10px; border-radius: 999px; font-weight: 700; }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-recover { background: #e3f2fd; color: #1565c0; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; line-height: 1.8; }

/* ---- 生年月日入力（和暦＋西暦8桁） ---- */
.bd-input { display: flex; flex-direction: column; gap: 8px; }
.bd-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bd-lab { font-size: 13px; color: var(--muted); white-space: nowrap; }
.bd-input input.bd-digits { flex: 1; min-width: 140px; letter-spacing: 2px; font-size: 18px; }
.bd-or { font-size: 13px; color: var(--muted); }
.bd-input select.bd-era { flex: none; width: 78px; min-width: 78px; padding-left: 8px; padding-right: 8px; }
.bd-input input.bd-num { width: 58px; min-width: 58px; flex: none; text-align: center; padding-left: 6px; padding-right: 6px; }
.bd-unit { font-size: 14px; color: var(--text); margin-right: 2px; }
.bd-preview { font-size: 14px; font-weight: 700; min-height: 18px; color: var(--muted); }
.bd-preview.ok { color: var(--primary-d); }
.bd-preview.warn { color: var(--warn); }

/* 指導文テンプレ：反映ボタン群 */
.guide-tmpl-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

/* バージョン表示（更新反映の確認用） */
.ver-badge { display: inline-block; margin-left: 10px; padding: 1px 8px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; vertical-align: middle; }
.ver-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ver-line { font-size: 12px; color: var(--muted); }

/* ---- フォーム ---- */
.form { display: flex; flex-direction: column; gap: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }
.field-label { font-weight: 700; font-size: 15px; }
.req { color: var(--warn); }
.field-hint { font-size: 13px; color: var(--muted); }
.inp {
  padding: 12px 14px; font-size: 16px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; width: 100%;
}
.inp:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.inp[readonly] { background: #f1f4f7; color: var(--muted); }

.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }
.choice {
  border: 1.5px solid var(--line); background: #fff; color: var(--text);
  padding: 11px 22px; border-radius: 12px; font-size: 16px; min-height: 44px; min-width: 64px;
}
.choice.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }

.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 6px; }
.danger-zone { border-top: 1px dashed var(--line); padding-top: 16px; margin-top: 6px; }

/* ---- ボタン ---- */
.btn { border: none; padding: 13px 22px; border-radius: 12px; font-size: 16px; font-weight: 700; min-height: 48px; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-d); }
.btn.ghost { background: #eef3f6; color: var(--primary); }
.btn.danger { background: var(--warn); color: #fff; }
.btn.danger-outline { background: #fff; color: var(--warn); border: 1.5px solid var(--warn); }
.btn.full { width: 100%; margin: 10px 0; }
.btn:active { opacity: .85; }
/* PDF提示モーダル（アンカーをボタン表示） */
a.btn { display: inline-block; text-align: center; text-decoration: none; box-sizing: border-box; }
.pdf-present { display: flex; flex-direction: column; gap: 4px; }
.pdf-present-msg { font-size: 14px; color: var(--muted); line-height: 1.6; margin: 0 0 6px; }
.pdf-present .pdf-open { font-size: 16px; padding: 14px; min-height: 52px; }

/* ---- 写真 ---- */
.photo-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.photo-thumb { position: relative; width: 90px; height: 90px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-del {
  position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff; border: none; font-size: 16px; line-height: 1;
}

/* ---- 患者詳細 ---- */
.detail-head { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.detail-name { font-size: 22px; font-weight: 800; }
.detail-meta { color: var(--muted); margin-top: 4px; font-size: 14px; }

.collap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow); }
.collap-head { width: 100%; text-align: left; background: none; border: none; padding: 14px 16px; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; min-height: 50px; }
.collap-head-action { margin-left: auto; flex: none; font-size: 13px; font-weight: 700; color: var(--primary-d); background: #eef5f8; border: 1.5px solid var(--primary); border-radius: 999px; padding: 6px 12px; white-space: nowrap; cursor: pointer; }
.collap-head-action:active { background: var(--primary); color: #fff; }
.collap-arrow { transition: transform .15s; color: var(--primary); }
.collap.open .collap-arrow { transform: rotate(90deg); }
.collap-body { display: none; padding: 0 16px 14px; }
.collap.open .collap-body { display: block; }

.tl-row { display: flex; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 15px; }
.tl-date { color: var(--primary); font-weight: 700; white-space: nowrap; }
.tl-title { font-weight: 600; }
.tl-note { color: var(--muted); }

.med-row { padding: 10px 0; border-top: 1px solid var(--line); }
.med-name { font-weight: 600; font-size: 16px; }
.med-detail { display: none; font-size: 14px; color: var(--muted); margin-top: 4px; padding-left: 6px; }
.med-row.open .med-detail { display: block; }

.section-title { font-size: 17px; font-weight: 800; margin: 18px 4px 10px; }
.session-list { display: flex; flex-direction: column; gap: 10px; }
.session-card { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.session-card:active { background: #f0f6f9; }
.session-card-body { flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0; }
.session-del { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--warn); background: #fff; color: var(--warn); font-size: 18px; line-height: 1; cursor: pointer; }
.session-del:active { background: var(--warn-bg); }
.session-date { font-size: 17px; font-weight: 700; }
.session-sub { color: var(--muted); font-size: 14px; }
.session-side { text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.session-count { font-size: 14px; color: var(--muted); }

/* ---- トースト ---- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(31,45,58,.95); color: #fff; padding: 13px 22px; border-radius: 12px;
  font-size: 15px; z-index: 200; box-shadow: var(--shadow); max-width: 80%; text-align: center;
}

/* ---- モーダル ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 150; padding: 20px; }
.modal-box { background: #fff; border-radius: 16px; max-width: 520px; width: 100%; max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-box.wide { max-width: 800px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 18px; font-weight: 800; }
.modal-close { background: none; border: none; font-size: 30px; line-height: 1; width: 44px; height: 44px; color: var(--muted); }
.modal-body { padding: 18px; overflow: auto; }
.modal-img { width: 100%; border-radius: 10px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 18px; }
.confirm-msg { font-size: 16px; line-height: 1.7; }

/* ---- Undoバー ---- */
.undo-bar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: #fff; display: flex; align-items: center; gap: 16px; padding: 12px 18px; border-radius: 12px; z-index: 180; box-shadow: var(--shadow); }
.undo-bar button { background: none; border: none; color: #6fd3ff; font-weight: 700; font-size: 15px; }

/* ---- PINロック ---- */
.pin-lock { position: fixed; inset: 0; background: var(--primary); display: flex; align-items: center; justify-content: center; z-index: 500; }
.pin-box { text-align: center; color: #fff; }
.pin-title { font-size: 20px; font-weight: 700; margin-bottom: 24px; }
.pin-dots { display: flex; gap: 18px; justify-content: center; margin-bottom: 30px; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; }
.pin-dot.filled { background: #fff; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px; justify-content: center; }
.pin-key { width: 76px; height: 76px; border-radius: 50%; border: none; background: rgba(255,255,255,.18); color: #fff; font-size: 28px; }
.pin-key:active { background: rgba(255,255,255,.35); }
.pin-error { color: #ffd2d2; margin-top: 18px; min-height: 20px; }

/* ---- 未入力グロー（淡く光らせる） ---- */
.empty-glow { background: var(--empty-glow) !important; box-shadow: 0 0 0 2px #ffe9a3 inset; }

/* ---- 値の正常/異常フィードバック ---- */
.val-ok { color: var(--ok); }
.val-warn { color: var(--warn); }
.inp.is-ok { border-color: var(--ok); background: var(--ok-bg); }
.inp.is-warn { border-color: var(--warn); background: var(--warn-bg); }

/* =====================================================================
 *  検査入力画面
 * ===================================================================== */
.exam-patientbar { display: flex; align-items: baseline; gap: 12px; padding: 4px 2px 10px; flex-wrap: wrap; }
.exam-pname { font-size: 20px; font-weight: 800; }
.exam-pmeta { color: var(--muted); font-size: 14px; }

.staff-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.staff-label { font-weight: 700; }
.staff-select { max-width: 360px; }
.staff-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.staff-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--primary); color: #fff; border-radius: 999px; padding: 6px 8px 6px 14px; font-size: 15px; font-weight: 700; }
.staff-chip .chip-x { background: rgba(255,255,255,.25); border: none; color: #fff; width: 24px; height: 24px; border-radius: 50%; font-size: 15px; line-height: 1; }
.staff-pick-list { display: flex; flex-direction: column; gap: 8px; }
.staff-pick-item { text-align: left; background: #eef4f7; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 16px; color: var(--text); min-height: 48px; }
.staff-pick-item:active { background: #e0edf2; }

/* 該当サマリー（sticky） */
.exam-summary {
  position: sticky; top: calc(var(--hdr-h, 52px) + var(--nav-h, 48px)); z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ok-bg); border: 1.5px solid var(--ok);
  border-radius: var(--radius); padding: 12px 18px; margin-bottom: 14px;
}
.exam-summary.declined { background: var(--warn-bg); border-color: var(--warn); }
.sum-count { font-size: 22px; font-weight: 900; }
.sum-judge { font-size: 17px; font-weight: 800; padding: 4px 14px; border-radius: 999px; }
.sum-judge.ok { background: var(--ok); color: #fff; }
.sum-judge.warn { background: var(--warn); color: #fff; }

.exam-area { display: flex; flex-direction: column; gap: 12px; }

/* カテゴリカード */
.cat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cat-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: #eef4f7; border-bottom: 1px solid var(--line); }
.cat-name { font-size: 17px; font-weight: 800; }
.cat-status { font-size: 13px; font-weight: 700; padding: 3px 12px; border-radius: 999px; }
.cat-status.warn { background: var(--warn-bg); color: var(--warn); }
.cat-status.ok { background: var(--ok-bg); color: var(--ok); }
.cat-status.none { background: #eef1f4; color: var(--muted); }
.cat-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 18px; }

.test-block { display: flex; flex-direction: column; gap: 8px; }
.test-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.help-icon { width: 26px; height: 26px; border-radius: 50%; border: none; background: #d9e6ec; color: var(--primary); font-weight: 800; font-size: 14px; flex: none; }
.help-text { font-size: 16px; line-height: 1.8; white-space: pre-wrap; }

/* その他の検査方法（折りたたみ） */
.test-more { border-top: 1px dashed var(--line); padding-top: 6px; }
.test-more-head { width: 100%; text-align: left; background: none; border: none; padding: 10px 4px; font-size: 14px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 8px; min-height: 44px; }
.test-more-head .collap-arrow { transition: transform .15s; }
.test-more.open .test-more-head .collap-arrow { transform: rotate(90deg); }
.test-more-body { display: none; flex-direction: column; gap: 18px; padding: 6px 0 4px; }
.test-more.open .test-more-body { display: flex; }

.inline-input { display: flex; align-items: center; gap: 8px; }
.num-inp { max-width: 160px; text-align: right; }
.num-inp.small { max-width: 90px; padding: 10px; }
.unit { color: var(--muted); font-size: 15px; }
.test-fb { font-size: 14px; font-weight: 700; }

.level-row { display: flex; gap: 10px; flex-wrap: wrap; padding: 4px; border-radius: 12px; }
.level-btn { width: 52px; height: 52px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-size: 19px; font-weight: 700; color: var(--text); }
.level-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.level-row.row-warn .level-btn.active { background: var(--warn); border-color: var(--warn); }
.level-row.row-ok .level-btn.active { background: var(--ok); border-color: var(--ok); }

/* 複数回測定 */
.multi-label, .multi-wrap .multi-label { font-size: 14px; color: var(--muted); }
.multi-inputs { display: flex; gap: 10px; margin: 6px 0; }
.adopted-box { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: #f1f4f7; flex-wrap: wrap; }
.adopted-box.warn { background: var(--warn-bg); }
.adopted-box.ok { background: var(--ok-bg); }
.adopted-label { font-size: 14px; color: var(--muted); }
.adopted-val { font-size: 20px; font-weight: 800; }
.adopted-judge { font-weight: 800; }
.adopted-box.warn .adopted-judge { color: var(--warn); }
.adopted-box.ok .adopted-judge { color: var(--ok); }

/* ODK */
.odk-row { display: flex; gap: 14px; }
.odk-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.odk-syl { font-weight: 800; font-size: 16px; color: var(--primary); }
.odk-device, .mini-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.mini-label { font-size: 14px; color: var(--muted); }
.chip { border: 1.5px solid var(--line); background: #fff; padding: 8px 16px; border-radius: 999px; font-size: 15px; min-height: 40px; color: var(--text); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }

/* TCI 舌イラスト */
.tci-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tci-result { display: flex; align-items: center; gap: 14px; padding: 8px 18px; border-radius: 12px; background: #f1f4f7; }
.tci-result.warn { background: var(--warn-bg); }
.tci-result.ok { background: var(--ok-bg); }
.tci-total { font-size: 16px; color: var(--muted); }
.tci-percent { font-size: 28px; font-weight: 900; }
.tci-judge { font-weight: 800; }
.tci-result.warn .tci-judge { color: var(--warn); }
.tci-result.ok .tci-judge { color: var(--ok); }
.tci-tongue {
  background: linear-gradient(#ffd6d9, #ffb3bb); border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%;
  padding: 26px 22px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: inset 0 -8px 16px rgba(0,0,0,.08);
}
.tci-label { font-size: 12px; color: #9a4a52; font-weight: 700; }
.tci-grid { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 64px); gap: 6px; }
.tci-cell { border-radius: 10px; border: 2px solid rgba(255,255,255,.7); font-size: 20px; font-weight: 800; color: #6b3338; background: rgba(255,255,255,.55); }
.tci-cell.s0 { background: rgba(255,255,255,.55); color: #b06a70; }
.tci-cell.s1 { background: #ffe08a; color: #7a5b00; }
.tci-cell.s2 { background: var(--warn); color: #fff; }
.tci-help { font-size: 13px; color: var(--muted); }

/* 質問紙 */
.quiz-wrap { display: flex; flex-direction: column; gap: 12px; }
.quiz-q { border-top: 1px solid var(--line); padding-top: 10px; }
.quiz-qtext { font-size: 15px; margin-bottom: 8px; }
.quiz-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.quiz-opt { min-width: 48px; height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-size: 17px; font-weight: 700; color: var(--text); padding: 0 12px; }
.quiz-opt.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.quiz-opt.abc-opt { font-size: 14px; }
.quiz-opt.a.active { background: var(--warn); border-color: var(--warn); }
.quiz-total { font-weight: 800; font-size: 16px; padding: 10px 14px; border-radius: 12px; background: #f1f4f7; }
.quiz-total.warn { background: var(--warn-bg); color: var(--warn); }
.quiz-total.ok { background: var(--ok-bg); color: var(--ok); }

/* 全身/口腔/疾患/薬剤エディタ内 */
.collap-body .field { margin-bottom: 14px; }
.inline-detail { align-items: center; flex-wrap: wrap; }
.num-mini { display: inline-flex; align-items: center; gap: 4px; }
.prev-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.check-chip { border: 1.5px solid var(--line); background: #fff; padding: 10px 18px; border-radius: 12px; font-size: 15px; min-height: 44px; color: var(--text); }
.check-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }

.med-edit-list { display: flex; flex-direction: column; margin-bottom: 10px; }
.med-edit-row { border-top: 1px solid var(--line); padding: 8px 0; }
.med-edit-main { display: flex; justify-content: space-between; align-items: center; }
.med-edit-detail { display: none; font-size: 14px; color: var(--muted); margin-top: 6px; }
.med-edit-row.open .med-edit-detail { display: block; }

.suggest-box { border: 1px solid var(--line); border-radius: 10px; margin-top: 4px; overflow: hidden; }
.suggest-box:empty { display: none; }
.suggest-item { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 15px; }
.suggest-item:active { background: #eef4f7; }

.tl-list { display: flex; flex-direction: column; margin-bottom: 10px; }
.tl-del, .tl-row .tl-del { margin-left: auto; width: 28px; height: 28px; border-radius: 50%; border: none; background: #eef1f4; color: var(--muted); font-size: 16px; }
.tl-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tl-add .inp { flex: 1; min-width: 120px; }
.inp.small { max-width: 170px; }

/* =====================================================================
 *  結果・指導画面
 * ===================================================================== */
.result-summary { border-radius: var(--radius); padding: 18px; text-align: center; margin-bottom: 14px; box-shadow: var(--shadow); }
.result-summary.ok { background: var(--ok-bg); border: 1.5px solid var(--ok); }
.result-summary.declined { background: var(--warn-bg); border: 1.5px solid var(--warn); }
.result-summary.recovered { background: #e3f2fd; border: 1.5px solid #1565c0; }
.rs-count { font-size: 30px; font-weight: 900; }
.rs-judge { font-size: 17px; font-weight: 700; margin-top: 4px; }
.result-summary.ok .rs-judge { color: var(--ok); }
.result-summary.declined .rs-judge { color: var(--warn); }
.result-summary.recovered .rs-judge { color: #1565c0; }
.rs-note { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.6; }

/* 回復（治癒）バナー（計画書情報） */
.recover-banner { background: #e3f2fd; border: 1.5px solid #90caf9; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.recover-head { font-weight: 800; color: #1565c0; font-size: 15px; }
.recover-sub { font-size: 13px; margin-top: 4px; line-height: 1.6; }

.mode-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.mode-label { font-weight: 700; }
.mode-seg { flex-wrap: wrap; }
.mode-hint { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

.guide-list { display: flex; flex-direction: column; gap: 10px; }
.guide-row { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.guide-row.applicable { border-color: #f3b9b9; }
.guide-row.notdone { opacity: .6; }
.guide-row.dragging { opacity: .5; border-style: dashed; }
.drag-handle { font-size: 24px; color: var(--muted); cursor: grab; padding: 0 4px; align-self: center; touch-action: none; user-select: none; }
.guide-check { flex: none; width: 38px; height: 38px; border-radius: 10px; border: 2px solid var(--line); background: #fff; color: #fff; font-size: 20px; font-weight: 900; align-self: center; }
.guide-check.on { background: var(--primary); border-color: var(--primary); }
.guide-check:disabled { opacity: .35; }
.guide-main { flex: 1; }
.guide-head { display: flex; align-items: center; gap: 10px; }
.guide-name { font-size: 17px; font-weight: 800; }
.tag-none { background: #eef1f4; color: var(--muted); }
.guide-val { font-size: 14px; color: var(--text); margin-top: 4px; }
.guide-tmpl { margin-top: 10px; background: #f5f9fb; border-left: 3px solid var(--primary); border-radius: 8px; padding: 10px 12px; }
.guide-tmpl-label { font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.guide-tmpl-text { font-size: 15px; line-height: 1.7; white-space: pre-wrap; }

.guide-note-intro { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
/* 指導文エントリ（結果・指導画面） */
.guide-entry { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 10px; background: #fafcfd; }
.guide-entry.on { border-color: var(--primary); background: #eef6fa; }
.guide-entry-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.guide-entry-title { font-size: 16px; font-weight: 800; }
/* 設定：指導文テンプレートエディタ */
.guide-tmpl-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.gt-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.gt-title { flex: 1; font-weight: 700; }
.guide-applicable { display: flex; flex-direction: column; gap: 10px; }

/* 備考（患者別メモ） */
.guide-noteblock { margin-top: 10px; }
.guide-note-label { font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.guide-note-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.guide-note-row .guide-note-label { margin-bottom: 0; }
.guide-note-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* インライン操作ボタン（テンプレ反映・前回コピー）— iPadで押しやすい高コントラスト */
.btn-chip { border: none; border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 700; min-height: 40px; white-space: nowrap; }
.btn-chip:active { opacity: .85; }
.btn-chip.tmpl { background: var(--primary); color: #fff; }
.btn-chip.tmpl:active { background: var(--primary-d); }
.btn-chip.prev { background: #fff; color: var(--primary-d); border: 1.5px solid var(--primary); }
.btn-chip.prev:active { background: #e6f1f6; }
.guide-note { width: 100%; resize: vertical; min-height: 56px; }
.guide-prevnote { margin-top: 8px; background: #f1f4f7; border-radius: 8px; padding: 8px 10px; }
.guide-prevnote-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.guide-prevnote-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.guide-prevnote-text { font-size: 14px; line-height: 1.6; white-space: pre-wrap; color: var(--text); }
.btn.tiny { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 9px; }

/* 計画書情報 */
.plan-info { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-top: 14px; }
.plan-info .section-title { margin: 0 0 12px; }
.plan-info .field { margin-bottom: 14px; }
.change-box { background: #f5f9fb; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 14px; }
.change-title { font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.change-item { display: flex; gap: 8px; align-items: center; font-size: 14px; padding: 3px 0; }
.change-tag { flex: none; background: var(--muted); color: #fff; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.change-tag.worse { background: var(--warn); }
.change-tag.better { background: #1565c0; }

/* 前回参照＋コピー（共通） */
.prevref { margin-top: 8px; background: #f1f4f7; border-radius: 8px; padding: 8px 10px; }
.prevref-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.prevref-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.prevref-text { font-size: 14px; line-height: 1.6; white-space: pre-wrap; color: var(--text); }
.prevref-text.muted { color: var(--muted); }

/* BMI */
.bmi-row { align-items: center; gap: 12px; }
.bmi-val { font-size: 18px; font-weight: 800; padding: 4px 12px; border-radius: 8px; background: #eef1f4; }
.bmi-val.ok { background: var(--ok-bg); color: var(--ok); }
.bmi-val.warn { background: var(--warn-bg); color: var(--warn); }
.bmi-class-row { margin-top: 2px; }

/* 栄養評価フラグ（下腿周囲長・体重減少） */
.flag-box { margin-top: 6px; font-size: 13px; font-weight: 700; line-height: 1.5; }
.flag-box:empty { display: none; }
.flag-ok { color: var(--ok); }
.flag-caution { color: #b8860b; }
.flag-warn { color: var(--warn); }

/* 指導・動機付けメモ */
.care-add { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.care-add-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.care-add-row .inp { flex: 1; min-width: 130px; }
.care-typerow { flex-wrap: wrap; }
.care-type { background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.care-staff { color: var(--muted); font-size: 13px; white-space: nowrap; }
.tl-row.careitem { align-items: center; flex-wrap: wrap; }
.tl-row.careitem .tl-note { color: var(--text); flex: 1; min-width: 140px; }

/* その他の項目タブ */
.other-guide { margin-top: 12px; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); overflow: hidden; }
.other-guide-head { width: 100%; text-align: left; background: #eef1f4; border: none; padding: 14px 16px; font-size: 15px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 10px; min-height: 50px; }
.other-guide-head .collap-arrow { color: var(--muted); transition: transform .15s; }
.other-guide.open .other-guide-head .collap-arrow { transform: rotate(90deg); }
.other-guide-body { display: none; flex-direction: column; gap: 10px; padding: 12px; }
.other-guide.open .other-guide-body { display: flex; }

/* =====================================================================
 *  設定画面
 * ===================================================================== */
.logo-prev { max-width: 200px; max-height: 90px; border: 1px solid var(--line); border-radius: 8px; display: block; margin-bottom: 8px; }

.thr-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.thr-label { font-size: 15px; }
.thr-hint { font-size: 12px; color: var(--muted); }
.thr-row .num-inp { max-width: 110px; }

.agg-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.agg-title { font-weight: 800; margin-bottom: 8px; }
.agg-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.agg-lab { font-size: 14px; color: var(--muted); min-width: 120px; }
.agg-row .inp { max-width: 200px; }

.fav-group { padding: 8px 0; border-top: 1px solid var(--line); }
.fav-cat { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.fav-group .check-chip { margin: 0 8px 8px 0; }

.desc-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.desc-title { font-weight: 700; margin-bottom: 8px; }

.master-title { font-weight: 800; margin: 12px 0 6px; }
.master-list { display: flex; flex-direction: column; }
.master-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.master-name { flex: 1; font-size: 15px; }
.master-row .inp.small { max-width: 160px; }

/* 小型折りたたみ項目（見出しだけ並べる） */
.item-collap { border: 1.5px solid #cdd9e0; border-radius: 12px; background: #fff; overflow: hidden; box-shadow: 0 1px 3px rgba(20,50,70,.07); margin-bottom: 10px; }
.item-collap-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; min-height: 52px; cursor: pointer; background: #eef5f8; border-left: 4px solid var(--primary); }
.item-collap-head:active { background: #e2eef3; }
.item-collap.open .item-collap-head { background: var(--primary); border-left-color: var(--primary-d); }
.item-collap.open .ic-title, .item-collap.open .ic-sub { color: #fff; }
.item-collap-head .ic-arrow { transition: transform .15s; color: var(--primary); flex: none; font-size: 18px; }
.item-collap.open .ic-arrow { transform: rotate(90deg); color: #fff; }
.ic-title { font-weight: 800; flex: 1; min-width: 0; font-size: 15px; }
.ic-sub { font-size: 12px; color: var(--muted); white-space: nowrap; background: rgba(255,255,255,.7); padding: 2px 8px; border-radius: 999px; }
.item-collap.open .ic-sub { background: rgba(255,255,255,.22); }
.item-collap-body { display: none; padding: 12px 14px 14px; border-top: 1.5px solid #e3edf2; }
.item-collap.open .item-collap-body { display: block; }

/* 検査項目の編集（大分類カード） */
.cat-edit-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.cat-edit-card.dragging { opacity: .5; border-style: dashed; }
.cat-edit-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cat-edit-name { flex: 1; font-weight: 800; }
.test-edit-row { border: 1.5px solid #d8e2e8; border-radius: 10px; background: #f7fafb; padding: 10px 12px; margin-bottom: 10px; }
.test-edit-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.test-edit-name { font-weight: 700; font-size: 15px; }
.test-edit-row .thr-row { border-top: none; padding: 4px 0; }
.agg-inline { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.agg-inline .inp.small { max-width: 110px; }
.cat-edit-add { margin-top: 8px; }
.cat-edit-add .inp { max-width: 280px; }

.test-edit-name-input { max-width: 240px; font-weight: 700; }
/* 検査説明の折りたたみ（項目編集内） */
.desc-collap { margin-top: 8px; border-top: 1px dashed var(--line); }
.desc-collap-head { width: 100%; text-align: left; background: none; border: none; padding: 8px 2px; font-size: 13px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 8px; min-height: 40px; }
.desc-collap-head .collap-arrow { transition: transform .15s; }
.desc-collap.open .desc-collap-head .collap-arrow { transform: rotate(90deg); }
.desc-collap-body { display: none; flex-direction: column; gap: 8px; padding: 4px 0 8px; }
.desc-collap.open .desc-collap-body { display: flex; }

/* 順番変更モーダル */
.order-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.order-item { display: flex; align-items: center; gap: 10px; background: #f5f9fb; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.order-item.dragging { opacity: .5; border-style: dashed; }
.order-name { flex: 1; font-weight: 700; }
.order-count { font-size: 13px; }

.staff-editor { margin-bottom: 16px; }
.staff-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.staff-item { display: flex; align-items: center; gap: 8px; }
.staff-item.dragging { opacity: .5; }
.staff-item .inp { flex: 1; }

/* =====================================================================
 *  帳票（計画書プレビュー / PDF）
 * ===================================================================== */
.doc-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.doc-seg { flex-wrap: wrap; }
.doc-hint { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.doc-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.doc-controls .doc-hint { margin-bottom: 0; }
.doc-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; background: #eef4f7; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-height: 44px; }
.doc-toggle input { width: 22px; height: 22px; }

.doc-prevlabel { font-weight: 700; font-size: 14px; color: var(--muted); align-self: center; }
.out-bar { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 12px; }
.out-label { font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.out-checks { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.out-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.out-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }

.print-doc { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.doc-break { break-after: page; page-break-after: always; }
/* A4 1ページに収める印刷（画像化）— 画面では幅に合わせて縮小表示 */
.print-img-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.print-img { max-width: 100%; height: auto; display: block; box-shadow: var(--shadow); }
/* A4プレビュー（印刷時の見た目）：210×297mm相当 */
.doc-page.a4 { width: 794px; min-height: 1123px; max-width: 794px; padding: 45px 53px; box-sizing: border-box; }
.a4-frame { width: 100%; display: flex; justify-content: center; overflow: hidden; }
.doc-page { background: #fff; width: 100%; max-width: 760px; padding: 24px 28px; border: 1px solid var(--line); box-shadow: var(--shadow); color: #1a1a1a; font-size: 13px; }
.doc-clinic-row { display: flex; align-items: center; gap: 12px; }
.doc-logo { max-height: 48px; max-width: 160px; }
.doc-clinic { font-size: 15px; font-weight: 700; }
.doc-title { text-align: center; font-size: 22px; font-weight: 800; margin: 8px 0 14px; letter-spacing: 2px; border-bottom: 2px solid #333; padding-bottom: 8px; }
.doc-patient { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.doc-patient th, .doc-patient td { border: 1px solid #999; padding: 6px 10px; text-align: left; font-size: 13px; }
.doc-patient th { background: #f0f3f5; width: 90px; white-space: nowrap; }

.doc-h2 { font-size: 15px; font-weight: 800; margin: 16px 0 6px; padding-left: 8px; border-left: 4px solid var(--primary); }
.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.doc-table th, .doc-table td { border: 1px solid #999; padding: 6px 8px; font-size: 12px; vertical-align: top; }
.doc-table th { background: #f0f3f5; }
.doc-table-2 td, .doc-table-2 th { white-space: nowrap; }
.cell-vals { line-height: 1.6; }
.cell-warn { color: var(--warn); font-weight: 700; }
.cell-ok { color: var(--ok); }
.cell-better { color: #1565c0; font-weight: 700; }
.cell-strong { font-weight: 800; }
.doc-table .muted { color: #999; }

/* 初回（経過判定なし）の案内 */
.init-note { background: #f1f5f8; border: 1px dashed #c2d0d8; border-radius: 8px; padding: 9px 12px; font-size: 14px; color: var(--muted); }

.doc-judge { padding: 8px 12px; border: 1.5px solid; border-radius: 6px; margin: 8px 0 4px; font-size: 14px; }
.doc-judge.ok { border-color: var(--ok); background: var(--ok-bg); }
.doc-judge.warn { border-color: var(--warn); background: var(--warn-bg); }
.doc-box { border: 1px solid #999; min-height: 48px; padding: 8px 10px; white-space: pre-wrap; line-height: 1.7; }
.doc-box-tall { min-height: 80px; font-size: 16px; }
.doc-guide { margin: 4px 0 8px; }
.doc-guide-name { font-weight: 700; }
.doc-guide-text { padding-left: 14px; line-height: 1.6; white-space: pre-wrap; }
.doc-guide-note { padding-left: 14px; color: #444; font-size: 12px; white-space: pre-wrap; }
.rec-guide { border-left: 3px solid var(--primary); padding: 8px 12px; margin: 8px 0; background: #f7fafc; }
.rec-guide .doc-guide-name { font-size: 14px; }
.rec-guide .doc-guide-text { padding-left: 0; font-size: 13px; }
.rec-guide .doc-guide-note { padding-left: 0; }
.doc-sign { display: flex; gap: 16px; margin-top: 20px; }
.sign-box { flex: 1; border: 1px solid #999; padding: 12px 10px; min-height: 60px; font-size: 12px; }
.doc-note { font-size: 11px; color: #555; margin-top: 6px; }

/* 患者向け指導表 */
.instr-head { display: flex; align-items: center; gap: 16px; border-bottom: 3px solid var(--primary); padding-bottom: 10px; margin-bottom: 14px; }
.instr-clinic { font-size: 13px; font-weight: 700; color: #555; }
.instr-title { font-size: 24px; font-weight: 800; margin: 2px 0 0; }
.instr-meta { margin-left: auto; text-align: right; font-size: 15px; font-weight: 700; white-space: pre-line; line-height: 1.5; }
.instr-block { display: flex; gap: 16px; border: 2px solid var(--primary); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; min-height: 150px; align-items: stretch; page-break-inside: avoid; break-inside: avoid; }
.instr-left { flex: 1; min-width: 0; }
.instr-name { font-size: 19px; font-weight: 800; color: var(--primary-d); border-left: 6px solid var(--primary); padding-left: 10px; margin-bottom: 8px; }
.instr-text { font-size: 15px; line-height: 1.7; white-space: pre-wrap; margin-bottom: 8px; }
.instr-method, .instr-note { display: flex; gap: 8px; font-size: 15px; line-height: 1.6; margin-top: 6px; }
.instr-tag { flex: none; background: var(--primary); color: #fff; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 700; height: fit-content; }
.instr-val { flex: 1; min-width: 0; white-space: pre-wrap; }
.instr-note .instr-tag { background: var(--warn); }
.instr-right { flex: none; width: 200px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.instr-img { max-width: 150px; max-height: 150px; border-radius: 8px; border: 1px solid var(--line); }
.instr-noimg { width: 150px; height: 140px; border: 2px dashed var(--line); border-radius: 8px; }
/* 項目別QR（写真と併用・コンパクト） */
.instr-qr { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.instr-qr-img { width: 70px; height: 70px; display: block; image-rendering: pixelated; }
.instr-qr-label { font-size: 10px; font-weight: 700; color: var(--primary-d); }
.instr-footer { font-size: 13px; color: #555; margin-top: 8px; text-align: center; }

.doc-compare th, .doc-compare td { text-align: center; white-space: pre-line; }
.doc-compare .row-h { background: #f0f3f5; font-weight: 700; text-align: left; white-space: nowrap; }
.doc-compare .row-h2 { text-align: left; }

/* =====================================================================
 *  経過グラフ
 * ===================================================================== */
.graph-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.graph-head-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.graph-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.graph-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; height: 420px; position: relative; }
.graph-wrap canvas { width: 100% !important; height: 100% !important; }
.graph-note { font-size: 13px; color: var(--muted); margin-top: 10px; line-height: 1.6; }

@media print {
  @page { margin: 12mm; }
  html, body { background: #fff !important; }
  .app-header, .navbar, .hdr-actions, .undo-bar, .toast, #modal-root, .backup-bar, #backup-banner, .no-print { display: none !important; }
  .app-main { padding: 0 !important; max-width: none !important; }
  .print-doc { display: block; }
  .doc-page, .doc-page.a4 { max-width: none; width: auto; min-height: 0; border: none; box-shadow: none; padding: 0; font-size: 12px; transform: none !important; margin: 0 !important; }
  .doc-h2, .doc-table tr, .doc-guide, .doc-sign { page-break-inside: avoid; }
  .cell-warn { color: #c00 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* A4 1ページに収める印刷：1帳票＝A4ぴったり1枚の枠に内接（はみ出し＝白紙ページを防止） */
  .print-img-wrap { display: block; }
  .print-img-page { height: 270mm; box-sizing: border-box; display: flex; align-items: flex-start; justify-content: center; overflow: hidden; }
  /* 2枚目以降はページ前で改ページ（最後の余分な白紙を作らない） */
  .print-img-page + .print-img-page { page-break-before: always; break-before: page; }
  .print-img { max-width: 100%; max-height: 270mm; width: auto; height: auto; box-shadow: none; margin: 0; }
}

/* ===== 設定画面：グループ分け（医院 / 低下症 / 発達不全症 / アプリ） ===== */
.set-group-wrap { margin: 18px 0 8px; }
.set-group-head { display: flex; align-items: baseline; gap: 10px; padding: 8px 12px; margin-bottom: 8px;
  border-left: 5px solid var(--primary); background: linear-gradient(90deg, #eef5f8, transparent); border-radius: 8px; }
.set-group-ic { font-size: 20px; line-height: 1; }
.set-group-title { font-size: 17px; font-weight: 900; color: var(--primary-d); }
.set-group-sub { font-size: 12px; color: var(--muted); font-weight: 600; }
.set-group { display: flex; flex-direction: column; gap: 8px; }
/* 発達不全症グループは色味を変えて区別 */
.set-group-dev .set-group-head { border-left-color: #6a4ea0; background: linear-gradient(90deg, #f1ecf8, transparent); }
.set-group-dev .set-group-title { color: #573f86; }
