/* ==========================================================================
   BelegPro – Rechnungen erstellen
   Gestaltung: ruhig, hell, präzise – angelehnt an Apples Designsprache.
   Systemschrift (San Francisco) auf Apple-Geräten, Inter als Ausweichschrift.
   ========================================================================== */

@font-face { font-family: "InterLocal"; src: url("fonts/InterVariable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --surface-2: #FBFBFD;
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .08);
  --ink: #1D1D1F;
  --ink-2: #6E6E73;
  --muted: #86868B;
  --line: rgba(0, 0, 0, .08);
  --line-strong: rgba(0, 0, 0, .14);

  --accent: #0071E3;
  --accent-hover: #0077ED;
  --accent-soft: rgba(0, 113, 227, .10);
  --on-accent: #FFFFFF;

  --red: #D70015;
  --red-soft: rgba(255, 59, 48, .10);
  --orange: #C93400;
  --orange-soft: rgba(255, 149, 0, .14);
  --green: #248A3D;

  --glass: rgba(255, 255, 255, .72);
  --shadow: 0 1px 1px rgba(0, 0, 0, .03), 0 6px 24px rgba(0, 0, 0, .05);
  --shadow-pop: 0 20px 60px rgba(0, 0, 0, .18);
  --focus: 0 0 0 4px rgba(0, 113, 227, .28);

  --r-s: 8px;
  --r-m: 12px;
  --r-l: 18px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "InterLocal", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #1C1C1E; --surface-2: #232325; --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .16);
    --ink: #F5F5F7; --ink-2: #A1A1A6; --muted: #8E8E93; --line: rgba(255, 255, 255, .09); --line-strong: rgba(255, 255, 255, .16);
    --accent: #0A84FF; --accent-hover: #409CFF; --accent-soft: rgba(10, 132, 255, .18);
    --red: #FF453A; --red-soft: rgba(255, 69, 58, .16); --orange: #FF9F0A; --orange-soft: rgba(255, 159, 10, .16); --green: #30D158;
    --glass: rgba(28, 28, 30, .72); --shadow: 0 0 0 1px rgba(255, 255, 255, .06); --shadow-pop: 0 24px 70px rgba(0, 0, 0, .6);
    --focus: 0 0 0 4px rgba(10, 132, 255, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1C1C1E; --surface-2: #232325; --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .16);
  --ink: #F5F5F7; --ink-2: #A1A1A6; --muted: #8E8E93; --line: rgba(255, 255, 255, .09); --line-strong: rgba(255, 255, 255, .16);
  --accent: #0A84FF; --accent-hover: #409CFF; --accent-soft: rgba(10, 132, 255, .18);
  --red: #FF453A; --red-soft: rgba(255, 69, 58, .16); --orange: #FF9F0A; --orange-soft: rgba(255, 159, 10, .16); --green: #30D158;
  --glass: rgba(28, 28, 30, .72); --shadow: 0 0 0 1px rgba(255, 255, 255, .06); --shadow-pop: 0 24px 70px rgba(0, 0, 0, .6);
  --focus: 0 0 0 4px rgba(10, 132, 255, .4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.47; letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  transition: background-color .25s;
}
h1, h2, h3 { margin: 0; line-height: 1.12; color: var(--ink); }
h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 16px; border-radius: 980px; border: 0;
  background: var(--fill); color: var(--ink); font-weight: 500; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, transform .1s;
}
.btn:hover { background: var(--line-strong); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--red); background: var(--red-soft); }
.btn-danger:hover { background: var(--red-soft); filter: brightness(.96); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-plain { background: transparent; color: var(--ink-2); }
.btn-plain:hover { background: var(--fill-2); color: var(--ink); }
.btn-sm { min-height: 30px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 46px; padding: 0 24px; font-size: 16px; }
.btn-icon { width: 34px; min-height: 34px; padding: 0; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- Formulare ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field small { color: var(--muted); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 9px 12px; border-radius: var(--r-s);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.select { appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%2386868B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px; }
.textarea { min-height: 84px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--fill-2); color: var(--ink-2); border-color: transparent; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-zip { display: grid; grid-template-columns: 120px 1fr; gap: 14px; }
.stack { display: grid; gap: 14px; }

/* Schalter im iOS-Stil */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 0; cursor: pointer; }
.toggle span { color: var(--ink); }
.toggle small { display: block; color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.toggle input { appearance: none; flex: none; width: 51px; height: 31px; border-radius: 99px; background: var(--fill); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.toggle input::after { 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; }
.toggle input:checked { background: #34C759; }
.toggle input:checked::after { transform: translateX(20px); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--ink-2); }
.check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); flex: none; }

/* Segmentierte Auswahl */
.segmented { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--fill); gap: 2px; }
.segmented button { min-height: 30px; padding: 0 14px; border: 0; background: transparent; border-radius: 7px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink); white-space: nowrap; }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.04); font-weight: 600; }
:root[data-theme="dark"] .segmented button[aria-pressed="true"], :root[data-theme="dark"] .segmented button[aria-selected="true"] { background: #636366; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .segmented button[aria-pressed="true"], :root:not([data-theme="light"]) .segmented button[aria-selected="true"] { background: #636366; } }
.segmented .n { color: var(--muted); margin-left: 5px; font-weight: 500; }
.segmented-block { display: flex; }
.segmented-block button { flex: 1; }

/* ---------- Hinweise & Badges ---------- */
.notice { padding: 12px 14px; border-radius: var(--r-m); font-size: 14px; background: var(--accent-soft); color: var(--ink); }
.notice-warn { background: var(--orange-soft); }
.notice-error { background: var(--red-soft); color: var(--red); }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--fill); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.draft { background: var(--orange-soft); color: var(--orange); }
.badge.issued { background: var(--accent-soft); color: var(--accent); }
.badge.void { background: var(--fill); color: var(--muted); }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 14px; }
.linklike:hover { text-decoration: underline; }

