/* ---- base.css ---- */
/* ひとり請求書 — base */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f6;
  --text: #182032;
  --text-2: #556074;
  --text-3: #8790a2;
  --border: #dde2ea;
  --border-strong: #c5ccd8;
  --primary: #1f4ea3;
  --primary-hover: #173e85;
  --primary-soft: #e9effb;
  --primary-ink: #ffffff;
  --accent: #d0212d;
  --ok: #157f4f;
  --ok-soft: #e5f4ec;
  --warn: #9a5800;
  --warn-soft: #fff3dc;
  --danger: #c0262d;
  --danger-soft: #fdeceb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.07), 0 6px 16px rgba(15, 23, 42, 0.05);
  --font: system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic UI', Meiryo, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0e131d;
    --surface: #161d2a;
    --surface-2: #1d2534;
    --text: #e7eaf0;
    --text-2: #a6aec0;
    --text-3: #7c859a;
    --border: #2a3345;
    --border-strong: #3a455b;
    --primary: #6f9bff;
    --primary-hover: #8cb0ff;
    --primary-soft: #1c2944;
    --primary-ink: #0b1220;
    --ok: #4cc38a;
    --ok-soft: #13301f;
    --warn: #f0b552;
    --warn-soft: #33270f;
    --danger: #ff7b7b;
    --danger-soft: #3a1717;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 6px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0e131d;
  --surface: #161d2a;
  --surface-2: #1d2534;
  --text: #e7eaf0;
  --text-2: #a6aec0;
  --text-3: #7c859a;
  --border: #2a3345;
  --border-strong: #3a455b;
  --primary: #6f9bff;
  --primary-hover: #8cb0ff;
  --primary-soft: #1c2944;
  --primary-ink: #0b1220;
  --ok: #4cc38a;
  --ok-soft: #13301f;
  --warn: #f0b552;
  --warn-soft: #33270f;
  --danger: #ff7b7b;
  --danger-soft: #3a1717;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
html.hs-noscroll, html.hs-noscroll body { overflow: hidden; }
img, svg { max-width: 100%; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { line-height: 1.35; margin: 0 0 0.5em; letter-spacing: 0.01em; }
p { margin: 0 0 1em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-ink); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(0.94); background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; }
.btn-link { border-color: transparent; background: transparent; color: var(--text-2); font-weight: 500; text-decoration: underline; }
.btn-link:hover { background: transparent; color: var(--danger); }
.btn-sm { min-height: 32px; padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { min-height: 52px; padding: 12px 26px; font-size: 16px; border-radius: 12px; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.ib {
  width: 28px; height: 28px; display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text-3);
  font: inherit; font-size: 14px; cursor: pointer;
}
.ib:hover { background: var(--surface-2); color: var(--text); }
.ib-del:hover { color: var(--danger); background: var(--danger-soft); }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 3px 11px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }

/* ---- form ---- */
.in {
  width: 100%; min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 15px; line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.in:hover { border-color: var(--text-3); }
.in:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.in::placeholder { color: var(--text-3); }
textarea.in { resize: vertical; min-height: 64px; }
select.in { padding-right: 28px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.in.num { text-align: right; font-variant-numeric: tabular-nums; }
.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.f-label small { font-weight: 500; color: var(--text-3); font-size: 11.5px; }
.f-msg { font-size: 12px; color: var(--text-3); min-height: 0; }
.f-msg.is-error { color: var(--danger); }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 560px) {
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
}

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border-strong); border-radius: 10px; padding: 3px; background: var(--surface-2); gap: 2px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 5px 12px; border-radius: 7px; font-size: 13.5px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg input:checked + span { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); }

