:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1d232b;
  --muted: #5d6772;
  --line: #dde1e6;
  --accent: #1f5f8b;
  --accent-soft: #e8f1f8;
  --good: #1d7a46;
  --bad: #b3261e;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06), 0 4px 16px rgba(20, 30, 45, 0.06);
  color-scheme: light;
}
* { 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: system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Yu Gothic UI', Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}
a { color: var(--accent); }
img { max-width: 100%; height: auto; }
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }

/* ---- ヘッダー・フッター ---- */
.site-head { position: sticky; top: 0; z-index: 10; background: rgba(255, 255, 255, 0.95); border-bottom: 1px solid var(--line); backdrop-filter: saturate(1.4) blur(6px); }
.site-head .wrap { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 700; text-decoration: none; white-space: nowrap; }
.logo img { width: 26px; height: 26px; }
.nav { display: flex; gap: 4px 16px; margin-left: auto; overflow-x: auto; font-size: 14px; white-space: nowrap; scrollbar-width: none; }
.nav a { padding: 6px 2px; color: var(--muted); text-decoration: none; }
.nav a:hover, .nav a[aria-current='page'] { color: var(--accent); }
.lang-switch { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); font-size: 13px; text-decoration: none; white-space: nowrap; }
@media (max-width: 760px) {
  .site-head .wrap { flex-wrap: wrap; gap: 0 12px; padding-top: 6px; }
  .nav { order: 3; width: 100%; margin-left: 0; padding-bottom: 4px; }
  .lang-switch { margin-left: auto; }
}
.site-foot { margin-top: 64px; padding: 32px 0 40px; border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 14px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 12px; }
.site-foot a { color: var(--muted); }

