/* 請求書・見積書・領収書の作成ツール（ZQT Lab.）。色は lab と同じ系統 */
:root {
  --ink: #1d2733;
  --ink-soft: #4a5866;
  --navy: #1e3a5c;
  --navy-deep: #132a45;
  --gold: #b9893f;
  --bg: #faf8f4;
  --tint: #eef2f6;
  --line: #d9dfe6;
  --white: #ffffff;
  --warn-bg: #fdf4e3;
  --warn-line: #e3c48b;
  --ok: #2f6b4f;
  --ng: #a04a2c;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo", sans-serif;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "MS PMincho", serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.7; overflow-wrap: anywhere; }
a { color: var(--navy); }
p { margin: 0 0 1em; }
.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.pc { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- 頭と導入 ---------- */
.site-head { background: rgba(250, 248, 244, .95); border-bottom: 1px solid var(--line); }
.site-head-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--navy); color: #fff; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; }
.logo-text { font-weight: 700; line-height: 1.2; }
.logo-text small { display: block; font-weight: 400; font-size: 11px; color: var(--ink-soft); }
.head-note { font-size: 12px; color: var(--ink-soft); text-align: right; }
.intro { padding: 28px 0 12px; }
.title { font-family: var(--serif); font-size: 23px; line-height: 1.45; margin: 0 0 10px; word-break: auto-phrase; }
.lead { color: var(--ink-soft); font-size: 15px; margin: 0; }
.lead strong { color: var(--ink); background: linear-gradient(transparent 62%, #f3e7d2 62%); }

/* ---------- 2段組み ---------- */
.app { display: flex; flex-direction: column; gap: 20px; padding-top: 16px; padding-bottom: 40px; }
.panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.preview-col { min-width: 0; }

/* ---------- 入力 ---------- */
.box { margin: 0; border: 1px solid var(--line); background: var(--white); border-radius: 14px; padding: 14px 14px 16px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.box-title { font-weight: 700; color: var(--navy); padding: 0 6px; font-size: 15px; }
.box-title small { font-weight: 400; color: var(--ink-soft); font-size: 12px; margin-left: 8px; }
.f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.f-label { font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.f-label em { font-style: normal; font-weight: 400; font-size: 11px; margin-left: 6px; color: var(--gold); }
.f input, .f select, .f textarea { width: 100%; min-width: 0; font-size: 16px; padding: 9px 10px; border: 1px solid #c5cdd6; border-radius: 8px; background: #fff; }
.f textarea { resize: vertical; line-height: 1.5; }
.f input:focus, .f select:focus, .f textarea:focus { outline: 2px solid rgba(30, 58, 92, .35); outline-offset: 1px; border-color: var(--navy); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 .f-grow { grid-column: auto; }
.row2:has(.f-keisho) { grid-template-columns: 1fr 92px; }
.f-msg { margin: -4px 0 0; font-size: 13px; color: var(--ng); }
.hint { margin: 0; font-size: 13px; color: var(--ink-soft); }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--navy); border-radius: 10px; overflow: hidden; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: grid; place-items: center; min-height: 46px; font-weight: 700; font-size: 15px; color: var(--navy); cursor: pointer; border-left: 1px solid var(--line); transition: background .2s, color .2s; }
.seg label:first-child span { border-left: 0; }
.seg input:checked + span { background: var(--navy); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: -3px; }
.convert { display: flex; flex-direction: column; gap: 6px; }
.convert .btn-sub + .hint { margin-bottom: 6px; }
.seg-5 { grid-template-columns: repeat(5, 1fr); }
.seg-5 span { font-size: 14px; }
.seg-2 { grid-template-columns: repeat(2, 1fr); }
.seg-2 span { font-size: 14px; min-height: 42px; }
.convert .f-label { margin: 0; }

/* 書類の流れ（見積書→発注書→納品書→請求書） */
.flow { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 0; align-items: stretch; }
.flow li { position: relative; flex: 1 1 0; min-width: 0; text-align: center; font-size: 12px; font-weight: 700; color: var(--navy); background: var(--tint); padding: 5px 4px 4px; line-height: 1.3; }
.flow li + li { margin-left: 12px; }
.flow li + li::before { content: ""; position: absolute; left: -10px; top: 50%; width: 7px; height: 7px; border-top: 2px solid var(--gold); border-right: 2px solid var(--gold); transform: translateY(-50%) rotate(45deg); }
.flow li small { display: block; font-size: 10px; font-weight: 400; color: var(--ink-soft); }
.flow li[data-side="buy"] { background: #f6ecd9; }
.flow li.now { outline: 2px solid var(--navy); outline-offset: -2px; }

/* 作り方のタブ */
.mode-tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--navy); margin-top: 6px; }
.mode-tabs button { flex: 1 1 0; min-width: 0; min-height: 46px; padding: 6px 10px; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--white); color: var(--navy); font-weight: 700; font-size: 15px; cursor: pointer; transition: background .2s, color .2s; }
.mode-tabs button[aria-selected="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.mode-tabs button:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
.paste { font-family: ui-monospace, "BIZ UDGothic", "MS Gothic", monospace; font-size: 14px !important; white-space: pre; overflow-x: auto; }
.ok-msg { color: var(--ok); }
.f-msg:empty { display: none; }

.item { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fbfcfd; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; animation: 出る .25s ease; }
@keyframes 出る { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.item-head { display: flex; align-items: center; gap: 8px; }
.item-no { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--tint); color: var(--navy); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.item-head .f { flex: 1; }
.item-nums { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, .7fr) minmax(0, 1.2fr) minmax(0, 1.4fr); gap: 6px; }
.item-nums .f input, .item-nums .f select { padding: 8px 6px; }
.item-nums .f-label { font-size: 11px; font-weight: 400; }
.item-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item-amount { font-size: 14px; font-weight: 700; color: var(--navy); }
.btn-del { border: 0; background: none; color: var(--ng); font-size: 13px; padding: 6px 4px; cursor: pointer; text-decoration: underline; }
.btn-add { align-self: flex-start; border: 1px dashed var(--navy); background: var(--tint); color: var(--navy); font-weight: 700; padding: 9px 16px; border-radius: 8px; cursor: pointer; }
.btn-add:disabled { opacity: .5; cursor: default; }
.mini-sum { font-size: 13px; color: var(--ink-soft); background: var(--tint); border-radius: 8px; padding: 8px 10px; }
.mini-sum:empty { display: none; }
.mini-sum b { color: var(--ink); }

.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-sub { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 14px; border: 1px solid var(--navy); border-radius: 999px; background: #fff; color: var(--navy); font-weight: 700; font-size: 14px; cursor: pointer; transition: background .2s, color .2s; text-align: center; }
.btn-sub:hover { background: var(--navy); color: #fff; }
.btn-quiet { border-color: var(--line); color: var(--ink-soft); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.file-btn:focus-within { outline: 3px solid var(--gold); }

/* ---------- プレビュー ---------- */
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 10px; }
.btn-main { min-height: 50px; padding: 0 26px; border: 0; border-radius: 999px; background: var(--navy); color: #fff; font-weight: 700; font-size: 16px; cursor: pointer; box-shadow: 0 6px 16px rgba(19, 42, 69, .18); transition: background .2s, transform .2s; }
.btn-main:hover { background: var(--navy-deep); transform: translateY(-1px); }
.toolbar-total { font-weight: 700; color: var(--navy); }
.checks { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.checks:empty { display: none; }
.warn { margin: 0; font-size: 13px; background: var(--warn-bg); border: 1px solid var(--warn-line); border-left-width: 4px; border-radius: 8px; padding: 8px 12px; line-height: 1.6; }
.check-list { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.check-list summary { cursor: pointer; font-weight: 700; color: var(--navy); }
.check-list ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; }
.check-list li { display: flex; gap: 8px; align-items: baseline; }
.check-list li::before { content: ""; }
.check-list li { font-size: 11px; font-weight: 700; }
.check-list li span { font-size: 13px; font-weight: 400; color: var(--ink); }
.check-list li.ok { color: var(--ok); }
.check-list li.ng { color: var(--ng); }
.print-hint { font-size: 12px; color: var(--ink-soft); margin: 10px 0 0; }
.btn-main:disabled { opacity: .45; cursor: default; transform: none; }

/* 収入印紙の目安 */
.stamp-info { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 8px; padding: 8px 12px; font-size: 13px; line-height: 1.6; }
.stamp-info.need { border-left-color: var(--gold); background: var(--warn-bg); border-color: var(--warn-line); }
.stamp-info p { margin: 0 0 4px; }
.stamp-head { font-weight: 700; font-size: 14px; color: var(--ink); }
.stamp-info details { margin: 4px 0 6px; }
.stamp-info summary { cursor: pointer; color: var(--navy); font-weight: 700; }
.stamp-note { font-size: 12px; color: var(--ink-soft); margin: 0 !important; }
.stamp-table { border-collapse: collapse; width: 100%; max-width: 420px; margin: 6px 0; font-size: 12.5px; background: #fff; }
.stamp-table th, .stamp-table td { border: 1px solid var(--line); padding: 3px 8px; text-align: left; }
.stamp-table th { background: var(--tint); font-weight: 700; color: var(--navy); }
.stamp-table td + td { text-align: right; white-space: nowrap; }
.stamp-table tr.now td { background: #f3e7d2; font-weight: 700; }

/* 一括作成 */
.batch-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.batch-empty { margin: 0; padding: 28px 16px; text-align: center; color: var(--ink-soft); background: #fff; border: 1px dashed var(--line); border-radius: 12px; font-size: 14px; grid-column: 1 / -1; }
.batch-fit { scroll-margin-top: 12px; }
.batch-sum-wrap { overflow-x: auto; margin-bottom: 12px; }
.batch-sum-wrap:empty { display: none; }
.batch-sum { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
.batch-sum th, .batch-sum td { border: 1px solid var(--line); padding: 4px 8px; text-align: right; white-space: nowrap; }
.batch-sum thead th { background: var(--tint); color: var(--navy); text-align: center; }
.batch-sum .c-client, .batch-sum tfoot th { text-align: left; white-space: normal; min-width: 8em; }
.batch-sum tfoot th, .batch-sum tfoot td { font-weight: 700; background: #f3f6f9; }

.sheet-fit { position: relative; width: 100%; overflow: hidden; border-radius: 4px; box-shadow: 0 10px 30px rgba(19, 42, 69, .14); background: #fff; }
.sheet { position: absolute; left: 0; top: 0; transform-origin: 0 0; width: 210mm; height: 297mm; overflow: hidden; background: #fff; color: #111; font-family: var(--font); font-size: 12.5px; line-height: 1.55; }
.sheet-in { padding: 15mm 14mm 12mm; }
.sheet p { margin: 0; }
.sheet .blank { display: inline-block; min-width: 14em; color: #aaa; }
.sh-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #1e3a5c; padding-bottom: 6px; margin-bottom: 18px; }
.sh-title { margin: 0; font-family: var(--serif); font-size: 30px; letter-spacing: .3em; font-weight: 700; color: #132a45; }
.sh-meta { margin: 0; font-size: 12px; display: grid; gap: 1px; text-align: right; }
.sh-meta div, .sh-cond div { display: flex; gap: 10px; justify-content: flex-end; }
.sh-meta dt, .sh-cond dt { color: #555; }
.sh-meta dd, .sh-cond dd { margin: 0; }
.sh-row { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
.sh-left { flex: 1; min-width: 0; }
.sh-to { font-size: 19px; font-weight: 700; border-bottom: 1px solid #333; padding-bottom: 3px; margin: 0 0 10px !important; display: inline-block; min-width: 60%; }
.sh-to .keisho { font-size: 15px; margin-left: .8em; }
.sh-lead { font-size: 12.5px; margin-bottom: 8px !important; }
.sh-cond { margin: 0 0 10px; display: grid; gap: 1px; }
.sh-cond div { justify-content: flex-start; }
.sh-cond dt { min-width: 6.5em; }
.sh-total { display: inline-flex; align-items: baseline; gap: 14px; border: 2px solid #1e3a5c; padding: 6px 16px; background: #f3f6f9; }
.sh-total span { font-weight: 700; }
.sh-total b { font-size: 24px; letter-spacing: .02em; }
.sh-total small { font-size: 11px; }
.sh-from { width: 36%; flex: none; font-size: 12px; line-height: 1.6; }
.sh-from-name { font-size: 15px; font-weight: 700; margin-bottom: 3px !important; }
.sh-reg { margin-top: 3px !important; font-weight: 700; }
.sh-items { width: 100%; border-collapse: collapse; font-size: 12px; }
.sh-items th { background: #1e3a5c; color: #fff; font-weight: 700; padding: 5px 6px; border: 1px solid #1e3a5c; white-space: nowrap; }
.sh-items td { border: 1px solid #b9c2cc; padding: 4px 6px; height: 25px; }
.sh-items tbody tr:nth-child(even) td { background: #f6f8fa; }
.sh-items .c-name { text-align: left; width: 44%; }
.sh-items .c-num { text-align: right; white-space: nowrap; }
.sh-items .c-unit, .sh-items .c-rate { text-align: center; white-space: nowrap; }
.sh-items .mark { margin-left: 4px; font-weight: 700; }
.sh-legend { font-size: 11px; margin-top: 3px !important; }
.sh-bottom { display: flex; justify-content: space-between; gap: 20px; margin-top: 12px; align-items: flex-start; }
.sh-bottom-left { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sh-break { border-collapse: collapse; font-size: 12px; }
.sh-break caption { text-align: left; font-size: 11px; color: #555; padding-bottom: 2px; }
.sh-break th, .sh-break td { border: 1px solid #b9c2cc; padding: 3px 8px; white-space: nowrap; }
.sh-break th { background: #f3f6f9; font-weight: 400; text-align: left; }
.sh-break th small { font-size: 10px; }
.sh-break td { text-align: right; min-width: 6.5em; }
.sh-sum { border-collapse: collapse; font-size: 12.5px; min-width: 40%; }
.sh-sum th, .sh-sum td { border: 1px solid #b9c2cc; padding: 4px 10px; }
.sh-sum th { background: #f3f6f9; text-align: left; font-weight: 400; }
.sh-sum td { text-align: right; white-space: nowrap; }
.sh-sum .sum-total th, .sh-sum .sum-total td { font-weight: 700; font-size: 14px; background: #e6ecf2; }
.sh-bank { border: 1px solid #b9c2cc; padding: 6px 10px; font-size: 12px; }
.sh-bank-title, .sh-note-title { font-weight: 700; font-size: 11px; color: #1e3a5c; }
.sh-note { margin-top: 14px; border: 1px solid #b9c2cc; padding: 6px 10px; font-size: 12px; min-height: 44px; }
.sheet .blank-s { min-width: 8em; border-bottom: 1px solid #999; }

/* 発注書 */
.sh-role { display: inline-block; font-size: 10.5px; font-weight: 700; color: #fff; background: #1e3a5c; padding: 0 8px; margin-bottom: 4px !important; letter-spacing: .1em; }
.sh-sign { position: relative; }
.sh-sign .sh-from-name { border-bottom: 1px solid #333; min-height: 1.6em; padding-right: 44px; }
.sh-line { border-bottom: 1px solid #999; min-height: 26px; padding-top: 6px; }
.sh-line span { font-size: 10.5px; color: #555; }
.sh-seal { position: absolute; right: 0; top: 22px; width: 40px; height: 40px; border: 1px solid #999; border-radius: 50%; color: #999; font-size: 11px; display: grid; place-items: center; }

/* 行が多い時（一括作成）は明細を詰める */
.sheet-in[data-dense] .sh-items { font-size: 11px; }
.sheet-in[data-dense] .sh-items td { height: 19px; padding: 1px 6px; }
.sheet-in[data-dense] .sh-head { margin-bottom: 12px; }
.sheet-in[data-dense] .sh-row { margin-bottom: 10px; }

/* 領収書 */
.sheet[data-type="ryoshu"] .sh-to { min-width: 70%; font-size: 21px; margin-bottom: 18px !important; }
.sh-receipt { text-align: center; margin: 0 auto 22px; width: 82%; }
.sh-big { display: flex; align-items: baseline; justify-content: center; gap: 14px; background: #f3f6f9; border: 2px solid #1e3a5c; padding: 10px 16px; margin-bottom: 12px; }
.sh-big-label { font-weight: 700; font-size: 15px; }
.sh-big-yen { font-size: 32px; font-weight: 700; letter-spacing: .03em; }
.sh-big-tax { font-size: 12px; }
.sh-tadashi { font-size: 14px; border-bottom: 1px solid #333; padding-bottom: 3px; text-align: left; margin-bottom: 8px !important; }
.sh-recv { font-size: 13px; text-align: left; }
.sh-stamp { width: 76px; height: 76px; border: 1px dashed #888; color: #888; font-size: 11px; display: grid; place-items: center; text-align: center; line-height: 1.4; margin-top: 12px; }
.sheet[data-type="ryoshu"] .sh-left { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }

/* ---------- 説明 ---------- */
.guide { background: #fff; border-top: 1px solid var(--line); padding: 32px 0 36px; }
.guide-in { max-width: 860px; }
.guide-title { font-family: var(--serif); font-size: 20px; margin: 0 0 12px; color: var(--navy-deep); }
.steps { margin: 0 0 28px; padding: 0; list-style: none; display: grid; gap: 10px; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 10px 12px 10px 48px; background: var(--bg); border-radius: 10px; font-size: 14px; }
.steps li::before { content: counter(s); position: absolute; left: 12px; top: 10px; width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.steps b { display: block; }
.faq { margin: 0 0 20px; }
.faq dt { font-weight: 700; margin-top: 14px; padding-left: 1.6em; text-indent: -1.6em; }
.faq dt::before { content: "Q. "; color: var(--gold); }
.faq dd { margin: 4px 0 0; padding-left: 1.6em; font-size: 14px; color: var(--ink-soft); }
.guide-text { font-size: 14px; color: var(--ink-soft); margin: 0 0 28px; }
.flow-guide { margin: 0 0 12px; }
.flow-guide li { font-size: 14px; padding: 8px 4px 6px; }
.flow-guide li small { font-size: 11px; }
.faq dd .stamp-table { margin: 8px 0; }
.disclaimer { font-size: 12px; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 12px; margin: 0; }

.site-foot { padding: 18px 0 26px; font-size: 12px; color: var(--ink-soft); }
.made { margin: 0; }

.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 50; width: max-content; max-width: calc(100% - 32px); background: var(--navy-deep); color: #fff; border-radius: 12px; padding: 10px 14px; font-size: 14px; display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 28px rgba(0, 0, 0, .25); animation: 出る .2s ease; }
.toast button { flex: none; border: 1px solid #fff; background: none; color: #fff; border-radius: 999px; padding: 4px 12px; font-weight: 700; cursor: pointer; }

@media (min-width: 700px) {
  .pc { display: inline; }
  .wrap { padding: 0 24px; }
  .intro { padding: 40px 0 16px; }
  .title { font-size: 30px; }
  .steps { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1000px) {
  .app { flex-direction: row; align-items: flex-start; gap: 28px; }
  .panel { width: 440px; flex: none; }
  .preview-col { flex: 1; position: sticky; top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 印刷（A4 1枚） ---------- */
@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff; margin: 0; padding: 0; }
  .no-print { display: none !important; }
  main, .app, .preview-col { display: block !important; padding: 0 !important; margin: 0 !important; width: auto !important; max-width: none !important; position: static !important; }
  .sheet-fit { height: auto !important; box-shadow: none; border-radius: 0; overflow: visible; }
  .sheet { position: static; transform: none !important; height: 296mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; break-after: avoid; page-break-after: avoid; }
  /* 一括作成は1社1ページ */
  .batch-list { display: block !important; }
  .batch-fit + .batch-fit { break-before: page; page-break-before: always; }
}