.tg { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; user-select: none; padding: 4px 0; }
.tg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tg-ui { width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; flex: none; transition: background 0.15s; }
.tg-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.tg input:checked + .tg-ui { background: var(--primary); }
.tg input:checked + .tg-ui::after { transform: translateX(16px); }
.tg input:focus-visible + .tg-ui { outline: 2px solid var(--primary); outline-offset: 2px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.card-h { font-size: 15px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: baseline; gap: 6px; }
.card-sub { font-size: 12.5px; font-weight: 500; color: var(--text-3); }
details.card > summary { cursor: pointer; list-style: none; margin: 0; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: '＋'; margin-left: auto; color: var(--text-3); font-weight: 400; }
details.card[open] > summary { margin-bottom: 12px; }
details.card[open] > summary::after { content: '－'; }
.sub-h { font-size: 13px; color: var(--text-2); margin: 16px 0 8px; padding-top: 12px; border-top: 1px dashed var(--border); }
.hint { font-size: 12.5px; color: var(--text-3); margin: 8px 0 0; line-height: 1.6; }
.notice { font-size: 13px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 12px; margin: 8px 0 0; color: var(--text-2); }
.notice b { color: var(--text); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; border-radius: 999px; padding: 4px 12px; background: var(--surface-2); color: var(--text-2); }
.badge.is-ok { background: var(--ok-soft); color: var(--ok); }
.badge.is-warn { background: var(--warn-soft); color: var(--warn); cursor: pointer; }
.badge-details summary { list-style: none; }
.badge-details summary::-webkit-details-marker { display: none; }
.badge-details ul { list-style: none; margin: 8px 0 4px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12.5px; }
.badge-details li.ng { color: var(--warn); font-weight: 700; }
.badge-details li.ok { color: var(--text-3); }
.badge-details p { font-size: 12px; color: var(--text-3); margin: 4px 0 0; }

.hs-toasts { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 1000; pointer-events: none; width: min(92vw, 460px); }
.hs-toast { background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); transition: opacity 0.4s, transform 0.4s; text-align: center; }
.hs-toast.is-ok { background: #13643f; }
.hs-toast.is-error { background: #9f1f25; }
.hs-toast.is-out { opacity: 0; transform: translateY(8px); }

dialog.hs-dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
dialog.hs-dialog::backdrop { background: rgba(10, 15, 25, 0.45); }
.dlg-head { padding: 16px 20px 0; font-weight: 700; font-size: 16px; }
.dlg-body { padding: 12px 20px; }
.dlg-foot { padding: 12px 20px 16px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

/* ---- editor.css ---- */
/* ひとり請求書 — editor */
.ed { --ed-top: 0px; }
.ed-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 0 14px;
}
.ed-types { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 2px; box-shadow: var(--shadow-sm); }
.ed-type { border: 0; background: transparent; color: var(--text-2); font: inherit; font-weight: 700; font-size: 14.5px; padding: 7px 16px; border-radius: 9px; cursor: pointer; }
.ed-type:hover { color: var(--text); background: var(--surface-2); }
.ed-type.is-on { background: var(--primary); color: var(--primary-ink); }
.ed-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.ed-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.ed-form { display: grid; gap: 14px; min-width: 0; }
.ed-preview { display: none; }
@media (min-width: 1080px) {
  .ed-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
  .ed-preview {
    display: flex; flex-direction: column; gap: 10px;
    position: sticky; top: calc(var(--ed-top) + 12px);
    max-height: calc(100vh - var(--ed-top) - 24px);
  }
  .ed-mobilebar { display: none !important; }
  .pv-close { display: none; }
}
.pv-bar { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-height: 30px; }
.pv-scroller { overflow: auto; border-radius: 10px; background: #e7eaf0; padding: 14px; flex: 1; min-height: 0; }
:root[data-theme='dark'] .pv-scroller { background: #0a0e16; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .pv-scroller { background: #0a0e16; } }
.paper-wrap { margin: 0 auto; position: relative; }
.paper { transform-origin: 0 0; width: max-content; }
.paper .doc { box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18); }
.pv-tip { font-size: 12px; color: var(--text-3); margin: 0; }

.ed-mobilebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}
.ed-mobilebar .btn { flex: 1; }
@media (max-width: 1079px) {
  .ed { padding-bottom: 72px; }
  .ed-actions > [data-act='print'] { display: none; }
  .ed.is-preview .ed-preview {
    display: flex; flex-direction: column; gap: 8px;
    position: fixed; inset: 0; z-index: 80; background: var(--bg); padding: 12px 12px 0;
  }
  .ed.is-preview .pv-scroller { padding: 8px; }
  .ed.is-preview .pv-tip { padding-bottom: 80px; }
  .ed.is-preview .ed-mobilebar { z-index: 90; }
  .ed.is-preview .ed-mobilebar [data-act='preview-open'] { display: none; }
}

.quick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; font-size: 12.5px; color: var(--text-3); }
.grid.g3 + .grid, .quick + .grid { margin-top: 12px; }
.grid.g-client { grid-template-columns: minmax(0, 1fr) 110px; }
.picker { display: flex; gap: 8px; margin-bottom: 10px; }
.picker select { flex: 1; }
details.more { margin-top: 10px; }
details.more > summary { cursor: pointer; font-size: 13px; color: var(--primary); font-weight: 600; margin-bottom: 10px; }
.row-set { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.row-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); min-width: 84px; }
.swatches { display: flex; gap: 8px; }
.sw { width: 26px; height: 26px; border-radius: 50%; background: var(--sw); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; }
.sw.is-on { box-shadow: 0 0 0 2px var(--text); }
.upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.ed-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.card-issuer > summary { color: var(--text); }

