/* COEXORA PORTAL: Oberflaeche nach der Coex-DESIGN.md (Stand 20.10.2026).
   App statt Webseite: dichter, Grundschrift 16 px, Trefferflaechen 44 x 44 px, mobil zuerst.
   Ein Grund (weiss), eine Tinte (ink), ein Akzent (Signalblau, nur fuer Handlung, Links, Fokus, aktive Navigation).
   Eckig, keine Schatten, keine Fotos. Die 48-Grad-Naht nur vor dem aktiven Navigationspunkt und im Kopf der
   Anmeldung. Keine Bewegung ausser der Fortschrittsanzeige beim Hochladen. Schriften lokal (public/fonts).
   Schrift: Source Sans 3 (Entscheid Matthias 27.11.2026), Ziffern tabellarisch; Archivo nur im Schriftzug
   "COEXORA PORTAL", IBM Plex Mono nur fuer Kennungen (IBAN, Codes), nicht fuer Betraege. */

@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/static/fonts/sourcesans3-400-latin.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: 'Source Sans 3'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/static/fonts/sourcesans3-400-latin-ext.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; }
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/static/fonts/sourcesans3-600-latin.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: 'Source Sans 3'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/static/fonts/sourcesans3-600-latin-ext.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; }
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/static/fonts/sourcesans3-700-latin.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: 'Source Sans 3'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/static/fonts/sourcesans3-700-latin-ext.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; }

@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 400 700; font-stretch: 62% 125%; font-display: swap;
  src: url('/static/fonts/archivo-var-latin.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: 'Archivo'; font-style: normal; font-weight: 400 700; font-stretch: 62% 125%; font-display: swap;
  src: url('/static/fonts/archivo-var-latin-ext.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; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/static/fonts/plexmono-400-latin.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: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/static/fonts/plexmono-400-latin-ext.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; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/static/fonts/plexmono-500-latin.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; }

:root {
  --ink: #172A3A;
  --accent: #0E60B0;
  --accent-hover: #0A4F94;
  --paper: #F7F8F9;
  --white: #FFFFFF;
  --graphit: #5A6B7B;
  --light-hover: #D9E8F7;
  --hair: rgba(23, 42, 58, .14);
  /* Feldrahmen: ink 55 % auf weiss = 3.6:1 (WCAG 1.4.11, Bedienelemente mind. 3:1) */
  --field-border: rgba(23, 42, 58, .55);
  --pad: 1rem;
  --nav-h: 64px;
  --capture-h: 52px;
  --side-w: 248px;
  --font: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --wordmark: 'Archivo', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--white); color: var(--ink);
  font-family: var(--font); font-size: 1rem; line-height: 1.5; font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; text-underline-offset: .22em; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 1px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: .5rem; top: -4rem; z-index: 50; background: var(--white); color: var(--ink); padding: .75rem 1rem; border: 2px solid var(--accent); }
.skip:focus { top: .5rem; }

/* ------------------------------------------------------------------ Typografie */
h1, h2, h3 { margin: 0; line-height: 1.1; letter-spacing: -.005em; text-wrap: balance; overflow-wrap: break-word; }
.h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.1rem); font-weight: 700; letter-spacing: -.015em; }
.h2 { font-size: 1.2rem; font-weight: 600; margin: 1.75rem 0 .75rem; }
.h3 { font-size: 1.05rem; font-weight: 600; }
.lead { color: var(--graphit); margin: .5rem 0 0; max-width: 60ch; }
.meta, .muted { color: var(--graphit); font-size: .875rem; }
.mono, .data-mono { font-family: var(--mono); font-weight: 400; font-size: .92em; white-space: nowrap; }
.amount, .num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.amount { font-weight: 600; }
p { margin: .5rem 0; max-width: 66ch; }
@media (max-width: 680px) { h1, h2 { hyphens: auto; } }

/* Naht-Marke: 48 Grad, 2 px, Signalblau; dekorativ */
.seam { position: relative; padding-left: .9em; }
.seam::before { content: ''; position: absolute; left: .2em; top: -.08em; width: 2px; height: 1.15em; background: var(--accent); transform: rotate(42deg); transform-origin: center; }

