/* 公證費用收費明細產生器：樣式移植自「自動估價網站」，所有 class 加 iv- 前綴以避免與網站 Bootstrap 主題衝突 */
#invoiceApp, .iv-paper {
  --iv-top: #263c5c;
  --iv-accent: #4872e4;
  --iv-ok: #25a580;
  --iv-warn: #bc9526;
  --iv-danger: #a72947;
  --iv-bg: #eef1f5;
  --iv-panel: #fff;
  --iv-ink: #1f2933;
  --iv-muted: #66727f;
  --iv-line: #d7dde4;
  --iv-title-row: #e6e9ee;
  --iv-odd-row: #f7f8fa;
  --iv-shadow: 0 1px 3px rgba(20, 30, 45, .08), 0 8px 24px rgba(20, 30, 45, .06);
  background: var(--iv-bg);
  color: var(--iv-ink);
  font-size: 14px;
  line-height: 1.5;
  padding: 24px 20px 40px;
}
#invoiceApp *, #invoiceApp *::before, #invoiceApp *::after, .iv-paper, .iv-paper *, .iv-paper *::before, .iv-paper *::after { box-sizing: border-box; }
#invoiceApp input, #invoiceApp select, #invoiceApp textarea, #invoiceApp button { font: inherit; color: inherit; }
#invoiceApp table { margin: 0; }

#invoiceApp .iv-paper, .iv-paper { background: #fff; color: var(--iv-ink); font-size: 14px; line-height: 1.5; }

.iv-layout {
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr) 250px;
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 1280px) { .iv-layout { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); } .iv-side { grid-column: 1 / -1; } }
@media (max-width: 860px) { .iv-layout { grid-template-columns: 1fr; } #invoiceApp { padding: 16px 12px 32px; } }

/* ===== 表單區 ===== */
.iv-pagetitle { font-size: 18px; margin: 0 0 12px; font-weight: 700; }
.iv-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--iv-line); overflow-x: auto; }
.iv-tab {
  padding: 8px 12px; border: 1px solid transparent; border-bottom: 0; background: none; cursor: pointer;
  color: var(--iv-muted); border-radius: 6px 6px 0 0; white-space: nowrap; font-size: 13px;
}
.iv-tab.active { background: var(--iv-panel); border-color: var(--iv-line); color: var(--iv-ink); font-weight: 600; margin-bottom: -1px; }
.iv-tabbox { background: var(--iv-panel); border: 1px solid var(--iv-line); border-top: 0; border-radius: 0 0 6px 6px; padding: 14px; box-shadow: var(--iv-shadow); }
.iv-pane { display: none; }
.iv-pane.active { display: block; }

.iv-title { background: var(--iv-title-row); padding: 7px 10px; margin: 14px -14px 10px; font-weight: 600; font-size: 13px; border-top: 1px solid var(--iv-line); border-bottom: 1px solid var(--iv-line); }
.iv-title:first-child { margin-top: -14px; border-top: 0; }

.iv-f { display: block; font-size: 12.5px; color: var(--iv-muted); margin: 0 0 9px; }
.iv-f > input, .iv-f > select, .iv-tabbox textarea, .iv-add {
  display: block; width: 100%; margin-top: 3px; padding: 6px 8px; border: 1px solid var(--iv-line); border-radius: 4px; background: #fff; color: var(--iv-ink); height: auto;
}
.iv-tabbox textarea { resize: vertical; min-height: 60px; margin-top: 0; }
#invoiceApp input:focus, #invoiceApp select:focus, #invoiceApp textarea:focus { outline: 2px solid rgba(72, 114, 228, .35); border-color: var(--iv-accent); }
.iv-row { display: flex; gap: 8px; }
.iv-row > .iv-f { flex: 1; min-width: 0; }
.iv-check { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; margin: 6px 0 0; cursor: pointer; }
.iv-check input { margin-top: 4px; }
.iv-hint { font-size: 12px; color: var(--iv-muted); margin: 2px 0 8px; }
.iv-hint:empty { display: none; }

.iv-item { border: 1px solid var(--iv-line); border-radius: 6px; padding: 10px 12px 12px; margin-bottom: 10px; background: #fcfcfd; }
.iv-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 13px; }
.iv-link { border: 0; background: none; color: var(--iv-danger); cursor: pointer; font-size: 12px; padding: 0; }
.iv-link:hover { text-decoration: underline; }

.iv-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 4px;
  border: 1px solid var(--iv-line); background: var(--iv-panel); cursor: pointer; font-size: 13px; text-decoration: none; color: var(--iv-ink); line-height: 1.4;
}
.iv-btn:hover { border-color: var(--iv-accent); color: var(--iv-ink); text-decoration: none; }
.iv-btn.primary { background: var(--iv-accent); border-color: var(--iv-accent); color: #fff; font-weight: 600; }
.iv-btn.primary:hover { filter: brightness(1.08); color: #fff; }
.iv-btn.block { width: 100%; }
.iv-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.iv-warnbox { background: rgba(188, 149, 38, .12); border-left: 4px solid var(--iv-warn); padding: 8px 12px; font-size: 12.5px; margin-top: 10px; border-radius: 0 4px 4px 0; }
.iv-warnbox p { margin: 2px 0; }

/* ===== 側欄 ===== */
.iv-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 84px; }
@media (max-width: 1280px) { .iv-side { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); } }
.iv-card { background: var(--iv-panel); border: 1px solid var(--iv-line); border-radius: 6px; padding: 14px; box-shadow: var(--iv-shadow); }
.iv-card h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: .04em; color: var(--iv-muted); font-weight: 700; }
.iv-card ul { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--iv-muted); }
.iv-card li { margin: 3px 0; }
.iv-stack { display: flex; flex-direction: column; gap: 8px; }

