/* ==========================================================================
   Mvisual｜商談キット 共通スタイル
   --------------------------------------------------------------------------
   デザインは「Webサイト制作 事前診断フォーム」(/site-shindan/) に統一。
   ・紺 #1e3a5f（見出し）× 青 #2d6cdf（アクセント）× 淡い青グレーの面
   ・白いカード・細い線・角丸・余白多め
   ・Webフォントは使わずシステムフォント（軽く、印刷でも崩れない）

   画面ではA4用紙を模して表示し、そのまま印刷すると同じ見た目でA4に出る。

   ⚠️ 印刷でCSSが効かない主な原因と、ここでの対処:
   1. 背景色・背景地が印刷されない
      → ブラウザは既定で背景を落とす。print-color-adjust:exact で強制する。
        （印刷ダイアログの「背景のグラフィック」ONも索引ページで案内している）
   2. 余白がブラウザ既定に上書きされる
      → @page で size:A4 と margin を明示する。
   3. 表や枠が途中で切れる
      → break-inside:avoid。表の見出しは display:table-header-group で各頁に出す。
   4. 見出しだけ頁末に取り残される
      → break-after:avoid。
   5. 画面用の影・固定要素が印刷に混ざる
      → @media print で全部落とす。position:fixed は印刷で暴れるので使わない。
   6. Webフォントが印刷時に間に合わない
      → そもそも使わない。システムフォントのみ。
   ========================================================================== */

:root {
  --navy: #1e3a5f;
  --blue: #2d6cdf;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #2b3440;
  --muted: #6b7686;
  --line: #e3e8ef;
  --line-mid: #cfd8e4;
  --accent: #eef4ff;
  --warn: #d0454c;
  --warn-bg: #fdf0f0;

  --f: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;

  /* A4 = 210×297mm。左右15mmずつ引いた180mmが本文の幅 */
  --page-w: 210mm;
  --page-pad: 15mm;
  --r: 10px;
}

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

html { background: #dfe4ec; }

body {
  font-family: var(--f);
  color: var(--text);
  font-size: 10pt;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.5; word-break: auto-phrase; color: var(--navy); }
p, li, td, th, dd, dt { word-break: auto-phrase; }

/* ── 画面用のツールバー（印刷では消える）────────────────────────── */
.toolbar {
  position: sticky; top: 0; z-index: 50;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 11px clamp(12px, 3vw, 24px);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted);
}
.toolbar a { color: var(--blue); text-decoration: none; font-weight: 600; }
.toolbar a:hover { text-decoration: underline; }
.toolbar .sp { flex: 1 1 auto; }
.toolbar button {
  font-family: inherit; font-size: 13px; font-weight: 600;
  background: var(--blue); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 20px; cursor: pointer;
}
.toolbar button:hover { background: #2359bd; }
.toolbar .hint { font-size: 12px; }

/* ── 用紙 ────────────────────────────────────────────────── */
.sheet {
  width: var(--page-w);
  min-height: 297mm;
  margin: 20px auto;
  padding: var(--page-pad);
  background: var(--card);
  box-shadow: 0 4px 24px rgba(30, 58, 95, .18);
}

/* ── 見出し（診断フォームのヘッダーに合わせる）──────────────────── */
.brand {
  text-align: center; font-size: 8pt; font-weight: 600;
  letter-spacing: .34em; color: var(--muted); margin-bottom: 7px;
}
/* 金額を書類内で最大にする関係を保つため、タイトルは金額より小さく置く
   （2026-07-30 ノア指示：金額は目立たせすぎない／ただし見積書内では最大）*/
.doc-title { text-align: center; font-size: 12.5pt; font-weight: 700; letter-spacing: .06em; }
.doc-sub { text-align: center; font-size: 9pt; color: var(--muted); margin-top: 6px; }
.rule { height: 1pt; background: var(--line); margin: 14px 0 16px; }

.head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.head .to { flex: 1 1 auto; }
.head .to .blank { border-bottom: 1pt solid var(--line-mid); height: 27px; margin-bottom: 4px; }
.head .to .lbl { font-size: 11pt; font-weight: 700; color: var(--navy); }
.head .to .note { font-size: 7.5pt; color: var(--muted); }

.issuer { font-size: 8.5pt; color: var(--muted); line-height: 1.7; }
.issuer .nm { font-size: 10.5pt; font-weight: 700; color: var(--navy); letter-spacing: .02em; }
.issuer .ow { font-size: 9pt; color: var(--text); }

/* ── 金額（診断フォームのカードの質感で）────────────────────────── */
.price-box {
  border: 1pt solid var(--line); border-radius: var(--r);
  overflow: hidden; margin: 16px 0 5px;
}
.price-box .row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 15px; background: var(--card);
}
.price-box .row + .row { border-top: 1pt solid var(--line); }
.price-box .row.lead { background: var(--accent); }
.price-box .k { font-size: 9.5pt; font-weight: 600; color: var(--navy); }
.price-box .v { font-size: 13.5pt; font-weight: 700; color: var(--navy); letter-spacing: -.01em; }
.tax-note { text-align: right; font-size: 8pt; color: var(--muted); }