/* ------------------------------------------------------------------ Kopf der App */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--white); border-bottom: 1px solid var(--hair);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 56px; padding: 0 var(--pad);
}
.brand { display: flex; align-items: baseline; gap: .5rem; color: var(--ink); min-height: 44px; align-items: center; }
.brand:hover { text-decoration: none; }
.brand__name { font-family: var(--wordmark); font-weight: 700; font-stretch: 112%; font-size: .9rem; letter-spacing: .03em; white-space: nowrap; }
.brand .mark { flex: none; }
.brand__x { color: var(--accent); }
.topbar__tenant { font-size: .875rem; color: var(--graphit); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; text-align: right; }
/* P15 Punkt 8: Firmenname und "Firma wechseln" (nur bei mehreren Firmen; schmal steht der Link unter "Mehr") */
.topbar__firma { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; min-width: 0; flex: 1 1 auto; }
.topbar__wechsel { display: none; font-size: .875rem; font-weight: 600; white-space: nowrap; min-height: 44px; align-items: center; }
@media (min-width: 600px) { .topbar__wechsel { display: inline-flex; } }

/* ------------------------------------------------------------------ Seitenrahmen Kunde (mobil) */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.main { flex: 1; padding: 1.25rem var(--pad) calc(var(--nav-h) + var(--capture-h) + 2rem + env(safe-area-inset-bottom)); max-width: 760px; width: 100%; }
.main--plain { padding-bottom: calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom)); }
.page-head { margin-bottom: 1.25rem; }

/* Navigation unten: vier Reiter */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--white); border-top: 1px solid var(--hair);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
  min-height: var(--nav-h); color: var(--graphit); font-size: .8rem; font-weight: 500; text-align: center;
}
.tabbar a:hover { text-decoration: none; color: var(--ink); }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: square; }
.tabbar a[aria-current='page'] { color: var(--accent); font-weight: 600; }
.tabbar a[aria-current='page'] .tab__label { position: relative; padding-left: .7em; }
.tabbar a[aria-current='page'] .tab__label::before { content: ''; position: absolute; left: .1em; top: .05em; width: 1.5px; height: 1em; background: var(--accent); transform: rotate(42deg); }

/* Knopf "Beleg erfassen": fest ueber der Navigation, volle Breite, rechteckig */
.capture {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 29;
  padding: .5rem var(--pad); background: var(--white); border-top: 1px solid var(--hair);
}
.capture .btn { width: 100%; }

/* ------------------------------------------------------------------ Schreibtisch: linke Spalte ab 960 px */
@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: var(--side-w) 1fr; grid-template-rows: auto 1fr; }
  .shell > .topbar { grid-column: 1 / -1; }
  .main, .main--plain { grid-row: 2; }
  .sidenav { grid-column: 1; grid-row: 2; border-right: 1px solid var(--hair); padding: 1.25rem 1rem; position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); }
  .main, .main--plain { grid-column: 2; padding: 2rem 2.5rem 3rem; max-width: 980px; }
  .tabbar { position: static; border: 0; padding: 0; background: transparent; }
  .tabbar ul { display: flex; flex-direction: column; gap: .25rem; }
  .tabbar a { flex-direction: row; justify-content: flex-start; gap: .75rem; min-height: 44px; padding: 0 .5rem; font-size: .95rem; }
  .capture { position: static; padding: 0 0 1.25rem; border: 0; background: transparent; }
}

/* ------------------------------------------------------------------ Knoepfe */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px; padding: .75rem 1.4rem;
  font: inherit; font-weight: 600; border: 0; border-radius: 0; cursor: pointer; text-align: center;
  background: var(--accent); color: var(--white); transition: background-color .18s;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: var(--white); }
