/* 見積書作成ツール */

.tool-head { max-width: 48em; }

.privacy-note {
  margin-top: 16px;
  font-size: 0.875rem;
  color: var(--muted);
  border-left: 3px solid var(--rule);
  padding: 2px 0 2px 12px;
  max-width: 48em;
}

.workspace {
  margin-top: 28px;
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
@media (max-width: 960px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}

/* 入力欄 */
.form-pane {
  background: var(--sheet);
  border: 1px solid var(--rule);
  padding: 4px 20px 24px;
}
.form-pane fieldset { border: 0; padding: 0; margin: 0; }
.form-pane fieldset + fieldset { margin-top: 20px; padding-top: 4px; border-top: 1px solid var(--rule-soft); }
.form-pane legend {
  float: left;
  width: 100%;
  font-weight: 700;
  font-size: 1rem;
  padding: 16px 0 0;
}
.form-pane legend + * { clear: both; }
.hint { font-size: 0.8125rem; color: var(--muted); margin-top: 6px; }

.items { margin-top: 8px; }
.item {
  border: 1px solid var(--rule-soft);
  border-radius: 4px;
  padding: 10px 12px 12px;
  margin-top: 10px;
  background: #fafcfb;
}
.item-top { display: flex; justify-content: space-between; align-items: center; font-size: 0.8125rem; color: var(--muted); }
.item-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin-top: 6px; }
.item-grid .wide { grid-column: 1 / -1; }
.item-grid label > span { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 2px; }
.item-amount { grid-column: 1 / -1; text-align: right; font-size: 0.875rem; color: var(--muted); }
.item-amount b { color: var(--ink); font-weight: 700; }

.add-item { margin-top: 12px; width: 100%; }

