
:root{
  --bg:#f4f7fb;--panel:#fff;--text:#172033;--muted:#6b7484;--line:#e2e7ef;
  --primary:#173f63;--primary2:#24777a;--sand:#c9a86a;--soft:#edf5f5;
  --danger:#b42318;--warning:#8a5a00;--success:#166534;
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{margin:0;font-family:Tahoma,Arial,sans-serif;background:var(--bg);color:var(--text);direction:rtl}
button,input,select,textarea{font:inherit}
button{cursor:pointer}
[hidden]{display:none!important}
.auth-screen{min-height:100vh;display:grid;place-items:center;padding:20px;background:linear-gradient(135deg,#edf6f5,#f8f4ea)}
.auth-card{width:min(470px,100%);background:#fff;border:1px solid var(--line);border-radius:20px;padding:30px;box-shadow:0 24px 70px rgba(23,63,99,.14)}
.auth-logo,.brand-mark{display:grid;place-items:center;background:#fff;color:#fff;font-weight:bold;border:1px solid var(--line);overflow:hidden}
.auth-logo{width:108px;height:108px;border-radius:22px;margin:auto;padding:6px}.auth-card h1{text-align:center;margin:16px 0 6px}.auth-card>p{text-align:center;color:var(--muted);margin:0 0 18px}.muted-inline{display:block;font-size:12px;margin-top:4px}
.auth-card label{margin-bottom:12px}.password-field{position:relative;width:100%}.password-field input{padding-left:46px}.password-toggle{position:absolute;left:6px;top:50%;transform:translateY(-50%);width:36px;height:34px;border:0;background:transparent;border-radius:7px;display:grid;place-items:center;font-size:18px;line-height:1;color:var(--muted);cursor:pointer}.password-toggle:hover{background:#eef3f8;color:var(--primary)}.password-toggle:focus-visible{outline:2px solid #9fb9d0;outline-offset:1px}.tabs{display:flex;background:#f2f4f7;padding:4px;border-radius:11px;margin:18px 0}.tab{flex:1;border:0;background:transparent;padding:9px 12px;border-radius:8px}.tab.active{background:#fff;box-shadow:0 2px 8px rgba(0,0,0,.07);font-weight:bold}
.wide{width:100%}.auth-msg{margin-top:12px;font-size:13px;color:var(--danger);line-height:1.6}
.topbar{min-height:86px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 22px;position:sticky;top:0;z-index:20}
.brand{display:flex;align-items:center;gap:11px}.brand h1{margin:0;font-size:18px}.brand small{color:var(--muted);display:block}.brand-logo-only{min-width:205px}.brand-logo-only .brand-mark{width:205px;height:66px;border:0;border-radius:0;padding:0;background:transparent}.brand-icon{width:100%;height:100%;object-fit:contain;object-position:right center}.brand-logo{width:100%;height:100%;object-fit:contain}.auth-brand-logo{max-width:100px;max-height:100px}
.top-context,.userbox{display:flex;align-items:center;gap:8px}.context-select{min-width:170px}.org-context,.year-context{display:flex;align-items:center;gap:7px}.context-caption{font-size:11px;color:var(--muted);white-space:nowrap}.current-org-name{display:inline-flex;align-items:center;min-height:40px;max-width:290px;padding:8px 13px;border:1px solid var(--line);border-radius:9px;background:#f8fafc;color:var(--primary);font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.year-select{min-width:115px}
.layout{display:grid;grid-template-columns:225px 1fr;min-height:calc(100vh - 118px)}.sidebar{background:#fff;border-left:1px solid var(--line);padding:18px 12px;position:sticky;top:86px;height:calc(100vh - 118px)}
.nav{width:100%;border:0;background:transparent;text-align:right;padding:12px 14px;border-radius:10px;color:var(--text);margin-bottom:5px}.nav:hover,.nav.active{background:var(--soft);color:var(--primary);font-weight:bold}
.content{padding:24px;min-width:0}.view{display:none}.view.active{display:block}
.page-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:18px}.page-head h2{margin:0 0 5px;font-size:25px}.page-head p{margin:0;color:var(--muted)}
.btn{border:1px solid var(--line);background:#fff;padding:10px 15px;border-radius:9px;color:var(--text)}.btn.primary{background:var(--primary);border-color:var(--primary);color:#fff}.btn.ghost{background:#fff}.btn.small{padding:7px 10px}.btn.danger{color:var(--danger)}.btn:disabled{opacity:.5;cursor:not-allowed}.link-btn{border:0;background:transparent;color:var(--primary);padding:0 0 8px}
.actions,.head-actions,.preview-actions{display:flex;gap:7px;flex-wrap:wrap}.actions.end{justify-content:flex-end;margin-top:16px}
.cards{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:18px}.cards.accounting-card{grid-template-columns:repeat(2,minmax(0,1fr))}
.stat{background:#fff;border:1px solid var(--line);border-radius:14px;padding:18px}.stat span{display:block;color:var(--muted);font-size:13px;margin-bottom:10px}.stat strong{font-size:22px}
.panel{background:#fff;border:1px solid var(--line);border-radius:14px;padding:18px;margin-bottom:18px}.panel-title,.section-title{font-weight:bold;margin-bottom:14px}.section-title{margin-top:20px}
.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.span2{grid-column:1/-1}
label{display:flex;flex-direction:column;gap:7px;font-size:13px;color:#374151}input,select,textarea{border:1px solid #d5dce6;border-radius:8px;padding:10px 11px;background:#fff;color:var(--text);width:100%}textarea{resize:vertical}
.wide-label{margin-top:16px}.form-row{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px;margin-bottom:18px}.form-row.short{grid-template-columns:2fr 1fr auto}
.toolbar{display:flex;gap:10px;margin-bottom:12px;flex-wrap:wrap}.field-inline{max-width:290px}
.table-wrap{overflow:auto}.data-table{width:100%;border-collapse:collapse}.data-table th,.data-table td{padding:11px;border-bottom:1px solid var(--line);text-align:right;vertical-align:middle}.data-table th{font-size:12px;color:var(--muted);background:#fafbfc}
.badge{display:inline-flex;padding:5px 9px;border-radius:999px;background:#eef2f7;font-size:12px;white-space:nowrap}.badge.active,.badge.paid,.badge.open{background:#eaf7ee;color:#166534}.badge.paused,.badge.partial,.badge.planning{background:#fff5dc;color:#92400e}.badge.closed,.badge.archived,.badge.completed{background:#f0f1f3;color:#475467}
.item-entry{display:grid;grid-template-columns:1.2fr 2fr .6fr .8fr auto;gap:8px;align-items:end}.totals{margin-top:18px;margin-right:auto;max-width:430px}.totals>div{display:flex;justify-content:space-between;align-items:center;padding:8px 0;border-bottom:1px dashed var(--line)}.totals .grand{font-size:18px;border-bottom:1px solid var(--line)}.totals input{max-width:160px}
.editor-grid{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(420px,.9fr);gap:18px;align-items:start}.preview-panel{position:sticky;top:92px}.preview-actions{justify-content:flex-end;margin-bottom:12px}
.invoice-paper{background:#fff;border:1px solid #d9dee7;min-height:720px;padding:34px;box-shadow:0 8px 30px rgba(30,42,60,.06)}.inv-head{display:flex;justify-content:space-between;gap:20px;border-bottom:2px solid var(--primary);padding-bottom:18px;margin-bottom:20px}.inv-logo{max-width:120px;max-height:70px;object-fit:contain}.inv-company h3{margin:0 0 7px;font-size:20px}.inv-company p,.inv-meta p,.inv-customer p{margin:3px 0;color:#495467;font-size:12px}.inv-title{text-align:left}.inv-title h2{margin:0 0 6px;color:var(--primary)}.inv-info{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:18px}.inv-box{border:1px solid var(--line);border-radius:8px;padding:12px}.inv-box h4{margin:0 0 8px;font-size:13px}.inv-table{width:100%;border-collapse:collapse;margin:16px 0}.inv-table th,.inv-table td{padding:9px;border-bottom:1px solid #dde2ea;text-align:right;font-size:12px}.inv-table th{background:#f4f7f9}.inv-total{width:48%;margin-right:auto}.inv-total div{display:flex;justify-content:space-between;padding:6px 0}.inv-total .final{font-size:16px;font-weight:bold;border-top:2px solid var(--primary);margin-top:5px;padding-top:9px}.inv-footer{margin-top:28px;border-top:1px solid var(--line);padding-top:12px;color:#596273;font-size:11px}
.project-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}.project-card{background:#fff;border:1px solid var(--line);border-radius:15px;padding:17px;display:flex;flex-direction:column;gap:12px}.project-card:hover{box-shadow:0 10px 30px rgba(23,63,99,.08);border-color:#c9d7e4}.project-card-head{display:flex;justify-content:space-between;gap:12px}.project-card h3{margin:0;font-size:18px}.project-code{color:var(--muted);font-size:12px}.project-card-stats{display:grid;grid-template-columns:repeat(2,1fr);gap:8px}.mini-stat{background:#f8fafc;border-radius:9px;padding:9px}.mini-stat span{font-size:11px;color:var(--muted);display:block}.mini-stat strong{font-size:14px}
.project-year-bar{display:flex;align-items:center;gap:12px;flex-wrap:wrap}.project-year-bar>div{margin-left:auto;display:flex;flex-direction:column}.project-year-bar small{color:var(--muted);margin-top:4px}.project-year-bar select{width:auto;min-width:130px}
.detail-tabs{max-width:620px;margin-bottom:15px}.project-tab{display:none}.project-tab.active{display:block}
.info-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}.info-cell{border:1px solid var(--line);border-radius:10px;padding:12px}.info-cell span{display:block;font-size:11px;color:var(--muted);margin-bottom:5px}
.file-upload-row{display:grid;grid-template-columns:2fr 1fr auto;gap:9px;align-items:end}.file-row{display:grid;grid-template-columns:2fr .8fr .8fr auto;gap:9px;padding:11px 0;border-bottom:1px solid var(--line);align-items:center}
.invite-box{display:grid;grid-template-columns:1fr 180px auto;gap:10px;align-items:end}.invite-box>div{display:flex;flex-direction:column}.invite-box small{color:var(--muted);margin-top:4px}.invite-code{background:#eef5f6;border:1px dashed var(--primary2);border-radius:10px;padding:12px;margin-top:12px;font-size:16px;font-weight:bold;display:flex;align-items:center;justify-content:space-between;gap:10px}.logo-uploader{display:grid;grid-template-columns:180px 1fr;gap:14px;align-items:center;border:1px dashed #c7d3e1;border-radius:12px;padding:14px;background:#f8fafc}.logo-preview-wrap{display:grid;place-items:center;height:120px;border:1px solid var(--line);border-radius:10px;background:#fff;padding:10px}.logo-preview{max-width:100%;max-height:100%;object-fit:contain}.logo-upload-controls small{color:var(--muted);line-height:1.7}.logo-upload-controls input{margin-bottom:8px}
.tax-box{display:grid;grid-template-columns:2fr 1fr 1fr;gap:14px;padding:15px;background:#f7f9fc;border:1px solid var(--line);border-radius:10px;margin:18px 0}.switch-line{flex-direction:row;align-items:center}.switch-line input{width:auto}.switch-line span{display:flex;flex-direction:column;gap:4px}.switch-line small{color:var(--muted)}
.note{padding:12px 14px;border-radius:9px;margin:14px 0;font-size:13px;line-height:1.7}.warning{background:#fff8e6;color:#6b4b00;border:1px solid #f2db9f}.toast{position:fixed;left:24px;bottom:24px;background:#172033;color:#fff;padding:11px 16px;border-radius:10px;opacity:0;transform:translateY(10px);pointer-events:none;transition:.2s;z-index:100}.toast.show{opacity:1;transform:translateY(0)}.empty{padding:24px;text-align:center;color:var(--muted)}
.performance-row{display:grid;grid-template-columns:2fr repeat(4,1fr);gap:8px;padding:10px;border-bottom:1px solid var(--line);align-items:center}.performance-row.header{font-size:12px;color:var(--muted);background:#fafbfc}.app-footer{height:32px;display:flex;align-items:center;justify-content:center;border-top:1px solid var(--line);background:#fff;color:var(--muted);font-size:11px;letter-spacing:.1px;padding:0 12px}
@media(max-width:1200px){.project-grid{grid-template-columns:repeat(2,1fr)}.editor-grid{grid-template-columns:1fr}.preview-panel{position:static}}
@media(max-width:1000px){.cards{grid-template-columns:repeat(2,1fr)}.form-row{grid-template-columns:repeat(2,1fr)}.top-context{gap:5px}.context-caption{display:none}.current-org-name{max-width:190px}.context-select{min-width:135px}.year-select{min-width:90px}}
@media(max-width:760px){.layout{grid-template-columns:1fr}.sidebar{display:flex;overflow:auto;border-left:0;border-bottom:1px solid var(--line);padding:8px;position:sticky;top:86px;z-index:15;height:auto}.nav{min-width:max-content;text-align:center;margin:0 3px}.content{padding:14px}.cards,.cards.accounting-card,.project-grid{grid-template-columns:1fr}.form-grid,.form-row,.form-row.short,.tax-box,.invite-box,.file-upload-row{grid-template-columns:1fr}.item-entry{grid-template-columns:1fr 1fr}.item-entry select,.item-entry #itemDesc{grid-column:1/-1}.page-head{flex-direction:column}.topbar{padding:8px 12px}.userbox #userLabel,.userbox #roleLabel{display:none}.brand h1{font-size:15px}.invoice-paper{padding:18px;min-height:auto}.inv-head{flex-direction:column}.inv-title{text-align:right}.inv-info{grid-template-columns:1fr}.inv-total{width:100%}.project-year-bar>div{width:100%;margin:0}.info-grid{grid-template-columns:1fr}.performance-row{grid-template-columns:1.7fr 1fr 1fr}.performance-row>*:nth-child(4),.performance-row>*:nth-child(5){display:none}.file-row{grid-template-columns:1fr}}
@media print{
@page{size:A4 portrait;margin:6mm}
html,body{height:auto!important;min-height:0!important;margin:0!important;padding:0!important;overflow:visible!important;background:#fff!important}
body{padding-bottom:0!important}
#authScreen,#joinScreen,body>.app-footer,#toast{display:none!important}
#appShell{display:block!important;height:auto!important;min-height:0!important}
#appShell>.topbar{display:none!important}
#appShell>.layout{display:block!important;height:auto!important;min-height:0!important}
#appShell .sidebar{display:none!important}
#appShell .content{display:block!important;padding:0!important;margin:0!important;height:auto!important;min-height:0!important}
#appShell .view{display:none!important}
#appShell #view-new-document{display:block!important;margin:0!important;padding:0!important}
#view-new-document>.page-head{display:none!important}
#view-new-document .editor-grid{display:block!important;margin:0!important;padding:0!important}
#view-new-document .editor-grid>.panel:first-child{display:none!important}
#view-new-document .preview-panel{display:block!important;position:static!important;margin:0!important;padding:0!important;border:0!important;box-shadow:none!important;background:#fff!important}
#view-new-document .preview-actions{display:none!important}
#invoicePreview{display:block!important;position:static!important;width:auto!important;min-height:0!important;margin:0!important;padding:6mm 8mm!important;border:0!important;box-shadow:none!important;background:#fff!important;page-break-after:avoid!important;break-after:avoid-page!important}
#invoicePreview .inv-head{padding-bottom:9px!important;margin-bottom:10px!important;gap:12px!important;break-inside:avoid!important}
#invoicePreview .inv-logo{max-width:90px!important;max-height:52px!important}
#invoicePreview .inv-company h3{font-size:17px!important;margin-bottom:3px!important}
#invoicePreview .inv-company p,#invoicePreview .inv-meta p,#invoicePreview .inv-customer p{font-size:9.5px!important;margin:1.5px 0!important;line-height:1.3!important}
#invoicePreview .inv-title h2{font-size:20px!important;margin-bottom:3px!important;line-height:1.2!important}
#invoicePreview .inv-title p{margin:2px 0!important;font-size:10.5px!important}
#invoicePreview .inv-info{gap:9px!important;margin-bottom:8px!important;break-inside:avoid!important}
#invoicePreview .inv-box{padding:7px 9px!important;break-inside:avoid!important;page-break-inside:avoid!important}
#invoicePreview .inv-box h4{margin-bottom:4px!important;font-size:11.5px!important}
#invoicePreview .inv-table{margin:8px 0!important;break-inside:avoid!important;page-break-inside:avoid!important}
#invoicePreview .inv-table th,#invoicePreview .inv-table td{padding:5px 6px!important;font-size:10px!important}
#invoicePreview .inv-total{width:50%!important;break-inside:avoid!important;page-break-inside:avoid!important}
#invoicePreview .inv-total div{padding:3px 0!important;font-size:10.5px!important}
#invoicePreview .inv-total .final{font-size:13.5px!important;padding-top:5px!important;margin-top:2px!important}
#invoicePreview .invoice-compliance{margin-top:8px!important;padding-top:7px!important;gap:8px!important;break-inside:avoid!important;page-break-inside:avoid!important}
#invoicePreview .invoice-qr-box{width:92px!important;flex:0 0 92px!important}
#invoicePreview .invoice-qr{width:84px!important;height:84px!important;padding:2px!important}
#invoicePreview .invoice-qr img,#invoicePreview .invoice-qr canvas{max-width:78px!important;max-height:78px!important}
#invoicePreview .qr-caption{font-size:7px!important;margin-top:1px!important}
#invoicePreview .compliance-note{font-size:8px!important;line-height:1.35!important}
#invoicePreview .vat-pill{font-size:8px!important;padding:2px 5px!important}
}

@media(max-width:760px){.brand-logo-only{min-width:145px}.brand-logo-only .brand-mark{width:145px;height:52px}.topbar{min-height:76px}.sidebar{top:76px}.layout{min-height:calc(100vh - 108px)}.app-footer{height:32px}}

/* WIZAN approved brand lockup */
.approved-auth-logo{width:min(390px,92%);height:120px;border:0!important;border-radius:0!important;background:transparent!important;padding:0!important;margin:0 auto 8px!important;overflow:visible!important}
.approved-auth-logo .auth-brand-logo{width:100%;height:100%;max-width:none;max-height:none;object-fit:contain}
.auth-product-note{text-align:center;color:var(--muted);font-size:13px;margin:0 0 16px}
.brand-logo-only{min-width:270px!important}.brand-logo-only .brand-mark{width:270px!important;height:74px!important;border:0!important;border-radius:0!important;padding:0!important;background:transparent!important;overflow:visible!important}.brand-logo-only .brand-icon{width:100%!important;height:100%!important;object-fit:contain!important;object-position:right center!important}
.logo-placeholder{color:var(--muted);font-size:12px;text-align:center}.logo-preview[hidden]{display:none!important}
/* Keep ownership visible at all times; reserve space so it never covers content */
body{padding-bottom:34px}.app-footer{position:fixed!important;bottom:0!important;left:0!important;right:225px!important;height:34px!important;z-index:40!important;display:flex!important;align-items:center!important;justify-content:center!important;border-top:1px solid var(--line)!important;background:rgba(255,255,255,.97)!important;color:var(--muted)!important;font-size:11px!important;box-shadow:0 -2px 8px rgba(23,63,99,.04)}
@media(max-width:760px){.approved-auth-logo{height:100px;width:min(330px,94%)}.brand-logo-only{min-width:190px!important}.brand-logo-only .brand-mark{width:190px!important;height:62px!important}.app-footer{right:0!important}.topbar{min-height:82px!important}.sidebar{top:82px!important}}

.app-footer a{color:inherit;text-decoration:none}.app-footer a:hover{text-decoration:underline}

.draft-status{display:block;min-height:18px;margin-top:6px;color:var(--primary2);font-size:12px;opacity:0;transition:.2s}.draft-status.visible{opacity:1}

/* v1.3.6 ZATCA / QR */
.invoice-compliance{display:flex;gap:14px;align-items:flex-start;justify-content:space-between;margin-top:22px;border-top:1px solid var(--line);padding-top:14px}.invoice-qr-box{width:132px;flex:0 0 132px;text-align:center}.invoice-qr{width:118px;height:118px;margin:auto;display:grid;place-items:center;background:#fff;padding:4px;border:1px solid var(--line);border-radius:7px}.invoice-qr img,.invoice-qr canvas{max-width:110px!important;max-height:110px!important}.qr-caption{font-size:10px;color:var(--muted);margin-top:5px}.compliance-note{font-size:10px;color:var(--muted);line-height:1.7;flex:1}.vat-pill{display:inline-flex;padding:4px 7px;border-radius:999px;background:#eaf7ee;color:#166534;font-size:10px}.tax-box{grid-template-columns:repeat(3,minmax(0,1fr))}.form-row{grid-template-columns:repeat(6,minmax(0,1fr))}@media(max-width:760px){.tax-box,.form-row{grid-template-columns:1fr}.invoice-compliance{flex-direction:column}.invoice-qr-box{width:100%}}

#docFiscalYear{background:#fff;font-weight:700;color:var(--primary)}

@media(max-width:760px){.top-context{position:absolute;top:82px;right:10px;left:10px;justify-content:center;background:#fff;border-bottom:1px solid var(--line);padding:6px;z-index:14}.current-org-name{max-width:210px;min-height:34px;padding:6px 9px}.context-select{min-height:34px;padding:6px 8px}.layout{padding-top:48px}.sidebar{top:130px!important}}