.btn--secondary { background: var(--white); color: var(--ink); border: 1.5px solid var(--ink); }
.btn--secondary:hover { background: var(--ink); color: var(--white); }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled='true'] { background: #C9D1D8; color: var(--ink); cursor: not-allowed; }
.btn.is-busy { cursor: progress; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; min-height: 44px; text-align: left; }
.linkbtn:hover { text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.25rem; align-items: center; }

/* ------------------------------------------------------------------ Formulare */
.form { display: grid; gap: 1.1rem; max-width: 560px; }
.field { display: grid; gap: .35rem; }
.field > label, .label { font-weight: 600; font-size: .95rem; }
.hint { color: var(--graphit); font-size: .875rem; margin: 0; }
.opt { color: var(--graphit); font-weight: 400; }
input[type='text'], input[type='email'], input[type='password'], input[type='date'], input[type='search'], select, textarea {
  width: 100%; min-height: 48px; padding: .7rem .8rem; font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--white); border: 1px solid var(--field-border); border-radius: 0; appearance: none;
}
textarea { min-height: 96px; resize: vertical; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2.2rem; }
input:hover, select:hover, textarea:hover { border-color: var(--ink); }
input.code { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .3em; max-width: 12ch; }
.field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea { border: 2px solid var(--ink); }
.field-error { margin: 0; font-weight: 600; font-size: .9rem; padding-left: .75rem; border-left: 3px solid var(--ink); }
.field-error::before { content: 'Fehler: '; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 600; font-size: .95rem; padding: 0; margin-bottom: .35rem; }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice span { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: .5rem; border: 1px solid var(--field-border); text-align: center; font-weight: 500; }
.choice input:checked + span { border: 2px solid var(--accent); background: var(--light-hover); font-weight: 600; }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.check { display: flex; gap: .75rem; align-items: flex-start; min-height: 44px; }
.check input { width: 24px; height: 24px; margin: .1rem 0 0; accent-color: var(--accent); flex: none; }
details.more { border-top: 1px solid var(--hair); padding-top: .75rem; }
details.more > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; color: var(--accent); }
details.more[open] > summary { margin-bottom: .75rem; }
.grid-2 { display: grid; gap: 1.1rem; }
@media (min-width: 560px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Fehlerzusammenfassung (fokussierbar, Links zu den Feldern) */
.alert { border-left: 3px solid var(--ink); background: var(--paper); padding: .9rem 1rem; margin: 0 0 1.25rem; }
.alert h2 { font-size: 1rem; font-weight: 700; margin: 0 0 .35rem; }
.alert ul { margin: 0; padding-left: 1.1rem; }
.notice { border-left: 3px solid var(--accent); background: var(--paper); padding: .9rem 1rem; margin: 0 0 1.25rem; }

/* ------------------------------------------------------------------ Beleg erfassen */
.pick { display: grid; gap: .75rem; }
.pick__btn {
  position: relative; display: flex; align-items: center; gap: 1rem; min-height: 72px; padding: 1rem 1.1rem;
  border: 1px solid var(--field-border); background: var(--white); color: var(--ink); font-weight: 600; font-size: 1.05rem; cursor: pointer;
}
.pick__btn:hover { border-color: var(--ink); background: var(--paper); }
.pick__btn input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.pick__btn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.75; flex: none; }
.pick__btn:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.preview { display: grid; gap: .5rem; border: 1px solid var(--hair); padding: .75rem; background: var(--paper); }
.preview img { max-height: 280px; object-fit: contain; background: var(--white); }
.progress { width: 100%; height: 8px; appearance: none; border: 0; background: var(--hair); }
.progress::-webkit-progress-bar { background: var(--hair); }
.progress::-webkit-progress-value { background: var(--accent); }
.progress::-moz-progress-bar { background: var(--accent); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ Listen und Zustaende */
.counts { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin: 0; padding: 0; list-style: none; }
.counts a { display: flex; flex-direction: column; gap: .15rem; padding: .9rem 1rem; border-top: 1px solid var(--hair); background: var(--paper); color: var(--ink); min-height: 72px; }
.counts a:hover { background: var(--light-hover); text-decoration: none; }
.counts strong { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.5rem; }
.counts span { font-size: .875rem; color: var(--graphit); }
@media (min-width: 680px) { .counts { grid-template-columns: repeat(4, 1fr); } }

.rlist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--hair); }
.rlist li { border-bottom: 1px solid var(--hair); }
.rlist a { display: grid; grid-template-columns: 1fr auto; gap: .2rem .75rem; padding: .85rem .25rem; color: var(--ink); min-height: 64px; }
.rlist a:hover { background: var(--paper); text-decoration: none; }
.rlist a.is-aktuell { box-shadow: inset 3px 0 0 var(--accent); padding-left: .75rem; }
.rlist__who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rlist__meta { color: var(--graphit); font-size: .875rem; }
.rlist__right { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; grid-row: 1 / span 2; grid-column: 2; }

.filters { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; margin: 0 0 1rem; list-style: none; padding-left: 0; }
.filters a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .9rem; border: 1px solid var(--field-border); color: var(--ink); white-space: nowrap; font-size: .95rem; }
.filters a[aria-current='true'] { border: 2px solid var(--accent); font-weight: 600; background: var(--light-hover); }
.filters a:hover { text-decoration: none; border-color: var(--ink); }
.pager { display: flex; justify-content: space-between; margin-top: 1rem; }
.pager a { min-height: 44px; display: inline-flex; align-items: center; }