.seal-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.seal-row img { width: 56px; height: 56px; object-fit: contain; border: 1px solid var(--rule-soft); background: #fff; }
.seal-row input[type="file"] { font-size: 0.875rem; max-width: 100%; }

/* プレビュー */
.preview-pane { position: sticky; top: 16px; }
@media (max-width: 960px) { .preview-pane { position: static; } }

.preview-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.preview-bar .total-mini { font-size: 0.875rem; color: var(--muted); }
.preview-bar .total-mini b { color: var(--ink); font-size: 1.125rem; }
.preview-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.sheet-frame {
  overflow: hidden;
  background: #dfe7e3;
  border: 1px solid var(--rule);
  padding: 12px;
}
.sheet-scaler { transform-origin: top left; width: 794px; }

/* 見積書本体（A4: 794 x 1123px @96dpi） */
.doc {
  width: 794px;
  min-height: 1123px;
  background: #fff;
  color: #111;
  padding: 64px 60px 56px;
  font-family: var(--gothic);
  font-size: 13px;
  line-height: 1.6;
  box-shadow: 0 1px 3px rgba(28, 42, 51, 0.18);
}
.doc-title {
  text-align: center;
  font-family: var(--mincho);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.6em;
  padding-left: 0.6em;
  border-bottom: 3px double #111;
  width: fit-content;
  min-width: 260px;
  white-space: nowrap;
  margin: 0 auto 28px;
  padding: 0 20px 4px calc(20px + 0.6em);
}
.doc-meta { text-align: right; font-size: 12px; }
.doc-meta div { white-space: nowrap; }

.doc-parties { display: flex; justify-content: space-between; gap: 24px; margin-top: 18px; }
.doc-client { flex: 1; min-width: 0; }
.doc-client-name {
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid #111;
  padding: 0 4px 2px;
  word-break: break-all;
}
.doc-client-name small { font-size: 14px; font-weight: 400; margin-left: 10px; }
.doc-greeting { margin-top: 12px; font-size: 12.5px; }

.doc-issuer { width: 270px; flex: none; font-size: 12px; position: relative; padding-right: 8px; }
.doc-issuer .issuer-name { font-size: 15px; font-weight: 700; margin-bottom: 2px; word-break: break-all; }
.doc-issuer div { word-break: break-all; }
.doc-issuer .seal {
  position: absolute;
  right: 0;
  top: -4px;
  width: 64px;
  height: 64px;
  object-fit: contain;
  opacity: 0.92;
}

.doc-total {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-top: 22px;
  border-bottom: 2px solid #111;
  padding: 0 4px 4px;
  width: 400px;
}
.doc-total span { font-size: 13px; }
.doc-total strong { font-size: 24px; font-family: var(--mincho); letter-spacing: 0.02em; }
.doc-total em { font-style: normal; font-size: 11px; }

.doc-terms { margin-top: 16px; border-collapse: collapse; width: 400px; font-size: 12px; }
.doc-terms th, .doc-terms td { border: 1px solid #7e8f99; padding: 4px 8px; text-align: left; }
.doc-terms th { width: 90px; background: #eef3f1; font-weight: 400; white-space: nowrap; }

.doc-items { margin-top: 22px; width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.doc-items th, .doc-items td { border: 1px solid #7e8f99; padding: 5px 8px; }
.doc-items thead th { background: #eef3f1; font-weight: 400; text-align: center; white-space: nowrap; }
.doc-items td { height: 30px; vertical-align: middle; word-break: break-all; }
.doc-items .c-name { width: auto; }
.doc-items .c-qty { width: 64px; text-align: right; }
.doc-items .c-unit { width: 52px; text-align: center; }
.doc-items .c-price { width: 96px; text-align: right; }
.doc-items .c-amount { width: 110px; text-align: right; }
.doc-items .reduced { font-size: 11px; margin-left: 4px; }

.doc-sum { margin-top: 0; margin-left: auto; border-collapse: collapse; font-size: 12px; width: 320px; }
.doc-sum th, .doc-sum td { border: 1px solid #7e8f99; border-top: 0; padding: 5px 8px; }
.doc-sum th { background: #eef3f1; font-weight: 400; text-align: left; }
.doc-sum td { text-align: right; width: 110px; }
.doc-sum tr.grand th, .doc-sum tr.grand td { font-weight: 700; font-size: 13px; }

.doc-note-label { margin-top: 20px; font-size: 12px; }
.doc-note { border: 1px solid #7e8f99; min-height: 70px; padding: 8px 10px; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.doc-reduced-note { font-size: 11px; margin-top: 6px; }

/* 解説 */
.guide { margin-top: 56px; }

/* 印刷：見積書だけを出力 */
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .site-header, .site-footer, .crumbs, .tool-head, .privacy-note, .form-pane,
  .preview-bar, .guide, .pr-box, .skip { display: none !important; }
  main { padding: 0; }
  .wrap { max-width: none; padding: 0; }
  .workspace { display: block; margin: 0; }
  .preview-pane { position: static; }
  .sheet-frame { border: 0; padding: 0; background: #fff; overflow: visible; height: auto !important; }
  .sheet-scaler { transform: none !important; height: auto !important; }
  .doc { box-shadow: none; min-height: 0; }
}

/* ---------- 請求書ツール用の追加 ---------- */
.doc-terms td { white-space: pre-wrap; word-break: break-all; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 0.9375rem; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 3px 0 0; flex: none; accent-color: var(--shu); }
.import-box {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 48em;
}
.doc-sum tr.minus td { color: #111; }
.doc-sum tr.pay th, .doc-sum tr.pay td { font-weight: 700; font-size: 13px; border-top: 2px solid #111; }
.warn { color: var(--shu-dark); }
.next-step {
  margin-top: 20px;
  font-size: 0.9375rem;
}
@media print { .import-box, .next-step { display: none !important; } }

/* ---------- 精算書ツール用の追加 ---------- */
.mode-switch { display: flex; gap: 0; margin-top: 20px; border: 1px solid var(--rule); border-radius: 4px; width: fit-content; max-width: 100%; background: var(--sheet); overflow: hidden; }
.mode-switch label { position: relative; }
.mode-switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.mode-switch span { display: block; padding: 10px 20px; font-weight: 700; font-size: 0.9375rem; color: var(--muted); }
.mode-switch label + label span { border-left: 1px solid var(--rule); }
.mode-switch input:checked + span { background: var(--ink); color: #fff; }
.mode-switch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }

.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-top: 8px; }
.doc-applicant { flex: 1; min-width: 0; font-size: 12.5px; }
.doc-applicant .to { font-size: 15px; font-weight: 700; margin-bottom: 10px; word-break: break-all; }
.doc-applicant table { border-collapse: collapse; width: 330px; }
.doc-applicant th, .doc-applicant td { border: 1px solid #7e8f99; padding: 4px 8px; text-align: left; font-size: 12px; }
.doc-applicant th { width: 80px; background: #eef3f1; font-weight: 400; white-space: nowrap; }
.doc-applicant td { word-break: break-all; }
.doc-stamps { border-collapse: collapse; flex: none; }
.doc-stamps th { border: 1px solid #7e8f99; background: #eef3f1; font-weight: 400; font-size: 11px; width: 66px; padding: 2px 0; text-align: center; }
.doc-stamps td { border: 1px solid #7e8f99; height: 66px; }

.doc-items.expense .c-date, .doc-items.transport .c-date { width: 58px; text-align: center; }
.doc-items .c-acct { width: 84px; }
.doc-items .c-payee { width: 120px; }
.doc-items .c-rcpt { width: 56px; text-align: center; }
.doc-items .c-trans { width: 76px; }
.doc-items .c-route { width: 168px; }
.doc-items .c-rt { width: 48px; text-align: center; }
.doc-items .c-amt { width: 92px; text-align: right; }
.doc-items tbody td { height: 28px; }

.doc-bottom { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-top: 16px; }
.doc-acct { border-collapse: collapse; font-size: 12px; width: 280px; }
.doc-acct caption { text-align: left; font-size: 12px; padding-bottom: 4px; }
.doc-acct th, .doc-acct td { border: 1px solid #7e8f99; padding: 4px 8px; }
.doc-acct th { background: #eef3f1; font-weight: 400; text-align: left; }
.doc-acct td { text-align: right; width: 100px; }
.doc-bottom .doc-sum { margin: 0 0 0 auto; }
.doc-bottom .doc-sum th, .doc-bottom .doc-sum td { border-top: 1px solid #7e8f99; }
@media print { .mode-switch { display: none !important; } }

.doc-applicant .to small { font-weight: 400; font-size: 13px; }

/* ---------- 給与計算ツール用の追加 ---------- */
.doc + .doc { margin-top: 16px; }
.slip-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-top: 24px; align-items: start; }
.slip-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.slip-table caption { text-align: left; font-weight: 700; font-size: 12.5px; padding-bottom: 4px; }
.slip-table th, .slip-table td { border: 1px solid #7e8f99; padding: 5px 8px; }
.slip-table th { background: #eef3f1; font-weight: 400; text-align: left; }
.slip-table td { text-align: right; white-space: nowrap; }
.slip-table tr.total th, .slip-table tr.total td { font-weight: 700; border-top: 2px solid #111; }
.shift-table { margin-top: 18px; }
.shift-table th, .shift-table td { text-align: center; }
.shift-table tbody td { height: 26px; }
.shift-table tr.total td { font-weight: 700; border-top: 2px solid #111; background: #f6f9f8; }
.shift-sum { text-align: left; }
.shift-sum .warn { margin-top: 4px; font-size: 0.8125rem; }
#minWageMsg { margin-top: 6px; }
.mw-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; margin-top: 1em; background: var(--sheet); }
.mw-table th, .mw-table td { border: 1px solid var(--rule); padding: 6px 10px; }
.mw-table thead th { background: #f7faf9; font-weight: 400; color: var(--muted); font-size: 0.8125rem; }
.mw-table td.n { text-align: right; font-variant-numeric: tabular-nums; }
.rate-table { width: 100%; border-collapse: collapse; margin-top: 1em; background: var(--sheet); }
.rate-table th, .rate-table td { border: 1px solid var(--rule); padding: 8px 12px; text-align: left; }
.rate-table thead th { background: #f7faf9; font-weight: 400; color: var(--muted); font-size: 0.8125rem; }
@media print {
  .doc + .doc { margin-top: 0; break-before: page; page-break-before: always; }
}
