/* Shared invoice-template presentation. All rules are scoped to template previews, cards, or template-page components. */
#invoicePreview[data-template="modern"],.paper[data-template="modern"]{--taccent:#0868ff;--tbg:#eaf3ff}
#invoicePreview[data-template="minimal"],.paper[data-template="minimal"]{--taccent:#0f766e;--tbg:#f3faf8;font-family:Arial,sans-serif}
#invoicePreview[data-template="classic"],.paper[data-template="classic"]{--taccent:#183b72;--tbg:#eef2f7;font-family:Georgia,"Times New Roman",serif}
#invoicePreview[data-template="professional"],.paper[data-template="professional"]{--taccent:#6941c6;--tbg:#f2ebfc}
#invoicePreview[data-template="compact"],.paper[data-template="compact"]{--taccent:#334155;--tbg:#f1f3f6}
#invoicePreview[data-template="clean"],.paper[data-template="clean"]{--taccent:#0b7285;--tbg:#e8f7fa}
#invoicePreview[data-template="corporate"],.paper[data-template="corporate"]{--taccent:#164e63;--tbg:#e9f2f5}
#invoicePreview[data-template="bold"],.paper[data-template="bold"]{--taccent:#1d4ed8;--tbg:#e6efff}
#invoicePreview[data-template="elegant"],.paper[data-template="elegant"]{--taccent:#9a7547;--tbg:#f7f2eb;font-family:Georgia,"Times New Roman",serif}
#invoicePreview[data-template="simple"],.paper[data-template="simple"]{--taccent:#475467;--tbg:#f2f4f7}
#invoicePreview[data-template],.paper[data-template]{--invoice-accent:var(--taccent);border-top-color:var(--taccent)}
#invoicePreview[data-template] .mark,.paper[data-template] .mark{background:var(--taccent)}
#invoicePreview[data-template] .previewgrand,.paper[data-template] .previewgrand{background:var(--tbg)}
#invoicePreview[data-template] .previewgrand strong,.paper[data-template] .previewgrand strong{color:var(--taccent)}
#invoicePreview[data-template] .paperhead,.paper[data-template] .paperhead{border-color:var(--taccent)}
#invoicePreview[data-template] .p-row.head,.paper[data-template] .p-row.head{background:var(--taccent);color:white}
#invoicePreview[data-template] .paperfoot strong,.paper[data-template] .paperfoot strong{color:var(--taccent)}
#invoicePreview[data-template="modern"]{border-radius:14px;box-shadow:0 12px 32px rgba(31,75,135,.13)}
#invoicePreview[data-template="modern"] .paperhead{border-bottom:1px solid #dce8fa;padding-bottom:12px}
#invoicePreview[data-template="modern"] .previewgrand{border-radius:9px}
#invoicePreview[data-template="minimal"]{box-shadow:none;border-top-width:2px;border-radius:4px}
#invoicePreview[data-template="minimal"] .billto,.paper[data-template="minimal"] .billto{border-color:#edf1f2;border-radius:2px;background:#fff}
#invoicePreview[data-template="minimal"] .p-row.head,.paper[data-template="minimal"] .p-row.head{background:#fff;color:#344054;border-bottom:1px solid #cbd5d3}
#invoicePreview[data-template="minimal"] .p-row:not(.head),.paper[data-template="minimal"] .p-row:not(.head){border-bottom:1px solid #eef2f1}
#invoicePreview[data-template="minimal"] .previewgrand{background:#fff;border-top:1px solid #d4e6e3;border-radius:0}
#invoicePreview[data-template="classic"] .paperhead{border-bottom:2px solid var(--taccent);padding-bottom:11px}
#invoicePreview[data-template="classic"] .paperhead h2,.paper[data-template="classic"] .paperhead h2{font-family:Georgia,"Times New Roman",serif;letter-spacing:.04em}
#invoicePreview[data-template="classic"] .p-row.head,.paper[data-template="classic"] .p-row.head{background:#183b72;color:#fff}
#invoicePreview[data-template="classic"] .billto{border:1px solid #cbd5e1;background:#f8fafc;border-radius:2px}
#invoicePreview[data-template="classic"] .previewgrand{border-radius:2px}
#invoicePreview[data-template="professional"] .paperhead{border-bottom:3px solid var(--taccent);padding-bottom:12px}
#invoicePreview[data-template="professional"] .billto{background:#f7f3ff;border-left:4px solid var(--taccent);border-radius:4px}
#invoicePreview[data-template="professional"] .previewgrand{border-radius:4px}
#invoicePreview[data-template="compact"]{padding:19px;border-radius:7px}
#invoicePreview[data-template="compact"] .paperhead{padding-bottom:7px}
#invoicePreview[data-template="compact"] .meta,#invoicePreview[data-template="compact"] .billto{margin-top:10px;margin-bottom:9px;padding:9px}
#invoicePreview[data-template="compact"] .p-row{min-height:24px;font-size:11px}
#invoicePreview[data-template="compact"] .previewgrand{border-radius:3px;padding:7px}
#invoicePreview[data-template="clean"]{border-top-width:3px;box-shadow:0 5px 20px rgba(13,116,133,.09)}
#invoicePreview[data-template="clean"] .paperhead{border-bottom:1px solid #c8e6eb}
#invoicePreview[data-template="clean"] .p-row.head,.paper[data-template="clean"] .p-row.head{background:#e8f7fa;color:#075766;border-bottom:2px solid #9ed2dc}
#invoicePreview[data-template="clean"] .previewgrand{border-radius:6px}
#invoicePreview[data-template="corporate"]{border-radius:4px}
#invoicePreview[data-template="corporate"] .paperhead{border-bottom:4px solid var(--taccent);padding-bottom:10px}
#invoicePreview[data-template="corporate"] .mark{border-radius:2px}
#invoicePreview[data-template="corporate"] .billto{border:1px solid #c6d9df;background:#f1f7f8;border-radius:3px}
#invoicePreview[data-template="bold"] .paperhead{background:#f2f6ff;border-bottom:4px solid var(--taccent);padding:12px;border-radius:7px}
#invoicePreview[data-template="bold"] .paperhead h2{font-weight:850;letter-spacing:.06em}
#invoicePreview[data-template="bold"] .p-row.head,.paper[data-template="bold"] .p-row.head{background:#1d4ed8;color:#fff}
#invoicePreview[data-template="bold"] .previewgrand{border-radius:2px;border-left:5px solid var(--taccent)}
#invoicePreview[data-template="elegant"]{border-radius:4px;box-shadow:0 9px 28px rgba(107,77,41,.12)}
#invoicePreview[data-template="elegant"] .paperhead{border-bottom:1px solid #d7c6ae;padding-bottom:12px}
#invoicePreview[data-template="elegant"] .paperhead h2{font-family:Georgia,"Times New Roman",serif;letter-spacing:.12em;font-weight:500}
#invoicePreview[data-template="elegant"] .p-row.head,.paper[data-template="elegant"] .p-row.head{background:#f7f2eb;color:#6c5335;border-bottom:1px solid #d7c6ae}
#invoicePreview[data-template="elegant"] .previewgrand{background:#f7f2eb;border-radius:0}
#invoicePreview[data-template="simple"]{box-shadow:none;border:1px solid #d0d5dd;border-top:3px solid var(--taccent);border-radius:3px}
#invoicePreview[data-template="simple"] .paperhead{border-bottom:1px solid #e4e7ec}
#invoicePreview[data-template="simple"] .p-row.head,.paper[data-template="simple"] .p-row.head{background:#f2f4f7;color:#344054;border-bottom:1px solid #d0d5dd}
#invoicePreview[data-template="simple"] .previewgrand{background:#f2f4f7;border-radius:2px}

