/* ============================================================
   estimate.css — 別紙 御見積書（A4縦 210×297mm）
   本編（A4横）とは別ファイル。@page は portrait。
   .sheet-v / .page-v は container-type:inline-size を持ち、
   内部はすべて cqw 指定 → 画面と印刷が完全に一致する。
   ============================================================ */

:root {
  --paper: #fcfcfa;
  --paper-2: #f4f4f0;
  --ink: #14171a;
  --ink-2: #565e64;
  --ink-3: #949a9e;
  --ink-4: #c4c8c9;
  --line: #e2e3de;
  --line-2: #eceded;
  --green: #1d4d3b;
  --green-2: #2f6b53;
  --green-pale: #eef3f0;
  --alert: #b5532f;
  --mincho: 'Noto Serif JP', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  --sans: 'Noto Sans JP', -apple-system, BlinkMacSystemFont,
          'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, sans-serif;
  --en: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --page-v-max: 820px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: #d7d8d3;
  -webkit-font-smoothing: antialiased;
}

.sheet-v {
  display: flex; flex-direction: column; align-items: center;
  gap: 22px; padding: 78px 16px 90px;
}
.page-v {
  position: relative; width: 100%; max-width: var(--page-v-max);
  aspect-ratio: 210 / 297;
  background: var(--paper);
  container-type: inline-size;
  overflow: hidden;
  box-shadow: 0 14px 44px rgba(18, 22, 20, .14);
}
.pad-v {
  position: absolute; inset: 0;
  padding: 6.2cqw 6.6cqw 5.4cqw;
  display: flex; flex-direction: column;
}

/* --- 表題 --- */
.est-head { display: flex; align-items: flex-end; justify-content: space-between; }
.est-head .et {
  font-family: var(--mincho); font-size: 4.2cqw; letter-spacing: .5em;
  font-weight: 500; padding-left: .5em;
}
.est-head .ee { font-family: var(--en); font-size: 1.1cqw; letter-spacing: .3em; color: var(--ink-3); text-transform: uppercase; }
.est-rule { height: 2px; background: var(--ink); margin-top: 1.4cqw; }

/* --- 宛先 / 発行情報 --- */
.est-meta { display: grid; grid-template-columns: 1.25fr 1fr; gap: 3.0cqw; padding-top: 3.0cqw; }
.est-to .to-name {
  font-size: 2.5cqw; letter-spacing: .1em; font-weight: 500;
  border-bottom: 1px solid var(--ink); padding-bottom: .8cqw;
}
.est-to .to-name small { font-size: 1.5cqw; margin-left: .6cqw; letter-spacing: .12em; }
.est-to .to-sub { margin-top: 1.0cqw; font-size: 1.15cqw; line-height: 1.85; color: var(--ink-2); }
.est-to .to-sub b { font-weight: 500; color: var(--ink); }

.est-issue { display: flex; flex-direction: column; gap: .55cqw; padding-top: .3cqw; }
.est-issue .ir { display: grid; grid-template-columns: 7.5cqw 1fr; font-size: 1.05cqw; letter-spacing: .04em; }
.est-issue .ir dt { color: var(--ink-3); }
.est-issue .ir dd { margin: 0; font-family: var(--en); letter-spacing: .02em; }

/* --- 合計金額 --- */
.est-total {
  margin-top: 2.6cqw; border: 1px solid var(--ink);
  display: grid; grid-template-columns: 13cqw 1fr; align-items: center;
}
.est-total .tl {
  background: var(--ink); color: #fff; padding: 1.5cqw 1.2cqw;
  font-size: 1.25cqw; letter-spacing: .16em; text-align: center; font-weight: 500;
  align-self: stretch; display: flex; align-items: center; justify-content: center;
}
.est-total .tv {
  padding: 1.2cqw 1.6cqw; font-family: var(--en); font-size: 3.6cqw;
  font-weight: 500; letter-spacing: .01em; display: flex; align-items: baseline; gap: .6cqw;
}
.est-total .tv small { font-family: var(--sans); font-size: 1.15cqw; font-weight: 400; color: var(--ink-3); letter-spacing: .1em; }

/* --- プランバッジ --- */
.plan-badge {
  display: inline-flex; align-items: baseline; gap: .8cqw;
  background: var(--green-pale); border-left: 3px solid var(--green);
  padding: .7cqw 1.2cqw; margin-top: 2.2cqw;
}
.plan-badge .bk { font-family: var(--en); font-size: .95cqw; letter-spacing: .2em; color: var(--green-2); }
.plan-badge .bj { font-family: var(--mincho); font-size: 1.9cqw; letter-spacing: .2em; font-weight: 500; color: var(--green); }
.plan-badge .bd { font-size: 1.0cqw; color: var(--ink-2); letter-spacing: .05em; }