/* Status: Wort plus Form, nie nur Farbe (App-Plan 4.1) */
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: .1rem .5rem; font-size: .8rem; font-weight: 600; border: 1px solid var(--ink); color: var(--ink); background: var(--white); white-space: nowrap; }
.badge--entwurf { border-style: dashed; border-color: var(--graphit); color: var(--ink); }
.badge--eingereicht { border-width: 1px; }
.badge--pruefung { border-width: 1px; border-left-width: 4px; }
.badge--uebergeben { border-width: 2px; }
.badge--verbucht { background: var(--ink); color: var(--white); }
.badge--abgelehnt, .badge--abgewiesen { border-style: double; border-width: 3px; }

/* Verlauf des Belegs */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { position: relative; padding: 0 0 1rem 2.25rem; min-height: 2.25rem; }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: 0; width: 1.6rem; height: 1.6rem; display: grid; place-items: center;
  font-family: var(--mono); font-size: .8rem; border: 1px dashed var(--graphit); color: var(--graphit); background: var(--white); }
.steps li.is-done::before { border: 1px solid var(--ink); background: var(--ink); color: var(--white); }
.steps li:not(:last-child) > .steps__line { position: absolute; left: .78rem; top: 1.7rem; bottom: .1rem; width: 1px; background: var(--hair); }
.steps__label { font-weight: 600; }
.steps__state { color: var(--graphit); font-size: .875rem; display: block; }

/* Datentabelle (Felder eines Belegs) */
.specs { margin: 0; display: grid; grid-template-columns: 1fr; border-top: 1px solid var(--hair); }
.specs > div { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr; gap: .25rem 1rem; padding: .6rem 0; border-bottom: 1px solid var(--hair); }
.specs dt { font-weight: 600; font-size: .9rem; }
.specs dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 420px) { .specs > div { grid-template-columns: 1fr; } }

.panel { border-top: 1px solid var(--hair); padding-top: 1rem; margin-top: 1.5rem; }
.lead-card { background: var(--paper); border-left: 3px solid var(--accent); padding: 1rem 1.1rem; }

/* ------------------------------------------------------------------ Anmeldung */
.auth { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--white); }
.auth__head { padding: 1.25rem var(--pad); border-bottom: 1px solid var(--hair); }
.auth__body { padding: 2rem var(--pad) 3rem; width: 100%; max-width: 460px; margin: 0 auto; }
.auth__body > .h1 { margin-bottom: 1.25rem; }
.auth__body > .lead { margin: -.5rem 0 1.25rem; }
.auth__foot { padding: 1rem var(--pad) 1.5rem; color: var(--graphit); font-size: .8rem; text-align: center; }
.auth__claim { color: var(--graphit); font-size: .9rem; margin: .25rem 0 0; }
.auth__wordmark { font-family: var(--wordmark); font-weight: 700; font-stretch: 122%; font-size: 1.15rem; letter-spacing: .05em; margin: 0; }
.auth__wordmark .x { color: var(--accent); }
.stepper { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1.5rem; font-size: .85rem; color: var(--graphit); }
.stepper li { flex: 1; border-top: 3px solid var(--hair); padding-top: .4rem; }
.stepper li[aria-current='step'] { border-top-color: var(--accent); color: var(--ink); font-weight: 600; }
.stepper li.is-done { border-top-color: var(--ink); }
.qr { width: 220px; height: 220px; border: 1px solid var(--hair); }
.secret { font-family: var(--mono); font-size: 1.05rem; letter-spacing: .05em; background: var(--paper); padding: .6rem .8rem; word-break: break-all; }
.codes { font-family: var(--mono); display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem 1rem; list-style: none; padding: 1rem; background: var(--paper); margin: 0; }

/* ------------------------------------------------------------------ Admin (Schreibtisch zuerst) */
.admin .main { max-width: 1160px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--hair); vertical-align: top; }
table.data th { font-weight: 600; font-size: .85rem; border-bottom: 1px solid var(--ink); }
table.data { font-variant-numeric: tabular-nums; }
table.data td.num { text-align: right; }
.banner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem 1.5rem; align-items: center; background: var(--paper); border-left: 3px solid var(--accent); padding: .8rem 1rem; margin-bottom: 1.25rem; }
.banner strong { font-weight: 700; }
ul.plain { padding-left: 1.1rem; }

