:root {
  --cream: #f7f2e8;
  --cream-2: #efe7d7;
  --paper: #fffdf8;
  --line: #e3d9c6;
  --navy: #1b2a4a;
  --navy-2: #2c4170;
  --navy-soft: #e6eaf2;
  --ink: #1f2430;
  --muted: #6f6a60;
  --green: #2f7d5b;
  --green-soft: #e3f1ea;
  --red: #b4483c;
  --red-soft: #f7e4e1;
  --gold: #b8913a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 42, 74, .05), 0 6px 20px rgba(27, 42, 74, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; color: var(--navy); font-weight: 600; margin: 0; }
h1 { font-size: 28px; letter-spacing: -.01em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; font-family: 'Inter', sans-serif; font-weight: 600; }
a { color: var(--navy-2); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--navy);
  color: #dfe4ee;
  padding: 26px 16px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; color: #fff; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--cream); color: var(--navy);
  display: grid; place-items: center; font-family: 'Fraunces', serif; font-weight: 600; font-size: 18px;
}
.brand-name { font-family: 'Fraunces', serif; font-size: 19px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: #c9d1e1; text-decoration: none; font-weight: 500; font-size: 14.5px;
}
.nav-link i { width: 18px; text-align: center; opacity: .85; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: var(--cream); color: var(--navy); }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8794b0; padding: 16px 12px 6px; }
.sidebar-foot { margin-top: auto; padding: 12px; font-size: 13px; color: #9aa6c0; display: flex; justify-content: space-between; align-items: center; }
.sidebar-foot button { background: none; border: 0; color: #c9d1e1; cursor: pointer; font-size: 13px; }
.sidebar-foot button:hover { color: #fff; }

.main { padding: 32px 40px 60px; max-width: 1280px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.mobile-bar { display: none; }

/* ---------- Cards ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.mt { margin-top: 18px; }

.kpi { padding: 18px 20px; }
.kpi-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.kpi-value { font-size: 26px; font-weight: 600; color: var(--navy); margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.dark { background: var(--navy); border-color: var(--navy); }
.kpi.dark .kpi-label, .kpi.dark .kpi-sub { color: #aab5cc; }
.kpi.dark .kpi-value { color: #fff; }
.icon-dot { width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 12px; background: var(--navy-soft); color: var(--navy); }
.icon-dot.g { background: var(--green-soft); color: var(--green); }
.icon-dot.r { background: var(--red-soft); color: var(--red); }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid var(--navy); background: var(--navy); color: #fff;
  padding: 9px 16px; border-radius: 10px; font: 500 14px 'Inter', sans-serif; cursor: pointer; text-decoration: none;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--navy-2); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn.ghost:hover { background: var(--cream-2); }
.btn.danger { background: transparent; color: var(--red); border-color: #e7c5bf; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 6px 9px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font: 14.5px 'Inter', sans-serif; color: var(--ink); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(44,65,112,.12); }
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 14px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); font-weight: 400; }
.check input { width: auto; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.seg { display: inline-flex; background: var(--cream-2); padding: 3px; border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font: 500 13.5px 'Inter'; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--paper); color: var(--navy); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 10px; border-bottom: 1px solid var(--line); }
td { padding: 11px 10px; border-bottom: 1px solid #efe8da; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fbf7ef; }
tfoot td { font-weight: 600; border-top: 2px solid var(--line); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--cream-2); color: var(--muted); }
.badge.navy { background: var(--navy-soft); color: var(--navy); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gold { background: #f5ecd6; color: #8a6a22; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid #efe8da; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; }
.cat-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--navy-soft); color: var(--navy); flex: none; }

.progress { height: 8px; border-radius: 99px; background: var(--cream-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--navy); border-radius: 99px; }

.empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.empty i { font-size: 28px; color: var(--line); display: block; margin-bottom: 10px; }

.chart-box { position: relative; height: 260px; }
.legend { display: grid; gap: 6px; margin-top: 14px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.legend-row .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-row .grow { flex: 1; }

.breakdown td { padding: 8px 6px; }
.breakdown tr.total td { font-weight: 700; color: var(--navy); border-top: 2px solid var(--navy); font-size: 16px; }
.breakdown tr.sub td { color: var(--muted); }

/* ---------- Modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 28, 48, .45); display: grid; place-items: center; z-index: 50; padding: 20px; overflow-y: auto; }
.modal { background: var(--paper); border-radius: 18px; width: 100%; max-width: 560px; padding: 26px; box-shadow: 0 20px 60px rgba(0,0,0,.25); max-height: calc(100vh - 40px); overflow-y: auto; }
.modal.wide { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.x { background: none; border: 0; font-size: 18px; color: var(--muted); cursor: pointer; }
#toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 60; display: grid; gap: 8px; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; animation: up .2s ease; }
.toast.err { background: var(--red); }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 36px; box-shadow: var(--shadow); }
.auth-card .brand { color: var(--navy); padding: 0 0 20px; }
.auth-card .brand-mark { background: var(--navy); color: var(--cream); }
.err-msg { background: var(--red-soft); color: var(--red); padding: 9px 12px; border-radius: 8px; font-size: 13.5px; margin-bottom: 12px; }

/* ---------- Scan ---------- */
.dropzone { border: 2px dashed var(--line); border-radius: 14px; padding: 28px; text-align: center; background: #fcf9f2; cursor: pointer; transition: .15s; }
.dropzone:hover { border-color: var(--navy-2); background: var(--navy-soft); }
.dropzone i { font-size: 30px; color: var(--navy); margin-bottom: 8px; }
.preview-img { max-width: 100%; max-height: 260px; border-radius: 10px; border: 1px solid var(--line); display: block; margin: 0 auto; }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
.spinner.dark { border-color: var(--line); border-top-color: var(--navy); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Invoice items editor ---------- */
.items-table input { padding: 7px 9px; font-size: 14px; }
.items-table td { padding: 5px 4px; border: 0; }
.items-table th { padding: 6px 4px; }

/* ---------- Invoice print ---------- */
.invoice-sheet { background: #fff; color: #111; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 13mm 18mm 0; position: relative; display: flex; flex-direction: column; box-shadow: var(--shadow); font-size: 10pt; line-height: 1.45; }
.invoice-sheet h1 { font-family: 'Fraunces', serif; color: var(--navy); font-size: 20pt; margin: 0 0 3mm; }
.inv-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 7mm; }
.inv-logo { font-family: 'Fraunces', serif; font-size: 16pt; color: var(--navy); font-weight: 600; }
.inv-sender { text-align: right; font-size: 9pt; color: #444; }
.inv-address { margin-bottom: 6mm; min-height: 22mm; }
.inv-meta { display: grid; grid-template-columns: auto 1fr; gap: .5mm 8mm; font-size: 9.5pt; margin-bottom: 6mm; }
.inv-meta span:nth-child(odd) { color: #666; }
.inv-items { width: 100%; border-collapse: collapse; margin-bottom: 6mm; font-size: 9.5pt; }
.inv-items th { border-bottom: 1.5px solid var(--navy); color: var(--navy); font-size: 8.5pt; padding: 2mm 1.5mm; }
.inv-items td { padding: 2mm 1.5mm; border-bottom: 1px solid #e6e6e6; }
.inv-sum { margin-left: auto; width: 80mm; font-size: 10pt; }
.inv-sum td { padding: 1.2mm 1.5mm; border: 0; }
.inv-sum tr.grand td { border-top: 1.5px solid var(--navy); font-weight: 700; font-size: 11.5pt; color: var(--navy); padding-top: 2mm; }
.inv-notes { margin-top: 5mm; font-size: 9.5pt; white-space: pre-line; }
.inv-spacer { flex: 1; min-height: 4mm; }
.qr-bill { position: relative; margin: 0 -18mm; height: 105mm; flex: none; break-inside: avoid; page-break-inside: avoid; background: #fff; border-top: 1px dashed #000; display: flex; font-family: Arial, Helvetica, sans-serif; color: #000; }
.qr-receipt { width: 62mm; padding: 5mm; border-right: 1px dashed #000; font-size: 8pt; position: relative; }
.qr-payment { flex: 1; padding: 5mm; display: flex; gap: 5mm; font-size: 10pt; }
.qr-title { font-weight: bold; font-size: 11pt; margin-bottom: 4mm; }
.qr-receipt .qr-title { font-size: 11pt; }
.qr-h { font-weight: bold; font-size: 6pt; margin-top: 2.5mm; }
.qr-payment .qr-h { font-size: 8pt; margin-top: 3mm; }
.qr-code-col { width: 51mm; }
.qr-code { width: 46mm; height: 46mm; margin: 5mm 0; }
.qr-amount { display: flex; gap: 6mm; }
.qr-accept { position: absolute; right: 5mm; bottom: 15mm; font-weight: bold; font-size: 6pt; }
.scissors { position: absolute; top: -9px; left: 8mm; font-size: 12px; background: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 30; }
  .mobile-bar button { background: none; border: 0; color: #fff; font-size: 20px; }
  .main { padding: 20px 16px 60px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  h1 { font-size: 24px; }
  .invoice-sheet { transform-origin: top left; }
}

/* ---------- Neue Features: Auth, PWA, Tabbar ---------- */
.auth-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; margin: 16px 0 12px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.install-link { background: rgba(255,255,255,.06); border: 1px dashed rgba(255,255,255,.25); margin-top: 14px; width: 100%; text-align: left; cursor: pointer; font-family: inherit; }
.install-steps { padding-left: 20px; line-height: 2; margin: 0 0 10px; }
.sidebar-backdrop { display: none; }
.tabbar { display: none; }

/* ---------- Fortschrittsringe ---------- */
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring .track { stroke: var(--cream-2); }
.ring .bar { transition: stroke-dashoffset .6s ease; stroke-linecap: round; }
.ring .ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-weight: 600; font-size: 15px; color: var(--navy); line-height: 1.1; }
.ring .ring-label small { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); }
.ring.sm { width: 58px; height: 58px; }
.ring.sm .ring-label { font-size: 12px; }
.budget-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.budget-card { display: flex; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; transition: border-color .15s, transform .1s; }
.budget-card:hover { border-color: var(--navy-2); }
.budget-card .grow { min-width: 0; flex: 1; }
.budget-card .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-card { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fff; display: flex; flex-direction: column; gap: 12px; }
.goal-head { display: flex; gap: 14px; align-items: center; }
.goal-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-rings { display: flex; gap: 18px; flex-wrap: wrap; }
.mini-ring { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 86px; text-align: center; font-size: 12px; color: var(--muted); cursor: pointer; }

/* ---------- Import ---------- */
.import-table td, .import-table th { padding: 7px 6px; font-size: 13.5px; }
.import-table select { padding: 6px 8px; font-size: 13px; min-width: 150px; }
.import-table tr.off td { opacity: .45; }
.import-table .txt { max-width: 340px; }
.import-table .txt .raw { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.import-table .vendor-in { padding: 5px 8px; font-size: 13.5px; font-weight: 500; border-color: transparent; background: transparent; }
.import-table .vendor-in:hover, .import-table .vendor-in:focus { border-color: var(--line); background: #fff; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; color: var(--ink); cursor: pointer; font-family: inherit; }
.chip:hover { border-color: var(--navy-2); background: var(--navy-soft); }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.scope-toggle { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 9px; font-size: 12px; cursor: pointer; font-family: inherit; white-space: nowrap; }
.scope-toggle.biz { background: #f5ecd6; color: #8a6a22; border-color: #e6d3a4; }
.step-dots { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.step-dots b { color: var(--navy); }

/* ---------- Assistent ---------- */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 480px; padding: 0; overflow: hidden; }
.chat-log { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { max-width: 80%; padding: 12px 16px; border-radius: 16px; line-height: 1.55; font-size: 14.5px; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--cream); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.bot p { margin: 0 0 8px; } .msg.bot p:last-child { margin: 0; }
.msg.bot ul { margin: 4px 0 8px; padding-left: 20px; } .msg.bot li { margin: 2px 0; }
.msg.bot strong { color: var(--navy); }
.msg.err { background: var(--red-soft); color: var(--red); border-color: #e7c5bf; }
.typing span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-input { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--line); background: var(--paper); align-items: flex-end; }
.chat-input textarea { min-height: 46px; max-height: 160px; resize: none; border-radius: 14px; }
.chat-input .btn { height: 46px; width: 46px; padding: 0; border-radius: 14px; flex: none; }
.chat-empty { margin: auto; text-align: center; max-width: 560px; padding: 20px; }
.chat-empty .bot-icon { width: 58px; height: 58px; border-radius: 18px; background: var(--navy); color: var(--cream); display: grid; place-items: center; font-size: 24px; margin: 0 auto 14px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }

/* ---------- Mobile: App-Feeling ---------- */
@media (max-width: 860px) {
  .mobile-bar { padding-top: calc(12px + env(safe-area-inset-top)); }
  .sidebar { padding-top: calc(26px + env(safe-area-inset-top)); z-index: 45; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(20,28,48,.4); z-index: 44; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar-backdrop.on { opacity: 1; pointer-events: auto; }
  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: rgba(255,253,248,.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .tab { flex: 1; background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; font: 500 10.5px 'Inter', sans-serif; color: var(--muted); padding: 6px 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tab i { font-size: 18px; }
  .tab.active { color: var(--navy); }
  .tab.fab i { width: 50px; height: 50px; border-radius: 16px; background: var(--navy); color: var(--cream); display: grid; place-items: center; margin-top: -24px; box-shadow: 0 6px 16px rgba(27,42,74,.35); font-size: 19px; }
  .tab.fab span { color: var(--navy); }
  #toast-root { bottom: calc(90px + env(safe-area-inset-bottom)); left: 16px; right: 16px; }
  .modal-bg { align-items: end; padding: 0; }
  .modal { border-radius: 22px 22px 0 0; max-height: 92vh; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: sheet .22s ease; }
  @keyframes sheet { from { transform: translateY(40px); opacity: .4; } }
  .chat-wrap { height: calc(100vh - 230px - env(safe-area-inset-bottom)); min-height: 380px; }
  .msg { max-width: 90%; }
  .page-head .actions { width: 100%; }
}
@media (display-mode: standalone) { .install-link { display: none !important; } }

/* ---------- Print (zuletzt, damit es Mobile-Regeln überschreibt) ---------- */
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .sidebar, .no-print, .mobile-bar, #toast-root, .tabbar, .sidebar-backdrop { display: none !important; }
  .layout { display: block !important; }
  .main { padding: 0 !important; max-width: none; }
  .invoice-sheet { box-shadow: none; margin: 0; width: 210mm; min-height: 0; height: 296.5mm; overflow: hidden; }
  .invoice-sheet.long { height: auto; overflow: visible; }
  .main > div, #page > div { overflow: visible !important; }
  #modal-root { display: none; }
}

