/* AI帳票作成：共通スタイル（CSP のためインライン style は使わない） */
:root {
  --brand: #0b5cab;
  --brand-weak: #e8f1fb;
  --ok: #1e7b34;
  --warn: #b25e00;
  --muted: #6c757d;
  --unconfirmed-bg: #f1f3f5;
}
html, body { height: 100%; }
body { font-size: 16px; background: #f7f9fb; }
.navbar-brand { font-weight: 700; letter-spacing: .02em; }
.app-main { padding-top: .75rem; padding-bottom: 5.5rem; }
.btn, .form-control, .form-select { min-height: 44px; }
.btn-sm { min-height: 36px; }
.hidden { display: none !important; }

/* ホーム */
.tpl-btn { text-align: left; padding: .9rem 1rem; font-size: 1.05rem; }
.tpl-btn small { display: block; color: var(--muted); font-size: .8rem; }
.section-title { font-size: .95rem; color: var(--muted); margin: 1.25rem 0 .5rem; font-weight: 600; }

/* 会話画面 */
.chat-header { position: sticky; top: 0; z-index: 10; background: #fff; border-bottom: 1px solid #dee2e6;
  padding: .5rem .75rem; }
.chat-header .title { font-weight: 700; font-size: 1.05rem; }
.progress-pill { font-weight: 700; color: var(--brand); white-space: nowrap; }
.panel { background: #fff; border: 1px solid #dee2e6; border-radius: .5rem; }
.chat-log { overflow-y: auto; padding: .75rem; height: calc(100vh - 250px); min-height: 280px; }
.msg { max-width: 92%; margin-bottom: .6rem; padding: .55rem .8rem; border-radius: .75rem;
  white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.msg.user { margin-left: auto; background: var(--brand); color: #fff; border-bottom-right-radius: .2rem; }
.msg.assistant, .msg.system { background: var(--brand-weak); color: #1d2b3a; border-bottom-left-radius: .2rem; }
.msg .at { font-size: .7rem; opacity: .7; display: block; margin-top: .15rem; }
.pending-card { border: 2px solid var(--warn); border-radius: .5rem; padding: .6rem .8rem; margin: .5rem 0;
  background: #fff8ef; }
.pending-card .arrow { font-weight: 700; color: var(--warn); }
.input-bar { border-top: 1px solid #dee2e6; padding: .5rem; background: #fff; }
.input-bar textarea { resize: none; }
.ai-banner { font-size: .85rem; }

/* 入力状況 */
.group-head { cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  padding: .55rem .75rem; border-bottom: 1px solid #eef0f2; font-weight: 600; background: #fbfcfd; }
.group-head .badge { font-size: .8rem; }
.field-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .5rem .75rem; border-bottom: 1px solid #f1f3f5; cursor: pointer; min-height: 44px; }
.field-row:hover, .field-row:focus { background: #f5f9ff; outline: none; }
.field-row .lbl { flex: 0 0 42%; font-size: .9rem; }
.field-row .val { flex: 1; text-align: right; font-size: .95rem; word-break: break-all; }
.field-row.is-unconfirmed .val { color: var(--muted); }
.field-row.is-absent .val, .field-row.is-unknown .val { color: #343a40; font-weight: 600; }
.req { color: #c92a2a; font-size: .75rem; margin-left: .25rem; }
.rec { color: var(--warn); font-size: .75rem; margin-left: .25rem; }
.badge-ai { background: #e7f5ff; color: #1864ab; border: 1px solid #a5d8ff; font-size: .7rem; margin-left: .3rem; }
.badge-default { background: #f3f0ff; color: #5f3dc4; border: 1px solid #d0bfff; font-size: .7rem; margin-left: .3rem; }
.status-btns .btn { min-width: 4.5rem; }
.opt-btns .btn { margin: 0 .35rem .35rem 0; }
.fields-scroll { max-height: calc(100vh - 210px); overflow-y: auto; }

/* 経過記録 */
.tl-row { display: flex; gap: .5rem; padding: .45rem .75rem; border-bottom: 1px solid #f1f3f5; align-items: center; }
.tl-row .t { font-variant-numeric: tabular-nums; font-weight: 700; width: 3.5rem; }
.tl-row .x { flex: 1; white-space: pre-wrap; }

/* プレビュー */
.pdf-wrap { overflow: auto; background: #6c757d; padding: .75rem; border-radius: .5rem; max-height: calc(100vh - 230px); }
.pdf-wrap canvas { display: block; margin: 0 auto .75rem; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.print-frame { position: absolute; width: 0; height: 0; border: 0; left: -9999px; }

/* スマホ下部タブ */
.bottom-tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: #fff; border-top: 1px solid #dee2e6;
  display: flex; }
.bottom-tabs button { flex: 1; border: 0; background: none; padding: .6rem 0 .7rem; font-size: .85rem; min-height: 56px; }
.bottom-tabs button.active { color: var(--brand); font-weight: 700; border-top: 3px solid var(--brand); }
@media (max-width: 991.98px) {
  .sp-panel { display: none; }
  .sp-panel.active { display: block; }
  .chat-log { height: calc(100vh - 280px); }
  .fields-scroll { max-height: none; }
}
@media (min-width: 992px) {
  .bottom-tabs { display: none; }
  .app-main { padding-bottom: 1rem; }
  .sp-only { display: none !important; }
}
.toast-container { z-index: 2000; }
.login-card { max-width: 420px; margin: 8vh auto; }
.table-sm td, .table-sm th { font-size: .85rem; }