/* items */
.it-head, .it-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px 58px 96px 84px 84px 88px;
  gap: 6px; align-items: center;
}
.it-head { font-size: 11.5px; font-weight: 700; color: var(--text-3); padding: 0 2px 6px; }
.it-head span:nth-child(n + 2):nth-child(-n + 6) { text-align: center; }
.it-list { display: grid; gap: 6px; }
.it-row .in { min-height: 36px; padding: 6px 8px; font-size: 14px; }
.it-row select.in { padding-right: 22px; background-position: calc(100% - 12px) 52%, calc(100% - 7px) 52%; font-size: 13px; }
.it-amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px; padding-right: 2px; }
.it-ops { display: flex; align-items: center; justify-content: flex-end; gap: 0; }
.it-wh { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; color: var(--text-2); margin-right: 2px; white-space: nowrap; cursor: pointer; }
.it-wh input { margin: 0; width: 13px; height: 13px; }
.it-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.it-total { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.it-total b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; margin-left: 4px; }
@media (max-width: 1279px) and (min-width: 1080px), (max-width: 720px) {
  .it-head { display: none; }
  .it-row {
    grid-template-columns: 1fr 1fr 1.6fr 1.4fr;
    grid-template-areas: 'name name name name' 'qty unit price rate' 'amt amt amt ops';
    padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  }
  .it-name { grid-area: name; }
  .it-qty { grid-area: qty; }
  .it-unit { grid-area: unit; }
  .it-price { grid-area: price; }
  .it-rate { grid-area: rate; }
  .it-amt { grid-area: amt; text-align: left; }
  .it-amt::before { content: '金額 '; font-weight: 500; color: var(--text-3); font-size: 12px; }
  .it-ops { grid-area: ops; }
}

