/* ============================================================
   Invoice Maker — Web Version Styles
   File: styles.css
   ============================================================ */

:root{
  --bg:#f1f5f9; --bg-elev:#ffffff; --card:#ffffff; --ink:#0f172a; --ink-2:#334155;
  --muted:#64748b; --muted-2:#94a3b8; --line:#e2e8f0; --line-strong:#cbd5e1;
  --primary:#4f46e5; --primary-dark:#4338ca; --primary-soft:#eef2ff; --accent:#0ea5e9;
  --danger:#dc2626; --danger-soft:#fef2f2; --success:#16a34a; --success-soft:#f0fdf4;
  --warning:#d97706; --warning-soft:#fffbeb;
  --shadow-sm:0 1px 2px rgba(15,23,42,.04);
  --shadow:0 1px 3px rgba(15,23,42,.06), 0 6px 16px rgba(15,23,42,.08);
  --shadow-lg:0 8px 30px rgba(15,23,42,.14);
  --radius:14px; --radius-sm:10px; --radius-xs:8px;
  --header-h:56px; --footer-h:64px;
  --safe-top:env(safe-area-inset-top, 0px); --safe-bottom:env(safe-area-inset-bottom, 0px);
  --tap:44px; --ease:cubic-bezier(.4,0,.2,1);
}
[data-theme="dark"]{
  --bg:#0b1220; --bg-elev:#111827; --card:#1e293b; --ink:#f1f5f9; --ink-2:#cbd5e1;
  --muted:#94a3b8; --muted-2:#64748b; --line:#334155; --line-strong:#475569;
  --primary:#818cf8; --primary-dark:#6366f1; --primary-soft:#1e1b4b; --accent:#38bdf8;
  --danger:#f87171; --danger-soft:#450a0a; --success:#4ade80; --success-soft:#052e16;
  --warning:#fbbf24; --warning-soft:#422006;
  --shadow:0 1px 3px rgba(0,0,0,.3), 0 6px 16px rgba(0,0,0,.4);
  --shadow-lg:0 8px 30px rgba(0,0,0,.6);
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent}
html,body{margin:0; padding:0; overscroll-behavior-y:none}
html{scroll-behavior:smooth}
body{font-family:'Inter',system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; background:var(--bg); color:var(--ink); font-size:15px; line-height:1.5; -webkit-font-smoothing:antialiased; padding-top:calc(var(--header-h) + var(--safe-top)); padding-bottom:calc(var(--footer-h) + var(--safe-bottom) + 8px); min-height:100vh}
a{color:var(--primary); text-decoration:none}
a:hover{text-decoration:underline}
button{font-family:inherit}