/* ---- 本文 ---- */
main { display: block; }
.hero { padding: 28px 0 4px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(23px, 4vw, 34px); line-height: 1.3; }
.hero p { margin: 0; color: var(--muted); max-width: 860px; }
.crumbs { margin: 16px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px; font-size: 13px; color: var(--muted); }
.crumbs li + li::before { content: '›'; margin: 0 6px 0 2px; }
section.block { margin-top: 36px; }
h2 { margin: 0 0 16px; font-size: 22px; line-height: 1.4; }
h3 { margin: 0 0 8px; font-size: 17px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.note { color: var(--muted); font-size: 14px; }
.prose { max-width: 780px; }
.prose h2 { margin-top: 36px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.links a { display: inline-block; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-size: 14px; text-decoration: none; }
.links a:hover { border-color: var(--accent); color: var(--accent); }
.faq details { padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.faq details + details { margin-top: 8px; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq p { margin: 10px 0 0; }
.tbl-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: #fff; font-size: 15px; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data thead th { background: var(--accent-soft); font-size: 13px; color: var(--muted); }
.prose table.data th { white-space: nowrap; }

/* ---- ボタン・入力 ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 22px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; cursor: pointer; font: inherit; font-weight: 700; text-decoration: none; text-align: center; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn.secondary { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn.small { min-height: 36px; padding: 5px 12px; font-size: 14px; font-weight: 600; }
.btn small { font-weight: 400; opacity: 0.9; }
.icon { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer; font: inherit; font-size: 16px; line-height: 1; }
.icon:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.icon:disabled { opacity: 0.35; cursor: default; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.field { display: block; min-width: 0; margin: 0; padding: 0; border: 0; }
.field.wide { grid-column: 1 / -1; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.field small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.field select, .field input[type='text'], .field input[type='number'], .range, .sign-nav select {
  width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid #c9cfd6; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; font-size: 16px;
}
.field input[type='range'] { width: 100%; accent-color: var(--accent); }
.radios { display: flex; flex-wrap: wrap; gap: 8px; }
.radios label { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; font-size: 14px; }
.radios label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.radios input { accent-color: var(--accent); }
.check-line { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-size: 14px; line-height: 1.5; cursor: pointer; }
.check-line input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }


/* ---- 作成画面 ---- */
.field textarea { width: 100%; padding: 8px 10px; border: 1px solid #c9cfd6; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; resize: vertical; }
.field input[type='date'] { width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid #c9cfd6; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.privacy-badge { margin: 8px 0 0; font-size: 13px; color: var(--good); font-weight: 700; }
.privacy-badge::before { content: '🔒 '; }
.disclaimer { margin-top: 24px; padding: 12px 16px; border-left: 4px solid var(--accent); background: var(--accent-soft); font-size: 14px; }
.cross { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.cross a { display: block; height: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); text-decoration: none; }
.cross a:hover { border-color: var(--accent); }
.cross small { display: block; color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 2px; }

.inv-app { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 24px; align-items: start; margin-top: 8px; }
@media (max-width: 980px) { .inv-app { grid-template-columns: minmax(0, 1fr); } }
.inv-form { display: grid; gap: 14px; min-width: 0; }
.inv-form fieldset { margin: 0; min-width: 0; }
.inv-form legend { padding: 0 6px; font-weight: 700; font-size: 15px; }
.inv-form .fields { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.inv-form .check-line.wide, .inv-form .field.wide { grid-column: 1 / -1; }
.inv-form .check-line { margin-top: 4px; }
.type-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: #e3e8ee; }
.type-tabs button { min-height: 42px; border: 0; border-radius: 9px; background: transparent; color: var(--ink); cursor: pointer; font: inherit; font-weight: 700; font-size: 15px; }
.type-tabs button[aria-pressed='true'] { background: #fff; color: var(--accent); box-shadow: var(--shadow); }
.more summary { cursor: pointer; font-weight: 700; }
.more .fields { margin-top: 12px; }

.lines { display: grid; gap: 10px; margin-top: 12px; }
.line { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.line label, .line > div { display: block; min-width: 0; }
.line span { display: block; font-size: 11px; font-weight: 700; color: var(--muted); }
.line input, .line select { width: 100%; min-height: 38px; padding: 4px 8px; border: 1px solid #c9cfd6; border-radius: 7px; background: #fff; font: inherit; font-size: 15px; }
.line .l-amt b { display: block; min-height: 38px; line-height: 38px; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; font-size: 14px; }
.l-btns { display: flex; gap: 3px; }
.l-btns .icon { min-width: 30px; height: 38px; padding: 0 4px; font-size: 14px; }
.l-desc { grid-column: span 9; order: 0; }
.line > * { order: 2; }
.line > .l-desc { order: 0; }
.line > .l-btns { order: 1; align-self: end; }
.l-qty { grid-column: span 2; } .l-unit { grid-column: span 2; } .l-price { grid-column: span 3; } .l-rate { grid-column: span 2; } .l-amt { grid-column: span 3; }
.l-btns { grid-column: span 3; justify-content: flex-end; }
@media (max-width: 640px) {
  .l-desc { grid-column: span 8; } .l-btns { grid-column: span 4; }
  .l-qty, .l-unit { grid-column: span 3; } .l-price { grid-column: span 6; }
  .l-rate { grid-column: span 6; } .l-amt { grid-column: span 6; }
}

.inv-side { position: sticky; top: 68px; display: grid; gap: 14px; min-width: 0; }
@media (max-width: 980px) { .inv-side { position: static; } }
.side-actions { display: grid; gap: 10px; }
.side-actions .btn { width: 100%; font-size: 17px; }
.side-actions .note { margin: 0; font-size: 13px; }
.sum-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.sum-box > div { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.sum-box span { display: block; font-size: 12px; color: var(--muted); }
.sum-box b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sum-box small { display: block; font-size: 11px; color: var(--muted); }
.checks { padding: 12px 14px; border: 1px solid #f0c9a0; border-radius: 10px; background: #fff8ef; font-size: 14px; }
.checks.good { border-color: #b7dcc5; background: #f1faf4; }
.checks ul { margin: 6px 0 0; padding: 0; list-style: none; }
.checks li.ok { color: var(--good); }
.checks li.ng { color: var(--bad); font-weight: 700; }
.checks li.opt { color: var(--muted); }
.checks small { display: block; margin-top: 6px; color: var(--muted); }
.inv-preview { position: relative; overflow: hidden; border-radius: 6px; background: #dfe4ea; }
.inv-preview .sheet { position: absolute; top: 0; left: 0; transform-origin: 0 0; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); }
.saved-box { padding: 14px; }
.saved-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.saved-head .note { font-size: 12px; margin: 0; }
.saved { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; max-height: 320px; overflow-y: auto; }
.saved li { display: flex; gap: 6px; align-items: stretch; }
.saved li.empty { color: var(--muted); font-size: 14px; }
.saved li button[data-open] { flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-align: left; cursor: pointer; font: inherit; }
.saved li.on button[data-open] { border-color: var(--accent); background: var(--accent-soft); }
.saved b { display: block; font-size: 14px; overflow-wrap: anywhere; }
.saved small { display: block; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.saved .icon { height: auto; }
.mini { display: grid; gap: 10px; max-width: 640px; }
.mini output { display: block; font-size: 16px; }
.mini output b { font-size: 22px; color: var(--accent); }
.mini output small { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }

/* ---- 書類（A4）---- */
.sheet { width: 210mm; min-height: 297mm; padding: 14mm 15mm; background: #fff; color: #111; font-family: 'Yu Gothic', 'YuGothic', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, 'Noto Sans JP', sans-serif; font-size: 10pt; line-height: 1.55; font-weight: 500; }
.sheet.en { font-family: 'Segoe UI', Arial, Helvetica, sans-serif; }
.sheet .ph { color: #b0b6bd; }
.s-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10mm; margin-bottom: 8mm; }
.s-top h1 { margin: 0; font-size: 22pt; letter-spacing: 0.3em; font-weight: 700; }
.sheet.en .s-top h1 { letter-spacing: 0.06em; text-transform: uppercase; }
.s-meta { border-collapse: collapse; font-size: 9.5pt; }
.s-meta th { padding: 1px 4mm 1px 0; text-align: left; font-weight: 500; color: #555; white-space: nowrap; }
.s-meta td { padding: 1px 0; text-align: right; white-space: nowrap; }
.s-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8mm; margin-bottom: 6mm; }
.s-row.end { margin-top: 4mm; }
.s-to-wrap { flex: 1; min-width: 0; }
.s-to { padding-bottom: 1.5mm; border-bottom: 1px solid #111; font-size: 14pt; font-weight: 700; overflow-wrap: anywhere; }
.s-to small { display: block; font-size: 8.5pt; font-weight: 500; color: #555; text-transform: uppercase; letter-spacing: 0.05em; }
.s-to .hon { margin-left: 3mm; font-size: 12pt; }
.s-to.big { margin: 0 0 6mm; max-width: 120mm; font-size: 16pt; }
.s-addr { margin-top: 1.5mm; font-size: 9pt; color: #333; }
.s-subj { margin: 4mm 0 0; }
.s-lead { margin: 3mm 0 0; font-size: 9.5pt; }
.s-amount { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2mm 5mm; margin-top: 4mm; padding: 2.5mm 4mm; border: 1.5px solid #111; }
.s-amount span { font-weight: 700; white-space: nowrap; }
.s-amount b { font-size: 17pt; font-variant-numeric: tabular-nums; }
.s-amount small { font-size: 8.5pt; color: #444; }
.s-from { position: relative; width: 72mm; flex: none; font-size: 9pt; overflow-wrap: anywhere; }
.s-from b { display: block; font-size: 11pt; margin-bottom: 1mm; padding-right: 20mm; }
.s-stamp { position: absolute; right: 0; top: 0; width: 18mm; height: 18mm; object-fit: contain; opacity: 0.92; }
.s-items { width: 100%; border-collapse: collapse; margin-top: 2mm; font-size: 9.5pt; }
.s-items th { padding: 1.6mm 2mm; background: #eef1f4; border-top: 1px solid #555; border-bottom: 1px solid #555; text-align: left; font-weight: 700; white-space: nowrap; }
.s-items td { padding: 1.6mm 2mm; border-bottom: 1px solid #d5d9de; vertical-align: top; overflow-wrap: anywhere; }
.s-items .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.s-items tr { break-inside: avoid; }
.s-sum { border-collapse: collapse; min-width: 78mm; font-size: 9.5pt; }
.s-sum th { padding: 1.2mm 3mm 1.2mm 0; text-align: left; font-weight: 500; white-space: nowrap; }
.s-sum td { padding: 1.2mm 0; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.s-sum tr.total th, .s-sum tr.total td { border-top: 1px solid #111; font-weight: 700; font-size: 11pt; }
.s-bank { flex: 1; min-width: 0; padding: 3mm; border: 1px solid #ccd2d8; font-size: 9pt; overflow-wrap: anywhere; }
.s-bank small { display: block; margin-top: 1mm; color: #555; }
.s-notes { margin-top: 6mm; padding: 3mm; border: 1px solid #ccd2d8; font-size: 9pt; overflow-wrap: anywhere; }
.s-for { margin: 0 0 6mm; font-size: 11pt; }
.s-breakdown { flex: 1; }
.s-breakdown > b { display: block; font-size: 9pt; color: #555; }
.s-stampbox { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 24mm; height: 28mm; flex: none; border: 1px dashed #888; color: #888; font-size: 8pt; text-align: center; }
.print-only { display: none; }

@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  body > :not(.print-only) { display: none !important; }
  .print-only { display: block; }
  .print-only .sheet { box-shadow: none; }
}