/* ── 表 ─────────────────────────────────────────────────── */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 9pt; }
th, td { border-bottom: 1pt solid var(--line); padding: 8px 10px; vertical-align: middle; text-align: left; }
thead th { background: var(--accent); color: var(--navy); font-weight: 600; font-size: 8.5pt; border-bottom: 1pt solid var(--line-mid); }
tbody tr:last-child td { border-bottom: 0; }
table.boxed { border: 1pt solid var(--line); border-radius: var(--r); overflow: hidden; }
td.num { text-align: right; font-weight: 600; white-space: nowrap; color: var(--navy); }

/* ── 注記ブロック ───────────────────────────────────────────── */
.notes { background: var(--bg); border: 1pt solid var(--line); border-radius: var(--r); padding: 12px 15px; }
.notes h4 { font-size: 9.5pt; font-weight: 700; margin-bottom: 5px; }
.notes ul { list-style: none; }
.notes li { font-size: 8.5pt; line-height: 1.75; padding-left: 1em; text-indent: -1em; }
.notes li::before { content: "・"; color: var(--muted); }

/* ── 特商法の確認枠（契約書の要）──────────────────────────────── */
.confirm { border: 1.2pt solid var(--blue); border-radius: var(--r); overflow: hidden; }
.confirm h3 {
  background: var(--blue); color: #fff; font-size: 10pt; font-weight: 600;
  padding: 8px 14px; letter-spacing: .02em;
}
.confirm .body { background: var(--card); padding: 11px 14px; }
.confirm dl { display: grid; grid-template-columns: 26% 1fr; gap: 5px 12px; }
.confirm dt { font-size: 8.8pt; font-weight: 700; color: var(--navy); }
.confirm dd { font-size: 8.8pt; line-height: 1.7; }
/* 確認枠の中の補足行（年額の目安など）。本文より一段落として読ませる */
.confirm dd .small { font-size: 8pt; color: var(--muted); }
/* 価格ボックスの「＋交通費」。金額と同じ大きさだと数字が2つあるように見える */
.price-box .v .plus { font-size: 9pt; font-weight: 600; color: var(--muted); }

/* ── 記入欄 ───────────────────────────────────────────────── */
.fields { border: 1pt solid var(--line); border-radius: var(--r); overflow: hidden; }
.fld { display: flex; min-height: 11mm; }
.fld + .fld { border-top: 1pt solid var(--line); }
.fld .k {
  width: 30%; background: var(--accent); padding: 6px 10px;
  font-size: 9pt; font-weight: 600; color: var(--navy);
  display: flex; align-items: center;
}
.fld .v {
  width: 70%; background: var(--card); padding: 6px 10px;
  font-size: 7.5pt; color: var(--muted); display: flex; align-items: center;
}
.fld.tall { min-height: 12.5mm; }
.fld.stamp { min-height: 26mm; }
.fld.sign { min-height: 13mm; }

/* ── 条項 ───────────────────────────────────────────────── */
.terms h3 { font-size: 10.5pt; font-weight: 700; margin-bottom: 6px; }
.terms p { font-size: 8.2pt; line-height: 1.7; margin-bottom: 4px; }
.terms b { font-weight: 700; color: var(--navy); }

