/* NiViDesk – Oberfläche: Hellgrau als ruhige Fläche, Marineblau für Text und Hauptaktionen,
   Türkis für Interaktion, Grün für positive Zustände. Schrift: Inter (lokal eingebunden, keine externen Abrufe). */
@font-face { font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900; src: url(fonts/inter-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900; src: url(fonts/inter-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
:root {
  /* Markenfarben */
  --marine: #0B2545; --tuerkis: #00D7C6; --gruen: #22E39F; --hellgrau: #F3F6F8;
  --mint: #7DEBDF; --nebel: #E6FAF8;
  --brand-gradient: linear-gradient(135deg, #00D7C6, #00BFAF 52%, #22E39F);
  --bg: #F3F6F8;
  --card: #FFFFFF;
  --card-2: #F7F9FB;
  --text: #0B2545;
  --muted: #5B6B80;
  --muted-2: #A4B0BF;
  --line: rgba(11, 37, 69, .12);
  --fill: rgba(11, 37, 69, .06);
  --fill-2: rgba(11, 37, 69, .04);
  --soft: var(--fill);
  --accent: #00897F;        /* Türkis, für Text und Symbole abgedunkelt (Kontrast auf Weiß) */
  --accent-soft: rgba(0, 215, 198, .14);
  --accent-text: #007A71;
  --primary: var(--marine); --on-primary: #FFFFFF;
  --switch-on: #12C98C;     /* Grün (positive Zustände), leicht abgedunkelt */
  --green: #0E8A5F; --green-soft: rgba(34, 227, 159, .18);
  --orange: #B5530A; --orange-soft: rgba(240, 150, 40, .15);
  --red: #C72E3A; --red-soft: rgba(220, 60, 70, .11);
  --purple: #6B4CC0; --purple-soft: rgba(120, 90, 220, .12);
  --radius: 14px;
  --shadow: none;
  --lift: 0 1px 0 rgba(11,37,69,.03), 0 8px 28px rgba(11,37,69,.08);
  --tabbar-h: 56px;
  --font: "Inter", Arial, Helvetica, sans-serif;
  --font-display: "Inter", Arial, Helvetica, sans-serif;
  --font-rounded: "Inter", Arial, Helvetica, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #03070D; --card: #0A1522; --card-2: #101E30; --text: #D3DCE6; --muted: #9DB0C6; --muted-2: #5F7690;
    --line: rgba(0, 215, 198, .13); --fill: rgba(243, 246, 248, .08); --fill-2: rgba(243, 246, 248, .05);
    --nebel: #101E30;
    --accent: #4FC9BE; --accent-soft: rgba(79, 201, 190, .16); --accent-text: #5FCFC4;
    --tuerkis: #3DBDB2; --primary: var(--tuerkis); --on-primary: #0B2545;
    --switch-on: #22E39F;
    --green: #3EE8AA; --green-soft: rgba(34, 227, 159, .16); --orange: #FFAE4A; --orange-soft: rgba(255, 174, 74, .16);
    --red: #FF6B6B; --red-soft: rgba(255, 107, 107, .16); --purple: #B79BFF; --purple-soft: rgba(183, 155, 255, .16);
    --lift: 0 8px 28px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 var(--font); letter-spacing: -.006em; font-feature-settings: 'cv11', 'ss01'; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-text); text-decoration: none; }
h1 { font: 700 30px/1.15 var(--font-display); letter-spacing: -.025em; margin: 0; }
h2 { font: 600 17px/1.3 var(--font-display); letter-spacing: -.015em; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 6px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Rahmen: Seitenleiste (Mac) / Tab-Leiste (iPhone) ---------- */
#app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: none; padding: 18px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: color-mix(in srgb, var(--bg) 70%, var(--card)); border-right: .5px solid var(--line); }
.sidebar { display: flex; flex-direction: column; }
.imp-links { margin-top: auto; padding: 14px 10px 0; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.imp-link { font-size: 12.5px; color: var(--muted); }
.legal h2 { margin-top: 18px; }
.legal ul { padding-left: 20px; }
.imp-link:hover { color: var(--text); text-decoration: underline; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 22px/1 var(--font-display); letter-spacing: -.035em; color: var(--text); padding: 6px 10px 24px; }
.brand img { width: 34px; height: auto; flex: none; }
.brand i { width: 1.5px; height: 24px; background: var(--text); opacity: .7; flex: none; }
.brand-lg { font-size: 32px; gap: 14px; }
.brand-lg img { width: 50px; }
.brand-lg i { height: 36px; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--text); font: 600 14.5px var(--font-display); letter-spacing: -.01em; margin-bottom: 1px; }
#nav a svg { color: var(--muted); }
#nav a:hover { background: var(--fill-2); }
#nav a.active { background: var(--primary); color: var(--on-primary); }
#nav a.active svg { color: var(--tuerkis); }
@media (prefers-color-scheme: dark) { #nav a.active svg { color: var(--marine); } }
#nav a svg, .tabbar a svg { width: 19px; height: 19px; flex: none; }
#nav .sep { height: .5px; background: var(--line); margin: 10px 10px; }
main { flex: 1; min-width: 0; padding: 34px 40px 72px; max-width: 1160px; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  main { padding: calc(10px + env(safe-area-inset-top)) 16px calc(var(--tabbar-h) + 30px + env(safe-area-inset-bottom)); }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 2px 0 env(safe-area-inset-bottom); background: color-mix(in srgb, var(--card) 78%, transparent);
    backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: .5px solid var(--line); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font: 600 10px var(--font-display); color: var(--muted); letter-spacing: 0; }
  .tabbar a svg { width: 24px; height: 24px; stroke-width: 1.7; }
  .tabbar a.active { color: var(--accent); }
  h1 { font-size: 32px; letter-spacing: -.03em; }
}

/* ---------- Seitenkopf ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 15px; margin-top: 4px; letter-spacing: -.005em; }
.back { display: inline-flex; align-items: center; gap: 2px; font-size: 16px; margin: 0 0 6px -4px; color: var(--accent-text); }
.back svg { width: 22px; height: 22px; stroke-width: 2.2; }

/* ---------- Karten = gruppierte Abschnitte ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title h2 { margin: 0; }
.card.flush > .card-title { padding: 16px 20px 2px !important; margin-bottom: 4px; }
.grid { display: grid; gap: 14px 12px; }
.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; }
@media (max-width: 640px) { .g2, .g4 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: 1fr; } .g2 > .full, .span2 { grid-column: 1 / -1; } .stack-sm { grid-template-columns: 1fr !important; } .card { padding: 16px; border-radius: 12px; } }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
@media (max-width: 1060px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.sticky { position: sticky; top: 20px; }

/* ---------- Formulare ---------- */
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; min-width: 0; }
input, select, textarea { font: inherit; font-size: 16px; letter-spacing: -.01em; color: var(--text); background: var(--fill); border: 0; border-radius: 10px;
  padding: 10px 12px; width: 100%; min-width: 0; outline: none; box-shadow: inset 0 0 0 1px transparent; transition: box-shadow .15s, background .15s; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus { background: var(--card); box-shadow: inset 0 0 0 1.5px var(--tuerkis), 0 0 0 4px var(--accent-soft); }
select { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 9 5-5 5 5M7 15l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
textarea { resize: vertical; min-height: 72px; line-height: 1.45; }
input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--muted-2); background: transparent; flex: none; padding: 0; cursor: pointer; display: grid; place-content: center; margin-top: 1px; }
input[type=checkbox]:checked { background: var(--tuerkis); border-color: var(--tuerkis);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4 8-9'/%3E%3C/svg%3E"); background-size: 14px; background-position: center; background-repeat: no-repeat; }
input[type=checkbox]:disabled { opacity: .45; }
input[type=checkbox]:focus { box-shadow: 0 0 0 4px var(--accent-soft); }
input[type=color] { padding: 3px; height: 42px; }
input[type=file] { background: none; padding: 0; }
label.check { display: flex; align-items: flex-start; gap: 12px; font-size: 15px; color: var(--text); cursor: pointer; padding: 3px 0; }
label.check small { display: block; color: var(--muted); font-size: 13px; margin-top: 1px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.45; }

/* ---------- Schaltflächen: Kapselform wie bei Apple ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 14.5px var(--font-display); letter-spacing: -.01em;
  padding: 8px 16px; min-height: 36px; border-radius: 980px; border: none; cursor: pointer; background: var(--fill); color: var(--text); white-space: nowrap; text-decoration: none;
  transition: background .15s, filter .15s, transform .08s; }
.btn:hover { filter: brightness(.96); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.tint { background: var(--accent-soft); color: var(--accent-text); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.ghost { background: transparent; color: var(--accent-text); padding: 6px 8px; }
.btn.ghost:hover { background: var(--fill-2); filter: none; }
.btn.sm { font-size: 13px; padding: 5px 12px; min-height: 30px; }
.btn.icon { padding: 0; width: 36px; height: 36px; }
.btn.sm.icon { width: 30px; height: 30px; }
.btn svg { width: 17px; height: 17px; stroke-width: 2; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--fill); color: var(--muted); white-space: nowrap; letter-spacing: 0; vertical-align: 1px; }
.badge.blue { background: var(--accent-soft); color: var(--accent-text); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }

/* ---------- Segmented Control & Suche ---------- */
.chips { display: flex; gap: 2px; overflow-x: auto; margin-bottom: 14px; padding: 2px; background: var(--fill); border-radius: 10px; scrollbar-width: none; width: fit-content; max-width: 100%; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: none; font: 600 13.5px var(--font-display); padding: 6px 14px; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; white-space: nowrap; flex: none; }
.chip-n { font-weight: 500; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chip.active { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.10), 0 0 0 .5px rgba(0,0,0,.04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .chip.active { background: var(--card-2); } }
.search { position: relative; margin-bottom: 16px; }
.search input { padding-left: 36px; background: var(--fill); }
.search input:focus { background: var(--fill); box-shadow: none; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }

/* ---------- Listen (inset grouped) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li > a, .list li > .row { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 36px 11px 20px; min-height: 56px; color: var(--text);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='14' viewBox='0 0 8 14' fill='none' stroke='%23C4C4C7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m1 1 6 6-6 6'/%3E%3C/svg%3E") no-repeat right 16px center; }
.list li > .row { background: none; padding-right: 20px; }
.list li:not(:last-child) > a::after, .list li:not(:last-child) > .row::after { content: ""; position: absolute; left: 20px; right: 0; bottom: 0; height: .5px; background: var(--line); }
.list li:not(:last-child) > a:has(.avatar, .doc-ico)::after { left: 70px; }
.list li > a:hover { background-color: var(--fill-2); }
.list li > a:active { background-color: var(--fill); }
.list .main { flex: 1; min-width: 0; }
.list .t1 { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .t2 { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.list .amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; font-size: 15px; }
.list .amount small { display: block; font-weight: 500; margin-top: 2px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--nebel); color: var(--marine); display: flex; align-items: center; justify-content: center; font: 700 14px var(--font-display); flex: none; letter-spacing: -.01em; }
@media (prefers-color-scheme: dark) { .avatar { background: var(--card-2); color: var(--mint); } }
.avatar svg { width: 20px; height: 20px; }
.doc-ico { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11.5px; flex: none; letter-spacing: .02em; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 15px; }

/* Einstellungs-Index: farbige Symbole wie in den iOS-Einstellungen */
.ico { width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.ico svg { width: 18px; height: 18px; stroke-width: 2; }
.list li:not(:last-child) > a:has(.ico)::after { left: 62px; }
.list li > a:has(.ico) { min-height: 48px; padding-top: 9px; padding-bottom: 9px; }
.group-title { font: 700 13px var(--font-display); color: var(--muted); margin: 22px 20px 7px; }
.group-title:first-child { margin-top: 0; }
.list-card { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 8px; }
.list li > a.profile-row { display: flex; align-items: center; gap: 14px; padding: 14px 36px 14px 18px; }
.profile-row .logo { width: 60px; height: 60px; border-radius: 50%; background: var(--fill); display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none; font: 600 22px var(--font-display); color: var(--muted); }
.profile-row .logo img { max-width: 80%; max-height: 80%; object-fit: contain; }
.profile-row .t1 { font-size: 19px !important; font-weight: 600 !important; letter-spacing: -.02em; }
@media (min-width: 861px) { .settings-index { max-width: 640px; } }

/* ---------- Übersicht ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
@media (max-width: 860px) { .kpis { grid-template-columns: 1fr 1fr; gap: 10px; } }
.kpi { background: var(--card); border-radius: var(--radius); padding: 14px 16px 15px; color: var(--text); display: block; transition: background .15s; }
a.kpi:hover { background: color-mix(in srgb, var(--card) 94%, var(--text)); }
.kpi .l { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .v { font: 600 26px/1.15 var(--font-display); letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kpi.warn .v { color: var(--red); }
.bars { display: flex; align-items: flex-end; gap: 5px; height: 128px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.bars .b i { display: block; width: 100%; max-width: 26px; background: var(--fill); border-radius: 5px; min-height: 3px; }
.bars .b i { background: var(--mint); opacity: .5; }
.bars .b.cur i { background: var(--brand-gradient); opacity: 1; }
.bars .b span { font-size: 10.5px; color: var(--muted); }

/* ---------- Positionen im Editor ---------- */
.items { display: flex; flex-direction: column; gap: 10px; }
.item { border-radius: 12px; padding: 12px 14px; background: var(--card-2); }
.item.text { background: transparent; border: 1px dashed var(--line); }
.item-head { display: flex; gap: 8px; align-items: flex-start; }
.item-head .pos { width: 24px; height: 24px; border-radius: 50%; background: var(--fill); color: var(--muted); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex: none; margin-top: 8px; }
.item input, .item select, .item textarea { background: var(--card); }
.item-fields { display: grid; grid-template-columns: 1fr 1fr 1.2fr 1fr 1fr; gap: 8px; margin-top: 8px; }
.item-fields.no-tax { grid-template-columns: 1fr 1fr 1.2fr 1fr; }
@media (max-width: 640px) { .item-fields, .item-fields.no-tax { grid-template-columns: 1fr 1fr 1fr; } }
.item-total { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 14px; color: var(--muted); }
.item-total b { font-variant-numeric: tabular-nums; color: var(--text); }
.item-tools { display: flex; gap: 2px; flex: none; }
.item textarea { min-height: 40px; margin-top: 6px; font-size: 15px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.totals { font-variant-numeric: tabular-nums; }
.totals .r { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 15px; }
.totals .r.big { font: 700 19px var(--font-display); letter-spacing: -.02em; border-top: .5px solid var(--line); margin-top: 8px; padding-top: 12px; }
.totals .r.muted { color: var(--muted); font-size: 13.5px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; background: var(--fill); border-radius: 10px; }
.seg.full { display: flex; }
.seg button { flex: 1; border: none; background: transparent; color: var(--text); font: 600 14px var(--font-display); padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.seg button.active { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.10), 0 0 0 .5px rgba(0,0,0,.04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg button.active { background: var(--card-2); } }

/* ---------- Belegansicht ---------- */
.doc-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.doc-hero .amount { font: 700 36px/1.1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
table.pos { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.pos th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 500; padding: 6px 8px 8px; border-bottom: .5px solid var(--line); }
table.pos td { padding: 10px 8px; border-bottom: .5px solid var(--line); vertical-align: top; }
table.pos tr:last-child td { border-bottom: none; }
table.pos td.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.pos tr.text td { background: var(--fill-2); font-weight: 600; }
table.pos th.right { text-align: right; }
@media (max-width: 640px) { table.pos .hide-sm { display: none; } }

/* ---------- Hinweise ---------- */
.notice { border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.45; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.notice.info { background: var(--accent-soft); color: var(--text); }
.notice.info svg { color: var(--accent); }
.notice.warn { background: var(--orange-soft); color: var(--text); }
.notice.warn svg { color: var(--orange); }
.notice.err { background: var(--red-soft); color: var(--text); }
.notice.err svg, .notice.err b { color: var(--red); }
.notice.ok { background: var(--green-soft); color: var(--text); }
.notice.ok svg { color: var(--green); }
a.notice { color: var(--text); }
a.notice:hover { filter: brightness(.98); }
.notice ul { margin: 4px 0 0; padding-left: 18px; }
.notice svg { width: 19px; height: 19px; flex: none; margin-top: 1px; stroke-width: 2; }

.fab { position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); width: 54px; height: 54px; border-radius: 50%; background: var(--primary); color: var(--on-primary); border: none;
  box-shadow: 0 6px 18px rgba(11,37,69,.28); display: none; align-items: center; justify-content: center; z-index: 15; cursor: pointer; }
.fab svg { width: 26px; height: 26px; stroke-width: 2.2; }
@media (max-width: 860px) { .fab { display: flex; } .hide-mobile { display: none !important; } }
@media (min-width: 861px) { .only-mobile { display: none !important; } }

/* ---------- Sheets ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .32); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .18s; }
.sheet { background: var(--card); border-radius: 16px; width: min(560px, 100%); max-height: min(86vh, 900px); display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,.28); animation: pop .2s cubic-bezier(.2,.8,.2,1); }
.sheet.wide { width: min(760px, 100%); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 10px; gap: 10px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-head .btn.icon { width: 30px; height: 30px; background: var(--fill); color: var(--muted); }
.sheet-head .btn.icon svg { width: 15px; height: 15px; stroke-width: 2.6; }
.sheet-body { padding: 4px 20px 18px; overflow: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); border-top: .5px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 640px) {
  .backdrop { align-items: flex-end; padding: 0; }
  .sheet, .sheet.wide { width: 100%; border-radius: 14px 14px 0 0; max-height: 93vh; animation: up .28s cubic-bezier(.2,.8,.2,1); }
  .sheet::before { content: ""; width: 36px; height: 5px; border-radius: 3px; background: var(--muted-2); opacity: .6; margin: 6px auto 0; flex: none; }
  .sheet-foot .btn { flex: 1; min-height: 44px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
@keyframes up { from { transform: translateY(60px); opacity: 0; } }
.pick-list { list-style: none; margin: 0 -20px; padding: 0; }
.pick-list li { padding: 13px 20px; border-bottom: .5px solid var(--line); cursor: pointer; }
.pick-list li:last-child { border-bottom: none; }
.pick-list li:hover { background: var(--fill-2); }

/* ---------- Toast ---------- */
#toast-root { position: fixed; left: 50%; transform: translateX(-50%); top: calc(14px + env(safe-area-inset-top)); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: color-mix(in srgb, var(--card) 86%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: var(--text); padding: 11px 18px; border-radius: 980px; font-size: 14.5px; font-weight: 500; box-shadow: 0 8px 30px rgba(0,0,0,.16), 0 0 0 .5px var(--line); animation: drop .25s cubic-bezier(.2,.8,.2,1); max-width: 92vw; }
.toast.err { color: var(--red); }
@keyframes drop { from { transform: translateY(-16px); opacity: 0; } }

.loading { color: var(--muted); padding: 48px; text-align: center; }
.save-state { font-size: 13px; color: var(--muted); }
.divider { height: .5px; background: var(--line); margin: 16px 0; }
.logo-prev { max-width: 220px; max-height: 80px; display: block; margin-bottom: 8px; background: #fff; border-radius: 8px; padding: 6px; }
details.more summary { cursor: pointer; color: var(--accent-text); font-weight: 500; font-size: 14.5px; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 14.5px; }
.timeline li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: .5px solid var(--line); }
.timeline li:last-child { border-bottom: none; }
.code { font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; color: var(--muted); }
@media (min-width: 1061px) { .cols.wide-preview { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

.vat-tab td.n, .vat-tab th.right { white-space: nowrap; }
@media (max-width: 860px) { .vat-tab td, .vat-tab th { padding-left: 4px; padding-right: 4px; font-size: 13.5px; } }

.login-wrap { min-height: 100vh; width: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; padding: 28px 24px; }
.login-card h2 { font-size: 20px; margin: 6px 0 2px; text-align: center; }
.login-card .brand { color: var(--text); }

/* Verlinkte Hinweise: Pfeil wie in iOS-Listen */
a.notice { padding-right: 34px; position: relative; }
a.notice::after { content: ""; position: absolute; right: 14px; top: 50%; width: 8px; height: 14px; transform: translateY(-50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='14' viewBox='0 0 8 14' fill='none' stroke='%238E8E93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m1 1 6 6-6 6'/%3E%3C/svg%3E") no-repeat center; }

/* Schalter (iOS-Switch) für Ja/Nein-Einstellungen */
label.check { align-items: center; justify-content: space-between; }
label.check > input[type=checkbox] { order: 2; width: 51px; height: 31px; border-radius: 16px; border: none; background: var(--fill); position: relative; transition: background .2s; margin: 0 0 0 auto; background-image: none !important; }
label.check > input[type=checkbox]::before { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform .2s cubic-bezier(.3,.7,.4,1); }
label.check > input[type=checkbox]:checked { background: var(--switch-on); }
label.check > input[type=checkbox]:checked::before { transform: translateX(20px); }
label.check > span { flex: 1; min-width: 0; }
form > label.check, .card > label.check { padding: 6px 0; }

/* Übersicht auf dem iPhone kompakter */
@media (max-width: 640px) {
  .kpi { padding: 12px 14px 13px; }
  .kpi .v { font-size: 22px; }
  .notice { font-size: 14px; }
  .page-head { margin-bottom: 18px; }
}

.settings-page { max-width: 920px; }
.timeline a { color: var(--text); }
.timeline a[style*='font-weight:700'] { color: var(--accent-text); }

/* Auswahlmodus in Listen */
.selecting .list li > a[data-id] { padding-left: 54px; background-image: none; }
.selecting .list li > a[data-id]::before { content: ""; position: absolute; left: 18px; top: 50%; width: 22px; height: 22px; margin-top: -11px; border-radius: 50%; border: 1.5px solid var(--muted-2); box-sizing: border-box; }
.selecting .list li > a[data-id].picked::before { background: var(--tuerkis) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4 8-9'/%3E%3C/svg%3E") center / 14px no-repeat; border-color: var(--tuerkis); }
.selecting .list li > a[data-id].picked { background-color: var(--accent-soft); }
.selecting .list li:not(:last-child) > a[data-id]::after { left: 54px; }
.selecting .fab { display: none !important; }
.select-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 22px; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 12px; border-radius: 980px;
  background: color-mix(in srgb, var(--card) 86%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 10px 34px rgba(0,0,0,.16), 0 0 0 .5px var(--line); animation: drop .2s ease-out; max-width: calc(100vw - 24px); }
.select-count { font-size: 14px; color: var(--muted); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 860px) { .select-bar { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); } }
@media (min-width: 861px) { .select-bar { margin-left: 118px; } }

/* Summe der Auswahl */
.select-bar.with-sum { padding-right: 18px; }
.select-bar.with-sum .select-count { white-space: normal; overflow: visible; display: flex; flex-direction: column; line-height: 1.25; color: var(--text); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.select-bar.with-sum .sum-n { font-size: 12px; color: var(--muted); }
.select-bar.with-sum .sum-v b { font-weight: 600; font-size: 16px; }
.select-bar.with-sum .sum-detail { color: var(--muted); font-size: 13px; }
@media (min-width: 641px) { .select-bar.with-sum .sum-detail::before { content: " · "; } }
@media (max-width: 640px) { .select-bar.with-sum .sum-detail { display: block; font-size: 12px; } }

/* Nummernkreise */
.num-preview { display: flex; flex-direction: column; gap: 2px; background: var(--card-2); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.num-preview b { font: 600 22px/1.2 var(--font-display); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tokens { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip-btn { border: none; background: var(--accent-soft); color: var(--accent-text); font: 600 13px var(--font-display); padding: 6px 10px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: baseline; }
.chip-btn small { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.chip-btn:hover { filter: brightness(.96); }

/* Ablage */
.ablage-info { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 16px; margin: 14px 0; padding: 12px 14px; background: var(--fill); border-radius: 12px; }
.ablage-info > div:first-child { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ablage-info svg { width: 20px; height: 20px; flex: none; color: var(--accent-text); }
.ablage-info .code { word-break: break-all; }

.navbadge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--accent); color: #fff; font: 700 12px var(--font-display); text-align: center; }
.navbadge[hidden] { display: none; }

.gsearch { padding: 0 10px 12px; }
.gsearch input { width: 100%; box-sizing: border-box; padding: 9px 12px; border-radius: 10px; border: 1px solid rgba(11,37,69,.14); background: #fff; color: var(--text); font: inherit; font-size: 14px; }
.gsearch input::placeholder { color: var(--muted); }
.gsearch input:focus { outline: 2px solid var(--mint, #00A99C); }
.mobile-search { display: none; }

.dash-sum { display: block; font-size: 22px; line-height: 1.3; margin: 2px 0 14px; color: var(--text); text-decoration: none; }
.dash-sum b { font-weight: 700; } .dash-sum .red { color: var(--red, #C72E3A); }
.dash-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.dash-actions .btn.lg { padding: 12px 18px; font-size: 15px; }
@media (max-width: 860px) { .dash-actions .btn.lg { flex: 1 1 100%; justify-content: center; } .dash-sum { font-size: 19px; } }
.todo { list-style: none; margin: 8px 0 0; padding: 0; }
.todo li + li { border-top: 1px solid var(--line, rgba(0,0,0,.08)); }
.todo a { display: flex; align-items: center; gap: 12px; padding: 11px 0; color: inherit; text-decoration: none; }
.todo .ti { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); flex: none; }
.todo .ti svg { width: 18px; height: 18px; }
.todo .ti.red { background: #fbebeb; color: #C72E3A; } .todo .ti.green { background: #e5f4e4; color: #2a7a2a; } .todo .ti.orange { background: #f9ece7; color: #b5541f; }
.todo .tt { flex: 1; min-width: 0; font-size: 15px; } .todo .tt small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.todo .ta { white-space: nowrap; }
.todo-empty { display: flex; align-items: center; gap: 8px; padding: 14px 0 4px; color: var(--muted); } .todo-empty svg { width: 18px; height: 18px; color: #2a7a2a; }
.dash-rev { padding: 0; } .dash-rev summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; list-style: none; }
.dash-rev summary::-webkit-details-marker { display: none; } .dash-rev .bars { padding: 0 16px 16px; height: 150px; }

.dash-rev summary::after { content: '▾'; color: var(--muted); margin-left: 6px; } .dash-rev[open] summary::after { content: '▴'; }
.dash-rev summary > span:first-child { flex: 1; }
@media (max-width: 860px) { .dash-rev summary { flex-wrap: wrap; } .dash-rev summary > span:first-child { flex: 1 1 100%; } }