/* ===== 單據（日式法律文書版式：明朝體、全框線表格、置中標題、「記」「以上」） ===== */
.iv-paper {
  background: #fff; color: #000; min-width: 0;
  font-family: "Noto Serif TC", "Source Han Serif TC", "Hiragino Mincho ProN", "PMingLiU", "MingLiU", "Songti TC", serif;
  font-size: 13px; line-height: 1.75;
}
.iv-paper b { font-weight: 700; }
.jp-meta { text-align: right; font-size: 12.5px; line-height: 1.6; }
.jp-title { text-align: center; font-size: 22px; font-weight: 700; letter-spacing: .6em; text-indent: .6em; margin: 28px 0 26px; color: #000; }
.jp-parties { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.jp-to { min-width: 0; flex: 1; font-size: 13px; }
.jp-to .jp-name { font-size: 16px; font-weight: 700; border-bottom: 1px solid #000; display: inline-block; padding: 0 4px 1px 0; margin-bottom: 4px; }
.jp-to div { margin: 0; }
.jp-from { text-align: right; font-size: 12px; line-height: 1.6; max-width: 55%; }
.jp-from b { font-size: 14px; display: block; }
.iv-logo { margin: 0 0 6px auto; width: 40px; height: 40px; border: 1px solid #000; display: grid; place-items: center; font-size: 18px; font-weight: 700; color: #000; background: #fff; }
.iv-logo.img { border: 0; width: auto; max-width: 150px; height: 44px; }
.iv-logo.img img { height: 100%; width: auto; max-width: 150px; object-fit: contain; }
.iv-ph { color: #555; font-weight: 400; }
.jp-lead { margin: 26px 0 12px; }
table.jp-total { width: 100%; border-collapse: collapse; margin: 0 0 6px; }
table.jp-total th, table.jp-total td { border: 1px solid #000; padding: 8px 12px; font-weight: 400; }
table.jp-total th { width: 26%; text-align: center; letter-spacing: .3em; background: #fff; }
table.jp-total b { font-size: 20px; margin-right: 10px; }
table.jp-total small { font-size: 11px; color: #000; }
.jp-ki { text-align: center; letter-spacing: 1em; text-indent: 1em; margin: 18px 0 10px; font-weight: 700; }

table.iv-lines { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.iv-lines th, table.iv-lines td { border: 1px solid #000; padding: 5px 8px; vertical-align: top; background: #fff; }
table.iv-lines th { text-align: center; font-weight: 700; white-space: nowrap; }
table.iv-lines .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.iv-lines .desc b { display: block; font-weight: 700; }
table.iv-lines .desc small { display: block; font-size: 11px; color: #000; }
table.iv-lines tr.group td { font-weight: 700; text-align: left; background: #fff; border-left: 1px solid #000; letter-spacing: .1em; padding: 3px 8px; }
table.iv-lines tfoot td { font-weight: 700; text-align: center; }
table.iv-lines tfoot td.num { text-align: right; }
.iv-empty { text-align: center; padding: 24px 8px !important; }

.jp-notes { margin-top: 22px; font-size: 12px; line-height: 1.7; }
.jp-notes-h { font-weight: 700; letter-spacing: .5em; margin-bottom: 2px; }
.jp-notes ol { margin: 0; padding-left: 1.6em; }
.jp-notes li { margin: 2px 0; }
.iv-note { margin-top: 6px; }
.iv-note p { margin: 0 0 4px; }
.jp-end { text-align: right; letter-spacing: .5em; margin-top: 22px; }

/* 紙張邊界：上 35mm／下 30mm／左右 30mm（日本法律文書慣例），由 html2pdf margin 控制；單據本身不再加內距 */
.iv-paper.iv-pdf { width: 100%; max-width: none; margin: 0; padding: 0; border: 0; box-shadow: none; }

.iv-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--iv-top); color: #fff; padding: 10px 18px; border-radius: 6px; transition: .25s; pointer-events: none; z-index: 1100; font-size: 13px;
}
.iv-toast.show { opacity: 1; transform: translateX(-50%); }

/* ===== PDF 即時預覽 ===== */
.iv-preview { position: sticky; top: 84px; height: calc(100vh - 104px); min-height: 520px; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--iv-line); border-radius: 6px; box-shadow: var(--iv-shadow); overflow: hidden; min-width: 0; }
.iv-preview-bar { display: flex; justify-content: space-between; padding: 8px 14px; font-size: 13px; border-bottom: 1px solid var(--iv-line); }
.iv-preview-bar span { color: var(--iv-muted); }
.iv-preview iframe { flex: 1; border: 0; width: 100%; background: #525659; }
@media (max-width: 860px) { .iv-preview { position: static; height: 80vh; } }

/* ===== 列印 / PDF ===== */
@media print {
  @page { size: A4; margin: 12mm; }
  html, body { background: #fff !important; }
  .navbar, nav.breadcrumb, footer, .fp-section, .iv-form, .iv-side, .iv-toast, .iv-preview { display: none !important; }
  #invoiceApp { padding: 0; background: #fff; }
  .iv-layout { display: block; }
  .iv-paper { border: 0; box-shadow: none; padding: 0; }
  table.iv-lines { min-width: 0; }
  .iv-totals-row, table.iv-lines tr { break-inside: avoid; }
}