/* Ten distinct, reusable miniature previews; no stock or random imagery. */
.template-thumb{--taccent:#0868ff;--tbg:#eaf3ff;position:relative;min-height:145px;overflow:hidden;padding:15px 17px;background:#fff;border:1px solid #e4e7ec;border-top:4px solid var(--taccent);border-radius:9px;box-shadow:0 5px 14px rgba(16,24,40,.08);color:#344054}
.template-thumb[data-template="modern"]{--taccent:#0868ff;--tbg:#eaf3ff}.template-thumb[data-template="minimal"]{--taccent:#0f766e;--tbg:#f3faf8}.template-thumb[data-template="classic"]{--taccent:#183b72;--tbg:#eef2f7}.template-thumb[data-template="professional"]{--taccent:#6941c6;--tbg:#f2ebfc}.template-thumb[data-template="compact"]{--taccent:#334155;--tbg:#f1f3f6}.template-thumb[data-template="clean"]{--taccent:#0b7285;--tbg:#e8f7fa}.template-thumb[data-template="corporate"]{--taccent:#164e63;--tbg:#e9f2f5}.template-thumb[data-template="bold"]{--taccent:#1d4ed8;--tbg:#e6efff}.template-thumb[data-template="elegant"]{--taccent:#9a7547;--tbg:#f7f2eb}.template-thumb[data-template="simple"]{--taccent:#475467;--tbg:#f2f4f7}
.thumb-head{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid #e9edf2;padding-bottom:8px}.thumb-logo{width:20px;height:20px;border-radius:5px;background:var(--taccent)}.thumb-title{font-size:10px;letter-spacing:.12em;font-weight:850;color:var(--taccent)}.thumb-parties{display:flex;gap:18px;margin:12px 0}.thumb-parties i,.thumb-foot i{display:block;height:4px;width:58px;margin:4px 0;background:#d9e0e8;border-radius:9px}.thumb-parties i:first-child{width:72px;background:#aab4c1}.thumb-table{border-top:9px solid var(--taccent);border-bottom:1px solid #e4e7ec;padding:5px 0}.thumb-table i{display:block;height:4px;margin:5px 0;background:#e5e9ef;border-radius:4px}.thumb-table i:nth-child(2){width:83%}.thumb-table i:nth-child(3){width:65%}.thumb-total{margin:9px 0 0 auto;width:37%;height:18px;display:flex;align-items:center;justify-content:space-between;background:var(--tbg);padding:0 5px;border-radius:3px}.thumb-total i,.thumb-total b{height:4px;width:22px;background:#b5c0ce;border-radius:4px}.thumb-total b{background:var(--taccent)}.thumb-foot{position:absolute;bottom:8px;left:17px;display:flex;gap:7px}.thumb-foot i{width:36px;height:3px;margin:0}
.template-thumb[data-template="minimal"]{box-shadow:none;border-radius:3px;border-top-width:2px}.template-thumb[data-template="minimal"] .thumb-table{border-top:1px solid #cbd5d3}.template-thumb[data-template="classic"]{font-family:Georgia,"Times New Roman",serif;border-radius:2px}.template-thumb[data-template="classic"] .thumb-table{border-top-width:12px}.template-thumb[data-template="professional"] .thumb-parties{padding:7px;background:var(--tbg);border-left:3px solid var(--taccent)}.template-thumb[data-template="compact"]{min-height:130px;padding:10px 13px;border-radius:5px}.template-thumb[data-template="compact"] .thumb-parties{margin:7px 0}.template-thumb[data-template="compact"] .thumb-table i{margin:3px 0}.template-thumb[data-template="clean"] .thumb-table{border-top:7px solid var(--tbg)}.template-thumb[data-template="clean"] .thumb-table b{display:block;height:4px;background:var(--taccent)}.template-thumb[data-template="corporate"]{border-radius:2px}.template-thumb[data-template="corporate"] .thumb-head{border-bottom:4px solid var(--taccent)}.template-thumb[data-template="bold"] .thumb-head{padding:8px;background:var(--tbg);border-bottom:4px solid var(--taccent)}.template-thumb[data-template="elegant"]{font-family:Georgia,"Times New Roman",serif;border-radius:3px}.template-thumb[data-template="elegant"] .thumb-table{border-top:1px solid #d7c6ae}.template-thumb[data-template="simple"]{border-top-width:2px;border-radius:3px;box-shadow:none}.template-thumb[data-template="simple"] .thumb-table{border-top:1px solid #d0d5dd}
.template-library-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.template-gallery-card{padding:12px;display:flex;flex-direction:column;gap:10px}.template-gallery-card h2{font-size:16px;margin:0}.template-gallery-card p{font-size:12px;line-height:1.5}.template-card-copy{display:flex;flex-direction:column;gap:8px;flex:1}.template-card-copy .btn{align-self:flex-start;margin-top:auto}.template-formats{display:flex;gap:6px;flex-wrap:wrap}.template-formats span{font-size:10px;font-weight:750;border:1px solid #d0d5dd;border-radius:99px;padding:3px 8px;color:#344054}
.template-comparison{border-collapse:collapse;width:100%;font-size:13px}.template-comparison th,.template-comparison td{padding:10px;border-bottom:1px solid #e4e7ec;text-align:left}.template-comparison thead{background:#f4f8ff}.template-comparison th{font-weight:750}.special-template-links{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:16px 0}.special-template-links a{display:grid;gap:5px;border:1px solid #e4e7ec;border-radius:9px;padding:12px;text-decoration:none;color:#344054}.special-template-links a:hover{border-color:#adc8ff;background:#f8fbff}.special-template-links span{font-size:12px;color:#667085}.special-template-links b{font-size:11px;color:#155eef}
.template-hero-actions{display:flex;gap:9px;flex-wrap:wrap;margin-top:14px}.template-download-panel{border:1px solid #dce9fb;background:#f7faff;padding:16px;border-radius:12px;margin:22px 0}.template-download-panel>strong{font-size:15px}.template-download-panel p{font-size:13px;margin:7px 0}.format-links{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}.format-links a{background:#fff;border:1px solid #cad8eb;border-radius:8px;padding:8px 11px;color:#155eef;text-decoration:none;font-size:12px;font-weight:700}.google-note{color:#667085;font-size:12px!important}.template-picker{display:grid;gap:6px}.template-picker>div{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.template-picker select{min-width:210px}.template-picker a{font-size:12px;color:#155eef}.template-picker small{color:#667085;font-size:11px}.template-hero-actions .btn.secondary{background:#fff;color:#155eef;border:1px solid #c9d8ee}
.template-recommendation{margin:1.25rem 0;padding:1rem 1.1rem;border:1px solid #d9e4f5;border-left:4px solid #537eea;border-radius:12px;background:#f7faff}.template-recommendation p{margin:.45rem 0}.template-recommendation a{font-weight:650;color:#2459bd}
#invoicePreview .actions{flex-wrap:wrap}#invoicePreview .actions .btn{min-width:72px}.template-choice select{border:1px solid #d0d5dd;border-radius:6px;padding:5px 7px;background:#fff;color:#344054;font-size:10px;max-width:140px}
@media(max-width:900px){
  .template-library-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .contenthero .template-hero-actions .btn{width:auto;min-height:44px}
  .template-picker select,.format-links a,.template-choice select,.fig-open-gallery{
    min-height:44px;font-size:14px;
  }
  .template-gallery-card .btn{min-height:44px}
}
@media(max-width:800px){.template-library-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.contenthero .template-hero-actions .btn{width:auto}}
@media(max-width:560px){
  .template-library-grid,.special-template-links{grid-template-columns:1fr}
  /* Scroll the table locally instead of widening the page */
  .section:has(.template-comparison),
  .content-section:has(.template-comparison),
  .wrap:has(.template-comparison){
    overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%;
  }
  .template-comparison{min-width:560px}
  .template-choice select{max-width:100%;font-size:16px}
  .preview-actions{grid-template-columns:repeat(2,1fr)}
}
@media print{.template-thumb{box-shadow:none}.template-hero-actions,.template-download-panel,.template-picker{display:none!important}}
/* Keep the modern template's small total text above WCAG AA contrast on its pale-blue highlight. */
#invoicePreview[data-template="modern"] .previewgrand strong,.paper[data-template="modern"] .previewgrand strong{color:#155eef}
/* The elegant thumbnail accent is decorative, but its text needs WCAG AA contrast. */
.template-thumb[data-template="elegant"] .thumb-title{color:#6c5335}
#invoicePreview[data-template="creative"],.paper[data-template="creative"]{--taccent:#c2410c;--tbg:#fff4ed;border-left:5px solid var(--taccent);border-radius:0 12px 12px 0;box-shadow:0 10px 28px rgba(194,65,12,.12)}
#invoicePreview[data-template="creative"] .paperhead{border-bottom:none;padding:12px 12px 12px 4px;background:linear-gradient(90deg,#fff4ed 0%,#fff 55%)}
#invoicePreview[data-template="creative"] .billto,.paper[data-template="creative"] .billto{margin-left:12px;border-radius:14px 4px 14px 4px;background:#fff7f2;border:1px dashed #fdba74}
#invoicePreview[data-template="creative"] .p-row.head,.paper[data-template="creative"] .p-row.head{background:#fff7f2;color:#9a3412;border-bottom:2px solid #fdba74}
#invoicePreview[data-template="creative"] .p-row:not(.head):nth-child(even),.paper[data-template="creative"] .p-row:not(.head):nth-child(even){background:#fffaf6}
#invoicePreview[data-template="creative"] .previewgrand{border-radius:999px;padding-left:16px;padding-right:16px;border:1px solid #fdba74;background:#fff4ed}
#invoicePreview[data-template="creative"] .previewgrand strong{color:#9a3412}
#invoicePreview[data-template="executive"],.paper[data-template="executive"]{--taccent:#0f172a;--tbg:#f8fafc;font-family:Georgia,"Times New Roman",serif;border:1px solid #cbd5e1;border-radius:0;box-shadow:none}
#invoicePreview[data-template="executive"] .paperhead{border-top:2px solid var(--taccent);border-bottom:1px solid var(--taccent);padding:14px 4px 12px;margin-bottom:4px}
#invoicePreview[data-template="executive"] .paperhead h2,.paper[data-template="executive"] .paperhead h2{font-family:Georgia,"Times New Roman",serif;letter-spacing:.18em;font-weight:600;text-transform:uppercase}
#invoicePreview[data-template="executive"] .meta{text-transform:uppercase;letter-spacing:.06em;font-size:11px}
#invoicePreview[data-template="executive"] .billto{border:1px solid #94a3b8;background:#fff;border-radius:0}
#invoicePreview[data-template="executive"] .p-row.head,.paper[data-template="executive"] .p-row.head{background:#0f172a;color:#fff;letter-spacing:.04em}
#invoicePreview[data-template="executive"] .previewgrand{background:#fff;border:2px solid #0f172a;border-radius:0}
#invoicePreview[data-template="executive"] .previewgrand strong{color:#0f172a}
.template-thumb[data-template="creative"]{--taccent:#c2410c;--tbg:#fff4ed;border-left:4px solid var(--taccent);border-radius:0 8px 8px 0}
.template-thumb[data-template="creative"] .thumb-parties{margin-left:6px;padding:6px;background:var(--tbg);border-radius:10px 2px}
.template-thumb[data-template="creative"] .thumb-table{border-top:6px solid #fdba74}
.template-thumb[data-template="creative"] .thumb-total{border-radius:999px;border:1px solid #fdba74}
.template-thumb[data-template="executive"]{--taccent:#0f172a;--tbg:#f8fafc;font-family:Georgia,"Times New Roman",serif;border:1px solid #cbd5e1;border-top:2px solid var(--taccent);border-radius:0;box-shadow:none}
.template-thumb[data-template="executive"] .thumb-head{border-bottom:1px solid var(--taccent)}
.template-thumb[data-template="executive"] .thumb-title{letter-spacing:.16em;color:#0f172a}
.template-thumb[data-template="executive"] .thumb-table{border-top-width:2px}
.template-thumb[data-template="executive"] .thumb-total{border:1px solid #0f172a;border-radius:0;background:#fff}

/* In-editor template gallery (Phase 5.0) */
.fig-template-gallery-overlay{position:fixed;inset:0;z-index:1200;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(15,23,42,.45)}
.fig-template-gallery-overlay[hidden]{display:none!important}
.fig-template-gallery{width:min(960px,100%);max-height:min(88vh,820px);display:flex;flex-direction:column;background:#fff;border:1px solid #d0d5dd;border-radius:14px;box-shadow:0 24px 64px rgba(15,23,42,.22);overflow:hidden;color:#101828}
.fig-template-gallery-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-start;padding:16px 18px;border-bottom:1px solid #e4e7ec;background:#f8fafc}
.fig-template-gallery-head h2{margin:0;font-size:18px}.fig-template-gallery-head p{margin:4px 0 0;font-size:12px;color:#667085}
.fig-template-gallery-close{border:0;background:transparent;font-size:22px;line-height:1;cursor:pointer;color:#475467;padding:4px 8px;border-radius:6px}
.fig-template-gallery-close:hover,.fig-template-gallery-close:focus-visible{background:#eef2f6;outline:2px solid #155eef;outline-offset:1px}
.fig-template-gallery-toolbar{display:flex;flex-wrap:wrap;gap:8px;padding:12px 18px;border-bottom:1px solid #eef2f6;align-items:center}
.fig-template-gallery-toolbar input[type="search"],.fig-template-gallery-toolbar select{border:1px solid #d0d5dd;border-radius:8px;padding:8px 10px;font-size:13px;min-height:40px;background:#fff}
.fig-template-gallery-toolbar input[type="search"]{flex:1;min-width:160px}
.fig-template-gallery-body{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(240px,.85fr);gap:0;min-height:0;flex:1;overflow:hidden}
.fig-template-gallery-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;padding:14px 16px;overflow:auto;align-content:start}
.fig-template-card{display:flex;flex-direction:column;gap:8px;border:1px solid #e4e7ec;border-radius:10px;padding:10px;background:#fff;cursor:pointer;text-align:left;color:inherit;font:inherit;min-height:0}
.fig-template-card:hover{border-color:#98b7f5;background:#f8fbff}
.fig-template-card:focus-visible{outline:2px solid #155eef;outline-offset:2px}
.fig-template-card.is-selected{border-color:#155eef;box-shadow:0 0 0 2px rgba(21,94,239,.18)}
.fig-template-card.is-active-preview{border-color:#0868ff;background:#f5f9ff}
.fig-template-card .template-thumb{min-height:110px;pointer-events:none}
.fig-template-card strong{font-size:13px}.fig-template-card small{font-size:11px;color:#667085;line-height:1.35}
.fig-template-preview-pane{border-left:1px solid #eef2f6;padding:16px;overflow:auto;background:#fbfdff;display:flex;flex-direction:column;gap:10px}
.fig-template-preview-pane h3{margin:0;font-size:16px}.fig-template-preview-pane p{margin:0;font-size:12px;color:#475467;line-height:1.5}
.fig-template-preview-pane .template-thumb{min-height:180px}
.fig-template-preview-meta{display:flex;flex-wrap:wrap;gap:6px}
.fig-template-preview-meta span{font-size:10px;font-weight:700;border:1px solid #d0d5dd;border-radius:999px;padding:3px 8px;color:#344054;background:#fff}
.fig-template-gallery-foot{display:flex;justify-content:space-between;gap:10px;flex-wrap:wrap;align-items:center;padding:12px 18px;border-top:1px solid #e4e7ec;background:#fff}
.fig-template-gallery-foot .btn{min-height:40px}
.fig-template-gallery-note{font-size:11px;color:#667085;max-width:52ch}
.template-choice .fig-open-gallery{border:1px solid #c9d8ee;background:#fff;color:#155eef;border-radius:6px;padding:5px 9px;font-size:10px;font-weight:700;cursor:pointer;min-height:28px}
.template-choice .fig-open-gallery:hover,.template-choice .fig-open-gallery:focus-visible{background:#f4f8ff;outline:2px solid #155eef;outline-offset:1px}
.template-selected{outline:2px solid #155eef;outline-offset:2px}
@media(max-width:820px){
  .fig-template-gallery-body{grid-template-columns:1fr}
  .fig-template-preview-pane{border-left:0;border-top:1px solid #eef2f6;max-height:38vh}
  .fig-template-gallery-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:480px){.fig-template-gallery-grid{grid-template-columns:1fr}}
@media print{.fig-template-gallery-overlay,.fig-open-gallery{display:none!important}}