/* ---------- App-Symbol ---------- */
.appicon { width: 34px; height: 34px; flex: none; border-radius: 9px; display: block; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.appicon-lg { width: 76px; height: 76px; border-radius: 18px; box-shadow: 0 10px 30px rgba(0,113,227,.28), 0 2px 4px rgba(0,0,0,.08); }

/* ==========================================================================
   Anmeldung
   ========================================================================== */
.auth { min-height: 100vh; display: flex; flex-direction: column; background:
  radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.auth-top { display: flex; justify-content: space-between; align-items: center; padding: 18px clamp(18px, 4vw, 40px); }
.auth-top .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; letter-spacing: -0.02em; }
.auth-top .brand .appicon { width: 28px; height: 28px; border-radius: 7px; }
.auth-main { flex: 1; display: grid; place-items: center; padding: 20px 18px 40px; }
.auth-col { width: min(420px, 100%); display: grid; gap: 28px; justify-items: center; text-align: center; }
.auth-col h1 { font-size: clamp(32px, 5vw, 44px); letter-spacing: -0.03em; }
.auth-col .lead { font-size: 17px; color: var(--ink-2); max-width: 34ch; margin-top: 10px; }
.auth-card { width: 100%; background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow); padding: 26px; display: grid; gap: 18px; text-align: left; }
.auth-feats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; font-size: 13px; color: var(--ink-2); }
.auth-feats span { display: inline-flex; align-items: center; gap: 6px; }
.auth-feats svg { width: 15px; height: 15px; color: var(--green); }
.auth-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; padding: 20px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.auth-foot a { color: var(--ink-2); }