/* ── 署名欄 ───────────────────────────────────────────────
   空白を全角スペースで作ると折り返して㊞だけ次行に落ちるので flex で組む。 */
.signbox { border: 1.2pt solid var(--blue); border-radius: var(--r); padding: 12px 15px 14px; background: var(--card); }
.signbox .t { font-size: 9.5pt; font-weight: 700; color: var(--navy); margin-bottom: 12px; }
.signbox .l { display: flex; align-items: flex-end; gap: 6px; font-size: 10pt; white-space: nowrap; }
.signbox .u { border-bottom: 1pt solid var(--line-mid); flex: 0 0 auto; }
.signbox .u.d { width: 13mm; }
.signbox .u.name { flex: 1 1 auto; min-width: 40mm; }
.signbox .cap { font-size: 9pt; color: var(--muted); }
.signbox .seal {
  flex: 0 0 auto; width: 13mm; height: 13mm;
  border: 1pt dashed var(--line-mid); border-radius: 50%;
  display: grid; place-items: center; font-size: 7.5pt; color: var(--muted);
}

/* ── 手書きで書き入れる欄（署名欄の外で使う）─────────────────────
   交通費のように毎回変わる金額は印字できない。空白のままだと書く場所が
   分からないので、下線だけ引いておく。 */
.wi { display: inline-block; min-width: 18mm; border-bottom: 1pt solid var(--line-mid); }
.wi.sm { min-width: 11mm; }
.wi.lg { min-width: 32mm; }

/* ── 同意のチェック欄（手でチェックを入れてもらう）─────────────────
   オプトイン型にするため、相手が「どこまで許すか」を選べる形にしている。 */
.consent { border: 1pt solid var(--line); border-radius: var(--r); overflow: hidden; }
.consent .item { display: flex; gap: 11px; padding: 8px 14px; align-items: flex-start; }
.consent .item + .item { border-top: 1pt solid var(--line); }
.consent .bx {
  flex: 0 0 auto; width: 5.5mm; height: 5.5mm; margin-top: 1.5mm;
  border: 1.2pt solid var(--navy); border-radius: 2px; background: var(--card);
}
.consent .tx { flex: 1 1 auto; }
.consent .tt { display: block; font-size: 9.5pt; font-weight: 700; color: var(--navy); }
.consent .dd { display: block; font-size: 8.2pt; color: var(--muted); line-height: 1.6; margin-top: 1px; }

/* ── 支払い方法カード ─────────────────────────────────────── */
.pay { border: 1pt solid var(--line); border-radius: var(--r); background: var(--card); padding: 14px 17px; }
.pay.rec { border: 1.2pt solid var(--blue); background: var(--accent); }
.pay .n { font-size: 11.5pt; font-weight: 700; color: var(--navy); }
.pay .m { font-size: 9pt; font-weight: 600; color: var(--blue); margin: 3px 0 6px; }
.pay .b { font-size: 9pt; line-height: 1.75; }

.mt6 { margin-top: 6px; } .mt10 { margin-top: 10px; }
.mt14 { margin-top: 15px; } .mt20 { margin-top: 22px; }
.right { text-align: right; }

/* 印字せず手書きしてもらう欄（引き落とし日など）。下線だけ引いて空けておく */
.cfg-blank {
  display: inline-block; min-width: 22mm;
  border-bottom: 1pt solid var(--line-mid);
}

