:root{
  --blue:#0b4a8b;--blue-2:#11376d;--red:#c91c2c;--green:#087f5b;--ink:#172033;--muted:#6b7280;
  --line:#dfe5ee;--soft:#f4f7fb;--paper:#fff;--shadow:0 18px 60px rgba(23,32,51,.12);
  --radius:18px;--accent:#0b4a8b;font-family:Inter,"Segoe UI",Tahoma,Arial,sans-serif;color:var(--ink);
}
*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:#eef3f8;color:var(--ink)}
button,input,textarea,select{font:inherit}.noscript{background:#7f1d1d;color:#fff;padding:12px;text-align:center}.topbar{height:76px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:10px 24px;position:sticky;top:0;z-index:50}.brand{display:flex;align-items:center;gap:14px;text-decoration:none;color:var(--ink)}.brand img{width:210px;max-width:35vw;height:auto}.brand-product{border-inline-start:1px solid var(--line);padding-inline-start:14px;font-size:20px;font-weight:700;white-space:nowrap}.brand-product b{color:var(--red)}.top-actions{display:flex;align-items:center;gap:10px}.compact-field{display:flex;align-items:center;gap:7px;font-size:12px;color:var(--muted)}select,input,textarea{border:1px solid #cfd8e5;border-radius:10px;background:#fff;color:var(--ink);padding:10px 12px;outline:none;transition:.2s}select:focus,input:focus,textarea:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 14%,transparent)}textarea{resize:vertical;line-height:1.55}.btn{text-decoration:none;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:10px;padding:10px 14px;cursor:pointer;font-weight:700;transition:.2s;text-align:center}.btn:hover{transform:translateY(-1px)}.btn.primary{background:var(--blue);color:#fff}.btn.ghost{background:#edf3fa;color:var(--blue)}.btn.secondary{background:#fff;border:1px solid var(--line);color:var(--ink)}.btn.add{background:#edf7f4;color:var(--green);width:100%;border:1px dashed #8dc8b8}.file-button{display:flex;align-items:center;justify-content:center}.app-shell{display:grid;grid-template-columns:280px minmax(390px,560px) minmax(460px,1fr);gap:18px;max-width:1900px;margin:auto;padding:18px}.settings-panel,.editor-panel,.preview-panel{min-width:0}.settings-panel{display:flex;flex-direction:column;gap:14px}.panel-card{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:16px;box-shadow:0 8px 25px rgba(23,32,51,.05)}.panel-card h2{font-size:15px;margin:0 0 14px}.intro-card p{font-size:12px;color:var(--muted);line-height:1.6;margin:8px 0 0}.status-line{display:flex;align-items:center;gap:8px;font-size:12px}.status-dot{width:10px;height:10px;border-radius:50%;background:#94a3b8;box-shadow:0 0 0 4px #e8edf4}.status-dot.idle{background:#2563eb;box-shadow:0 0 0 4px #dbeafe}.status-dot.loading{animation:pulse 1.2s infinite}.status-dot.ready{background:#16a34a;box-shadow:0 0 0 4px #dcfce7}.status-dot.fallback{background:#f59e0b;box-shadow:0 0 0 4px #fef3c7}@keyframes pulse{50%{opacity:.35}}.template-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px}.template-card{border:1px solid var(--line);background:#fff;border-radius:13px;padding:9px;cursor:pointer;text-align:start;transition:.2s}.template-card:hover,.template-card.active{border-color:var(--accent);box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 10%,transparent)}.template-card b{display:block;font-size:12px;margin-top:7px}.template-card small{display:block;color:var(--muted);font-size:10px;line-height:1.4;margin-top:3px}.template-thumb{height:56px;border-radius:7px;background:#f8fafc;border:1px solid #e5e7eb;display:block;position:relative;overflow:hidden}.template-thumb:before,.template-thumb:after{content:"";position:absolute;background:#cbd5e1;border-radius:4px}.ats-thumb:before{width:60%;height:4px;top:9px;left:20%}.ats-thumb:after{width:75%;height:30px;top:19px;left:12%;background:repeating-linear-gradient(#d8dee8 0 3px,transparent 3px 8px)}.maroc-thumb{background:linear-gradient(90deg,var(--accent) 0 31%,#fff 31%)}.maroc-thumb:before{width:22%;height:4px;left:5%;top:10px;background:#fff}.maroc-thumb:after{width:58%;height:30px;right:5%;top:12px;background:repeating-linear-gradient(#d8dee8 0 3px,transparent 3px 8px)}.classic-thumb:before{width:48%;height:5px;top:8px;left:26%;background:var(--accent)}.classic-thumb:after{width:75%;height:28px;top:21px;left:12%;background:repeating-linear-gradient(#d8dee8 0 3px,transparent 3px 8px)}.rtl-thumb:before{width:45%;height:5px;top:9px;right:8%;background:var(--accent)}.rtl-thumb:after{width:78%;height:28px;top:21px;right:8%;background:repeating-linear-gradient(#d8dee8 0 3px,transparent 3px 8px)}.setting-row{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:15px;font-size:12px}.setting-row select{min-width:120px}.color-palette{display:flex;gap:7px}.color-dot{width:24px;height:24px;border-radius:50%;border:3px solid #fff;box-shadow:0 0 0 1px #cbd5e1;background:var(--dot);cursor:pointer}.color-dot.active{box-shadow:0 0 0 2px var(--dot)}.action-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.editor-panel{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:20px;box-shadow:0 8px 25px rgba(23,32,51,.05);height:calc(100vh - 112px);overflow:auto}.editor-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:14px}.eyebrow{font-size:11px;text-transform:uppercase;letter-spacing:.14em;color:var(--red);font-weight:800;margin:0 0 5px}.editor-heading h1{font-size:23px;margin:0}.autosave{font-size:11px;color:var(--green);background:#eaf8f2;padding:6px 9px;border-radius:999px;white-space:nowrap}.form-section{border:1px solid var(--line);border-radius:14px;margin:12px 0;background:#fff;overflow:hidden}.form-section summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:10px;padding:14px 15px;background:#fbfcfe}.form-section summary::-webkit-details-marker{display:none}.form-section summary span{display:grid;place-items:center;width:30px;height:30px;border-radius:9px;background:#eaf1fa;color:var(--blue);font-size:11px;font-weight:800}.form-section summary b{font-size:14px}.form-content{border-top:1px solid var(--line);padding:16px}.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:13px}.form-content label{display:flex;flex-direction:column;gap:6px;font-size:12px;font-weight:700}.form-content label small{font-weight:400;color:var(--muted)}.photo-field{grid-column:1/-1}.repeat-list{display:flex;flex-direction:column;gap:12px}.repeat-card{border:1px solid var(--line);border-radius:13px;padding:13px;background:#fbfcfe;position:relative}.repeat-card .repeat-title{font-size:12px;font-weight:800;color:var(--blue);margin-bottom:10px}.repeat-card .remove-item{position:absolute;top:9px;inset-inline-end:9px;border:0;background:#fee2e2;color:#991b1b;width:28px;height:28px;border-radius:8px;cursor:pointer}.repeat-card .wide{grid-column:1/-1}.preview-panel{height:calc(100vh - 112px);display:flex;flex-direction:column;background:#1d2736;border-radius:var(--radius);overflow:hidden;box-shadow:var(--shadow)}.preview-toolbar{height:58px;display:flex;align-items:center;justify-content:space-between;padding:10px 16px;color:#fff;background:#141c28}.preview-toolbar strong{display:block;font-size:13px}.preview-toolbar small{font-size:10px;color:#aab6c8}.icon-btn{width:34px;height:34px;border-radius:9px;border:1px solid #3a4658;background:#202b3a;color:#fff;font-size:18px;cursor:pointer}.preview-stage{flex:1;overflow:auto;padding:24px;position:relative;background:radial-gradient(circle at 50% 10%,#344258,#1d2736 70%)}.preview-loading{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;color:#d7dfeb;z-index:4;background:rgba(29,39,54,.88)}.preview-loading.hidden{display:none}.spinner{width:34px;height:34px;border:3px solid #536176;border-top-color:#fff;border-radius:50%;animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.typst-preview,.html-preview{max-width:850px;margin:auto}.typst-preview svg{display:block;width:100%;height:auto;background:white;box-shadow:0 12px 35px rgba(0,0,0,.35)}.html-preview{display:block;overflow:visible}.html-preview.active{display:block}.cv-fallback{width:794px;max-width:100%;min-height:1123px;transform-origin:top left;background:#fff;margin:auto;padding:48px;color:#222;box-shadow:0 12px 35px rgba(0,0,0,.35);font-family:Arial,Tahoma,sans-serif}.cv-fallback.rtl{direction:rtl;text-align:right}.cv-fallback.ltr{direction:ltr;text-align:left}.cv-fallback h1{font-size:30px;margin:0;color:var(--cv-accent)}.cv-fallback .cv-title{font-size:15px;margin:6px 0}.cv-fallback .contacts{font-size:11px;color:#555;border-bottom:2px solid var(--cv-accent);padding-bottom:12px;margin-bottom:18px}.cv-fallback h2{font-size:15px;color:var(--cv-accent);border-bottom:1px solid var(--cv-accent);padding-bottom:4px;margin:18px 0 8px}.cv-fallback p,.cv-fallback li{font-size:12px;line-height:1.55}.cv-entry{margin-bottom:12px}.cv-entry-head{display:flex;justify-content:space-between;gap:15px;font-weight:bold}.cv-entry-meta{font-size:11px;color:#666}.toast{position:fixed;bottom:22px;inset-inline-start:50%;transform:translateX(-50%) translateY(20px);opacity:0;pointer-events:none;background:#111827;color:#fff;padding:11px 16px;border-radius:10px;z-index:100;box-shadow:var(--shadow);transition:.25s;font-size:13px}.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}.footer{display:flex;align-items:center;justify-content:space-between;padding:18px 25px;color:#667085;font-size:12px}.footer p{margin:0}.footer nav{display:flex;gap:15px}.footer a{color:var(--blue);text-decoration:none}
@media(max-width:1250px){.app-shell{grid-template-columns:250px minmax(380px,1fr)}.preview-panel{grid-column:1/-1;height:auto;min-height:760px}.editor-panel{height:auto}.settings-panel{grid-row:1}.preview-stage{min-height:700px}}
@media(max-width:820px){.topbar{height:auto;min-height:68px;padding:10px 12px;flex-wrap:wrap}.brand img{width:170px}.brand-product{font-size:16px}.top-actions{width:100%;justify-content:flex-end;overflow:auto}.compact-field span{display:none}.app-shell{display:block;padding:10px}.settings-panel,.editor-panel,.preview-panel{margin-bottom:12px}.editor-panel{padding:13px}.grid-2{grid-template-columns:1fr}.preview-panel{min-height:650px}.preview-stage{padding:10px;min-height:590px}.footer{flex-direction:column;gap:10px}.template-grid{grid-template-columns:1fr 1fr}}
@media(max-width:520px){.brand img{width:145px}.brand-product{display:none}.top-actions .btn.ghost{display:none}.btn{padding:9px 11px;font-size:12px}.editor-heading h1{font-size:19px}.autosave{display:none}.action-grid{grid-template-columns:1fr}.template-grid{grid-template-columns:1fr 1fr}.cv-fallback{padding:28px}}
@media print{body{background:#fff;overflow:hidden}.topbar,.settings-panel,.editor-panel,.preview-toolbar,.footer,.toast{display:none!important}.app-shell{display:block;padding:0}.preview-panel{height:auto;background:#fff;box-shadow:none}.preview-stage{padding:0;background:#fff;overflow:visible}.typst-preview svg{box-shadow:none}.html-preview{display:block!important}.cv-fallback{box-shadow:none;width:210mm;min-height:297mm;margin:0;padding:14mm}}
.fallback-header{display:flex;align-items:center;gap:16px}.fallback-header>div{flex:1}.fallback-photo{width:92px;height:92px;border-radius:14px;object-fit:cover;border:3px solid color-mix(in srgb,var(--cv-accent) 22%,white)}
.template-maroc .fallback-header{background:linear-gradient(120deg,var(--cv-accent),color-mix(in srgb,var(--cv-accent) 72%,#111));color:#fff;padding:20px;border-radius:12px}.template-maroc .fallback-header h1{color:#fff}.template-maroc .contacts{color:#e8eef8;border-color:#fff}.template-classic .fallback-header{text-align:center;justify-content:center}.template-classic .fallback-header>div{flex:0 1 auto}.template-classic .fallback-photo{border-radius:50%}.template-rtl{font-family:Tahoma,Arial,sans-serif}

.invoice-app{background:#eef3f8}.invoice-shell{display:grid;grid-template-columns:minmax(420px,610px) minmax(560px,1fr);gap:18px;max-width:1800px;margin:auto;padding:18px}.invoice-editor{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:20px;box-shadow:0 8px 25px rgba(23,32,51,.05);height:calc(100vh - 112px);overflow:auto}.invoice-editor-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:14px}.invoice-editor-head h1{font-size:24px;margin:0}.invoice-note{font-size:12px;line-height:1.65;border-radius:12px;padding:11px 13px;margin:12px 0}.success-note{background:#edf8f4;border:1px solid #b9dfd2;color:#17664e}.legal-warning{background:#fff8e7;border:1px solid #eed28d;color:#6b4c00}.invoice-editor .wide{grid-column:1/-1}.invoice-editor .company-field.hidden,.invoice-editor .ae-field.hidden{display:none}.logo-upload small{color:var(--muted);font-weight:400}.invoice-items{display:flex;flex-direction:column;gap:10px;margin-bottom:10px}.invoice-item{display:grid;grid-template-columns:minmax(150px,2fr) 72px 92px 100px 78px 34px;gap:7px;align-items:end;background:#fbfcfe;border:1px solid var(--line);border-radius:13px;padding:10px}.invoice-item label{display:flex;flex-direction:column;gap:5px;font-size:10px;font-weight:700}.invoice-item input{min-width:0;padding:8px}.invoice-item .remove-line{height:36px;border:0;border-radius:9px;background:#fee2e2;color:#991b1b;cursor:pointer;font-size:18px}.invoice-line-total{font-size:11px;color:var(--blue);font-weight:800;white-space:nowrap;padding-bottom:10px}.invoice-actions-bottom{display:flex;justify-content:flex-end;gap:9px;margin-top:14px}.invoice-preview-panel{height:calc(100vh - 112px);display:flex;flex-direction:column;background:#1d2736;border-radius:var(--radius);overflow:hidden;box-shadow:var(--shadow)}.invoice-preview-toolbar{flex:0 0 58px}.invoice-preview-stage{flex:1;overflow:auto;padding:24px;background:radial-gradient(circle at 50% 10%,#344258,#1d2736 70%)}.invoice-preview-fit{width:794px;transform-origin:top center;margin:0 auto}.invoice-paper{--invoice-accent:#0b4a8b;width:794px;min-height:1123px;background:#fff;color:#1f2937;padding:42px 44px 34px;font-family:"Segoe UI",Arial,Tahoma,sans-serif;box-shadow:0 12px 35px rgba(0,0,0,.35);direction:ltr;text-align:left}.invoice-paper.ar{direction:rtl;text-align:right;font-family:Tahoma,"Segoe UI",Arial,sans-serif}.invoice-paper.bi{direction:ltr}.invoice-head{display:grid;grid-template-columns:1fr 250px;gap:28px;align-items:start;border-bottom:3px solid var(--invoice-accent);padding-bottom:18px}.invoice-paper.ar .invoice-head{grid-template-columns:250px 1fr}.invoice-brand-block{display:flex;gap:16px;align-items:flex-start}.invoice-logo{width:108px;height:76px;object-fit:contain;border-radius:8px}.invoice-logo-placeholder{width:86px;height:72px;display:grid;place-items:center;border:2px solid var(--invoice-accent);border-radius:14px;color:var(--invoice-accent);font-weight:900;font-size:22px;background:#f8fbff}.invoice-seller h1{margin:0 0 4px;font-size:22px;color:var(--invoice-accent)}.invoice-seller p{margin:2px 0;font-size:10px;line-height:1.45;color:#4b5563}.invoice-title{text-align:right}.invoice-paper.ar .invoice-title{text-align:left}.invoice-title .doc-title{font-size:31px;font-weight:900;letter-spacing:.04em;color:var(--invoice-accent)}.invoice-title .invoice-no{font-size:15px;font-weight:800;margin:5px 0 13px}.invoice-meta{display:grid;grid-template-columns:auto 1fr;gap:5px 10px;font-size:10px}.invoice-meta b{color:#4b5563}.invoice-client{margin-top:20px;border:1px solid #dbe3ed;border-inline-start:5px solid var(--invoice-accent);border-radius:8px;padding:12px 14px;background:#f9fbfd}.invoice-client-label{font-size:10px;color:var(--invoice-accent);font-weight:900;text-transform:uppercase;letter-spacing:.07em}.invoice-client strong{display:block;font-size:15px;margin:4px 0}.invoice-client p{margin:2px 0;font-size:10px;color:#4b5563;white-space:pre-line}.invoice-table{width:100%;border-collapse:collapse;margin-top:18px;table-layout:fixed}.invoice-table th{background:var(--invoice-accent);color:#fff;font-size:10px;padding:9px 7px;text-align:center}.invoice-table th:first-child{text-align:left}.invoice-paper.ar .invoice-table th:first-child{text-align:right}.invoice-table td{border-bottom:1px solid #dfe5ee;padding:9px 7px;font-size:10px;vertical-align:top;text-align:center}.invoice-table td:first-child{text-align:left;font-weight:650}.invoice-paper.ar .invoice-table td:first-child{text-align:right}.invoice-table .description{width:42%}.invoice-table .qty{width:9%}.invoice-table .unit{width:10%}.invoice-table .price{width:14%}.invoice-table .discount{width:10%}.invoice-table .total{width:15%}.invoice-summary{display:grid;grid-template-columns:1fr 270px;gap:25px;margin-top:18px;align-items:start}.invoice-paper.ar .invoice-summary{grid-template-columns:270px 1fr}.invoice-words{border:1px solid #dfe5ee;border-radius:8px;padding:11px 13px;min-height:88px}.invoice-words b{display:block;color:var(--invoice-accent);font-size:10px;margin-bottom:5px}.invoice-words p{font-size:10px;line-height:1.55;margin:3px 0}.totals-box{border:1px solid #d5deea;border-radius:8px;overflow:hidden}.total-row{display:grid;grid-template-columns:1fr 110px;gap:10px;padding:8px 10px;font-size:11px;border-bottom:1px solid #e5eaf1}.total-row:last-child{border:0}.total-row strong:last-child,.total-row span:last-child{text-align:right}.invoice-paper.ar .total-row strong:last-child,.invoice-paper.ar .total-row span:last-child{text-align:left}.total-row.net{background:var(--invoice-accent);color:#fff;font-size:13px;font-weight:900}.invoice-notes{display:grid;grid-template-columns:1fr 210px;gap:25px;margin-top:20px;min-height:85px}.invoice-notes h3{font-size:10px;color:var(--invoice-accent);margin:0 0 5px}.invoice-notes p{font-size:9.5px;line-height:1.55;margin:2px 0;white-space:pre-line}.signature-box{text-align:center;align-self:end;border-top:1px solid #cdd6e1;padding-top:8px;font-size:10px;color:#4b5563}.invoice-footer{margin-top:22px;border-top:1px solid #cfd8e5;padding-top:10px;font-size:8.8px;line-height:1.45;color:#4b5563;display:grid;grid-template-columns:1fr auto;gap:15px}.invoice-footer p{margin:1px 0}.invoice-legal-note{font-weight:700;color:#374151}.invoice-paper.compact{padding:34px 38px 28px}.invoice-paper.compact .invoice-head{padding-bottom:13px}.invoice-paper.compact .invoice-table{margin-top:13px}.invoice-paper.compact .invoice-table td{padding:6px 5px;font-size:9px}.invoice-paper.compact .invoice-table th{padding:7px 5px;font-size:9px}.invoice-paper.compact .invoice-summary{margin-top:13px}.invoice-paper.compact .invoice-notes{margin-top:13px;min-height:66px}.invoice-paper.ultra-compact{padding:27px 32px 24px}.invoice-paper.ultra-compact .invoice-head{gap:18px;padding-bottom:10px}.invoice-paper.ultra-compact .invoice-logo{width:88px;height:62px}.invoice-paper.ultra-compact .invoice-seller h1{font-size:19px}.invoice-paper.ultra-compact .invoice-title .doc-title{font-size:27px}.invoice-paper.ultra-compact .invoice-client{margin-top:12px;padding:8px 11px}.invoice-paper.ultra-compact .invoice-table{margin-top:10px}.invoice-paper.ultra-compact .invoice-table td{padding:4px;font-size:8.3px}.invoice-paper.ultra-compact .invoice-table th{padding:5px 4px;font-size:8px}.invoice-paper.ultra-compact .invoice-summary{margin-top:10px;gap:16px}.invoice-paper.ultra-compact .invoice-words{min-height:65px;padding:7px 9px}.invoice-paper.ultra-compact .total-row{padding:5px 8px;font-size:9px}.invoice-paper.ultra-compact .invoice-notes{margin-top:10px;min-height:50px}.invoice-paper.ultra-compact .invoice-footer{margin-top:12px}.invoice-item-empty{text-align:center;padding:15px;color:var(--muted);font-size:12px}@media(max-width:1150px){.invoice-shell{grid-template-columns:1fr}.invoice-editor{height:auto}.invoice-preview-panel{height:auto;min-height:760px}.invoice-preview-stage{min-height:700px}}@media(max-width:720px){.invoice-shell{padding:10px}.invoice-editor{padding:13px}.invoice-item{grid-template-columns:1fr 1fr}.invoice-item label:first-child{grid-column:1/-1}.invoice-line-total{padding:5px 0}.invoice-preview-stage{padding:10px}.invoice-editor-head h1{font-size:20px}.invoice-actions-bottom{flex-direction:column}.invoice-actions-bottom .btn{width:100%}}@media print{.invoice-app .topbar,.invoice-app .invoice-editor,.invoice-app .preview-toolbar,.invoice-app .footer,.invoice-app .toast{display:none!important}.invoice-shell{display:block;padding:0}.invoice-preview-panel{height:auto;background:#fff;box-shadow:none}.invoice-preview-stage{padding:0;background:#fff;overflow:visible}.invoice-preview-fit{transform:none!important;width:auto!important;height:auto!important}.invoice-paper{box-shadow:none;width:210mm;min-height:297mm;padding:12mm}}


/* ===== CasaFacture Pro V25.2 visual/mobile polish ===== */
:root{
  --blue:#102a43;
  --blue-2:#183f63;
  --green:#0b7a57;
  --red:#d3372e;
  --muted:#667d8e;
  --line:#dce6ed;
  --paper:#ffffff;
  --soft:#f4f8fa;
  --radius:22px;
  --shadow:0 18px 48px rgba(16,42,67,.12);
}
html{scrollbar-gutter:stable}
.invoice-app{
  margin:0;
  min-height:100vh;
  background:#eef3f6;
  color:#17364d;
  font-family:Tahoma,"Segoe UI",Arial,sans-serif;
}
.facture-topbar{
  position:sticky;
  top:0;
  z-index:80;
  min-height:72px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:8px max(18px,calc((100vw - 1440px)/2));
  background:rgba(255,255,255,.97);
  border-bottom:1px solid #dce6ed;
  backdrop-filter:blur(14px);
}
.facture-brand{display:flex;align-items:center;gap:12px;color:#102a43;text-decoration:none;font-weight:900}
.facture-brand img{width:178px;height:auto;aspect-ratio:620/319;object-fit:contain}
.facture-brand span{padding-inline-start:12px;border-inline-start:1px solid #dce6ed;white-space:nowrap}
.facture-brand b{color:#0b7a57}
.facture-top-actions{display:flex;gap:8px}
.invoice-shell{
  max-width:1440px;
  margin:0 auto;
  padding:18px;
  gap:18px;
}
.invoice-editor{
  border:1px solid #dce6ed;
  border-radius:22px;
  background:#fff;
  box-shadow:0 10px 34px rgba(16,42,67,.07);
  scrollbar-gutter:stable;
}
.invoice-editor-head{
  position:sticky;
  top:0;
  z-index:5;
  padding-bottom:14px;
  background:linear-gradient(180deg,#fff 82%,rgba(255,255,255,.92));
}
.invoice-editor-head h1{color:#102a43}
.eyebrow{color:#0b7a57!important;font-weight:900}
.autosave{background:#edf8f3!important;color:#0b7a57!important;border-color:#c9e5d8!important}
.invoice-note.success-note{
  background:#f2faf6;
  border-color:#cbe6d9;
  color:#245c47;
}
.form-section{
  border-color:#dce6ed!important;
  border-radius:15px!important;
  overflow:clip;
}
.form-section>summary{
  min-height:52px;
  background:#f8fafb;
  color:#17364d;
}
.form-section>summary span{
  background:#102a43!important;
  color:#fff!important;
}
.form-content input,
.form-content select,
.form-content textarea{
  min-height:46px;
  border-color:#d3dfe7!important;
  border-radius:11px!important;
  background:#fff;
}
.form-content input:focus,
.form-content select:focus,
.form-content textarea:focus{
  outline:3px solid rgba(11,122,87,.12)!important;
  border-color:#0b7a57!important;
}
.invoice-color-presets{
  display:flex;
  gap:7px;
  flex-wrap:wrap;
  margin-top:8px;
}
.invoice-color-preset{
  width:29px;height:29px;border-radius:50%;
  border:3px solid #fff;
  box-shadow:0 0 0 1px #cfdbe3;
  background:var(--swatch);
  cursor:pointer;
}
.invoice-color-preset.active{box-shadow:0 0 0 3px rgba(11,122,87,.22)}
.btn.primary{background:#102a43!important;border-color:#102a43!important}
.btn.add{background:#edf8f3!important;color:#0b7a57!important;border-color:#c8e4d6!important}
.invoice-preview-panel{
  border-radius:22px;
  background:#162433;
  box-shadow:0 18px 46px rgba(16,42,67,.18);
}
.invoice-preview-stage{
  background:radial-gradient(circle at 50% 5%,#33495d,#162433 72%);
}
.invoice-paper{--invoice-accent:#102a43}
.invoice-title .doc-title{letter-spacing:.025em}
.invoice-client{background:#f8fafb}
.invoice-table th{letter-spacing:.015em}
.facture-footer{
  max-width:1440px;
  margin:0 auto;
  padding:18px 22px 28px;
  display:flex;
  justify-content:space-between;
  gap:15px;
  color:#657b8c;
  font-size:12px;
}
.facture-footer p{margin:0}
.facture-footer nav{display:flex;gap:14px;flex-wrap:wrap}
.facture-footer a{color:#173b53;text-decoration:none;font-weight:750}
.facture-mobile-tabs,.facture-mobile-actions{display:none}

/* More stable item layout and cheaper paints */
.invoice-item,.invoice-paper,.invoice-preview-fit{contain:layout style}
.invoice-preview-fit{will-change:transform}

@media(max-width:1150px){
  .invoice-shell{grid-template-columns:1fr}
  .invoice-editor{height:auto;overflow:visible}
  .invoice-preview-panel{height:auto;min-height:690px}
  .invoice-preview-stage{min-height:620px}
}

@media(max-width:720px){
  body.invoice-app{padding-bottom:66px}
  .facture-topbar{
    min-height:62px;
    padding:6px 10px;
  }
  .facture-brand img{width:130px}
  .facture-brand span{font-size:12px;padding-inline-start:8px}
  .facture-top-actions{display:none}

  .facture-mobile-tabs{
    position:sticky;
    top:62px;
    z-index:70;
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:4px;
    padding:6px 10px;
    background:#fff;
    border-bottom:1px solid #dce6ed;
  }
  .facture-mobile-tabs button{
    min-height:42px;
    border:0;
    border-radius:10px;
    background:#f1f5f7;
    color:#536d7f;
    font-weight:900;
  }
  .facture-mobile-tabs button.active{background:#102a43;color:#fff}

  .invoice-shell{padding:9px;display:block}
  .invoice-editor{padding:12px;border-radius:16px}
  .invoice-editor-head{
    position:static;
    padding:2px 0 10px;
  }
  .invoice-editor-head h1{font-size:19px}
  .invoice-note{font-size:11px}
  .form-section{margin-bottom:8px}
  .form-section>summary{padding:10px;min-height:48px}
  .form-content{padding:11px!important}
  .grid-2{grid-template-columns:1fr!important}
  .invoice-item{grid-template-columns:1fr 1fr!important}
  .invoice-item label:first-child{grid-column:1/-1}
  .invoice-actions-bottom{display:none}

  .invoice-preview-panel{
    display:none;
    min-height:0;
    border-radius:16px;
  }
  body.facture-preview-mobile .invoice-editor{display:none}
  body.facture-preview-mobile .invoice-preview-panel{display:flex;min-height:calc(100vh - 130px)}
  body.facture-preview-mobile .invoice-preview-stage{min-height:calc(100vh - 190px)}
  .invoice-preview-stage{padding:8px}
  .invoice-preview-toolbar{min-height:50px}

  .facture-mobile-actions{
    position:fixed;
    inset-inline:0;
    bottom:0;
    z-index:90;
    display:grid;
    grid-template-columns:1fr 1.35fr;
    gap:7px;
    padding:7px max(10px,env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));
    background:rgba(255,255,255,.98);
    border-top:1px solid #dce6ed;
    box-shadow:0 -10px 24px rgba(16,42,67,.08);
  }
  .facture-mobile-actions button{
    min-height:46px;
    border:1px solid #d7e2e9;
    border-radius:11px;
    background:#fff;
    color:#173b53;
    font-weight:900;
  }
  .facture-mobile-actions .primary{background:#0b7a57;color:#fff;border-color:#0b7a57}
  .facture-footer{padding-bottom:82px;display:block;text-align:center}
  .facture-footer nav{justify-content:center;margin-top:7px}
}