.app-header{position:fixed; top:0; left:0; right:0; height:calc(var(--header-h) + var(--safe-top)); padding-top:var(--safe-top); background:rgba(255,255,255,.85); backdrop-filter:saturate(180%) blur(14px); -webkit-backdrop-filter:saturate(180%) blur(14px); border-bottom:1px solid var(--line); z-index:50; display:flex; align-items:center; justify-content:space-between; padding-left:8px; padding-right:8px}
[data-theme="dark"] .app-header{background:rgba(17,24,39,.85)}
.app-header .app-title{display:flex; align-items:center; gap:8px; font-weight:800; font-size:16px}
.logo-dot{width:30px; height:30px; border-radius:8px; background:linear-gradient(135deg,var(--primary),var(--accent)); display:grid; place-items:center; color:#fff; font-weight:800; font-size:13px; flex-shrink:0}
.icon-touch{background:transparent; border:0; width:var(--tap); height:var(--tap); display:grid; place-items:center; color:var(--ink); cursor:pointer; border-radius:10px; transition:background .15s var(--ease)}
.icon-touch:active{background:var(--line)}
.burger-icon{display:grid; gap:4px; width:20px}
.burger-icon i{display:block; height:2px; background:currentColor; border-radius:2px; transition:transform .25s var(--ease), opacity .2s var(--ease)}
.burger-icon i:nth-child(1){width:18px}
.burger-icon i:nth-child(2){width:14px; margin-left:auto}
.burger-icon i:nth-child(3){width:18px}

.progress-track{position:fixed; top:calc(var(--header-h) + var(--safe-top)); left:0; right:0; height:3px; background:var(--line); z-index:49}
.progress-bar{height:100%; width:0%; background:linear-gradient(90deg,var(--primary),var(--accent)); transition:width .35s var(--ease); border-radius:0 4px 4px 0}

.side-nav{position:fixed; top:0; left:0; bottom:0; width:300px; max-width:85vw; background:var(--card); z-index:100; transform:translateX(-105%); transition:transform .3s var(--ease); display:flex; flex-direction:column; box-shadow:var(--shadow-lg); padding-top:var(--safe-top); padding-bottom:var(--safe-bottom); visibility:hidden}
.side-nav.open{transform:translateX(0); visibility:visible}
.side-nav-header{padding:18px 16px 14px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:flex-start; background:linear-gradient(135deg,var(--primary-soft),transparent)}
.brand-row{display:flex; gap:10px; align-items:center}
.brand-row .logo-dot{width:36px; height:36px; font-size:14px}
.brand-title{font-weight:800; font-size:15px; color:var(--ink)}
.brand-sub{font-size:11px; color:var(--muted); margin-top:2px}
.side-nav-list{flex:1; overflow-y:auto; padding:8px; display:flex; flex-direction:column; gap:2px}
.side-nav-list a{display:flex; align-items:center; gap:12px; padding:12px 12px; border-radius:10px; color:var(--ink); font-weight:500; font-size:14px; cursor:pointer; transition:background .15s}
.side-nav-list a:hover, .side-nav-list a:active{background:var(--bg); text-decoration:none}
.nav-ico{width:24px; text-align:center; font-size:16px; flex-shrink:0}
.nav-sep{height:1px; background:var(--line); margin:8px 12px}
.side-nav-footer{padding:12px 16px; border-top:1px solid var(--line)}
.contact-card{background:var(--bg); border-radius:10px; padding:10px 12px; font-size:12px; display:grid; gap:6px}
.contact-link{color:var(--ink-2); font-weight:500}
.contact-link:hover{color:var(--primary)}
.version{font-size:10px; color:var(--muted-2); margin-top:8px; text-align:center}

.scrim{position:fixed; inset:0; background:rgba(15,23,42,.5); z-index:99; opacity:0; visibility:hidden; transition:opacity .25s var(--ease), visibility .25s}
.scrim.open{opacity:1; visibility:visible}

.settings-sheet{position:fixed; left:0; right:0; bottom:0; background:var(--card); z-index:100; border-radius:20px 20px 0 0; transform:translateY(105%); transition:transform .3s var(--ease); box-shadow:var(--shadow-lg); max-height:90vh; display:flex; flex-direction:column; padding-bottom:var(--safe-bottom)}
.settings-sheet.open{transform:translateY(0)}
.sheet-handle{width:40px; height:4px; background:var(--line-strong); border-radius:4px; margin:10px auto 4px}
.sheet-header{display:flex; justify-content:space-between; align-items:center; padding:6px 16px 14px; border-bottom:1px solid var(--line)}
.sheet-header h3{margin:0; font-size:17px; font-weight:700}
.sheet-body{padding:16px; overflow-y:auto; flex:1; display:grid; gap:14px}
.sheet-footer{padding:12px 16px 14px; border-top:1px solid var(--line)}
.setting-group label{display:block; font-size:12px; color:var(--muted); font-weight:600; margin-bottom:6px}
.setting-group input, .setting-group select{width:100%; padding:11px 12px; border:1px solid var(--line); border-radius:10px; font:inherit; color:var(--ink); background:var(--card); outline:none}
.setting-group input:focus, .setting-group select:focus{border-color:var(--primary); box-shadow:0 0 0 3px rgba(79,70,229,.12)}
.btn-danger-outline{width:100%; padding:11px 12px; border:1px solid #fecaca; background:var(--danger-soft); color:var(--danger); border-radius:10px; font-weight:600; font-size:13px; cursor:pointer; transition:all .15s var(--ease)}
.btn-danger-outline:active{background:#fecaca}

.app-main{padding:12px 12px 0; max-width:720px; margin:0 auto; display:flex; flex-direction:column; gap:14px}
.accordion{background:var(--card); border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; box-shadow:var(--shadow-sm); transition:border-color .2s var(--ease), box-shadow .2s var(--ease)}
.accordion.is-valid{border-color:var(--success)}
.accordion.is-active{box-shadow:var(--shadow)}
.acc-head{width:100%; background:transparent; border:0; padding:14px 14px; display:flex; align-items:center; gap:12px; cursor:pointer; text-align:left; font:inherit; color:var(--ink); font-weight:600; font-size:15px}
.step-num{width:28px; height:28px; border-radius:50%; background:var(--bg); color:var(--muted); display:grid; place-items:center; font-size:13px; font-weight:700; flex-shrink:0; transition:all .2s var(--ease)}
.accordion.is-active .step-num{background:var(--primary); color:#fff}
.accordion.is-valid .step-num{background:var(--success); color:#fff}
.accordion.is-valid .step-num .num-txt{display:none}
.accordion.is-valid .step-num::before{content:"✓"; font-size:14px}
.step-title{flex:1}
.chev{color:var(--muted); font-size:18px; transition:transform .25s var(--ease)}
.accordion.is-active .chev{transform:rotate(180deg)}
.acc-body{padding:0 14px 14px; display:none; animation:slideDown .25s var(--ease)}
.accordion.is-active .acc-body{display:block}
@keyframes slideDown{from{opacity:0; transform:translateY(-6px)} to{opacity:1; transform:translateY(0)}}

label{display:block; font-size:12px; color:var(--muted); font-weight:600; margin-bottom:5px}
label .opt{color:var(--muted-2); font-weight:400}
input, textarea, select{width:100%; padding:11px 12px; border:1px solid var(--line); border-radius:10px; font:inherit; color:var(--ink); background:var(--card); outline:none; -webkit-appearance:none; appearance:none}
select{background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat:no-repeat; background-position:right 12px center; padding-right:34px}
input:focus, textarea:focus, select:focus{border-color:var(--primary); box-shadow:0 0 0 3px rgba(79,70,229,.12)}
textarea{resize:vertical; min-height:80px; line-height:1.5}
input::placeholder, textarea::placeholder{color:var(--muted-2)}
input[type="date"]{min-height:44px; padding-right:0px; position:relative}
input[type="date"]::-webkit-calendar-picker-indicator{position:absolute; right:8px; top:50%; transform:translateY(-50%); margin:0; padding:0}
input[type="number"]{-moz-appearance:textfield}
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button{-webkit-appearance:none; margin:0}
.hint{font-size:11px; color:var(--muted); margin-top:5px; line-height:1.4}
.grid-2{display:grid; grid-template-columns:1fr 1fr; gap:10px}

.seg{display:inline-flex; width:100%; border:1px solid var(--line); border-radius:10px; overflow:hidden; background:var(--bg)}
.seg button{flex:1; border:0; padding:10px 12px; background:transparent; cursor:pointer; font:inherit; font-weight:600; font-size:13px; color:var(--muted); transition:all .15s var(--ease)}
.seg button.active{background:var(--primary); color:#fff}

.step-actions{display:flex; gap:8px; margin-top:14px; margin-bottom:4px}
.btn-next, .btn-back{flex:1; padding:12px; border-radius:10px; font-weight:600; font-size:14px; border:0; cursor:pointer; transition:all .15s var(--ease)}
.btn-next{background:var(--primary); color:#fff}
.btn-next:active{background:var(--primary-dark)}
.btn-back{background:var(--bg); color:var(--ink-2); border:1px solid var(--line)}
.btn-back:active{background:var(--line)}

.logo-upload{display:flex; gap:10px; align-items:center}
.logo-pick{flex:1; display:flex; align-items:center; justify-content:center; min-height:90px; border:2px dashed var(--line-strong); border-radius:10px; cursor:pointer; background:var(--bg); color:var(--muted); font-size:13px; font-weight:500; padding:8px; transition:all .15s var(--ease)}
.logo-pick:active{border-color:var(--primary); background:var(--primary-soft)}
.logo-pick img{max-width:100%; max-height:80px; object-fit:contain}

.btn-add-item{width:100%; padding:12px; background:var(--primary-soft); color:var(--primary-dark); border:1px dashed var(--primary); border-radius:10px; font-weight:600; cursor:pointer; transition:all .15s var(--ease)}
.btn-add-item:active{background:var(--primary); color:#fff}

.item{border:1px solid var(--line); border-radius:12px; padding:12px; background:var(--bg); margin-bottom:10px}
[data-theme="dark"] .item{background:var(--bg-elev)}
.item-head{display:flex; justify-content:space-between; align-items:center; margin-bottom:8px}
.item-head .label{font-size:12px; font-weight:700; color:var(--muted)}
.item-actions{display:flex; gap:6px}
.icon-btn{border:1px solid var(--line); background:var(--card); width:34px; height:34px; border-radius:8px; cursor:pointer; display:grid; place-items:center; font-size:14px; color:var(--muted); transition:all .15s var(--ease)}
.icon-btn:active{background:var(--line)}
.icon-btn.danger:active{color:var(--danger); border-color:#fecaca; background:var(--danger-soft)}

.editor-toolbar{display:flex; gap:4px; margin-bottom:4px; flex-wrap:wrap}
.editor-toolbar button{border:1px solid var(--line); background:var(--card); padding:6px 10px; border-radius:6px; cursor:pointer; font-size:12px; font-weight:600; color:var(--ink); min-width:30px}
.editor-toolbar button:active{background:var(--line)}
.editor{min-height:80px; padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:var(--card); outline:none; line-height:1.6; font-size:13px; -webkit-user-select:text; user-select:text}
.editor:focus{border-color:var(--primary); box-shadow:0 0 0 3px rgba(79,70,229,.12)}
.editor ul{margin:6px 0 6px 18px; padding:0}
.editor b, .editor strong{font-weight:700}
.editor i, .editor em{font-style:italic}
.item-meta{display:grid; grid-template-columns:80px 1fr 1fr; gap:10px; margin-top:10px}
.item-amount{display:flex; align-items:center; justify-content:flex-end; font-weight:700; padding:11px 0}
.calc-readout{padding:11px 12px; border-radius:10px; background:var(--ink); color:#fff; font-weight:700; font-size:15px; text-align:center}
.form-footer-spacer{height:20px}

.app-footer{position:fixed; left:0; right:0; bottom:0; background:rgba(255,255,255,.95); backdrop-filter:saturate(180%) blur(14px); -webkit-backdrop-filter:saturate(180%) blur(14px); border-top:1px solid var(--line); padding-bottom:var(--safe-bottom); display:flex; align-items:center; gap:6px; padding-top:8px; padding-left:10px; padding-right:10px; z-index:45; height:calc(var(--footer-h) + var(--safe-bottom))}
[data-theme="dark"] .app-footer{background:rgba(17,24,39,.95)}
.foot-btn{flex:1; background:transparent; border:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; padding:6px 4px; color:var(--muted); cursor:pointer; font-size:11px; font-weight:600; border-radius:10px; transition:all .15s var(--ease); min-height:48px}
.foot-btn:active:not(:disabled){background:var(--bg)}
.foot-clear{color:var(--danger)}
.foot-preview{color:var(--ink-2)}
.foot-download{color:#fff; background:var(--primary); box-shadow:0 4px 12px rgba(79,70,229,.3)}
.foot-download:active:not(:disabled){background:var(--primary-dark)}
.foot-download:disabled{background:var(--line); color:var(--muted-2); box-shadow:none; cursor:not-allowed}
.foot-share{color:var(--accent); background:var(--primary-soft)}
.foot-share:active:not(:disabled){background:#dbeafe}
.foot-share:disabled{background:var(--line); color:var(--muted-2); cursor:not-allowed}
.foot-btn svg{flex-shrink:0}

.modal{position:fixed; inset:0; background:rgba(15,23,42,.65); z-index:200; display:none; align-items:stretch; justify-content:center; flex-direction:column; opacity:0; transition:opacity .25s var(--ease); padding-top:var(--safe-top); padding-bottom:var(--safe-bottom)}
.modal.open{display:flex; opacity:1}
.modal-head{display:flex; align-items:center; justify-content:space-between; padding:12px 16px; background:var(--card); border-bottom:1px solid var(--line); flex-shrink:0}
.modal-head h3{margin:0; font-size:16px; font-weight:700}
.modal-body{flex:1; overflow:auto; padding:16px; background:var(--bg); -webkit-overflow-scrolling:touch}
#previewModal .modal-body{padding:0; overflow:auto; background:#e2e8f4; display:block; width:100%}
#previewScaleWrapper{transform-origin:top left; width:794px; background:#fff; box-shadow:0 4px 20px rgba(15,23,42,.15); margin:0 auto}
#previewModal #invoice{max-width:none !important; width:794px !important; margin:0 !important; border-radius:0 !important}
.modal-head .icon-touch{color:var(--ink-2)}
.modal-head .icon-touch:last-child{color:var(--primary)}
.modal-sm{align-items:center; justify-content:center; padding:24px}
.modal-card{background:var(--card); border-radius:16px; padding:20px; max-width:380px; width:100%; box-shadow:var(--shadow-lg)}
.modal-card h3{margin:0 0 8px; font-size:17px; font-weight:700}
.modal-card p{margin:0 0 14px; font-size:13px; color:var(--ink-2); line-height:1.5}
.modal-actions{display:flex; gap:8px; margin-top:14px}
.btn{flex:1; padding:11px; border-radius:10px; font-weight:600; font-size:14px; border:1px solid var(--line); background:var(--card); color:var(--ink); cursor:pointer; transition:all .15s var(--ease)}
.btn:active{background:var(--bg)}
.btn-ghost{background:transparent; color:var(--muted)}
.btn-danger{background:var(--danger); color:#fff; border-color:var(--danger)}
.btn-block{width:100%; padding:13px}
.btn-primary{background:var(--primary); color:#fff; border-color:var(--primary)}
.contact-list{display:grid; gap:6px; margin-bottom:14px}
.contact-row{display:block; padding:11px 12px; background:var(--bg); border-radius:10px; color:var(--ink-2); font-weight:500; font-size:13px}
.contact-row:active{background:var(--primary-soft)}

.toast{position:fixed; bottom:calc(var(--footer-h) + var(--safe-bottom) + 16px); left:50%; transform:translateX(-50%) translateY(20px); background:var(--ink); color:#fff; padding:11px 18px; border-radius:24px; font-size:13px; font-weight:500; opacity:0; pointer-events:none; transition:opacity .25s var(--ease), transform .25s var(--ease); z-index:300; box-shadow:var(--shadow-lg); max-width:90vw; text-align:center}
.toast.show{opacity:1; transform:translateX(-50%) translateY(0)}

@media (min-width:768px){body{font-size:16px} .app-main{padding:18px 18px 0; gap:16px} .acc-head{padding:18px 18px; font-size:16px} .acc-body{padding:0 18px 18px} .item{padding:14px} .foot-btn{font-size:12px} .grid-2{gap:14px}}
@media (min-width:1024px){.app-main{max-width:880px}}

/* ============================================================ INVOICE PREVIEW CSS ============================================================ */
.invoice-doc{background:#ffffff; color:#0f172a; padding:24px 22px; min-height:600px; font-family:'Inter',system-ui,sans-serif; font-size:13px; line-height:1.5; border-radius:8px; box-shadow:0 4px 20px rgba(15,23,42,.08); max-width:680px; margin:0 auto}
.inv-top{display:flex; justify-content:space-between; align-items:flex-start; gap:16px; flex-wrap:wrap}
.inv-brand{display:flex; flex-direction:column; gap:4px; align-items:flex-start}
.inv-brand img{height:50px; width:auto; max-width:160px; object-fit:contain; margin-bottom:2px; border-radius:4px}
.inv-brand .biz-name{font-size:18px; font-weight:800; color:#0f172a}
.inv-brand .biz-sub{font-size:12px; color:#64748b}
.inv-meta{text-align:right; font-size:12px; color:#334155}
.inv-meta .inv-title{font-size:30px; font-weight:800; letter-spacing:.05em; color:#4f46e5; line-height:1}
.inv-meta .inv-no{font-size:13px; color:#64748b; margin-top:4px}
.inv-meta #pDates{margin-top:8px}
.inv-meta #pDates div{margin-top:2px}
.inv-meta #pDates strong{color:#0f172a}
.inv-meta .balance-top{margin-top:10px; display:inline-block; padding:6px 12px; border-radius:8px; background:#eef2ff; color:#4338ca; font-weight:700; font-size:13px}
.inv-meta .badge{display:inline-block; padding:3px 10px; border-radius:999px; font-size:11px; font-weight:700; margin-top:8px}
.badge.unpaid{background:#fef2f2; color:#b91c1c}
.badge.partial{background:#fffbeb; color:#b45309}
.badge.paid{background:#f0fdf4; color:#15803d}
.inv-parties{margin:24px 0 16px}
.inv-parties h4{margin:0 0 6px; font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:#64748b; font-weight:700}
.inv-parties .party{font-size:13px; white-space:pre-line; border-left:3px solid #4f46e5; padding-left:10px; color:#0f172a}
table.inv-items{width:100%; border-collapse:collapse; margin-top:6px}
table.inv-items th{text-align:left; font-size:10px; text-transform:uppercase; letter-spacing:.06em; color:#64748b; font-weight:700; padding:10px 8px; background:#f8fafc; border-bottom:1px solid #e2e8f0}
table.inv-items th.num{text-align:right}
table.inv-items td{padding:10px 8px; border-bottom:1px solid #e2e8f0; vertical-align:top; font-size:12px; color:#0f172a}
table.inv-items td.num{text-align:right; white-space:nowrap}
.item-title{font-weight:700; display:block; margin-bottom:3px; font-size:13px}
.item-desc{font-size:11px; color:#475569; line-height:1.55}
.item-desc ul{margin:4px 0 0 16px; padding:0}
.inv-bottom{display:flex; justify-content:space-between; align-items:flex-start; margin-top:18px; gap:20px; flex-wrap:wrap}
.payee-box{flex:1; min-width:180px; max-width:50%; font-size:11px}
.payee-box h4{margin:0 0 6px; font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:#64748b; font-weight:700}
.payee-box .content{white-space:pre-line; color:#334155; line-height:1.6; border-left:3px solid #e2e8f0; padding-left:10px}
.inv-totals{width:260px; flex-shrink:0; font-size:13px}
.inv-totals .row{display:flex; justify-content:space-between; padding:5px 0; color:#0f172a}
.inv-totals .row.muted{color:#64748b}
.inv-totals .divider{border-top:1px solid #e2e8f0; margin:5px 0}
.inv-totals .total{font-size:14px; font-weight:800}
.inv-totals .balance-due{margin-top:8px; padding:11px 12px; background:#0f172a; color:#fff; border-radius:8px; display:flex; justify-content:space-between; align-items:center; font-size:15px; font-weight:800}
.inv-notes{margin-top:24px; font-size:11px}
.inv-notes > div{padding:12px 0; border-top:1px solid #e2e8f0; border-bottom:1px solid #e2e8f0}
.inv-notes > div + div{border-top:none}
.inv-notes h4{margin:0 0 4px; font-size:10px; text-transform:uppercase; letter-spacing:.08em; color:#64748b; font-weight:700}
.inv-notes .content{white-space:pre-line; color:#334155; line-height:1.55}

/* PDF mode: force desktop layout regardless of device viewport */
.invoice-doc.pdf-mode{
  box-shadow:none !important;
  border-radius:0 !important;
  margin:0 !important;
  max-width:none !important;
  padding:32px 28px !important;
  width:100% !important;
  box-sizing:border-box !important;
  font-size:13px !important;
}
.invoice-doc.pdf-mode .inv-top,
.invoice-doc.pdf-mode .inv-parties,
.invoice-doc.pdf-mode table.inv-items,
.invoice-doc.pdf-mode .inv-bottom,
.invoice-doc.pdf-mode .inv-notes{
  page-break-inside:avoid !important;
  break-inside:avoid !important;
}
.invoice-doc.pdf-mode .inv-top tr,
.invoice-doc.pdf-mode table.inv-items tr{
  page-break-inside:avoid !important;
  break-inside:avoid !important;
}
.invoice-doc.pdf-mode .inv-top{flex-wrap:nowrap !important}
.invoice-doc.pdf-mode .inv-meta .inv-title{font-size:30px !important}
.invoice-doc.pdf-mode .inv-brand .biz-name{font-size:18px !important}
.invoice-doc.pdf-mode .inv-brand .biz-sub{font-size:12px !important}
.invoice-doc.pdf-mode .inv-parties .party{font-size:13px !important}
.invoice-doc.pdf-mode table.inv-items th{font-size:10px !important; padding:10px 8px !important}
.invoice-doc.pdf-mode table.inv-items td{padding:10px 8px !important; font-size:12px !important}
.invoice-doc.pdf-mode .item-title{font-size:13px !important}
.invoice-doc.pdf-mode .item-desc{font-size:11px !important}
.invoice-doc.pdf-mode .inv-bottom{flex-direction:row !important; gap:20px !important; flex-wrap:wrap !important}
.invoice-doc.pdf-mode .payee-box{max-width:50% !important; width:auto !important; min-width:180px !important; font-size:11px !important}
.invoice-doc.pdf-mode .inv-totals{width:260px !important; max-width:none !important; font-size:13px !important}
.invoice-doc.pdf-mode .inv-notes{font-size:11px !important}

/* ---- Saved invoices picker ---- */
.inv-row{display:flex; align-items:center; gap:10px; padding:12px 12px; border:1px solid var(--line); border-radius:10px; background:var(--bg); cursor:pointer; transition:all .15s var(--ease)}
.inv-row:active{background:var(--primary-soft); border-color:var(--primary)}
.inv-row-text{flex:1; min-width:0; display:flex; flex-direction:column}
.inv-row-name{font-weight:600; font-size:14px; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0}
.inv-row-meta{font-size:11px; color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; margin-top:2px}
.inv-row-meta .amt{color:var(--primary-dark); font-weight:700}
.inv-row-actions{display:flex; gap:6px; flex-shrink:0}
.inv-empty{padding:24px 16px; text-align:center; color:var(--muted); font-size:13px; line-height:1.5}
.inv-sheet-footer{padding:12px 16px 14px; border-top:1px solid var(--line); display:flex; gap:8px}
.btn-clear-all{flex:1; padding:11px 12px; border:1px solid #fecaca; background:var(--danger-soft); color:var(--danger); border-radius:10px; font-weight:600; font-size:13px; cursor:pointer; transition:all .15s var(--ease)}
.btn-clear-all:active{background:#fecaca}
.btn-clear-all:disabled{opacity:.5; cursor:not-allowed}
.confirm-modal-card{background:var(--card); border-radius:16px; padding:20px; max-width:380px; width:100%; box-shadow:var(--shadow-lg); margin:auto}
.confirm-modal-card h3{margin:0 0 8px; font-size:17px; font-weight:700}
.confirm-modal-card p{margin:0 0 14px; font-size:13px; color:var(--ink-2); line-height:1.55}
.confirm-modal-card .meta-line{font-size:12px; color:var(--muted); margin-bottom:10px; padding:8px 10px; background:var(--bg); border-radius:8px; border-left:3px solid var(--primary)}
.confirm-modal-card .modal-actions{display:flex; flex-direction:column; gap:8px; margin-top:14px}
.confirm-modal-card .modal-actions .btn{width:100%}
.confirm-modal-card .modal-actions .btn-row{display:flex; gap:8px}
.confirm-modal-card .modal-actions .btn-row .btn{flex:1}

/* ---- Picker sheets ---- */
.picker-row{display:flex; align-items:center; gap:10px; padding:12px 12px; border:1px solid var(--line); border-radius:10px; background:var(--bg); cursor:pointer; transition:all .15s var(--ease)}
.picker-row:active{background:var(--primary-soft); border-color:var(--primary)}
.picker-name{flex:1; font-weight:600; font-size:14px; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0}
.picker-sub{flex:1; font-size:11px; color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; margin-top:2px}
.picker-text-wrap{flex:1; min-width:0; display:flex; flex-direction:column}
.picker-actions{display:flex; gap:6px; flex-shrink:0}
.picker-empty{padding:24px 16px; text-align:center; color:var(--muted); font-size:13px; line-height:1.5}
.btn-select{width:100%; padding:11px 12px; background:var(--primary-soft); color:var(--primary-dark); border:1px dashed var(--primary); border-radius:10px; font-weight:600; cursor:pointer; transition:all .15s var(--ease); font-size:13px; text-align:left; display:flex; align-items:center; justify-content:space-between; gap:8px}
.btn-select:active{background:var(--primary); color:#fff}
.btn-select .chev-right{color:currentColor; font-size:14px}
.sheet-list{display:flex; flex-direction:column; gap:6px; padding:0; margin:0; list-style:none}
.sheet-toolbar{display:flex; gap:8px; margin-bottom:12px}
.sheet-toolbar .btn-add-item{margin:0}
.profile-logo-thumb{width:32px; height:32px; border-radius:6px; object-fit:contain; background:#fff; border:1px solid var(--line); flex-shrink:0}
.profile-initial-dot{width:32px; height:32px; border-radius:6px; background:linear-gradient(135deg,var(--primary),var(--accent)); color:#fff; display:grid; place-items:center; font-weight:700; font-size:13px; flex-shrink:0}
.client-avatar{width:32px; height:32px; border-radius:50%; background:var(--primary-soft); color:var(--primary-dark); display:grid; place-items:center; font-weight:700; font-size:13px; flex-shrink:0; text-transform:uppercase}
.form-stack{display:grid; gap:10px}
.form-stack label{margin-bottom:0}
.form-stack input, .form-stack textarea, .form-stack select{margin-bottom:0}
.modal-card .form-stack{margin-top:6px}

/* ---- AdSense Interstitial Overlay ---- */
.ad-interstitial-overlay{position:fixed; inset:0; background:rgba(15,23,42,.92); z-index:400; display:none; align-items:center; justify-content:center; padding:16px; opacity:0; transition:opacity .3s var(--ease)}
.ad-interstitial-overlay.open{display:flex; opacity:1}
.ad-interstitial-card{background:#fff; border-radius:16px; max-width:500px; width:100%; overflow:hidden; box-shadow:0 12px 50px rgba(0,0,0,.4)}
.ad-interstitial-head{display:flex; align-items:center; justify-content:space-between; padding:10px 14px; background:#f1f5f9; border-bottom:1px solid #e2e8f0}
.ad-interstitial-label{font-size:11px; font-weight:700; color:#64748b; text-transform:uppercase; letter-spacing:.06em; background:#e2e8f0; padding:3px 8px; border-radius:6px}
.ad-interstitial-timer{font-size:14px; font-weight:700; color:#4f46e5; min-width:24px; text-align:center}
.ad-interstitial-skip{background:transparent; border:0; width:32px; height:32px; border-radius:8px; cursor:pointer; color:#64748b; font-size:16px; display:grid; place-items:center; transition:all .15s var(--ease)}
.ad-interstitial-skip:not(:disabled):active{background:#e2e8f0}
.ad-interstitial-skip:disabled{opacity:.4; cursor:not-allowed}
.ad-interstitial-body{padding:12px; min-height:400px; display:flex; align-items:center; justify-content:center}
.ad-interstitial-body .adsbygoogle{width:100% !important; min-height:400px !important; display:block !important}