/* ==========================================================================
   App-Rahmen
   ========================================================================== */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px 16px;
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--line);
}
.rail .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--r-s); color: var(--ink); font-weight: 500; font-size: 14.5px; }
.nav a svg { width: 19px; height: 19px; color: var(--accent); }
.nav a:hover { background: var(--fill-2); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent); color: #fff; }
.nav a[aria-current="page"] svg { color: #fff; }
.rail-new { margin: 18px 4px 0; }
.rail-bottom { margin-top: auto; display: grid; gap: 12px; padding: 0 8px; font-size: 12.5px; color: var(--muted); }
.rail-user { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.rail-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.rail-legal { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.rail-legal a { color: var(--muted); }
.rail-credit { font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.rail-credit a { color: var(--ink-2); }

.main { min-width: 0; padding: 22px clamp(18px, 3.4vw, 44px) 80px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 26px; }
.search-trigger {
  display: flex; align-items: center; gap: 8px; width: min(360px, 100%); min-height: 36px; padding: 0 12px;
  border: 0; background: var(--fill); border-radius: 10px; color: var(--muted); cursor: pointer; text-align: left; font-size: 14px;
}
.search-trigger svg { width: 16px; height: 16px; }
.search-trigger kbd { margin-left: auto; }
kbd { font: 500 11px var(--font); padding: 1px 6px; border-radius: 5px; background: var(--surface); color: var(--muted); box-shadow: 0 0 0 1px var(--line); }
.local-badge { font-size: 12px; font-weight: 600; color: var(--orange); background: var(--orange-soft); padding: 5px 10px; border-radius: 99px; white-space: nowrap; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--ink-2); margin-top: 6px; font-size: 15px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 2px; font-size: 15px; margin-bottom: 6px; }
.back svg { width: 18px; height: 18px; }

.card { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 10px; }

/* ---------- Start ---------- */
.hero-new { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 28px; flex-wrap: wrap;
  background: linear-gradient(135deg, #0071E3, #3E9BFF); color: #fff; border-radius: var(--r-l); }
.hero-new h2 { color: #fff; font-size: 26px; }
.hero-new p { color: rgba(255,255,255,.85); margin-top: 6px; }
.hero-new .btn { background: #fff; color: #0071E3; font-weight: 600; }
.hero-new .btn:hover { background: #EAF3FF; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 16px 0 20px; }
.tile { display: flex; align-items: center; gap: 14px; padding: 18px 20px; color: var(--ink); }
.tile:hover { text-decoration: none; box-shadow: var(--shadow), 0 0 0 2px var(--accent-soft); }
.tile-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.tile-ic svg { width: 21px; height: 21px; }
.tile strong { display: block; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.tile span { color: var(--ink-2); font-size: 13.5px; }

.steps { display: grid; gap: 2px; margin: 12px 0 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: center; padding: 12px 4px; border-top: 1px solid var(--line); }
.steps li:first-child { border-top: 0; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; background: var(--fill); color: var(--ink-2); flex: none; }
.steps li.done::before { content: "✓"; background: #34C759; color: #fff; }
.steps li.done span { color: var(--muted); }
.steps li .btn { margin-left: auto; }

/* ---------- Listen ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 16px 18px 12px; }
.toolbar .input { max-width: 260px; min-height: 34px; padding: 6px 12px; background: var(--fill); border-color: transparent; }
.toolbar .input:focus { background: var(--surface); }

.list { list-style: none; margin: 0; padding: 0 8px 8px; }
.row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto; gap: 16px; align-items: center; padding: 12px 14px; border-radius: var(--r-m); cursor: pointer; color: var(--ink); }
.row:hover { background: var(--fill-2); text-decoration: none; }
.row + .row { box-shadow: inset 0 1px 0 var(--line); }
.row:hover + .row, .row + .row:hover { box-shadow: none; }
.row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-weight: 600; text-align: right; white-space: nowrap; }
.row-3 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; }

.empty { padding: 48px 24px; text-align: center; display: grid; justify-items: center; gap: 12px; }
.empty-ic { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--fill); color: var(--muted); }
.empty-ic svg { width: 28px; height: 28px; }
.empty p { color: var(--ink-2); max-width: 40ch; }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.editor-form { display: grid; gap: 16px; min-width: 0; }
.editor-form .card-pad { display: grid; gap: 14px; }
.section-title { font-size: 17px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-title small { font-weight: 400; font-size: 13px; color: var(--muted); }
.items { display: grid; gap: 10px; }
.item { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) 34px; gap: 8px; align-items: end; padding: 12px; border-radius: var(--r-m); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.item .input, .item .select { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.item .select { padding-right: 28px; }
.item .it-title { grid-column: 1 / 5; font-weight: 500; }
.item .desc { grid-column: 1 / -1; min-height: 36px; padding: 7px 10px; font-size: 13.5px; }
.item .mini { display: grid; gap: 3px; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.item-total { grid-column: 1 / -1; text-align: right; font-size: 14px; font-weight: 600; margin-top: -2px; }
.amt, .item-total, .totals-mini, .tile strong, .sheet table, .sheet .sh-totals, .sheet .sh-meta { font-variant-numeric: tabular-nums; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.add-row .select { max-width: 280px; min-height: 34px; padding-top: 5px; padding-bottom: 5px; font-size: 14px; }
.totals-mini { display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--r-m); background: var(--fill-2); }
.totals-mini div { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-2); }
.totals-mini .grand { font-weight: 700; font-size: 19px; color: var(--ink); padding-top: 6px; letter-spacing: -0.02em; }

.preview { position: sticky; top: 20px; min-width: 0; }
.preview-frame { position: relative; overflow: hidden; border-radius: 6px; box-shadow: var(--shadow-pop); }
.preview-scale { transform-origin: top left; }
.preview-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 13px; color: var(--muted); }

/* ==========================================================================
   Rechnungsblatt (DIN A4) – immer hell, es ist Papier.
   ========================================================================== */
.sheet {
  width: 210mm; min-height: 297mm; padding: 16mm 18mm 14mm 24mm; background: #fff; color: #1D1D1F;
  font-family: var(--font); font-size: 9.4pt; line-height: 1.45; letter-spacing: -0.005em; position: relative;
  display: flex; flex-direction: column;
}
.sheet .sh-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10mm; min-height: 26mm; }
.sheet .sh-logo img { max-height: 22mm; max-width: 60mm; object-fit: contain; display: block; }
.sheet .sh-name { font-weight: 700; font-size: 15pt; letter-spacing: -0.02em; }
.sheet .sh-seller { text-align: right; font-size: 8.4pt; color: #6E6E73; }
.sheet .sh-seller strong { display: block; color: #1D1D1F; font-size: 10pt; font-weight: 600; }
.sheet .sh-mid { display: flex; justify-content: space-between; gap: 10mm; margin-top: 12mm; }
.sheet .sh-addr { width: 85mm; min-height: 40mm; }
.sheet .sh-sender { font-size: 6.8pt; color: #86868B; border-bottom: 0.25mm solid #D2D2D7; padding-bottom: 1mm; margin-bottom: 3mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet .sh-meta { min-width: 62mm; font-size: 8.6pt; }
.sheet .sh-meta div { display: flex; justify-content: space-between; gap: 6mm; padding: .6mm 0; }
.sheet .sh-meta span { color: #86868B; }
.sheet .sh-meta b, .sheet .sh-meta strong { font-weight: 600; }
.sheet .sh-titlerow { display: flex; justify-content: space-between; align-items: center; gap: 6mm; margin: 8mm 0 3mm; }
.sheet .sh-title { color: #1D1D1F; font-size: 17pt; font-weight: 700; letter-spacing: -0.025em; margin: 0; white-space: nowrap; }
.sheet .sh-flag { font-size: 8pt; font-weight: 600; padding: 1mm 3mm; border-radius: 99px; background: #F2F2F7; color: #6E6E73; }
.sheet .sh-flag.draft { background: #FFF4E5; color: #C93400; }
.sheet .sh-intro { white-space: pre-line; margin-bottom: 5mm; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 8.9pt; }
.sheet th { text-align: left; font-weight: 600; font-size: 7.8pt; color: #86868B; padding: 2mm 1.5mm; border-bottom: 0.3mm solid #1D1D1F; }
.sheet td { padding: 2.2mm 1.5mm; border-bottom: 0.2mm solid #E5E5EA; vertical-align: top; }
.sheet td strong { font-weight: 600; }
.sheet .r { text-align: right; white-space: nowrap; }
.sheet .it-desc { color: #6E6E73; font-size: 8.2pt; white-space: pre-line; }
.sheet .sh-totals { margin-left: auto; width: 78mm; margin-top: 3mm; font-size: 9.2pt; }
.sheet .sh-totals div { display: flex; justify-content: space-between; padding: 1mm 1.5mm; }
.sheet .sh-totals .grand { font-weight: 700; font-size: 11.5pt; border-top: 0.3mm solid #1D1D1F; margin-top: 1mm; padding-top: 2mm; letter-spacing: -0.015em; }
.sheet .sh-note { margin-top: 5mm; font-size: 8.6pt; color: #6E6E73; }
.sheet .sh-outro { margin-top: 5mm; white-space: pre-line; }
.sheet .sh-pay { display: flex; gap: 5mm; align-items: center; margin-top: 6mm; padding: 3.5mm 4mm; background: #F5F5F7; border-radius: 3mm; font-size: 8.4pt; break-inside: avoid; }
.sheet .sh-pay svg { width: 23mm; height: 23mm; flex: none; background: #fff; padding: 1.2mm; border-radius: 1.5mm; }
.sheet .sh-pay strong { display: block; font-size: 9pt; font-weight: 600; }
.sheet .sh-foot { margin-top: auto; padding-top: 8mm; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; font-size: 7pt; color: #86868B; border-top: 0.2mm solid #E5E5EA; }
.sheet .sh-foot div { padding-top: 2mm; }
.sheet .sh-watermark { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; overflow: hidden; }
.sheet .sh-watermark span { transform: rotate(-30deg); font-size: 64pt; font-weight: 800; letter-spacing: .08em; color: rgba(29, 29, 31, .05); white-space: nowrap; }

/* ---------- Dialoge, Spotlight, Mitteilungen ---------- */
dialog { border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--ink); width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: var(--shadow-pop); }
dialog[open] { animation: pop .22s cubic-bezier(.2, .9, .3, 1); }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
dialog::backdrop { background: rgba(0, 0, 0, .32); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 6px 22px; }
.dlg-body { padding: 14px 22px 22px; display: grid; gap: 14px; overflow-y: auto; max-height: calc(100vh - 200px); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg-foot .left { margin-right: auto; }

.palette { width: min(640px, calc(100vw - 32px)); margin-top: 14vh; background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px); border-radius: 14px; }
.palette .pal-in { display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.palette .pal-in svg { width: 22px; height: 22px; color: var(--muted); flex: none; }
.palette input { width: 100%; border: 0; padding: 16px 0; font-size: 20px; background: transparent; outline: none; letter-spacing: -0.02em; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette li button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 0; background: transparent; border-radius: 8px; text-align: left; cursor: pointer; font-size: 14.5px; }
.palette li button[aria-selected="true"] { background: var(--accent); color: #fff; }
.palette li button[aria-selected="true"] svg, .palette li button[aria-selected="true"] .hint { color: rgba(255,255,255,.85); }
.palette li .hint { margin-left: auto; color: var(--muted); font-size: 13px; }
.palette li svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.palette .group { font-size: 11.5px; color: var(--muted); padding: 10px 12px 4px; font-weight: 600; }

.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; justify-items: center; pointer-events: none; }
.toast { background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); color: var(--ink); padding: 11px 18px; border-radius: 99px; font-size: 14px; font-weight: 500; box-shadow: 0 8px 30px rgba(0,0,0,.14), 0 0 0 .5px var(--line-strong); max-width: min(440px, calc(100vw - 32px)); animation: drop .3s cubic-bezier(.2, .9, .3, 1); }
.toast.err { color: var(--red); }
@keyframes drop { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

.logo-prev { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo-prev img { max-height: 48px; max-width: 160px; border-radius: var(--r-s); padding: 6px; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.settings { display: grid; gap: 20px; max-width: 820px; }
.settings h3 { margin-bottom: 2px; }
.settings .hint { font-size: 13px; color: var(--ink-2); }
.theme-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.theme-pick button { border: 0; background: none; padding: 0; cursor: pointer; display: grid; gap: 8px; justify-items: center; font-size: 13px; font-weight: 500; color: var(--ink); }
.theme-pick .sw { width: 100%; max-width: 150px; aspect-ratio: 16 / 10; border-radius: 10px; box-shadow: 0 0 0 1px var(--line-strong); overflow: hidden; display: grid; grid-template-columns: 30% 1fr; }
.theme-pick .sw i { display: block; }
.theme-pick .sw-light i:first-child { background: #ECECF0; } .theme-pick .sw-light i:last-child { background: #fff; }
.theme-pick .sw-dark i:first-child { background: #2C2C2E; } .theme-pick .sw-dark i:last-child { background: #1C1C1E; }
.theme-pick .sw-auto { background: linear-gradient(135deg, #fff 50%, #1C1C1E 50%); grid-template-columns: 1fr; }
.theme-pick button[aria-pressed="true"] .sw { box-shadow: 0 0 0 3px var(--accent); }
.danger-zone h3 { color: var(--red); }
.loading { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }

#print-root { display: none; }

/* ---------- Responsiv ---------- */
@media (max-width: 1180px) {
  .editor { grid-template-columns: 1fr; }
  .preview { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 50; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); }
  .rail .brand, .rail-bottom, .rail-new { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .nav a { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 2px; text-align: center; color: var(--muted); }
  .nav a svg { width: 23px; height: 23px; color: var(--muted); }
  .nav a[aria-current="page"] { background: transparent; color: var(--accent); }
  .nav a[aria-current="page"] svg { color: var(--accent); }
  .main { padding: 14px 16px 110px; }
  .search-trigger { width: auto; flex: 1; }
  .search-trigger kbd { display: none; }
  h1 { font-size: 30px; }
  .grid-2, .grid-3, .tiles { grid-template-columns: 1fr; }
  .tiles { gap: 10px; }
  .item { grid-template-columns: 1fr 1fr 34px; }
  .item .it-title { grid-column: 1 / 3; }
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row .hide-sm { display: none; }
  .toolbar .input { max-width: none; width: 100%; }
  .toolbar .segmented { overflow-x: auto; max-width: 100%; }
  .theme-pick { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Druck ---------- */
@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff !important; }
  #app, .toasts, dialog { display: none !important; }
  #print-root { display: block; }
  .sheet .sh-pay, .sheet table tr { break-inside: avoid; }
}