/* ------------------------------------------------------------------ Rechnungsmaske (P15, nach Lexoffice-Prinzip)
   Eine Seite, ein Speichern. Weisse Flaechen auf hellgrauem Grund statt Haarlinien, eckig, keine Schatten.
   Felder der Positionstabelle ohne Rahmen, Rahmen erst bei Hover und Fokus. Signalblau nur fuer Hauptaktion,
   Links und Fokus. Fusszeile mit Total bleibt unten stehen. Auf dem Handy wird jede Position ein eigener Block. */
:root { --sheet: #F2F4F6; --field: #F7F8F9; --tint: #E8F0F9; --edge: rgba(23, 42, 58, .22); --line: rgba(23, 42, 58, .10); }
.main--sheet { background: var(--sheet); max-width: none; }
@media (min-width: 960px) { .main--sheet { max-width: none; padding: 1.75rem 2rem 0; } }
.rm { max-width: 1160px; margin: 0 auto; display: grid; gap: 1.25rem; }
.rm .alert, .rm .notice { margin: 0; background: var(--white); }
.rm-head { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: flex-end; justify-content: space-between; }
.rm-head .lead { margin-top: .25rem; }
.rm-back { font-size: .95rem; font-weight: 600; display: inline-flex; align-items: center; min-height: 44px; }
.rm-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.card { background: var(--white); padding: 1.25rem; display: grid; gap: 1rem; align-content: start; min-width: 0; }
@media (min-width: 680px) { .card { padding: 1.5rem; } }
.card > .h2, .card__title { margin: 0; font-size: 1.1rem; font-weight: 600; }
.card__head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: baseline; justify-content: space-between; }
.rm .field > label, .rm legend.lbl, .lbl { font-weight: 600; font-size: .875rem; color: var(--graphit); }
.rm input[type='text'], .rm input[type='date'], .rm input[type='search'], .rm select, .rm textarea { min-height: 44px; padding: .55rem .75rem; border-color: var(--edge); }
.rm input:hover, .rm select:hover, .rm textarea:hover { border-color: rgba(23, 42, 58, .5); }
.rm input:focus, .rm select:focus, .rm textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.rm .field.is-invalid input, .rm .field.is-invalid select { border: 2px solid var(--ink); }
.rm-dates { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.rm-fixed { min-height: 44px; display: flex; align-items: center; padding: 0 .75rem; background: var(--field); color: var(--graphit); }
.rm-dates .rm-span { grid-column: 1 / -1; }
@media (max-width: 420px) { .rm-dates { grid-template-columns: 1fr; } }
.rm-due { display: flex; gap: .5rem; align-items: center; }
.rm-due input { flex: 1 1 auto; min-width: 0; }
.chip { min-height: 44px; padding: 0 .8rem; border: 0; background: var(--tint); color: var(--accent); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--light-hover); }
.rm-addr { background: var(--field); padding: .85rem 1rem; display: flex; gap: 1rem; justify-content: space-between; align-items: flex-start; }
.rm-addr p { margin: 0; white-space: pre-line; }
.rm-addr__land { font-size: .85rem; font-weight: 600; color: var(--graphit); white-space: nowrap; }
.rm-note { font-size: .875rem; color: var(--graphit); margin: 0; }
.rm-links { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; }
.rm-links a, .rm-links .linkbtn { font-weight: 600; display: inline-flex; align-items: center; min-height: 44px; }