/* ── 未設定の警告（印刷にも出す。設定漏れのまま配るのを防ぐ）───────── */
.unset-alert {
  background: var(--warn-bg); border: 1.2pt solid var(--warn); border-radius: var(--r);
  color: var(--warn); padding: 12px 16px; margin-bottom: 15px;
  font-size: 9pt; font-weight: 700;
}
.unset-alert ul { margin: 6px 0 0 18px; font-weight: 400; }
.cfg-unset { background: #fbe3e3; color: var(--warn); font-weight: 700; padding: 0 4px; border-radius: 3px; }

/* ══════════════════════════════════════════════════════════════
   印刷
   ══════════════════════════════════════════════════════════════ */
@page {
  size: A4 portrait;
  margin: 14mm 15mm;
}

@media print {
  /* 背景色・地色を必ず出す。これを入れないと枠や見出し帯が全部白く抜ける */
  *, *::before, *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html, body { background: #fff !important; }

  /* 画面専用のUIは全部落とす */
  .toolbar, .no-print { display: none !important; }

  /* 用紙の見た目（影・余白・幅指定）は @page に任せる */
  .sheet {
    width: auto; min-height: 0;
    margin: 0; padding: 0;
    box-shadow: none;
  }

  /* 枠やカードが頁をまたいで割れないようにする */
  .price-box, .notes, .confirm, .fields, .signbox, .pay, .consent, table, .head {
    break-inside: avoid; page-break-inside: avoid;
  }
  .fld, tr { break-inside: avoid; page-break-inside: avoid; }

  /* 見出しだけが頁末に取り残されるのを防ぐ */
  h1, h2, h3, h4, .doc-title, .brand { break-after: avoid; page-break-after: avoid; }

  /* 表が複数頁になったとき見出し行を毎頁出す */
  thead { display: table-header-group; }

  /* 印刷でリンクの下線・色が邪魔になるので消す */
  a { color: inherit !important; text-decoration: none !important; }

  /* 明示的に改頁したいとき */
  .page-break { break-before: page; page-break-before: always; }
}

/* 語中改行を止める（check_ja_typography.py の指摘を受けて囲う単位＝文節）*/
.nb { white-space: nowrap; }

/* ── 宛名の差し込み（doc.js）──────────────────────────────────── */
/* 画面上で「誰あての紙か」を出す。印刷では .toolbar ごと消える */
.toolbar .who-tag {
  font-size: 12px; font-weight: 700; color: var(--blue);
  background: var(--accent); border-radius: 999px; padding: 4px 12px;
}
/* 差し込まれた宛名。手書き用の下線の上に載る想定なので行の高さを合わせる */
.head .to .blank.client-filled {
  font-size: 13pt; font-weight: 700; color: var(--navy);
  line-height: 27px; padding-left: 2px;
}

/* ── 手順・お願いのブロック（電子契約の案内などで使う）───────────── */
.howto {
  background: var(--accent); border: 1px solid var(--line-mid);
  border-radius: 6px; padding: 11px 14px;
}
.howto .t { font-size: 10pt; font-weight: 700; color: var(--navy); margin-bottom: 5px; }
.howto .b { font-size: 9pt; line-height: 1.85; }
.howto .b .small { font-size: 8pt; color: var(--muted); }

/* ── 廃止した書類に載せる帯（印刷にも必ず出す）─────────────────── */
.retired {
  background: var(--warn-bg); border: 2px solid var(--warn);
  border-radius: 6px; padding: 12px 15px; margin-bottom: 16px;
}
.retired .t { font-size: 11pt; font-weight: 700; color: var(--warn); margin-bottom: 5px; }
.retired .b { font-size: 9pt; line-height: 1.8; color: var(--text); }

/* ── 番号つきの手順（お客様に見せる操作説明）──────────────────── */
.steps { counter-reset: st; }
.steps .s {
  position: relative; padding: 0 0 12px 40px; counter-increment: st;
}
.steps .s::before {
  content: counter(st); position: absolute; left: 0; top: 0;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 9pt; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.steps .s .h { font-size: 10pt; font-weight: 700; color: var(--navy); line-height: 26px; }
.steps .s .d { font-size: 9pt; line-height: 1.8; margin-top: 2px; }

/* ── 公開ページ用（mvisual.jp 下書き・2026-10-17）：スマホで横スクロールしないように紙の幅をほどく ── */
@media screen and (max-width: 840px) {
  .sheet { width: auto; max-width: 100%; min-height: 0; margin: 0; padding: 20px 16px; box-shadow: none; }
  .sheet table, .sheet tbody, .sheet tr, .sheet th, .sheet td { display: block; width: auto; }
  .sheet th { padding-bottom: 2px; border-bottom: 0; }
  .sheet td { padding-top: 2px; }
  .toolbar { flex-wrap: wrap; }
}
