:root{--accent:#24346b;--bg:#f4f6fb;--card:#fff;--text:#172038;--muted:#6b7280;--line:#e5e7eb;--danger:#b42318;--ok:#177245;--warn:#b7791f;--shadow:0 8px 24px rgba(20,30,60,.08)}*{box-sizing:border-box}body{margin:0;font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;background:var(--bg);color:var(--text)}a{color:inherit;text-decoration:none}.app{display:grid;grid-template-columns:250px 1fr;min-height:100vh}.sidebar{background:#16234f;color:#fff;padding:22px 16px;position:sticky;top:0;height:100vh}.brand{font-weight:800;font-size:20px;line-height:1.1;margin-bottom:24px}.brand small{display:block;font-size:12px;font-weight:500;opacity:.75;margin-top:4px}.nav a{display:block;padding:11px 13px;border-radius:10px;margin:3px 0;color:#eef2ff}.nav a:hover,.nav a.active{background:rgba(255,255,255,.13)}.sidebar-bottom{position:absolute;bottom:18px;left:16px;right:16px;font-size:12px;opacity:.8}.main{padding:26px 30px;min-width:0}.topbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:22px}.topbar h1{margin:0;font-size:28px}.userbox{font-size:13px;color:var(--muted)}.card{background:var(--card);border:1px solid var(--line);border-radius:16px;box-shadow:var(--shadow);padding:18px}.grid{display:grid;gap:16px}.grid.cols4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid.cols2{grid-template-columns:repeat(2,minmax(0,1fr))}.metric b{font-size:26px;display:block;margin-top:6px}.metric span{color:var(--muted);font-size:13px}.btn{display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:10px;padding:10px 14px;font-weight:700;cursor:pointer;background:#eef1f6;color:#1f2937}.btn.primary{background:var(--accent);color:#fff}.btn.danger{background:#fff0f0;color:var(--danger)}.btn.small{padding:7px 10px;font-size:12px}.actions{display:flex;gap:8px;flex-wrap:wrap}.tablewrap{overflow:auto;background:#fff;border:1px solid var(--line);border-radius:14px}.table{width:100%;border-collapse:collapse;min-width:760px}.table th,.table td{padding:11px 12px;border-bottom:1px solid var(--line);text-align:left;vertical-align:top}.table th{background:#f8fafc;font-size:12px;text-transform:uppercase;letter-spacing:.03em;color:#667085}.table tr:last-child td{border-bottom:0}.muted{color:var(--muted)}.tag{display:inline-block;padding:4px 8px;border-radius:999px;font-size:12px;background:#eef2ff}.tag.ok{background:#e9f7ef;color:var(--ok)}.tag.warn{background:#fff7e6;color:var(--warn)}.tag.danger{background:#fff0f0;color:var(--danger)}.formgrid,.grid-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.formgrid .wide,.grid-form .wide{grid-column:1/-1}label{display:flex;flex-direction:column;gap:6px;font-size:13px;font-weight:700}input,select,textarea{width:100%;border:1px solid #cfd5e1;border-radius:9px;padding:10px 11px;background:#fff;font:inherit;color:var(--text)}textarea{min-height:90px;resize:vertical}input:focus,select:focus,textarea:focus{outline:2px solid color-mix(in srgb,var(--accent) 24%,transparent);border-color:var(--accent)}.alert{padding:11px 13px;border-radius:10px;margin:12px 0;white-space:pre-line}.alert.success{background:#eaf8f0;color:var(--ok)}.alert.error{background:#fff0f0;color:var(--danger)}.alert.info{background:#edf4ff;color:#234b8a}.toolbar{display:flex;justify-content:space-between;align-items:center;gap:12px;margin:14px 0}.search{max-width:360px}.setup-body,.login-body{display:grid;place-items:center;min-height:100vh;padding:24px}.setup-card,.login-card{width:min(760px,100%);background:#fff;border:1px solid var(--line);border-radius:20px;padding:28px;box-shadow:var(--shadow)}.login-card{width:min(430px,100%)}.brand-mark{width:46px;height:46px;border-radius:13px;display:grid;place-items:center;background:#16234f;color:#fff;font-size:24px;font-weight:800}.hint{font-size:12px;color:var(--muted);font-weight:400}.invoice-editor{display:grid;grid-template-columns:minmax(0,1fr) 330px;gap:18px}.sticky-card{position:sticky;top:18px}.invoice-items{display:flex;flex-direction:column;gap:10px}.item-row{border:1px solid var(--line);border-radius:12px;padding:12px;background:#fff;display:grid;grid-template-columns:2.2fr .7fr .9fr 1.1fr .9fr 36px;gap:8px;align-items:end}.item-row .desc{grid-column:1/-1}.item-row label{font-size:11px}.totals{display:grid;grid-template-columns:1fr auto;gap:8px;font-size:14px}.totals .grand{font-size:19px;font-weight:800;border-top:2px solid var(--text);padding-top:10px;margin-top:4px}.stock-low{background:#fff8e8}.invoice-paper{background:#fff;max-width:900px;margin:0 auto;border:1px solid var(--line);box-shadow:var(--shadow);padding:38px 46px}.invoice-head{display:flex;justify-content:space-between;gap:30px}.invoice-logo{max-height:70px;max-width:220px}.invoice-title{text-align:right}.invoice-title h2{font-size:30px;margin:0}.invoice-address{margin:34px 0 26px}.invoice-meta{display:grid;grid-template-columns:1fr 1fr;gap:20px}.invoice-lines{width:100%;border-collapse:collapse;margin-top:25px}.invoice-lines th,.invoice-lines td{padding:10px;border-bottom:1px solid #ddd;text-align:left}.invoice-lines th:last-child,.invoice-lines td:last-child{text-align:right}.invoice-sums{margin-left:auto;margin-top:20px;width:min(420px,100%)}.invoice-sums div{display:grid;grid-template-columns:1fr auto;padding:5px 0}.invoice-sums .grand{font-size:20px;font-weight:800;border-top:2px solid #222;margin-top:6px;padding-top:10px}.footer{margin-top:36px;padding-top:14px;border-top:1px solid #ddd;font-size:11px;color:#555}.section-title{display:flex;align-items:center;justify-content:space-between;gap:12px}.logo-preview{max-height:90px;max-width:240px;border:1px solid var(--line);padding:6px;border-radius:8px}.bar{height:9px;background:#edf0f5;border-radius:99px;overflow:hidden}.bar i{display:block;height:100%;background:var(--accent)}@media(max-width:1050px){.grid.cols4{grid-template-columns:repeat(2,1fr)}.invoice-editor{grid-template-columns:1fr}.sticky-card{position:static}}@media(max-width:760px){.app{grid-template-columns:1fr}.sidebar{position:static;height:auto}.sidebar-bottom{display:none}.nav{display:flex;overflow:auto;gap:4px}.nav a{white-space:nowrap}.main{padding:18px}.grid.cols4,.grid.cols2,.formgrid,.grid-form{grid-template-columns:1fr}.invoice-items .item-row{grid-template-columns:1fr 1fr}.item-row .desc{grid-column:1/-1}.item-row>*:first-child{grid-column:1/-1}.topbar{align-items:flex-start;gap:10px}.topbar h1{font-size:23px}}@media print{body{background:#fff}.app>.sidebar,.topbar,.no-print,.alert{display:none!important}.app{display:block}.main{padding:0}.invoice-paper{box-shadow:none;border:0;max-width:none;padding:0}.invoice-paper .footer{position:relative}.card{box-shadow:none;border:0}.print-hide{display:none!important}@page{size:A4;margin:14mm}}

.invoice-add-bottom{display:flex;justify-content:flex-start;margin-top:14px;padding-top:12px;border-top:1px solid var(--line)}
.target-ok{margin-top:10px;font-weight:600}.target-error{margin-top:10px;font-weight:700}.invoice-paper{display:flex;flex-direction:column;min-height:1120px}.invoice-paper>.footer{margin-top:auto}.invoice-paper>.footer b{font-weight:700}@media print{.invoice-paper{min-height:269mm;display:flex;flex-direction:column}.invoice-paper>.footer{margin-top:auto;page-break-inside:avoid}}

/* ===== v2.0 Design & usability ===== */
:root{--sidebar:#16234f;--invoice-font-size:12px;--invoice-logo-width:220px}
.sidebar{background:var(--sidebar)}
.btn,.nav a,.table a,.sidebar-bottom a{transition:background-color .16s ease,color .16s ease,transform .16s ease,box-shadow .16s ease,filter .16s ease}
.btn:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 7px 16px rgba(22,32,56,.13);filter:brightness(.96)}
.btn.primary:hover:not(:disabled){filter:brightness(1.13);box-shadow:0 8px 20px color-mix(in srgb,var(--accent) 28%,transparent)}
.btn.danger:hover:not(:disabled){background:#ffe0e0;color:#8f1710;filter:none}
.btn.preview-btn:hover:not(:disabled){background:#dfe6f3;color:#111827;filter:none}
.btn:active:not(:disabled){transform:translateY(0);box-shadow:none}
.btn:focus-visible,.nav a:focus-visible{outline:3px solid color-mix(in srgb,var(--accent) 35%,transparent);outline-offset:2px}
.btn:disabled{opacity:.5;cursor:not-allowed}
.nav a:hover{background:rgba(255,255,255,.21);transform:translateX(2px)}
.nav a.active{background:rgba(255,255,255,.16);box-shadow:inset 3px 0 0 rgba(255,255,255,.75)}
.sidebar-bottom a:hover{color:#fff;text-decoration:underline}
.table tbody tr{transition:background-color .15s ease}.table tbody tr:hover{background:#fafbfe}
.actions.stack{display:grid;grid-template-columns:1fr}

.settings-sections{display:grid;gap:18px;max-width:1120px}.settings-sections h2{margin-top:0}.settings-savebar{position:sticky;bottom:16px;display:flex;justify-content:flex-end;z-index:5;padding:10px 0}.settings-savebar .btn{box-shadow:0 8px 24px rgba(20,30,60,.18)}

.invoice-texts{display:grid;gap:10px}.invoice-text-row{display:grid;grid-template-columns:1fr 2.2fr 1.15fr 38px;gap:9px;align-items:end;border:1px solid var(--line);border-radius:12px;padding:12px;background:#fbfcff}.invoice-text-row label{font-size:11px}.invoice-text-row .text-body textarea{min-height:64px}

.invoice-paper{font-size:var(--invoice-font-size);line-height:1.45}.invoice-logo{max-width:var(--invoice-logo-width);height:auto}.invoice-number{font-size:16px;margin:2px 0 10px}.invoice-date-row{display:grid;grid-template-columns:auto auto;gap:14px;justify-content:end;font-size:11px;margin-top:3px}.invoice-date-row span{color:#667085}.invoice-standard-text,.invoice-free-text{margin:14px 0;white-space:normal}.invoice-free-text b{display:block;margin-bottom:2px}.invoice-standard-text.below-total{margin-top:18px}.invoice-note{margin:12px 0}.invoice-actionbar{margin-bottom:14px}.cancellation-card{max-width:900px;margin:18px auto 0}.cancellation-card form{display:grid;gap:12px}.checkline{margin:2px 0}

.invoice-paper.layout-modern .invoice-lines th{background:#f4f6fb;border-bottom:2px solid color-mix(in srgb,var(--accent) 35%,#d9deea)}.invoice-paper.layout-modern .invoice-title h2{color:var(--accent)}
.invoice-paper.layout-classic{border-radius:0}.invoice-paper.layout-classic .invoice-title h2{font-family:Georgia,serif;color:#111}.invoice-paper.layout-classic .invoice-lines th{background:#fff;border-top:1px solid #333;border-bottom:1px solid #333}.invoice-paper.layout-classic .invoice-lines td{border-bottom:1px solid #bbb}
.invoice-paper.layout-compact{padding:28px 38px;line-height:1.3}.invoice-paper.layout-compact .invoice-address{margin:24px 0 18px}.invoice-paper.layout-compact .invoice-lines{margin-top:16px}.invoice-paper.layout-compact .invoice-lines th,.invoice-paper.layout-compact .invoice-lines td{padding:7px 8px}.invoice-paper.layout-compact .invoice-sums{margin-top:14px}.invoice-paper.layout-compact .invoice-standard-text,.invoice-paper.layout-compact .invoice-free-text{margin:9px 0}

.modal{display:none;position:fixed;inset:0;z-index:1000}.modal.open{display:block}.modal-backdrop{position:absolute;inset:0;background:rgba(13,20,38,.72);backdrop-filter:blur(2px)}.modal-dialog{position:relative;z-index:1;width:min(1040px,calc(100% - 40px));height:calc(100vh - 32px);margin:16px auto;background:#eef1f6;border-radius:16px;overflow:auto;box-shadow:0 30px 70px rgba(0,0,0,.28)}.modal-toolbar{position:sticky;top:0;z-index:4;display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#fff;border-bottom:1px solid var(--line)}#invoice-preview-content{padding:22px}.preview-paper{min-height:1120px}.modal-open{overflow:hidden}

@media(max-width:900px){.invoice-text-row{grid-template-columns:1fr 1fr}.invoice-text-row .text-body{grid-column:1/-1}.invoice-text-row .remove-text{align-self:end}.modal-dialog{width:calc(100% - 14px);margin:7px;height:calc(100vh - 14px)}#invoice-preview-content{padding:8px}.preview-paper{padding:24px 20px;min-height:auto}}

@media print{
  .invoice-paper{font-size:var(--invoice-font-size)}
  body.modal-open #invoice-form,body.modal-open .invoice-actionbar,body.modal-open .cancellation-card{display:none!important}
  body.modal-open .modal{display:block!important;position:static}
  body.modal-open .modal-backdrop,body.modal-open .modal-toolbar{display:none!important}
  body.modal-open .modal-dialog{width:auto;height:auto;margin:0;background:#fff;box-shadow:none;overflow:visible}
  body.modal-open #invoice-preview-content{padding:0}
  body.modal-open .preview-paper{display:flex!important}
}

/* v2.1 – separates invoice design from app design and adds payment details */
.invoice-paper{--invoice-accent:#24346b;--invoice-line:#d9deea;--invoice-header-bg:#f4f6fb}
.invoice-paper .invoice-title h2{color:var(--invoice-accent)}
.invoice-paper .invoice-lines th,.invoice-paper .invoice-lines td{border-color:var(--invoice-line)}
.invoice-paper.layout-modern .invoice-lines th{background:var(--invoice-header-bg);border-bottom:2px solid var(--invoice-line)}
.invoice-paper.layout-modern .invoice-title h2{color:var(--invoice-accent)}
.invoice-paper.layout-elegant{border-top:6px solid var(--invoice-accent);padding-top:32px}
.invoice-paper.layout-elegant .invoice-title h2{font-family:Georgia,serif;font-weight:500;letter-spacing:.02em}
.invoice-paper.layout-elegant .invoice-lines th{background:transparent;border-top:1px solid var(--invoice-accent);border-bottom:1px solid var(--invoice-accent)}
.invoice-paper.layout-elegant .invoice-sums .grand{border-top-color:var(--invoice-accent)}
.invoice-paper.layout-minimal{border:0;box-shadow:none}
.invoice-paper.layout-minimal .invoice-title h2{color:#111;font-weight:600}
.invoice-paper.layout-minimal .invoice-lines th{background:transparent;border-bottom:1px solid var(--invoice-line);text-transform:none}
.invoice-paper.layout-minimal .invoice-lines td{border-bottom:1px solid var(--invoice-line)}
.invoice-paper.layout-classic .invoice-title h2{color:#111}
.invoice-paper.layout-compact .invoice-title h2{color:var(--invoice-accent)}
.invoice-paper.total-box .invoice-sums{border:1px solid var(--invoice-line);border-radius:10px;padding:12px 14px}
.invoice-paper.total-box .invoice-sums .grand{border-top:1px solid var(--invoice-line)}
.invoice-paper.total-accent .invoice-sums{border:1px solid var(--invoice-accent);border-radius:10px;padding:12px 14px}
.invoice-paper.total-accent .invoice-sums .grand{background:var(--invoice-accent);color:#fff;margin:8px -14px -12px;padding:11px 14px;border-top:0;border-radius:0 0 9px 9px}
.invoice-paper.footer-plain>.footer{border-top:0}
.invoice-paper.footer-boxed>.footer{border:1px solid var(--invoice-line);border-radius:8px;padding:10px 12px}
.invoice-paper.footer-line>.footer{border-top:1px solid var(--invoice-line)}
.invoice-payment{margin:14px 0 8px;display:grid;gap:5px;max-width:620px}
.invoice-payment>div{display:grid;grid-template-columns:145px 1fr;gap:12px;align-items:start}
.invoice-payment span{color:#667085;font-size:.92em}
.invoice-payment b{font-weight:600}
@media(max-width:600px){.invoice-payment>div{grid-template-columns:1fr;gap:2px}}

/* v2.4: getrennte Schriftgrößen für alle Rechnungsbereiche */
.invoice-paper .invoice-title h2{font-size:var(--invoice-title-size,30px)}
.invoice-paper .invoice-number{font-size:var(--invoice-number-size,16px)}
.invoice-paper .invoice-date-row{font-size:var(--invoice-date-size,11px)}
.invoice-paper .invoice-address{font-size:var(--invoice-address-size,12px)}
.invoice-paper .invoice-lines{font-size:var(--invoice-table-size,12px)}
.invoice-paper .invoice-lines small{font-size:var(--invoice-description-size,10px)}
.invoice-paper .invoice-sums{font-size:var(--invoice-totals-size,12px)}
.invoice-paper .invoice-sums .grand{font-size:var(--invoice-grand-size,20px)}
.invoice-paper .invoice-standard-text,.invoice-paper .invoice-free-text,.invoice-paper .invoice-note{font-size:var(--invoice-text-size,12px)}
.invoice-paper .invoice-payment{font-size:var(--invoice-payment-size,12px)}
.invoice-paper .footer{font-size:var(--invoice-footer-size,11px)}


/* v2.5: mobile-first polish + SEPA payment QR */
.invoice-payment-wrap{display:flex;align-items:flex-start;justify-content:space-between;gap:22px;margin-top:18px;break-inside:avoid;page-break-inside:avoid}
.invoice-payment-wrap .invoice-payment{flex:1;min-width:0;margin-top:0}
.payment-qr{width:132px;flex:0 0 132px;text-align:center;padding:7px;border:1px solid var(--invoice-line,#d9deea);border-radius:9px;background:#fff;color:#222;font-size:8.5px;line-height:1.2}
.payment-qr-code{width:104px;height:104px;margin:0 auto 5px;display:flex;align-items:center;justify-content:center;overflow:hidden}
.payment-qr-code canvas{display:block!important;width:104px!important;height:104px!important;max-width:100%}.payment-qr-code img{display:none!important}.payment-qr-code .qr-error{font-size:8px;line-height:1.15;color:#777}
.payment-qr small{font-size:9px}

@media(max-width:900px){
  body{overflow-x:hidden}
  .app{grid-template-columns:1fr}
  .sidebar{position:relative;top:auto;height:auto;padding:14px 12px 10px;z-index:10}
  .brand{font-size:18px;margin:0 0 12px;line-height:1.05}
  .brand small{font-size:11px;margin-top:3px}
  .nav{display:flex;gap:6px;overflow-x:auto;overscroll-behavior-x:contain;padding-bottom:4px;scrollbar-width:thin;-webkit-overflow-scrolling:touch}
  .nav a{flex:0 0 auto;white-space:nowrap;padding:9px 11px;border:1px solid rgba(255,255,255,.08)}
  .sidebar-bottom{display:none}
  .main{padding:16px;max-width:100vw;overflow:hidden}
  .topbar{margin-bottom:16px;gap:12px;flex-wrap:wrap}
  .topbar h1{font-size:24px;line-height:1.15}
  .grid.cols4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .invoice-editor{grid-template-columns:1fr;gap:14px}
  .sticky-card{position:static}
  .toolbar{align-items:stretch;flex-wrap:wrap}
  .toolbar>.actions,.toolbar>form{max-width:100%}
  .search{max-width:none;width:100%}
  .tablewrap{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
  .table{min-width:680px}
  .modal-dialog{width:100%;height:100dvh;margin:0;border-radius:0}
  .modal-toolbar{padding:10px 12px;gap:8px;flex-wrap:wrap}
  .modal-toolbar .actions{margin-left:auto}
  #invoice-preview-content{padding:10px;overflow-x:auto}
  .preview-paper{min-width:680px;margin:0 auto}
}

@media(max-width:600px){
  .main{padding:12px}
  .card{padding:14px;border-radius:13px}
  .topbar h1{font-size:21px}
  .grid.cols4,.grid.cols2,.formgrid,.grid-form{grid-template-columns:1fr}
  .metric b{font-size:23px}
  .actions{width:100%}
  .actions .btn,.actions a.btn{flex:1 1 auto;min-height:42px}
  .toolbar{flex-direction:column;align-items:stretch}
  .toolbar input,.toolbar select,.toolbar .btn{min-height:44px}
  input,select,textarea{font-size:16px;min-height:44px} /* prevents iOS zoom */
  textarea{min-height:96px}
  .invoice-items .item-row{grid-template-columns:1fr;padding:12px;gap:10px}
  .item-row>*:first-child,.item-row .desc{grid-column:1}
  .item-row .btn{width:100%;min-height:40px}
  .invoice-add-bottom .btn{width:100%}
  .invoice-text-row{grid-template-columns:1fr;gap:10px}
  .invoice-text-row .remove-text{width:100%;min-height:40px}
  .settings-savebar{position:sticky;bottom:8px;z-index:12}
  .settings-savebar .btn{width:100%;min-height:48px;box-shadow:0 8px 26px rgba(0,0,0,.16)}
  .invoice-actionbar{display:grid;grid-template-columns:1fr 1fr;gap:8px}
  .invoice-actionbar .btn{width:100%;min-height:42px}
  .invoice-paper:not(.preview-paper){padding:22px 18px;min-height:auto;width:100%;box-shadow:none}
  .invoice-paper:not(.preview-paper) .invoice-head{gap:14px;align-items:flex-start}
  .invoice-paper:not(.preview-paper) .invoice-logo{max-width:min(var(--invoice-logo-width),46vw)}
  .invoice-paper:not(.preview-paper) .invoice-title h2{font-size:min(var(--invoice-title-size),24px)}
  .invoice-paper:not(.preview-paper) .invoice-lines{display:block;overflow-x:auto;-webkit-overflow-scrolling:touch}
  .invoice-paper:not(.preview-paper) .invoice-lines thead,.invoice-paper:not(.preview-paper) .invoice-lines tbody{display:table;width:620px;table-layout:auto}
  .invoice-paper:not(.preview-paper) .invoice-sums{width:100%}
  .invoice-payment-wrap{flex-direction:column;gap:12px}
  .payment-qr{align-self:center}
  .cancellation-card{margin-top:12px}
  .login-body,.setup-body{padding:12px}
  .login-card,.setup-card{padding:20px 16px;border-radius:16px}
}

@media(max-width:420px){
  .grid.cols4{grid-template-columns:1fr}
  .invoice-actionbar{grid-template-columns:1fr}
  .topbar{align-items:flex-start}
  .userbox{width:100%}
  .btn{padding:10px 11px}
}

@media print{
  .payment-qr{border:1px solid #bbb!important;break-inside:avoid!important;page-break-inside:avoid!important}
  .invoice-payment-wrap{display:flex!important;flex-direction:row!important}
}


/* v2.5.1 – QR/preview/print hotfix */
@media print{
  /* Avoid browser rounding that could push an otherwise one-page invoice onto page 2. */
  .invoice-paper{min-height:263mm!important;height:auto!important;overflow:visible!important}
  .invoice-payment-wrap{margin-top:10px!important;gap:14px!important;break-inside:avoid!important;page-break-inside:avoid!important}
  .invoice-payment{margin:6px 0 4px!important;gap:3px!important}
  .payment-qr{width:118px!important;flex-basis:118px!important;padding:5px!important}
  .payment-qr-code{width:92px!important;height:92px!important;margin-bottom:3px!important}
  .payment-qr-code canvas{width:92px!important;height:92px!important}
  .footer{margin-top:18px!important;padding-top:9px!important}
  .invoice-standard-text.below-total{margin-top:10px!important}
  .invoice-note{margin:8px 0!important}
}

/* v2.5.2 – echte A4-Fusszeile: immer am unteren Seitenrand, nicht im Inhaltsfluss */
.invoice-paper{position:relative}
@media print{
  /* A4 hat bei 14 mm Seitenrand eine nutzbare Hoehe von 269 mm. */
  .invoice-paper{
    position:relative!important;
    min-height:0!important;
    height:269mm!important;
    padding:0 0 29mm 0!important;
    box-sizing:border-box!important;
    overflow:visible!important;
  }
  .invoice-paper>.footer{
    position:absolute!important;
    left:0!important;
    right:0!important;
    bottom:0!important;
    margin:0!important;
    padding-top:7px!important;
    break-inside:avoid!important;
    page-break-inside:avoid!important;
  }
  /* Die Fusszeile soll niemals durch flex-auto nach unten gedrueckt werden. */
  .invoice-paper>.footer{margin-top:0!important}
}

/* Auch in der Rechnungsansicht/Vorschau optisch als echte Fusszeile darstellen. */
@media screen and (min-width:601px){
  .invoice-paper:not(.preview-paper){padding-bottom:92px}
  .invoice-paper:not(.preview-paper)>.footer{position:absolute;left:46px;right:46px;bottom:28px;margin:0}
  .preview-paper{position:relative;padding-bottom:92px}
  .preview-paper>.footer{position:absolute;left:46px;right:46px;bottom:28px;margin:0}
}

/* ===== v2.6 Produktions-Design: vollständige Textfarben + stabile A4-Ausgabe ===== */
.invoice-paper{
  color:var(--invoice-text,#000);
}
.invoice-paper .invoice-title h2{
  color:var(--invoice-heading,#000)!important;
}
.invoice-paper .invoice-date-row span,
.invoice-paper .muted,
.invoice-paper .invoice-payment span,
.invoice-paper .invoice-address small{
  color:var(--invoice-muted,#000)!important;
}
.invoice-paper .invoice-lines th,
.invoice-paper .invoice-lines td,
.invoice-paper .invoice-standard-text,
.invoice-paper .invoice-free-text,
.invoice-paper .invoice-note,
.invoice-paper .invoice-payment,
.payment-qr{
  color:var(--invoice-text,#000);
}
.invoice-paper .invoice-sums .grand{
  color:var(--invoice-total,#000)!important;
}
.invoice-paper.total-accent .invoice-sums .grand{
  color:var(--invoice-total,#000)!important;
}
.invoice-paper>.footer{
  color:var(--invoice-footer,#000)!important;
}

/* Mobile: die App bleibt bedienbar, die Rechnung selbst wird als A4-Vorschau gescrollt. */
@media(max-width:600px){
  .invoice-paper:not(.preview-paper){
    min-width:0;
    overflow:visible;
  }
  .invoice-paper:not(.preview-paper)>.footer{
    position:static!important;
    margin-top:24px!important;
    padding-top:8px!important;
  }
}

/* Druck: Footer ist Bestandteil der A4-Seite und erhält reservierten Platz. */
@media print{
  html,body{width:210mm;min-height:297mm}
  .invoice-paper{
    width:100%!important;
    max-width:none!important;
    height:269mm!important;
    min-height:269mm!important;
    padding:0 0 28mm 0!important;
    margin:0!important;
    position:relative!important;
    box-shadow:none!important;
    border:0!important;
    overflow:hidden!important;
    color:var(--invoice-text,#000)!important;
  }
  .invoice-paper>.footer{
    position:absolute!important;
    left:0!important;
    right:0!important;
    bottom:0!important;
    min-height:22mm;
    margin:0!important;
    padding-top:6px!important;
    background:#fff!important;
  }
  .invoice-payment-wrap{margin-top:8px!important}
}

/* ===== v2.7: echte tiefe Fusszeile + lokaler PDF-Download ===== */
@page{size:A4;margin:14mm 14mm 7mm 14mm}

@media print{
  html,body{width:auto!important;min-height:0!important}
  .invoice-paper{
    width:100%!important;
    height:276mm!important; /* 297 - 14 mm oben - 7 mm unten */
    min-height:276mm!important;
    padding:0 0 27mm 0!important;
    overflow:hidden!important;
  }
  .invoice-paper>.footer{
    left:0!important;
    right:0!important;
    bottom:0!important;
    min-height:0!important;
    padding-top:4px!important;
    margin:0!important;
    line-height:1.22!important;
  }
}

/* In der gespeicherten Ansicht sitzt die Fusszeile ebenfalls sichtbar tiefer. */
@media screen and (min-width:601px){
  .invoice-paper:not(.preview-paper){min-height:1120px;padding-bottom:78px}
  .invoice-paper:not(.preview-paper)>.footer{bottom:12px}
  .preview-paper{min-height:1120px;padding-bottom:78px}
  .preview-paper>.footer{bottom:12px}
}

/* Unsichtbare A4-Kopie fuer den direkten PDF-Download. */
.pdf-export-stage{
  position:fixed;
  left:-12000px;
  top:0;
  width:210mm;
  height:297mm;
  overflow:hidden;
  background:#fff;
  z-index:-9999;
}
.invoice-paper.pdf-export{
  width:210mm!important;
  max-width:none!important;
  height:297mm!important;
  min-height:297mm!important;
  margin:0!important;
  padding:14mm 14mm 29mm 14mm!important;
  border:0!important;
  box-shadow:none!important;
  position:relative!important;
  overflow:hidden!important;
  background:#fff!important;
}
.invoice-paper.pdf-export>.footer{
  position:absolute!important;
  left:14mm!important;
  right:14mm!important;
  bottom:7mm!important;
  margin:0!important;
  padding-top:4px!important;
  min-height:0!important;
  line-height:1.22!important;
  background:#fff!important;
}
.invoice-paper.pdf-export .invoice-payment-wrap{
  margin-top:8px!important;
  break-inside:avoid!important;
  page-break-inside:avoid!important;
}
.invoice-paper.pdf-export .payment-qr{
  width:118px!important;
  flex-basis:118px!important;
  padding:5px!important;
}
.invoice-paper.pdf-export .payment-qr-code,
.invoice-paper.pdf-export .payment-qr-code canvas{
  width:92px!important;
  height:92px!important;
}

/* v2.8 Bestandsjournal */
.stock-summary{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px;padding:10px 0;border-top:1px solid var(--line,#e3e7ef);border-bottom:1px solid var(--line,#e3e7ef)}
.stock-summary span{font-size:13px;white-space:nowrap}
.stock-in{color:#166534}.stock-out{color:#991b1b}
@media(max-width:700px){.stock-summary{display:grid;grid-template-columns:1fr 1fr}.stock-booking-form{grid-template-columns:1fr!important}}

/* v2.9 Schnellrechnung + sichere Testlöschung */
.inline-form{display:inline-flex;margin:0}
.quick-customer-box{border:1px solid #d9deea;border-radius:12px;padding:14px;background:#fafbfe}
.quick-customer-box .section-title{margin-bottom:10px}
@media(max-width:720px){.quick-customer-box{padding:12px}.actions .inline-form{width:100%}.actions .inline-form .btn{width:100%}}


/* v3.0 – Bedienungs-Feinschliff */
.invoice-step{display:flex;align-items:center;gap:9px;margin:0 0 10px;color:#1f2937}
.invoice-step>span,.field-step{display:inline-flex;align-items:center;justify-content:center;width:25px;height:25px;border-radius:50%;background:var(--accent,#24346b);color:#fff;font-weight:800;font-size:13px}
.quick-customer-box{border:1px solid #dbe1ec;background:#f8fafc;border-radius:12px;padding:14px;margin-top:2px}
.payment-field{border:1px solid #dbe1ec;border-radius:10px;padding:10px;background:#fff}
.field-step{margin-right:5px}
.invoice-list-actions{white-space:nowrap;align-items:center}
.action-menu{position:relative;display:inline-block}
.action-menu summary{list-style:none;cursor:pointer;min-width:38px;text-align:center}
.action-menu summary::-webkit-details-marker{display:none}
.action-menu-pop{position:absolute;right:0;top:calc(100% + 6px);z-index:50;min-width:180px;background:#fff;border:1px solid #dbe1ec;border-radius:10px;box-shadow:0 12px 30px rgba(0,0,0,.15);padding:6px}
.menu-action{display:block;width:100%;border:0;background:transparent;text-align:left;padding:9px 10px;border-radius:7px;color:inherit;text-decoration:none;font:inherit;cursor:pointer}
.menu-action:hover{background:#f2f4f8}
.danger-text{color:#a61b1b!important}
@media(max-width:700px){.action-menu-pop{position:fixed;right:12px;left:12px;top:auto;bottom:12px}.quick-customer-box{padding:10px}}

/* ===== v3.0.1 FINAL: echte A4-Fusszeile am physischen Seitenrand =====
   Diese Regeln stehen bewusst am Dateiende und ersetzen alle aelteren Footer-Regeln. */
@page{size:A4;margin:0!important}

/* Bildschirm / Vorschau: komplette A4-Seite simulieren. */
@media screen and (min-width:601px){
  .invoice-paper,
  .invoice-paper.preview-paper{
    position:relative!important;
    width:min(210mm,100%)!important;
    min-height:297mm!important;
    height:auto!important;
    padding:14mm 14mm 30mm 14mm!important;
    box-sizing:border-box!important;
    overflow:visible!important;
  }
  .invoice-paper>.footer,
  .invoice-paper.preview-paper>.footer{
    position:absolute!important;
    left:14mm!important;
    right:14mm!important;
    bottom:7mm!important;
    margin:0!important;
    padding-top:4px!important;
    line-height:1.2!important;
    background:#fff!important;
  }
}

/* Drucken: keine Browser-Seitenraender addieren. Die Rechnung IST die A4-Seite. */
@media print{
  html,body{
    width:210mm!important;
    height:auto!important;
    margin:0!important;
    padding:0!important;
    background:#fff!important;
  }
  .invoice-paper{
    position:relative!important;
    width:210mm!important;
    max-width:210mm!important;
    height:297mm!important;
    min-height:297mm!important;
    margin:0!important;
    padding:14mm 14mm 30mm 14mm!important;
    box-sizing:border-box!important;
    overflow:hidden!important;
    border:0!important;
    box-shadow:none!important;
    background:#fff!important;
  }
  .invoice-paper>.footer{
    position:absolute!important;
    left:14mm!important;
    right:14mm!important;
    bottom:7mm!important;
    margin:0!important;
    padding-top:4px!important;
    min-height:0!important;
    line-height:1.2!important;
    background:#fff!important;
    break-inside:avoid!important;
    page-break-inside:avoid!important;
  }
}

/* Direkter PDF-Download: identische Geometrie wie beim Druck. */
.invoice-paper.pdf-export{
  position:relative!important;
  width:210mm!important;
  max-width:210mm!important;
  height:297mm!important;
  min-height:297mm!important;
  margin:0!important;
  padding:14mm 14mm 30mm 14mm!important;
  box-sizing:border-box!important;
  overflow:hidden!important;
  background:#fff!important;
}
.invoice-paper.pdf-export>.footer{
  position:absolute!important;
  left:14mm!important;
  right:14mm!important;
  bottom:7mm!important;
  margin:0!important;
  padding-top:4px!important;
  min-height:0!important;
  line-height:1.2!important;
  background:#fff!important;
}

/* ===== v3.0.2 Mobile: nur die obere Navigation horizontal bewegen ===== */
@media (max-width:900px){
  html,body{width:100%;max-width:100%;overflow-x:hidden!important}
  .app{display:block!important;width:100%!important;max-width:100%!important;overflow-x:hidden!important}
  .sidebar{width:100%!important;max-width:100vw!important;overflow:hidden!important;position:relative!important}
  .brand{width:100%;overflow:hidden}
  /* Nur diese Zeile darf horizontal gewischt werden. */
  .nav{
    display:flex!important;
    width:100%!important;
    max-width:100%!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    white-space:nowrap!important;
    overscroll-behavior-x:contain!important;
    -webkit-overflow-scrolling:touch!important;
    touch-action:pan-x!important;
    scrollbar-width:thin;
  }
  .nav a{flex:0 0 auto!important;white-space:nowrap!important}
  /* Der eigentliche Seiteninhalt bleibt fest im Viewport. */
  .main{width:100%!important;max-width:100%!important;min-width:0!important;overflow-x:hidden!important}
  .main>*{max-width:100%}
  .card,.invoice-editor,.topbar,.toolbar{min-width:0!important;max-width:100%!important}

  /* Rechnungsansicht selbst darf nicht mit der Navigation mitscrollen. */
  .invoice-paper:not(.preview-paper){
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    margin-left:0!important;
    margin-right:0!important;
  }

  /* Vorschau bleibt ebenfalls im Bildschirm; nur Tabellen koennen intern scrollen. */
  #invoice-preview-content{width:100%!important;max-width:100%!important;overflow-x:hidden!important;padding:10px!important}
  .preview-paper{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    margin:0 auto!important;
  }
}

@media (max-width:600px){
  /* A4-Inhalt mobil lesbar statt als breites weisses Blatt neben dem Bildschirm. */
  .preview-paper,.invoice-paper:not(.preview-paper){padding-left:14px!important;padding-right:14px!important}
  .preview-paper .invoice-head,.invoice-paper:not(.preview-paper) .invoice-head{gap:10px;flex-wrap:wrap}
  .preview-paper .invoice-title,.invoice-paper:not(.preview-paper) .invoice-title{margin-left:auto}
  .preview-paper .invoice-lines,.invoice-paper:not(.preview-paper) .invoice-lines{
    display:block!important;
    width:100%!important;
    max-width:100%!important;
    overflow-x:auto!important;
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior-x:contain!important;
  }
  .preview-paper .invoice-lines thead,.preview-paper .invoice-lines tbody,
  .invoice-paper:not(.preview-paper) .invoice-lines thead,.invoice-paper:not(.preview-paper) .invoice-lines tbody{
    display:table;
    width:600px;
    table-layout:auto;
  }
  /* Die feste Fusszeile bleibt innerhalb des Rechnungsblatts. */
  .invoice-paper:not(.preview-paper)>.footer,.preview-paper>.footer{left:14px!important;right:14px!important}
}