/* Segmentschalter Netto/Brutto (Radio-Gruppe, ohne Skript bedienbar) */
.seg { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.seg__opts { display: inline-flex; background: #E3E8ED; padding: 3px; }
.seg__opt { position: relative; }
.seg__opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg__opt span { display: flex; align-items: center; min-height: 38px; padding: 0 1rem; font-weight: 600; font-size: .95rem; color: var(--graphit); }
.seg__opt input:checked + span { background: var(--white); color: var(--ink); }
.seg__opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Zahlteil und Texte */
.rm-qr { display: flex; gap: .75rem; align-items: center; background: var(--tint); padding: .75rem 1rem; margin: 0; }
.rm-qr svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 2; flex: none; }
.rm-bank { font-size: .95rem; margin: 0; }
.rm-texts { margin: 0; display: grid; gap: .75rem; }
.rm-texts dt { font-weight: 600; font-size: .875rem; color: var(--graphit); }
.rm-texts dd { margin: .15rem 0 0; white-space: pre-line; }

/* Positionstabelle: Kopfzeile nur am Schreibtisch, je Feld eine Beschriftung (am Schreibtisch nur fuer Screenreader) */
.rm-pos { display: grid; }
.rm-row, .rm-thead { display: grid; grid-template-columns: minmax(200px, 1fr) 80px 88px 112px 76px minmax(150px, 176px) 112px 44px; gap: .25rem .5rem; align-items: start; }
.rm-thead { background: var(--field); padding: .6rem .75rem; }
.rm-thead span { font-weight: 600; font-size: .85rem; color: var(--graphit); padding: 0 .5rem; }
.rm-thead .r { text-align: right; }
.rm-row { padding: .6rem .75rem; border-bottom: 1px solid var(--line); } /* Zeilentrenner der Tabelle */
.rm-row:hover { background: #FAFBFC; }
.rm-cell { display: grid; gap: .15rem; min-width: 0; }
.rm-cell__lbl { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.rm-pos .cell { width: 100%; min-width: 0; min-height: 40px; padding: .4rem .5rem; border: 1px solid transparent; background-color: var(--field); color: var(--ink); font: inherit; border-radius: 0; }
.rm-pos select.cell { padding-right: 1.6rem; background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; }
.rm-pos .cell:hover { border-color: var(--edge); background-color: var(--white); }
.rm-pos .cell:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); background-color: var(--white); }
.rm-pos .cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.rm-pos .cell--title { font-weight: 600; }
.rm-pos textarea.cell--desc { min-height: 34px; font-size: .9rem; color: var(--graphit); resize: vertical; }
.rm-pos .cell[aria-invalid='true'] { border: 2px solid var(--ink); background-color: var(--white); }
.rm-row .field-error { font-size: .85rem; padding-left: .5rem; }
.rm-sum-cell { min-height: 40px; display: flex; align-items: center; justify-content: flex-end; padding-right: .5rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rm-del { width: 44px; height: 44px; border: 0; background: transparent; color: var(--graphit); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.rm-del svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.rm-del:hover { color: var(--ink); background: var(--field); }
.rm-pos__add { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; padding: .25rem .75rem 0; }
.rm-pos__add .linkbtn { font-weight: 600; }
@media (max-width: 860px) {
  .rm-thead { display: none; }
  .rm-row { grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--field); border: 0; padding: .75rem; margin-bottom: .75rem; gap: .6rem; }
  .rm-row:hover { background: var(--field); }
  .rm-row .rm-cell--title { grid-column: 1 / -1; }
  .rm-cell__lbl { position: static !important; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal; font-size: .8rem; font-weight: 600; color: var(--graphit); }
  .rm-pos .cell { background-color: var(--white); border-color: var(--edge); }
  .rm-row .rm-cell--tax { grid-column: span 2; }
  .rm-row .rm-cell--sum { grid-column: 1 / 3; }
  .rm-sum-cell { justify-content: flex-start; padding: 0; }
  .rm-row .rm-del { justify-self: end; align-self: end; }
}

/* Summen: laufen beim Tippen mit (Skript), sonst Stand der letzten Speicherung */
.rm-sum { display: flex; justify-content: flex-end; }
.rm-sum dl { width: 100%; max-width: 420px; margin: 0; display: grid; gap: .4rem; }
.rm-sum dl > div { display: flex; justify-content: space-between; gap: 1rem; }
.rm-sum dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rm-sum .rm-vat { color: var(--graphit); }
.rm-sum .rm-total { margin-top: .5rem; padding: .9rem 1rem; background: var(--ink); color: var(--white); align-items: baseline; }
.rm-total dt { font-weight: 600; }
.rm-total dd { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
.rm-sum__hint { font-size: .85rem; color: var(--graphit); margin: 0; text-align: right; max-width: none; }

/* Fusszeile: bleibt unten stehen (mobil ueber der Navigation) */
.rm-foot { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 15; background: var(--white); border-top: 3px solid var(--ink);
  padding: .75rem var(--pad); margin: 0 calc(-1 * var(--pad)); display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; justify-content: space-between; }
@media (max-width: 680px) {
  .rm-foot { gap: .5rem; padding-top: .5rem; padding-bottom: .5rem; }
  .rm-foot__actions { width: 100%; }
  .rm-foot__total { width: 100%; }
  .rm-foot__actions .btn { flex: 1 1 0; padding: .5rem .75rem; }
  .rm-foot .rm-drop { order: 2; }
}
@media (min-width: 960px) { .rm-foot { bottom: 0; margin: 0 -2rem; padding: .75rem 2rem; } }
.rm-foot__total { color: var(--graphit); font-size: .95rem; margin: 0; }
.rm-foot__total strong { color: var(--ink); font-size: 1.1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rm-foot__actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.rm-foot .btn { min-height: 44px; padding: .5rem 1.2rem; }
.btn--quiet { background: var(--tint); color: var(--accent); }
.btn--quiet:hover { background: var(--light-hover); color: var(--accent-hover); }
.rm-drop { position: relative; }
.rm-drop > summary { list-style: none; cursor: pointer; color: var(--graphit); font-weight: 500; min-height: 44px; display: inline-flex; align-items: center; }
.rm-drop > summary::-webkit-details-marker { display: none; }
.rm-drop > summary:hover { color: var(--ink); text-decoration: underline; }
.rm-drop__panel { position: absolute; bottom: calc(100% + .5rem); left: 0; width: min(320px, 80vw); background: var(--white); border: 1px solid var(--ink); padding: 1rem; display: grid; gap: .75rem; }
.rm-drop__panel p { margin: 0; }
.rm-default { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.rm-view .specs { border-top: 0; }

/* ------------------------------------------------------------------ Bewegung */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
@media print {
  .tabbar, .capture, .topbar form, .rm-foot { display: none; }
  .main { padding: 0; }
}

/* ------------------------------------------------------------------ Vorschau als Rechnungsdokument (P15) */
/* Das Blatt waechst mit der Breite (A4-Seitenverhaeltnis); das Dokument im iframe verkleinert sich selbst. */
.blatt { margin: 1.25rem 0 .5rem; padding: .75rem; background: var(--paper); border: 1px solid var(--hair); }
.blatt__frame { display: block; width: 100%; max-width: 210mm; aspect-ratio: 210 / 297; margin: 0 auto; border: 1px solid var(--hair); background: var(--white); }
@media (max-width: 480px) { .blatt { padding: 0; border: 0; background: none; } }

/* ------------------------------------------------------------------ Vorschlaege aus dem Beleg (P15) */
.vorschlag { margin: .3rem 0 0; font-size: .875rem; color: var(--accent); }
.vorschlag::before { content: ''; display: inline-block; width: 1.5px; height: .9em; margin-right: .45em; background: var(--accent); transform: rotate(42deg); vertical-align: -.05em; }
/* Mehrere Betraege im Beleg (P15 Punkt 6): Liste unter dem Betrag; mit Skript je Betrag ein Knopf */
.alternativen { margin-top: -.5rem; padding: .6rem .75rem; background: var(--tint); }
.alternativen__titel { margin: 0 0 .4rem; font-size: .875rem; font-weight: 600; }
.alternativen__liste { margin: 0; padding: 0; list-style: none; display: grid; gap: .35rem; font-size: .9rem; }
.alternativen__knopf { width: 100%; min-height: 44px; padding: .5rem .75rem; justify-content: flex-start; text-align: left; font-weight: 600; background: var(--white); }

/* ------------------------------------------------------------------ Beleg neben dem Formular (P15 Punkt 5)
   Schmal: der Beleg steht ueber dem Formular, zuklappbar, mit begrenzter Hoehe. Ab 1200 px: Formular links, Beleg
   rechts, beim Scrollen stehend (sticky) und in sich scrollbar. "Groesser" zeigt die Seiten in voller Breite. */
.split { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); grid-template-areas: "beleg" "haupt"; }
.split__haupt { grid-area: haupt; min-width: 0; }
.beleg { grid-area: beleg; min-width: 0; border: 1px solid var(--hair); background: var(--paper); padding: .5rem .75rem .75rem; }
.beleg__kopf { display: flex; align-items: center; min-height: 44px; cursor: pointer; }
.beleg__titel { margin: 0; display: inline; }
/* schmal zuklappbar: sichtbarer Hinweis (summary ist fuer Screenreader ohnehin auf- und zuklappbar) */
.beleg__kopf::after { content: "Einklappen"; margin-left: auto; color: var(--accent); font-size: .9rem; }
.beleg__klapp:not([open]) > .beleg__kopf::after { content: "Aufklappen"; }
.beleg__leiste { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; align-items: center; min-height: 44px; }
.beleg__leiste a { display: inline-flex; align-items: center; min-height: 44px; }
.beleg__status { margin: .25rem 0 .5rem; }
.beleg__seiten { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; max-height: 60vh; overflow: auto; }
.beleg__seite { margin: 0; display: grid; gap: .35rem; min-width: 0; }
.beleg__nr { font-size: .85rem; color: var(--graphit); }
.beleg__seite img { width: 100%; height: auto; background: var(--white); border: 1px solid var(--hair); }
.beleg__xml { display: grid; gap: .75rem; }
.beleg__xml:empty { display: none; }
.beleg__xml-titel { margin: 0; font-weight: 600; }
.beleg__xml .specs, .beleg__pos { background: var(--white); }
.beleg__xml .specs > div { padding-left: .5rem; padding-right: .5rem; }
table.data th.num { text-align: right; }
.beleg__summen dd { font-variant-numeric: tabular-nums; }
@media (min-width: 1200px) {
  .main--split, .main--split.main--plain { max-width: 1560px; }
  /* P15 Punkt 7: Formular schmaler (440 statt 560 px), der Beleg bekommt den Rest */
  .split { grid-template-columns: minmax(0, 440px) minmax(0, 1fr); grid-template-areas: "haupt beleg"; gap: 2.5rem; align-items: start; }
  /* Kompakt wie die Rechnungsmaske (.rm): 40 px hohe Felder, engere Abstaende; nur am Schreibtisch, auf dem Handy
     bleiben die 48 px fuer den Daumen */
  .split__haupt .form { gap: .7rem; }
  .split__haupt .field { gap: .2rem; }
  .split__haupt .field > label, .split__haupt legend { font-size: .875rem; }
  .split__haupt legend { margin-bottom: .2rem; }
  .split__haupt .hint, .split__haupt .vorschlag { font-size: .8125rem; }
  .split__haupt input[type='text'], .split__haupt input[type='date'], .split__haupt select, .split__haupt textarea { min-height: 40px; padding: .45rem .65rem; }
  .split__haupt select { padding-right: 2rem; }
  .split__haupt textarea { min-height: 72px; }
  .split__haupt .choices { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem; }
  .split__haupt .choice span { min-height: 40px; padding: .35rem .25rem; font-size: .9rem; }
  .split__haupt .grid-2 { gap: .7rem; }
  .split__haupt details.more { padding-top: .35rem; }
  .split__haupt details.more > summary { min-height: 40px; }
  .split__haupt details.more[open] > summary { margin-bottom: .35rem; }
  .split__haupt .alternativen { margin-top: -.3rem; }
  .split__haupt .alternativen__knopf { min-height: 40px; padding: .35rem .65rem; }
  .split__haupt .actions { margin-top: .75rem; }
  .beleg { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; }
  .beleg__kopf { cursor: default; list-style: none; pointer-events: none; }
  .beleg__kopf::-webkit-details-marker { display: none; }
  .beleg__kopf::after { content: none; }
  .beleg__seiten { max-height: none; overflow: visible; }
}
/* Groesser: die Seiten in voller Breite ueber der Seite, schliessen mit demselben Knopf oder Esc */
.beleg--gross { position: fixed; inset: 0; z-index: 60; max-height: none; overflow: auto; padding: 1rem var(--pad) 2rem; background: var(--paper); border: 0; }
@media (min-width: 1200px) { .beleg--gross { position: fixed; top: 0; max-height: none; } }
.beleg--gross .beleg__seiten { max-height: none; overflow: visible; }
.beleg--gross .beleg__seite img { width: 100%; max-width: 1400px; margin: 0 auto; }
@media print { .beleg { display: none; } }

/* ------------------------------------------------------------------ Handy verbinden (P15 Punkt 9) */
.schritte { margin: 1rem 0 1.25rem; padding-left: 1.25rem; display: grid; gap: .4rem; max-width: 60ch; }
.koppeln { display: grid; gap: .75rem; max-width: 520px; }
.koppeln__qr .qr { width: 260px; height: 260px; max-width: 100%; background: var(--white); }
.koppeln__zahl-titel { margin: .5rem 0 0; font-size: .875rem; font-weight: 600; color: var(--graphit); }
.koppeln__zahl { margin: 0; font-size: 3.5rem; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .08em; color: var(--ink); }
.koppeln .actions { margin-top: .25rem; }
.koppeln .actions form { margin: 0; }
input.code--kopplung { max-width: 14ch; letter-spacing: .15em; text-transform: uppercase; }
.koppeln__konto { margin: .75rem 0 1rem; padding: .6rem .75rem; background: var(--tint); }
