:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.container { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; flex-shrink: 0; }
.muted { color: var(--muted); }
.pre-line { white-space: pre-line; font-size: 14px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 18px; }
.brand-name { font-size: 18px; margin-right: 8px; }
.badge-local { display: inline-block; font-size: 12px; font-weight: 600; color: #065f46; background: #d1fae5; padding: 2px 8px; border-radius: 999px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.tab-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.tab-btn { background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 7px 12px; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab-btn.active { background: #eff6ff; color: var(--primary); border-color: #bfdbfe; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.landing-hero { text-align: center; padding: 42px 0 28px; max-width: 820px; margin: 0 auto; }
.landing-hero h1 { font-size: 34px; margin: 8px 0 12px; line-height: 1.25; letter-spacing: -0.02em; }
.land-sub { font-size: 16px; color: var(--muted); margin: 0 0 22px; }
.land-cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 32px; }
@media (max-width: 860px) { .features-3 { grid-template-columns: 1fr; } }
.features-3 h3 { margin: 0 0 8px; font-size: 16px; }
.features-3 p { margin: 0; font-size: 14px; }

.workspace { display: grid; grid-template-columns: 1fr 1.05fr; gap: 24px; align-items: start; }
@media (max-width: 960px) { .workspace { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .row-2, .row-3 { grid-template-columns: 1fr; } }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: #374151; }
.label-with-action { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.label-with-action label { margin-bottom: 0; }
.link-btn { background: none; border: 0; color: var(--primary); font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; }
.saved-clients { display: flex; gap: 8px; margin-top: 6px; align-items: center; }

input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 14px; background: #fff; }
.logo-row { display: flex; gap: 8px; align-items: center; }
.logo-row input[type="file"] { min-width: 0; }
.sig-pad { border: 1px dashed #94a3b8; border-radius: 8px; cursor: crosshair; background: #f8fafc; width: 100%; max-width: 340px; height: 80px; display: block; }

.items-header { display: flex; justify-content: space-between; align-items: center; margin: 10px 0 8px; }
.items-header h2 { margin: 0; font-size: 15px; }
.items-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.item-row { display: grid; grid-template-columns: 2fr 70px 95px 36px; gap: 8px; align-items: center; }
.custom-field-row { display: grid; grid-template-columns: 1fr 1.3fr 36px; gap: 8px; align-items: center; }

.btn { border: 0; border-radius: 8px; padding: 9px 15px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; transition: 0.15s ease; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #eff6ff; color: var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-accent { background: var(--accent); color: #fff; white-space: nowrap; }
.actions-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.invoice-sheet { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; box-shadow: 0 4px 16px rgba(0,0,0,0.05); overflow: hidden; }
.inv-top { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.preview-logo { max-height: 54px; max-width: 160px; margin-bottom: 10px; display: block; object-fit: contain; }
.inv-title { font-size: 26px; font-weight: 800; letter-spacing: 0.04em; text-align: right; color: var(--primary); }
.meta-grid { display: grid; grid-template-columns: auto auto; gap: 4px 14px; font-size: 13px; margin-top: 8px; text-align: right; }
.inv-billto { margin-bottom: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
.bill-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 4px; }

.inv-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; font-size: 14px; }
.inv-table th { text-align: left; padding: 9px 8px; border-bottom: 2px solid var(--text); font-size: 12px; text-transform: uppercase; }
.inv-table td { padding: 9px 8px; border-bottom: 1px solid var(--border); }
.inv-table .num { text-align: right; }

.inv-totals { margin-left: auto; width: 250px; max-width: 100%; font-size: 14px; }
.tot-row { display: flex; justify-content: space-between; padding: 5px 0; }
.tot-grand { border-top: 2px solid var(--text); margin-top: 6px; padding-top: 8px; font-size: 17px; }
.inv-notes { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border); }

.invoice-sheet.theme-navy .inv-top { background: #1e3a5f; color: #fff; margin: -32px -32px 24px; padding: 28px 32px; }
.invoice-sheet.theme-navy .inv-top .muted { color: #cbd5e1; }
.invoice-sheet.theme-navy .inv-title { color: #fff; }
.invoice-sheet.theme-navy .inv-table th { background: #f1f5f9; border-bottom-color: #1e3a5f; color: #1e3a5f; }
.invoice-sheet.theme-slate { border-top: 6px solid #0f766e; }
.invoice-sheet.theme-slate .inv-title { color: #0f766e; }

.pro-showcase { background: #f0fdfa; border: 1px solid #99f6e4; border-radius: var(--radius); padding: 26px; margin-bottom: 36px; }
.pro-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.promo-pill { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.pro-header h2 { margin: 4px 0 6px; font-size: 21px; }
.pro-header p { margin: 0; font-size: 14px; color: #374151; max-width: 760px; }
.pro-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 860px) { .pro-grid { grid-template-columns: 1fr; } }
.pro-item { background: #fff; border: 1px solid #ccfbf1; border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.pro-item img { width: 100%; height: 220px; object-fit: contain; background: #f8fafc; border-bottom: 1px solid var(--border); cursor: zoom-in; padding: 6px; }
.pro-item-text { padding: 18px; justify-content: center; }
.pro-badge-box { display: inline-block; align-self: flex-start; font-size: 12px; font-weight: 700; background: #eff6ff; color: #1d4ed8; padding: 4px 10px; border-radius: 6px; margin-bottom: 10px; }
.pro-caption { padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.pro-item-text .pro-caption { padding: 0; }
.pro-caption strong { font-size: 14px; }
.pro-caption span { font-size: 13px; color: var(--muted); }

.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.kpi-box strong { font-size: 20px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.pill-btn { background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.pill-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.status-pill { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.status-InProgress { background: #dbeafe; color: #1e40af; }
.status-Completed { background: #d1fae5; color: #065f46; }
.status-OnHold { background: #fef3c7; color: #92400e; }
.promo-card { background: #f0fdfa; border: 1px solid #99f6e4; border-radius: 10px; padding: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Modal / Lightbox */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.72); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-box { background: #fff; border-radius: 12px; max-width: 920px; width: 100%; max-height: 90vh; overflow: auto; padding: 22px; position: relative; }
.modal-box img { width: 100%; height: auto; display: block; border-radius: 8px; }
.modal-close { position: sticky; top: 0; float: right; background: #111827; color: #fff; border: 0; border-radius: 999px; width: 32px; height: 32px; font-size: 18px; cursor: pointer; }

.footer { border-top: 1px solid var(--border); background: var(--surface); padding: 16px 0; font-size: 13px; color: var(--muted); }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  .workspace { display: block; }
  .tab-pane { display: none !important; }
  .tab-pane.active { display: block !important; }
  .invoice-sheet { border: 0; box-shadow: none; padding: 0; }
  .invoice-sheet.theme-navy .inv-top { margin: 0 0 24px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.doc-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.doc-badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--border); background: #f3f4f6; color: #9ca3af; cursor: pointer; }
.doc-badge.done { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.doc-badge.done-receipt { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.pricing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 22px 0; }
@media (max-width: 720px) { .pricing-grid { grid-template-columns: 1fr; } }
.price-card { background: #fff; border: 1px solid #99f6e4; border-radius: 12px; padding: 20px; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; }
.price-card.featured { border: 2px solid var(--accent); box-shadow: 0 6px 20px rgba(15,118,110,0.08); }
.price-num { font-size: 28px; font-weight: 800; color: #0f172a; }
.terms-note { font-size: 12px; color: #475569; margin-top: 8px; line-height: 1.5; }
.terms-note a { color: var(--primary); font-weight: 600; }
.terms-article { max-width: 820px; margin: 28px auto 48px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.terms-article h1 { margin-top: 0; font-size: 26px; color: #1e3a5f; }
.terms-article h2 { margin-top: 22px; font-size: 17px; color: #0f766e; }
.terms-article p, .terms-article li { font-size: 14px; color: #374151; line-height: 1.7; }
.pay-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }

.backup-bar { background: #fffbeb; border-bottom: 1px solid #fde68a; padding: 7px 0; font-size: 13px; color: #92400e; }
.backup-bar.saved { background: #ecfdf5; border-bottom-color: #a7f3d0; color: #065f46; }
.btn-danger { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.rec-tag { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 999px; margin-left: 6px; }
.rec-yes { background: #d1fae5; color: #065f46; }
.rec-no { background: #f3f4f6; color: #6b7280; }

@media (min-width: 1024px) {
  .topbar-inner { flex-wrap: nowrap; gap: 10px; }
  .brand-name { font-size: 16px; margin-right: 6px; }
  .badge-local { font-size: 11px; padding: 2px 7px; white-space: nowrap; }
  .tab-nav { flex-wrap: nowrap; gap: 4px; }
  .tab-btn { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
  .topbar-actions { flex-wrap: nowrap; gap: 6px; }
  .topbar-actions .btn-sm, .topbar-actions select { padding: 5px 9px; font-size: 12px; }
}

.pro-grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 760px) { .pro-grid-4 { grid-template-columns: 1fr; } }

.print-brand-footer { display: none; }
@page { size: auto; margin: 0mm; }
@media print {
  html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  .invoice-sheet { padding: 16mm 18mm !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
  .invoice-sheet.theme-navy .inv-top { margin: -16mm -18mm 20px !important; padding: 16mm 18mm 22px !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-brand-footer {
    display: block !important; margin-top: 28px; padding-top: 10px;
    border-top: 1px solid #e5e7eb; text-align: center;
    font-size: 11px; color: #9ca3af; letter-spacing: 0.02em;
  }
}

.compare-wrap { margin: 22px 0; overflow-x: auto; background: #fff; border: 1px solid #99f6e4; border-radius: 12px; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.compare-table th, .compare-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.compare-table th { background: #f8fafc; font-weight: 700; color: #0f172a; }
.compare-table th.col-pro { background: #0f766e; color: #fff; }
.compare-table td.col-pro { background: #f0fdfa; font-weight: 600; color: #065f46; }
.compare-table tr:last-child td { border-bottom: 0; }

.item-col-heads { display: grid; grid-template-columns: 2fr 70px 95px 36px; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; padding: 0 2px; }
@media (max-width: 600px) { .item-col-heads { display: none; } }

.landing-hero { max-width: 1020px; }
.landing-hero h1 { font-size: clamp(24px, 2.9vw, 32px); }
.compare-table th.col-free { background: #e5e7eb; color: #374151; }
.compare-table td.col-free { background: #f9fafb; color: #6b7280; }

/* SEO Use-Case & FAQ Sections */
.seo-section { margin: 36px 0; }
.seo-section h2 { font-size: 22px; margin: 0 0 8px; color: #0f172a; }
.seo-section .seo-lead { color: #475569; font-size: 15px; margin: 0 0 18px; line-height: 1.65; }
.usecase-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.usecase-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px 18px; }
.usecase-card h3 { margin: 0 0 6px; font-size: 15px; color: #0f172a; }
.usecase-card p { margin: 0; font-size: 13.5px; color: #475569; line-height: 1.6; }
.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 14px 18px; }
.faq-item summary { cursor: pointer; font-weight: 600; font-size: 15px; color: #0f172a; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 18px; font-weight: 500; color: #64748b; flex-shrink: 0; }
.faq-item[open] summary::after { content: "−"; color: #0f766e; }
.faq-item p { margin: 10px 0 0; font-size: 14px; color: #475569; line-height: 1.65; }

/* Swiss Geometric Folded-Corner Brand Mark */
.brand-mark-svg { background: transparent !important; padding: 0; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; box-shadow: none !important; }

/* Local PDF Desk Styles (v5.3) */
.pdf-hero { margin-bottom: 18px; }
.pdf-hero h1 { font-size: clamp(22px, 2.8vw, 30px); margin: 8px 0 0; color: #0f2942; line-height: 1.25; }
.pdf-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
@media (max-width: 980px) {
  .pdf-layout { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
  .pdf-main-col, .pdf-side-col { display: contents; }
  .pdf-main-col > .card, .pdf-side-col > .card { width: 100%; box-sizing: border-box; margin-top: 0 !important; margin-bottom: 0 !important; }
  .pdf-main-col > .card:nth-child(1) { order: 1; }
  .pdf-main-col > .card:nth-child(2) { order: 2; }
  .pdf-side-col > .card:nth-child(1) { order: 3; }
  .pdf-side-col > .card:nth-child(2) { order: 4; }
  .pdf-main-col > .export-bottom-card { order: 5; }
}
.pdf-dropzone { border: 2px dashed #94a3b8; border-radius: 14px; background: #f8fafc; padding: 26px 18px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; margin-bottom: 14px; }
.pdf-dropzone:hover, .pdf-dropzone.drag-over { border-color: #0f766e; background: #f0fdfa; }
.pdf-toolbar { padding: 12px 14px; margin-bottom: 14px; }
.pdf-quick-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pdf-quick-row input { flex: 1; min-width: 190px; }
.pdf-status-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-top: 8px; border-top: 1px solid #f1f5f9; }
.pdf-status { font-size: 13px; color: #475569; }
.pdf-status.error { color: #b91c1c; font-weight: 600; }
.pdf-empty { padding: 34px 20px; text-align: center; }
.pdf-pages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 12px; }
.pdf-page-card { background: #fff; border: 2px solid #e2e8f0; border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, box-shadow .15s; }
.pdf-page-card.selected { border-color: #0f766e; box-shadow: 0 2px 10px rgba(15, 118, 110, .12); }
.pdf-page-card.dragging { opacity: .45; }
.pdf-card-top { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.pdf-chk-wrap { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font-weight: 700; font-size: 13px; color: #0f2942; }
.pdf-card-mini-btns { display: inline-flex; gap: 2px; }
.mini-ic { border: 1px solid #e2e8f0; background: #f8fafc; color: #334155; border-radius: 6px; width: 22px; height: 22px; font-size: 12px; cursor: pointer; padding: 0; line-height: 1; }
.mini-ic:hover { background: #e2e8f0; }
.mini-ic.danger:hover { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.pdf-thumb-box { height: 176px; background: #f8fafc; border: 1px solid #f1f5f9; border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; }
.pdf-thumb-box img { max-width: 94%; max-height: 94%; object-fit: contain; transition: transform .15s; }
.pdf-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 11.5px; color: #64748b; }
.pdf-src-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 88px; }
.pdf-panel { padding: 16px; }
.pdf-opt-group { padding: 11px 0; border-top: 1px solid #f1f5f9; }
.pdf-opt-group:first-of-type { border-top: none; padding-top: 0; }
.pdf-switch-row { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: #0f2942; }
.pdf-switch-row input[type="checkbox"] { width: 16px; height: 16px; margin: 0; flex-shrink: 0; }
.pdf-sub-box { margin-top: 9px; padding: 10px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; }
.wm-presets { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.wm-presets .pill-btn { font-size: 11.5px; padding: 3px 8px; }
.pdf-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.mini-lbl { display: block; font-size: 11.5px; font-weight: 600; color: #475569; margin-bottom: 3px; }
.pdf-export-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

/* Standalone /pdf/ App Identity & FAQ Polish */
.pdf-brand-sub { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: #e0f2fe; color: #0f2942; font-size: 11.5px; font-weight: 700; letter-spacing: .2px; }
.pdf-trust-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.pdf-trust-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; background: #fff; border: 1px solid #cbd5e1; font-size: 12.5px; color: #334155; font-weight: 500; }
.pdf-faq-wrap { margin-top: 34px; }

/* Local PDF Desk v2.0 — 2-Tab Mode, Live WYSIWYG Preview & Draggable Overlays */
.pdf-pro-banner { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 16px; border-radius: 12px; background: linear-gradient(135deg, #f0fdfa 0%, #eff6ff 100%); border: 1px solid #99f6e4; margin-bottom: 16px; }
.pdf-mode-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 2px solid #e2e8f0; padding-bottom: 10px; }
.pdf-mode-tab { border: 1px solid #cbd5e1; background: #fff; color: #334155; font-weight: 700; font-size: 14px; padding: 10px 18px; border-radius: 10px; cursor: pointer; transition: all .15s; }
.pdf-mode-tab:hover { border-color: #0f766e; color: #0f2942; }
.pdf-mode-tab.active { background: #0f2942; color: #fff; border-color: #0f2942; box-shadow: 0 2px 8px rgba(15, 41, 66, .18); }

.preview-topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.live-stage-wrap { display: flex; justify-content: center; align-items: center; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 12px; padding: 18px; height: 540px; overflow: hidden; }
.live-stage { position: relative; display: inline-block; max-width: 100%; background: #fff; box-shadow: 0 8px 28px rgba(15, 23, 42, .14); border-radius: 4px; overflow: hidden; user-select: none; }
.live-stage > img { display: block; max-width: 100%; max-height: 496px; width: auto; height: auto; object-fit: contain; pointer-events: none; }
.live-wm-layer { position: absolute; inset: 0; background-size: 100% 100%; background-repeat: no-repeat; pointer-events: none; }
.live-pn-layer { position: absolute; font-size: 12px; font-weight: 700; color: #334155; background: rgba(255,255,255,.72); padding: 2px 8px; border-radius: 4px; pointer-events: none; }
.live-pn-layer.pos-tl { top: 10px; left: 12px; }
.live-pn-layer.pos-tc { top: 10px; left: 50%; transform: translateX(-50%); }
.live-pn-layer.pos-tr { top: 10px; right: 12px; }
.live-pn-layer.pos-bl { bottom: 22px; left: 12px; }
.live-pn-layer.pos-bc { bottom: 22px; left: 50%; transform: translateX(-50%); }
.live-pn-layer.pos-br { bottom: 22px; right: 12px; }
.live-online-wm-bar { position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,0.82); padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; color: #334155; pointer-events: none; white-space: nowrap; letter-spacing: .2px; }

.live-drag-box { position: absolute; border: 2px dashed #0f766e; background: rgba(15, 118, 110, .06); border-radius: 6px; cursor: move; touch-action: none; padding: 2px; }
.live-drag-box.stamp-box { border-color: #b91c1c; background: rgba(185, 28, 28, .05); }
.live-drag-box img { display: block; width: 100%; height: auto; pointer-events: none; }
.drag-tag { position: absolute; top: -18px; left: 0; font-size: 10px; font-weight: 700; background: #0f766e; color: #fff; padding: 1px 6px; border-radius: 4px; pointer-events: none; }
.stamp-box .drag-tag { background: #b91c1c; }

.edit-thumb-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.edit-thumb-item { flex: 0 0 116px; border: 2px solid #e2e8f0; border-radius: 10px; padding: 6px; background: #fff; transition: border-color .15s; }
.edit-thumb-item.active { border-color: #0f766e; background: #f0fdfa; }
.edit-thumb-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.edit-thumb-img { height: 112px; display: flex; align-items: center; justify-content: center; background: #f8fafc; border-radius: 6px; overflow: hidden; cursor: pointer; }
.edit-thumb-img img { max-width: 94%; max-height: 94%; object-fit: contain; }

.extract-action-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #f1f5f9; }

.pdf-empty-inside { text-align: center; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* Local PDF Desk v3.0 — Single-Screen Unified Studio */
.edit-thumb-item { flex: 0 0 132px; border: 2px solid #e2e8f0; border-radius: 10px; padding: 6px; background: #fff; transition: border-color .15s, opacity .15s; }
.edit-thumb-item.unchecked { opacity: 0.55; border-style: dashed; }
.edit-thumb-item.active { border-color: #0f766e; background: #f0fdfa; opacity: 1; }
.edit-thumb-chk { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font-weight: 700; font-size: 12.5px; color: #0f2942; }
.edit-thumb-chk input { width: 14px; height: 14px; margin: 0; }
.pdf-export-box { margin-top: 12px; padding-top: 12px; border-top: 2px solid #e2e8f0; }
.pdf-jpg-sub { margin-top: 10px; padding: 10px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; }

/* v3.1 True A4 Paper Base Layer & Draggable Image Transform */
.live-stage.a4-paper {
  width: 350px;
  height: 495px;
  aspect-ratio: 210 / 297;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
}
.live-stage.a4-paper:active { cursor: grabbing; }
.live-stage.a4-paper > img {
  max-width: 90%;
  max-height: 90%;
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  pointer-events: none;
}
.btn-toggle-on { background: #0f2942 !important; color: #fff !important; border-color: #0f2942 !important; }

/* v3.2 A4 Portrait / Landscape + Multi-Image Canva-Style Layers */
.live-stage.a4-portrait {
  width: 350px;
  height: 495px;
  aspect-ratio: 210 / 297;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
  position: relative;
  overflow: hidden;
}
.live-stage.a4-landscape {
  width: 495px;
  height: 350px;
  aspect-ratio: 297 / 210;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
  position: relative;
  overflow: hidden;
}
.live-stage.a4-portrait > #livePreviewImg,
.live-stage.a4-landscape > #livePreviewImg {
  display: none;
}
.live-layers-container {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}
.canvas-img-layer {
  position: absolute;
  cursor: move;
  touch-action: none;
  border: 2px solid transparent;
  border-radius: 3px;
  transform-origin: center center;
  box-sizing: border-box;
}
.canvas-img-layer:hover {
  border-color: rgba(15, 118, 110, 0.45);
}
.canvas-img-layer.active-layer {
  border-color: #0f766e;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.18);
}
.canvas-img-layer img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}
.layer-badge {
  position: absolute;
  top: -18px;
  left: 0;
  font-size: 10px;
  font-weight: 700;
  background: #0f2942;
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  pointer-events: none;
  display: none;
}
.canvas-img-layer.active-layer .layer-badge { display: inline-block; }
.live-stage.stage-drop-active { outline: 3px dashed #0f766e; outline-offset: 4px; }

/* v3.3 Photoshop / Canva Transform Handles (4 Corners Proportional + 4 Edges Stretch + Top Rotate Handle) */
.tf-handle {
  position: absolute;
  width: 11px;
  height: 11px;
  background: #ffffff;
  border: 2px solid #0f766e;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  display: none;
  z-index: 6;
}
.canvas-img-layer.active-layer .tf-handle,
.canvas-img-layer.active-layer .tf-rot-handle,
.canvas-img-layer.active-layer .tf-rot-stem {
  display: block;
}
.tf-handle.nw { top: -6px; left: -6px; cursor: nwse-resize; border-radius: 50%; }
.tf-handle.ne { top: -6px; right: -6px; cursor: nesw-resize; border-radius: 50%; }
.tf-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; border-radius: 50%; }
.tf-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; border-radius: 50%; }
.tf-handle.n  { top: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; width: 16px; height: 7px; border-radius: 4px; }
.tf-handle.s  { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; width: 16px; height: 7px; border-radius: 4px; }
.tf-handle.w  { left: -6px; top: 50%; transform: translateY(-50%); cursor: ew-resize; width: 7px; height: 16px; border-radius: 4px; }
.tf-handle.e  { right: -6px; top: 50%; transform: translateY(-50%); cursor: ew-resize; width: 7px; height: 16px; border-radius: 4px; }

.tf-rot-stem {
  display: none;
  position: absolute;
  top: -22px;
  left: 50%;
  width: 2px;
  height: 16px;
  background: #0f766e;
  transform: translateX(-50%);
  pointer-events: none;
}
.tf-rot-handle {
  display: none;
  position: absolute;
  top: -38px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #0f2942;
  color: #ffffff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  cursor: grab;
  box-shadow: 0 2px 5px rgba(0,0,0,.25);
  z-index: 7;
}
.tf-rot-handle:active { cursor: grabbing; }

/* v3.5 Proper Z-Index Layering, Draggable Watermark, Bottom Export Grid & Clean FAQ */
.live-layers-container { z-index: 1; }
.live-drag-box { z-index: 4; }
.live-wm-layer { z-index: 8; pointer-events: none; }
.live-wm-single-box { position: absolute; z-index: 8; cursor: move; touch-action: none; border: 1.5px dashed rgba(15, 41, 66, 0.35); border-radius: 4px; }
.live-wm-single-box:hover { border-color: #0f2942; background: rgba(15, 41, 66, 0.04); }
.live-wm-single-box img { display: block; width: 100%; height: auto; pointer-events: none; user-select: none; }
.live-pn-layer { z-index: 9; }
.live-online-wm-bar { z-index: 12 !important; }

.export-bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 720px) { .export-bottom-grid { grid-template-columns: 1fr; } }
.export-col-jpg { padding-left: 16px; border-left: 1px solid #e2e8f0; }
@media (max-width: 720px) { .export-col-jpg { padding-left: 0; border-left: none; border-top: 1px solid #e2e8f0; padding-top: 12px; } }

/* v4.0 Clear Tool Grouping (Current Page vs Document-Wide), Chevron Accordions & Resizable Text Boxes */
.tool-group-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .2px;
  margin-bottom: 8px;
}
.tool-group-banner.current-scope {
  background: #e0f2fe;
  color: #0f2942;
  border: 1px solid #bae6fd;
}
.tool-group-banner.doc-scope {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.scope-pill {
  background: #0f2942;
  color: #fff;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
}
.acc-item {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fff;
  overflow: hidden;
}
.acc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  cursor: pointer;
  background: #f8fafc;
  user-select: none;
  font-size: 13.5px;
  font-weight: 700;
  color: #0f2942;
}
.acc-head:hover { background: #f1f5f9; }
.acc-arrow {
  font-size: 14px;
  color: #475569;
  font-weight: 800;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  transition: transform .15s;
}
.acc-body {
  padding: 10px 11px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
.mini-scope-tag {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  color: #0f766e;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 999px;
  padding: 1px 6px;
}
.mini-scope-tag:empty { display: none; }

/* Resizable / Rotatable Text Layers on Live Preview */
.live-texts-container { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.canvas-text-layer {
  position: absolute;
  pointer-events: auto;
  cursor: move;
  touch-action: none;
  padding: 2px 6px;
  border: 1.5px dashed transparent;
  border-radius: 4px;
  white-space: nowrap;
  transform-origin: center center;
  user-select: none;
}
.canvas-text-layer:hover { border-color: rgba(29, 78, 216, 0.45); }
.canvas-text-layer.active-text { border-color: #1d4ed8; background: rgba(29, 78, 216, 0.05); }
.canvas-text-layer.active-text .tf-handle,
.canvas-text-layer.active-text .tf-rot-handle,
.canvas-text-layer.active-text .tf-rot-stem { display: block; }

/* v4.1 Aspect-Ratio-Locked Zoom Modal, Universal Element Handles & Multi-Line Text */
.pdf-zoom-modal-box {
  width: auto !important;
  max-width: 92vw !important;
  max-height: 92vh !important;
  padding: 16px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
}
#pdfZoomImg {
  width: auto !important;
  height: auto !important;
  max-width: 86vw !important;
  max-height: 84vh !important;
  object-fit: contain !important;
  display: block;
  border-radius: 4px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, .18);
  background: #fff;
}
.acc-chk { width: 16px; height: 16px; margin: 0; flex-shrink: 0; cursor: pointer; }
.acc-head .acc-title { flex: 1; }

/* Show corner resize handles on Signature, Stamp, Watermark & Page Number! */
.resizable-el .tf-handle { display: block; }
.live-pn-layer.resizable-el {
  pointer-events: auto;
  cursor: default;
  border: 1.5px dashed rgba(15, 118, 110, 0.45);
  padding: 2px 10px;
}
.live-pn-layer.resizable-el .tf-handle.se { right: -6px; bottom: -6px; width: 10px; height: 10px; }

/* Multi-line text support */
.canvas-text-layer {
  white-space: pre-wrap !important;
  line-height: 1.3;
  min-width: 48px;
}

/* v4.2 Edge-to-Edge Range Sliders (0% to 100% full travel) */
input[type="range"] {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  margin: 4px 0 !important;
  width: 100% !important;
  cursor: pointer;
}

/* v4.4 Lightbox Gallery: Top-Right × on Image Frame, Left/Right Arrows & Bottom Page Dots */
.zoom-lightbox-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 96vw;
  max-height: 96vh;
}
.zoom-stage-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.zoom-img-frame {
  position: relative;
  display: inline-block;
  line-height: 0;
}
.zoom-close-btn {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: #0f2942;
  color: #ffffff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
}
.zoom-close-btn:hover { background: #b91c1c; }
.zoom-nav-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(15, 41, 66, .82);
  color: #ffffff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, opacity .15s;
}
.zoom-nav-btn:hover:not(:disabled) { background: #0f766e; }
.zoom-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.zoom-footer-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.zoom-counter {
  font-size: 12.5px;
  font-weight: 700;
  color: #ffffff;
  background: rgba(15, 41, 66, .78);
  padding: 2px 10px;
  border-radius: 999px;
}
.zoom-dots {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 70vw;
}
.zoom-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: rgba(255, 255, 255, .45);
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.zoom-dot.active {
  background: #14b8a6;
  transform: scale(1.3);
}