/* --- 明細 --- */
.est-tbl { width: 100%; border-collapse: collapse; margin-top: 1.4cqw; }
.est-tbl thead th {
  font-size: .98cqw; letter-spacing: .12em; font-weight: 400; color: #fff;
  background: var(--ink); padding: .8cqw .9cqw; text-align: left;
}
.est-tbl thead th.r { text-align: right; }
.est-tbl thead th.c { text-align: center; }
.est-tbl td {
  padding: .95cqw .9cqw; border-bottom: 1px solid var(--line);
  font-size: 1.05cqw; vertical-align: top; line-height: 1.6;
}
.est-tbl td.r { text-align: right; font-family: var(--en); letter-spacing: .01em; }
.est-tbl td.c { text-align: center; font-size: .98cqw; color: var(--ink-2); }
.est-tbl td .sub { display: block; font-size: .86cqw; color: var(--ink-3); margin-top: .28cqw; line-height: 1.7; }
.est-tbl tr.blank td { height: 2.2cqw; border-bottom: 1px solid var(--line-2); }

.est-sum { margin-top: 1.6cqw; display: flex; justify-content: flex-end; }
.est-sum table { border-collapse: collapse; width: 46%; }
.est-sum td { padding: .68cqw .9cqw; font-size: 1.05cqw; border-bottom: 1px solid var(--line); }
.est-sum td:first-child { color: var(--ink-2); letter-spacing: .08em; }
.est-sum td:last-child { text-align: right; font-family: var(--en); letter-spacing: .01em; }
.est-sum tr.grand td {
  border-top: 2px solid var(--ink); border-bottom: none;
  font-size: 1.5cqw; font-weight: 500; padding-top: .9cqw;
}
.est-sum tr.grand td:first-child { font-size: 1.05cqw; letter-spacing: .12em; }

/* --- 備考 --- */
.est-note { margin-top: auto; padding-top: 2.0cqw; display: grid; grid-template-columns: 1fr 1fr; gap: 2.4cqw; }
.est-note h5 {
  margin: 0 0 .6cqw; font-size: 1.0cqw; letter-spacing: .14em;
  color: var(--ink-3); font-weight: 400; border-bottom: 1px solid var(--line); padding-bottom: .4cqw;
}
.est-note ul { list-style: none; margin: 0; padding: 0; }
.est-note li {
  font-size: .92cqw; line-height: 1.85; color: var(--ink-2);
  padding-left: 1.1cqw; position: relative; margin-bottom: .18cqw;
}
.est-note li::before { content: '・'; position: absolute; left: 0; color: var(--ink-4); }
.est-note li b { color: var(--ink); font-weight: 500; }

/* --- 発行元 --- */
.est-from {
  margin-top: 2.0cqw; padding-top: 1.4cqw; border-top: 1px solid var(--ink);
  display: grid; grid-template-columns: 1fr 11cqw; gap: 2.0cqw; align-items: start;
}
.est-from .fn { font-size: 1.55cqw; letter-spacing: .12em; font-weight: 500; }
.est-from .fd { margin-top: .6cqw; font-size: .95cqw; line-height: 1.9; color: var(--ink-2); }
.est-from .seal {
  border: 1px dashed var(--ink-4); aspect-ratio: 1; display: flex;
  align-items: center; justify-content: center;
  font-size: .82cqw; color: var(--ink-4); letter-spacing: .1em;
}

/* --- 要記入プレースホルダ --- */
.fill {
  display: inline-block; min-width: 6cqw; border-bottom: 1px dashed var(--alert);
  color: var(--alert); font-size: .88em; letter-spacing: .06em; text-align: center;
  padding: 0 .3cqw;
}

/* --- 画面UI --- */
.topbar {
  position: sticky; top: 0; z-index: 50; background: rgba(252,252,250,.94);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  height: 52px; display: flex; align-items: center; gap: 16px; padding: 0 22px;
}
.topbar .tb-title { font-size: 12px; letter-spacing: .14em; color: var(--ink-2); }
.topbar .tb-title b { font-weight: 500; color: var(--ink); }
.topbar .tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.btn {
  font-family: inherit; font-size: 12px; letter-spacing: .1em; padding: 8px 15px;
  border: 1px solid var(--ink-4); background: transparent; color: var(--ink-2);
  cursor: pointer; transition: .2s;
}
.btn:hover { background: var(--ink); color: #fff; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-2); }
.screen-note {
  max-width: var(--page-v-max); margin: 0 auto 4px; font-size: 12px;
  color: #5c625f; line-height: 1.9; background: rgba(255,255,255,.6);
  padding: 12px 16px; border-left: 3px solid var(--alert);
}
.screen-note b { color: var(--alert); }

@media (max-width: 900px) {
  .sheet-v { padding: 68px 8px 60px; gap: 12px; }
}

/* ============================ 印刷（A4縦） ============================ */
@page { size: A4 portrait; margin: 0; }

@media print {
  html, body { background: #fff !important; }
  .topbar, .screen-note { display: none !important; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .sheet-v { display: block; padding: 0; gap: 0; }
  .page-v {
    width: 210mm; height: 297mm; max-width: none; aspect-ratio: auto;
    margin: 0; box-shadow: none !important; overflow: hidden;
    break-inside: avoid; break-after: page;
    page-break-inside: avoid; page-break-after: always;
  }
  .page-v:last-child { break-after: auto; page-break-after: auto; }
  .est-tbl tr, .est-note li { break-inside: avoid; page-break-inside: avoid; }
  .est-tbl thead th { background: #14171a !important; color: #fff !important; }
  .est-total .tl { background: #14171a !important; color: #fff !important; }
  .plan-badge { background: #eef3f0 !important; }
  a[href]::after { content: "" !important; }
  a { color: inherit !important; text-decoration: none !important; }
}