/* ---- doc.css ---- */
/* ひとり請求書 — 書類（A4）と印刷 */
.doc {
  --doc-accent: #1f4ea3;
  --doc-ink: #1b1d22;
  --doc-sub: #4b505b;
  --doc-line: #cdd2db;
  --doc-tint: color-mix(in srgb, var(--doc-accent) 9%, #ffffff);
  /* BIZ UDP 系を先頭に：Chrome の PDF で康熙部首に化けない（Windows 10/11 標準搭載） */
  --doc-font: 'BIZ UDPGothic', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', YuGothic, Meiryo, 'Noto Sans JP', sans-serif;
  width: 210mm;
  min-height: 297mm;
  padding: 15mm 15mm 14mm;
  background: #fff;
  color: var(--doc-ink);
  font-family: var(--doc-font);
  font-size: 9.6pt;
  font-weight: 500;
  line-height: 1.55;
  position: relative;
  overflow: hidden;
  text-align: left;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color-scheme: light;
}
.doc.f-mincho { --doc-font: 'BIZ UDPMincho', 'Hiragino Mincho ProN', 'Yu Mincho', YuMincho, 'Noto Serif JP', 'MS PMincho', serif; }
.doc *, .doc *::before, .doc *::after { box-sizing: border-box; }
.doc h1, .doc p, .doc dl, .doc dd, .doc table { margin: 0; }
.doc th, .doc b, .doc strong { font-weight: 700; }
.doc-ph { color: #b3b8c2; font-weight: 400; }
.doc-label { color: var(--doc-sub); font-size: 8.5pt; white-space: nowrap; }

.doc-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 8mm;
  border-bottom: 2px solid var(--doc-accent); padding-bottom: 3mm; margin-bottom: 7mm;
}
.doc-title { font-size: 21pt; letter-spacing: 0.42em; font-weight: 700; line-height: 1.2; color: var(--doc-ink); }
.doc-meta { display: grid; gap: 0.8mm; font-size: 9pt; }
.doc-meta div { display: flex; gap: 3mm; justify-content: flex-end; }
.doc-meta dt { color: var(--doc-sub); }
.doc-meta dd { min-width: 30mm; text-align: right; font-variant-numeric: tabular-nums; }

.doc-parties { display: grid; grid-template-columns: minmax(0, 1fr) 68mm; gap: 9mm; align-items: start; }
.doc-client-line { display: flex; align-items: baseline; gap: 3mm; border-bottom: 1px solid var(--doc-ink); padding-bottom: 1.5mm; }
.doc-client-name { font-size: 14pt; font-weight: 700; word-break: break-word; }
.doc-honor { font-size: 11pt; white-space: nowrap; }
.doc-client-sub { font-size: 8.5pt; color: var(--doc-sub); margin-top: 1.5mm; }
.doc-subject { margin-top: 4.5mm; display: flex; gap: 3mm; align-items: baseline; font-size: 10pt; }
.doc-lead { margin: 4mm 0 2.5mm !important; font-size: 9.4pt; }
.doc-total { display: flex; align-items: baseline; gap: 4mm; padding: 3mm 4.5mm; background: var(--doc-tint); border-left: 3px solid var(--doc-accent); }
.doc-total-label { font-weight: 700; font-size: 10pt; }
.doc-total-value { font-size: 19pt; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; line-height: 1.2; }
.doc-total-note { font-size: 8.5pt; color: var(--doc-sub); }
.doc-keydates { margin-top: 3mm; }
.doc-keydates div { justify-content: flex-start; }
.doc-keydates dt { min-width: 20mm; }
.doc-keydates dd { text-align: left; min-width: 0; }

.doc-from { font-size: 8.8pt; line-height: 1.6; position: relative; word-break: break-word; }
.doc-logo { max-width: 52mm; max-height: 15mm; display: block; margin-bottom: 2.5mm; object-fit: contain; }
.doc-from-main { position: relative; min-height: 12mm; padding-right: 2mm; }
.doc-from-name { font-size: 11pt; font-weight: 700; position: relative; z-index: 1; }
.doc-from-person { font-size: 9.6pt; position: relative; z-index: 1; }
.doc-from-addr, .doc-from-contact { margin-top: 1.5mm; color: var(--doc-sub); }
.doc-regno { margin-top: 1.5mm; font-weight: 700; letter-spacing: 0.02em; }
.doc-seal { position: absolute; right: 0; top: -1.5mm; width: 17mm; height: 17mm; opacity: 0.88; mix-blend-mode: multiply; pointer-events: none; z-index: 2; }
.doc-seal svg, .doc-seal img { width: 100%; height: 100%; object-fit: contain; display: block; }

.doc-items { width: 100%; border-collapse: collapse; margin-top: 7mm; font-size: 9pt; table-layout: fixed; }
.doc-items thead { display: table-header-group; }
.doc-items tr { break-inside: avoid; page-break-inside: avoid; }
.doc-items th { background: var(--doc-accent); color: #fff; padding: 1.8mm 2mm; text-align: center; font-size: 8.5pt; letter-spacing: 0.05em; }
.doc-items td { padding: 1.8mm 2mm; border-bottom: 1px solid var(--doc-line); vertical-align: top; word-break: break-word; }
.doc-items tbody tr:nth-child(even) td { background: #f8f9fb; }
.doc-items .c-name { text-align: left; }
.doc-items .c-qty { width: 15mm; text-align: right; }
.doc-items .c-unit { width: 12mm; text-align: center; }
.doc-items .c-price { width: 24mm; text-align: right; }
.doc-items .c-rate { width: 14mm; text-align: center; }
.doc-items .c-amt { width: 27mm; text-align: right; }
.doc-items th.c-name, .doc-items th.c-qty, .doc-items th.c-price, .doc-items th.c-amt { text-align: center; }
.doc-items td.c-qty, .doc-items td.c-price, .doc-items td.c-amt { font-variant-numeric: tabular-nums; }

.doc-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 68mm; gap: 9mm; margin-top: 4mm; align-items: start; }
.doc-breakdown { border-collapse: collapse; font-size: 8.4pt; width: 100%; }
.doc-breakdown caption { text-align: left; font-weight: 700; color: var(--doc-sub); padding-bottom: 1mm; }
.doc-breakdown th, .doc-breakdown td { border: 1px solid var(--doc-line); padding: 1.2mm 2mm; }
.doc-breakdown thead th { background: #f3f4f7; text-align: center; }
.doc-breakdown tbody th { text-align: left; font-weight: 500; }
.doc-breakdown td { text-align: right; font-variant-numeric: tabular-nums; }
.doc-sums { border-collapse: collapse; width: 100%; font-size: 9.5pt; }
.doc-sums tr { border-bottom: 1px solid var(--doc-line); }
.doc-sums th { text-align: left; font-weight: 500; padding: 1.3mm 2mm; color: var(--doc-sub); }
.doc-sums td { text-align: right; padding: 1.3mm 2mm; font-variant-numeric: tabular-nums; }
.doc-sums tr.is-total th, .doc-sums tr.is-total td { font-weight: 700; color: var(--doc-ink); font-size: 11pt; background: var(--doc-tint); }
.doc-sums tr.is-total { border-bottom: 2px solid var(--doc-accent); }

.doc-bank, .doc-notes { margin-top: 5mm; border: 1px solid var(--doc-line); padding: 2.5mm 3.5mm; font-size: 9pt; display: grid; grid-template-columns: 17mm minmax(0, 1fr); gap: 3mm; align-items: baseline; break-inside: avoid; }
.doc-foot { margin-top: 3mm !important; font-size: 8pt; color: var(--doc-sub); }
.doc-watermark {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 5; pointer-events: none;
  font-size: 80pt; font-weight: 800; letter-spacing: 0.25em; color: rgba(208, 33, 45, 0.1); transform: rotate(-24deg);
}

/* modern */
.doc.t-modern .doc-head { background: var(--doc-accent); margin: -15mm -15mm 8mm; padding: 11mm 15mm 6mm; border: 0; }
.doc.t-modern .doc-title { color: #fff; letter-spacing: 0.28em; }
.doc.t-modern .doc-meta dt { color: rgba(255, 255, 255, 0.78); }
.doc.t-modern .doc-meta dd { color: #fff; }
.doc.t-modern .doc-total { border-left: 0; border-radius: 2mm; }
.doc.t-modern .doc-items th { background: var(--doc-tint); color: var(--doc-ink); border-bottom: 2px solid var(--doc-accent); }
.doc.t-modern .doc-items tbody tr:nth-child(even) td { background: transparent; }
.doc.t-modern .doc-bank, .doc.t-modern .doc-notes { border: 0; background: #f6f7f9; border-radius: 2mm; }

/* classic */
.doc.t-classic .doc-head { display: block; text-align: center; border-bottom: 0; margin-bottom: 5mm; }
.doc.t-classic .doc-title { display: inline-block; padding: 0 6mm 1.5mm; border-bottom: 3px double var(--doc-ink); letter-spacing: 0.6em; text-indent: 0.6em; }
.doc.t-classic .doc-meta { margin-top: 3mm; }
.doc.t-classic .doc-items th { background: #f1f2f4; color: var(--doc-ink); border: 1px solid #6b7078; }
.doc.t-classic .doc-items td { border: 1px solid #8c919a; }
.doc.t-classic .doc-items tbody tr:nth-child(even) td { background: transparent; }
.doc.t-classic .doc-total { background: transparent; border-left: 0; border-bottom: 3px double var(--doc-ink); padding-left: 0; }
.doc.t-classic .doc-sums tr.is-total th, .doc.t-classic .doc-sums tr.is-total td { background: transparent; }
.doc.t-classic .doc-sums tr.is-total { border-bottom: 3px double var(--doc-ink); }

/* receipt */
.doc.type-receipt { min-height: 170mm; }
.doc .rc-client { margin-top: 2mm; width: 125mm; }
.rc-amount { display: flex; align-items: baseline; gap: 5mm; margin: 7mm 0 4mm; padding: 4mm 6mm; background: var(--doc-tint); border-bottom: 3px double var(--doc-ink); width: 135mm; }
.rc-amount-label { font-weight: 700; font-size: 10.5pt; }
.rc-amount-value { font-size: 24pt; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.03em; line-height: 1.15; }
.rc-dash { margin-left: 0.3mm; }
.rc-amount-note { font-size: 8.5pt; color: var(--doc-sub); }
.rc-purpose { display: flex; gap: 4mm; align-items: baseline; border-bottom: 1px solid var(--doc-line); width: 135mm; padding-bottom: 1.5mm; font-size: 10.5pt; }
.rc-lead { margin: 4mm 0 7mm !important; }
.rc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 68mm; gap: 9mm; align-items: start; }
.rc-breakdown { border-collapse: collapse; font-size: 8.6pt; width: 100%; }
.rc-breakdown caption { text-align: left; font-weight: 700; color: var(--doc-sub); padding-bottom: 1mm; }
.rc-breakdown th, .rc-breakdown td { border: 1px solid var(--doc-line); padding: 1.2mm 2mm; text-align: left; font-weight: 500; }
.rc-breakdown th { background: #f3f4f7; white-space: nowrap; }
.rc-stamp { margin-top: 5mm; width: 24mm; height: 28mm; border: 1px dashed #8a8f99; display: grid; align-content: center; justify-items: center; gap: 1mm; font-size: 8pt; color: #7a7f89; }
.doc.type-receipt .doc-items { margin-top: 6mm; }
.doc.t-modern.type-receipt .rc-amount { border-bottom: 0; border-radius: 2mm; }
.doc.t-classic.type-receipt .rc-amount { background: transparent; }

/* 印刷 */
.print-root { display: none; }
@page { size: A4 portrait; margin: 0; }
@media print {
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  body > *:not(.print-root) { display: none !important; }
  .print-root { display: block !important; }
  .print-root .doc { box-shadow: none !important; min-height: 0; overflow: visible; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
}

/* ---- tools.css ---- */
/* ひとり請求書 — 計算ツール */
.tool-grid { display: grid; gap: 18px; align-items: start; }
@media (min-width: 960px) { .tool-grid { grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); } }
.tool-form { display: grid; gap: 12px; }
.tool-form .tg { display: flex; }
.tool-result { display: grid; gap: 14px; }
.tool-out { display: grid; gap: 12px; }
.out-h { font-weight: 800; font-size: 15px; }
.in-xl { font-size: 22px; min-height: 52px; font-weight: 700; }
.seg-lg span { padding: 8px 16px; font-size: 14.5px; }

.mcards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.mcard { position: relative; border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface); display: grid; gap: 4px; align-content: start; }
.mcard.is-best { border: 2px solid var(--ok); background: color-mix(in srgb, var(--ok-soft) 55%, var(--surface)); }
.mcard.is-na { opacity: 0.6; }
.mcard-badge { position: absolute; top: -10px; right: 10px; background: var(--ok); color: #fff; font-size: 11.5px; font-weight: 800; border-radius: 999px; padding: 2px 10px; }
.mcard-h { font-weight: 800; font-size: 14px; color: var(--text-2); }
.mcard-v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; line-height: 1.25; }
.mcard-v small { font-size: 13px; margin-left: 2px; font-weight: 700; }
.mcard-v .na { font-size: 15px; color: var(--text-3); }
.mcard-r { font-size: 12.5px; color: var(--text-2); font-weight: 700; }
.mcard-n { font-size: 12px; color: var(--text-3); margin: 4px 0 0; line-height: 1.55; }
.mcard-d summary { font-size: 12px; color: var(--primary); cursor: pointer; margin-top: 4px; }
.mcard-d dl { margin: 6px 0 0; font-size: 12px; display: grid; gap: 2px; }
.mcard-d dl div { display: flex; justify-content: space-between; gap: 8px; }
.mcard-d dt { color: var(--text-3); }
.mcard-d dd { margin: 0; font-variant-numeric: tabular-nums; }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13.5px; }
.bar-label { color: var(--text-2); font-weight: 700; }
.bar-track { height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: color-mix(in srgb, var(--primary) 55%, var(--surface)); }
.bar-row.is-cur .bar-fill { background: var(--primary); }
.bar-row.is-cur .bar-label { color: var(--text); }
.bar-value { font-variant-numeric: tabular-nums; font-weight: 800; text-align: right; white-space: nowrap; }
.bar-value small { font-weight: 500; color: var(--text-3); font-size: 11.5px; margin-left: 2px; }
@media (max-width: 520px) {
  .bar-row { grid-template-columns: 52px minmax(0, 1fr); }
  .bar-value { grid-column: 2; text-align: left; }
}

.callout { background: var(--warn-soft); color: var(--text); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin: 0; }
.callout b { color: var(--warn); }
.callout.is-tip { background: var(--ok-soft); }
.callout.is-tip b { color: var(--ok); }
.checks { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; font-size: 14px; }

.kv { width: 100%; border-collapse: collapse; font-size: 15px; }
.kv th { text-align: left; font-weight: 500; color: var(--text-2); padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv td { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv tr.is-minus td { color: var(--danger); }
.kv tr.is-total th, .kv tr.is-total td { font-size: 18px; font-weight: 800; color: var(--text); border-bottom: 2px solid var(--text); }
.big-kv { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 6px 0 4px; }
.big-kv span { font-weight: 700; color: var(--text-2); }
.big-kv b { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.big-kv b small { font-size: 15px; margin-left: 2px; }
.formula { font-size: 12.5px; color: var(--text-3); margin: 0; font-variant-numeric: tabular-nums; }

/* アフィリエイト */
.aff { display: grid; gap: 10px; }
.aff-h { font-weight: 800; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.pr { font-size: 10.5px; font-weight: 700; color: var(--text-3); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; line-height: 1.6; }
.aff-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.aff-item { display: grid; gap: 4px; align-content: start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s; }
.aff-item:hover { border-color: var(--primary); box-shadow: var(--shadow); color: var(--text); }
.aff-name { font-weight: 800; font-size: 14.5px; display: flex; gap: 6px; align-items: center; }
.aff-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.aff-cta { font-size: 13px; color: var(--primary); font-weight: 700; margin-top: 2px; }

/* ---- site.css ---- */
/* ひとり請求書 — サイト */
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.wrap-wide { max-width: 1440px; }
.wrap-narrow { max-width: 780px; }
@media (max-width: 560px) { .wrap { padding: 0 16px; } }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 200; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.hd { display: flex; align-items: center; gap: 16px; min-height: 58px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; color: var(--text); text-decoration: none; letter-spacing: 0.02em; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand img { width: 28px; height: 28px; display: block; }
.nav { display: flex; align-items: center; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.nav a { color: var(--text-2); text-decoration: none; font-size: 13.5px; font-weight: 600; padding: 7px 10px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current='page'] { color: var(--primary); background: var(--primary-soft); }
.nav .nav-pro { color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); margin-left: 4px; }
.nav-toggle { display: none; margin-left: auto; }
@media (max-width: 1000px) {
  .nav-toggle { display: inline-flex; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 12px 14px; flex-direction: column; align-items: stretch; box-shadow: var(--shadow); }
  .nav.is-open { display: flex; }
  .nav a { padding: 11px 12px; font-size: 15px; }
  .nav .nav-pro { margin: 6px 0 0; text-align: center; }
}

main { display: block; }
.hero-mini { padding-top: 26px; padding-bottom: 4px; }
.hero-mini h1 { font-size: clamp(21px, 3vw, 28px); font-weight: 800; margin-bottom: 6px; }
.lead { color: var(--text-2); font-size: 15px; margin-bottom: 10px; max-width: 760px; }
.pills { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.pills li { font-size: 12.5px; font-weight: 700; color: var(--ok); background: var(--ok-soft); border-radius: 999px; padding: 3px 11px; }
.pills li::before { content: '✓ '; }

.section { padding: 40px 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

/* 記事 */
.prose { font-size: 16px; line-height: 1.9; padding-top: 32px; padding-bottom: 48px; }
.prose h1 { font-size: clamp(24px, 3.4vw, 32px); font-weight: 800; margin-bottom: 12px; }
.prose h2 { font-size: 21px; font-weight: 800; margin: 2.2em 0 0.7em; padding-left: 12px; border-left: 4px solid var(--primary); }
.prose h3 { font-size: 17.5px; font-weight: 800; margin: 1.8em 0 0.6em; }
.prose p, .prose ul, .prose ol, .prose table, .prose figure { margin: 0 0 1.1em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: 0.25em 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose thead th { background: var(--surface-2); }
.prose td.num, .prose th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.prose .meta { color: var(--text-3); font-size: 13.5px; margin-bottom: 1.6em; }
.prose blockquote { margin: 0 0 1.1em; padding: 10px 16px; border-left: 3px solid var(--border-strong); color: var(--text-2); background: var(--surface); border-radius: 0 8px 8px 0; }
.prose .box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; margin: 0 0 1.4em; }
.prose .box-h { font-weight: 800; margin-bottom: 6px; }
.prose .box > :last-child { margin-bottom: 0; }
.prose .box-ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); background: color-mix(in srgb, var(--ok-soft) 50%, var(--surface)); }
.prose .box-warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: color-mix(in srgb, var(--warn-soft) 60%, var(--surface)); }
.prose .cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 1.4em 0; }
.prose .sources { font-size: 13.5px; color: var(--text-2); }
.prose .toc { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 20px; font-size: 14.5px; }
.prose .toc ol { margin: 6px 0 0; }
.crumbs { font-size: 12.5px; color: var(--text-3); padding-top: 16px; }
.crumbs a { color: var(--text-3); }
.crumbs span { margin: 0 6px; }

.faq { margin-top: 2em; }
.faq details { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 8px; }
.faq summary { cursor: pointer; padding: 14px 18px; font-weight: 700; list-style: none; display: flex; gap: 10px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: 'Q'; color: var(--primary); font-weight: 800; }
.faq .a { padding: 0 18px 14px 40px; color: var(--text-2); font-size: 15px; }
.faq .a p:last-child { margin-bottom: 0; }

.cards-3 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.link-card { display: grid; gap: 6px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); text-decoration: none; box-shadow: var(--shadow-sm); transition: border-color 0.15s, transform 0.15s; }
.link-card:hover { border-color: var(--primary); color: var(--text); transform: translateY(-1px); }
.link-card b { font-size: 16px; }
.link-card span { font-size: 13.5px; color: var(--text-2); line-height: 1.6; }
.link-card .tag { font-size: 11.5px; font-weight: 800; color: var(--accent); }

.ad-slot { margin: 28px auto; min-height: 0; text-align: center; }
.ad-slot:empty { display: none; }
.ad-label { display: block; font-size: 11px; color: var(--text-3); margin-bottom: 4px; }

/* Pro 紹介 */
.pro-hero { padding: 48px 0 28px; text-align: center; }
.pro-hero h1 { font-size: clamp(26px, 4vw, 40px); font-weight: 900; letter-spacing: 0.01em; }
.pro-hero .lead { margin: 0 auto 18px; }
.price { font-size: 15px; color: var(--text-2); margin-top: 10px; }
.price b { font-size: 22px; color: var(--text); }
.compare { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 12px; overflow: hidden; font-size: 14.5px; }
.compare th, .compare td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: center; }
.compare th:first-child, .compare td:first-child { text-align: left; }
.compare thead th { background: var(--surface-2); }
.compare .yes { color: var(--ok); font-weight: 800; }
.compare .no { color: var(--text-3); }
.feature-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.feature b { display: block; font-size: 15.5px; margin-bottom: 4px; }
.feature p { font-size: 14px; color: var(--text-2); margin: 0; }

.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 40px; padding: 36px 0 28px; font-size: 13.5px; color: var(--text-2); }
.ft-cols { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin: 18px 0 22px; }
.ft-cols h4 { font-size: 13px; color: var(--text); margin-bottom: 8px; }
.ft-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.ft-cols a { color: var(--text-2); text-decoration: none; }
.ft-cols a:hover { color: var(--primary); text-decoration: underline; }
.ft-note { font-size: 12px; color: var(--text-3); line-height: 1.7; }
.ft-copy { font-size: 12px; color: var(--text-3); margin: 0; }
