/* ===== Tokens ===== */
:root {
  --bg: #f4f5f2;
  --bg-grad: radial-gradient(1200px 500px at 85% -10%, rgba(15, 118, 110, .10), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f7f8f6;
  --border: #e3e6e1;
  --border-strong: #cfd4cd;
  --text: #17201d;
  --text-2: #5c6762;
  --text-3: #8a948f;
  --accent: #0f766e;
  --accent-hover: #0b5f58;
  --accent-soft: #e2f2ef;
  --accent-text: #ffffff;
  --danger: #c2410c;
  --danger-soft: #fdece4;
  --ok: #15803d;
  --ok-soft: #e3f4e8;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 16px rgba(20, 30, 25, .05);
  --shadow-lg: 0 10px 40px rgba(20, 30, 25, .14);
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e1412;
  --bg-grad: radial-gradient(1200px 500px at 85% -10%, rgba(45, 212, 191, .08), transparent 60%);
  --surface: #161e1b;
  --surface-2: #1c2622;
  --border: #26322e;
  --border-strong: #34433e;
  --text: #e7eeeb;
  --text-2: #a3b0ab;
  --text-3: #71807a;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-soft: rgba(45, 212, 191, .12);
  --accent-text: #06201c;
  --danger: #fb923c;
  --danger-soft: rgba(251, 146, 60, .12);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0e1412;
    --bg-grad: radial-gradient(1200px 500px at 85% -10%, rgba(45, 212, 191, .08), transparent 60%);
    --surface: #161e1b;
    --surface-2: #1c2622;
    --border: #26322e;
    --border-strong: #34433e;
    --text: #e7eeeb;
    --text-2: #a3b0ab;
    --text-3: #71807a;
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-soft: rgba(45, 212, 191, .12);
    --accent-text: #06201c;
    --danger: #fb923c;
    --danger-soft: rgba(251, 146, 60, .12);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  font-feature-settings: 'cv11', 'ss01';
  transition: background-color .2s, color .2s;
}
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--text-2); margin: .25rem 0 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  height: 62px; display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent); color: var(--accent-text);
}
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab {
  padding: 7px 14px; border-radius: 999px; text-decoration: none;
  color: var(--text-2); font-weight: 500; font-size: .93rem; transition: background .15s, color .15s;
  white-space: nowrap; flex: none;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--accent); background: var(--accent-soft); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-mail { color: var(--text-2); font-size: .88rem; }

/* ===== Layout ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.col-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.col-side { position: sticky; top: 84px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ===== Card ===== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head .card-title { margin: 0; }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.sub-title { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 18px 0 4px; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.span-2 { grid-column: span 2; }
.span-full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: .82rem; font-weight: 500; color: var(--text-2); }
.hint { color: var(--text-3); font-size: .8rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select {
  width: 100%; height: 42px; padding: 0 12px;
  font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
select {
  appearance: none; cursor: pointer; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%238a948f' stroke-width='3' stroke-linecap='round' d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input.num { font-family: var(--mono); text-align: right; font-size: .92rem; }
.input-affix { position: relative; display: flex; }
.input-affix .affix {
  position: absolute; top: 0; bottom: 0; left: 12px; display: grid; place-items: center;
  color: var(--text-3); font-size: .88rem; pointer-events: none;
}
.input-affix input { padding-left: 30px; }
.input-affix.affix-right .affix { left: auto; right: 12px; }
.input-affix.affix-right input { padding-left: 12px; padding-right: 32px; }
.input-affix input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: .9rem; text-decoration: none;
  border: 1px solid transparent; cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 32px; padding: 0 11px; font-size: .84rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text-2); cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* Copy button (icon via CSS mask) */
.copy-btn {
  flex: none; width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; cursor: pointer; position: relative; color: var(--text-3);
  transition: background .15s, color .15s, border-color .15s;
}
.copy-btn::before {
  content: ''; position: absolute; inset: 7px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='12' height='12' rx='2'/%3E%3Cpath d='M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='12' height='12' rx='2'/%3E%3Cpath d='M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}
.copy-btn:hover { background: var(--accent-soft); color: var(--accent); }
.copy-btn.copied { color: var(--ok); background: var(--ok-soft); }
.copy-btn.copied::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' d='m5 12 5 5 9-10'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' d='m5 12 5 5 9-10'/%3E%3C/svg%3E");
}

/* ===== Teilrechnungen ===== */
.tr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tr-row {
  display: grid; grid-template-columns: 130px minmax(0, 1fr) 36px; align-items: center; gap: 12px;
  animation: slideIn .18s ease-out;
}
.tr-label { font-weight: 500; color: var(--text-2); font-size: .9rem; white-space: nowrap; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-4px); } }
.empty { color: var(--text-3); text-align: center; padding: 18px; margin: 0; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.tr-total {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 30px; align-items: center; gap: 10px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); font-weight: 600;
}
.tr-total > span:first-child { color: var(--text-2); font-size: .9rem; }

/* ===== Result ===== */
.money { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.money.neg { color: var(--danger); }
.hero-result {
  background: var(--accent-soft); border-radius: var(--radius-sm); padding: 16px 16px 14px; margin-bottom: 8px;
}
.hero-label { font-size: .8rem; font-weight: 500; color: var(--accent); }
.hero-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.hero-value { font-size: 1.75rem; font-weight: 500; color: var(--text); letter-spacing: -.02em; }
.result-list { margin: 0; }
.result-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.result-row:last-child { border-bottom: 0; }
.result-row dt { color: var(--text-2); font-size: .9rem; display: flex; align-items: center; gap: 8px; }
.result-row dd { margin: 0; display: flex; align-items: center; gap: 6px; }
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: .72rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border);
}
.check-badge {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  font-size: .7rem; font-weight: 700; background: var(--ok-soft); color: var(--ok);
}
.check-badge.bad { background: var(--danger-soft); color: var(--danger); }

/* ===== Firmenliste ===== */
.inline-form { display: flex; gap: 8px; margin-bottom: 12px; }
.inline-form input { flex: 1; }
.filter { margin-bottom: 8px; }
.firm-list { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto; }
.firm-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 4px 4px 10px; border-radius: var(--radius-sm);
}
.firm-list li:hover { background: var(--surface-2); }
.firm-list li.new { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } }

/* ===== Segmented ===== */
.segmented { display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.segmented button {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
  border: 0; border-radius: 9px; background: transparent; color: var(--text-2);
  font: inherit; font-weight: 500; font-size: .9rem; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: .9rem; font-weight: 500; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* ===== Auth pages ===== */
.auth-body { display: grid; place-items: center; padding: 24px 16px; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; font-size: 1.1rem; margin-bottom: 20px; }
.auth-card { padding: 30px; }
.auth-card h1 { font-size: 1.35rem; }
.auth-card form { margin-top: 20px; }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: .9rem; margin-top: 16px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }

/* ===== Responsive ===== */
@media (max-width: 1020px) {
  .grid { grid-template-columns: 1fr; }
  .col-side { position: static; }
}
/* Reiter in eigene Zeile, sobald die vier Reiter nicht mehr neben Logo und Mail passen */
@media (max-width: 1100px) {
  .topbar-inner { gap: 10px; height: auto; min-height: 58px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .user-mail { display: none; }
  .tabs { order: 3; width: 100%; margin: 0; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  /* Verlauf zeigt an, dass links/rechts noch Reiter sind */
  .tabs.more-right { -webkit-mask-image: linear-gradient(to right, #000 80%, transparent); mask-image: linear-gradient(to right, #000 80%, transparent); }
  .tabs.more-left { -webkit-mask-image: linear-gradient(to left, #000 80%, transparent); mask-image: linear-gradient(to left, #000 80%, transparent); }
  .tabs.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 15%, #000 85%, transparent); mask-image: linear-gradient(to right, transparent, #000 15%, #000 85%, transparent); }
}
@media (max-width: 760px) {
  .topbar-inner { padding-left: 16px; padding-right: 16px; }
  .brand-text { display: none; }
  .tab { padding: 6px 12px; }
  .container { padding: 20px 16px 48px; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: 1 / -1; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .tr-row { grid-template-columns: auto minmax(0, 1fr) 36px; gap: 10px; }
  .card { padding: 18px; }
  /* ≥ 16px verhindert das automatische Hineinzoomen von iOS Safari beim Antippen */
  input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, input.num { font-size: 16px; }
  .hero-value { font-size: 1.5rem; }
}
@media (max-width: 420px) {
  .form-grid { grid-template-columns: 1fr; }
  .tr-row { grid-template-columns: minmax(0, 1fr) 36px; }
  .tr-label { grid-column: 1 / -1; margin-bottom: -4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== Projekte: Senden-Karte, Projekt-Tabellen, Dialoge ===== */

.small { font-size: .82rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }

/* Senden-Karte in den Rechnern */
.send-card { margin-top: 20px; }
.send-card .muted { margin: -6px 0 12px; }
/* Werte untereinander (Beschriftung links, Betrag rechts) – so wird kein Betrag abgeschnitten */
.send-preview { display: flex; flex-direction: column; margin: 0 0 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 12px; }
.send-preview > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0; }
.send-preview > div + div { border-top: 1px solid var(--border); }
.send-preview dt { font-size: .84rem; color: var(--text-2); }
.send-preview dd { margin: 0; font-size: .9rem; white-space: nowrap; }
.send-row { display: flex; gap: 8px; }
.send-row select { flex: 1; min-width: 0; }

/* Unter-Navigation der Projekte */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 18px; }
.subnav-item {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); text-decoration: none; font-size: .88rem; font-weight: 500; white-space: nowrap;
}
.subnav-item:hover { color: var(--text); border-color: var(--border-strong); }
.subnav-item.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* Projekt-Tabelle – passt ohne seitliches Scrollen:
   breit = kompakte Tabelle über die volle Fensterbreite, schmal (≤ 1340 px) = eine Karte je Rechnung */
.container:has(> .view[data-view="projekte"]:not([hidden])) { max-width: 1680px; }
.table-wrap { overflow-x: auto; }
.ptable { width: 100%; border-collapse: collapse; font-size: .84rem; }
.ptable th {
  text-align: left; font-size: .7rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .02em;
  padding: 6px 6px; border-bottom: 1px solid var(--border-strong); line-height: 1.25; vertical-align: bottom;
}
.ptable td { padding: 7px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ptable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ptable .cell-title { min-width: 96px; }
.ptable tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.ptable tr.row-link { cursor: pointer; }
.ptable tr.row-link:hover { background: var(--accent-soft); }
.ptable tfoot td { font-weight: 700; border-top: 2px solid var(--border-strong); border-bottom: 0; padding-top: 10px; }
.ptable td.act, .ptable th.act { width: 64px; padding: 2px 0; text-align: right; white-space: nowrap; }
.icon-btn.sum-btn { width: 28px; font-weight: 700; font-size: 1rem; color: var(--text-3); }
.icon-btn.sum-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn.sum-btn.aus { background: #fde2d0; color: #7f3200; text-decoration: line-through; }
.ptable a { color: var(--text); font-weight: 600; text-decoration: none; }

@media (max-width: 1340px) {
  .ptable thead { display: none; }
  .ptable, .ptable tbody, .ptable tfoot { display: block; }
  .ptable tr {
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; position: relative;
    padding: 12px 14px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  }
  .ptable tbody tr:nth-child(even) { background: var(--surface); }
  .ptable td { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 4px 0; border: 0; min-width: 0; }
  .ptable td[data-label]::before {
    content: attr(data-label); font-family: var(--font); font-size: .74rem; color: var(--text-3); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }
  .ptable .cell-title { grid-column: 1 / -1; font-weight: 600; font-size: .95rem; padding-right: 40px; display: block; }
  .ptable .cell-date { grid-column: 1 / -1; color: var(--text-2); padding-top: 0; margin-bottom: 4px; }
  .ptable .cell-date:empty { display: none; }
  .ptable td.act { position: absolute; top: 6px; right: 6px; width: auto; }
  .ptable td.act:empty { display: none; }
  .ptable tfoot tr { background: var(--accent-soft); border-color: transparent; }
  .ptable tfoot td { border: 0; padding-top: 4px; }
  .ptable td[colspan] { grid-column: 1 / -1; justify-content: center; }
}
@media (max-width: 520px) {
  .ptable tr { grid-template-columns: 1fr; }
}
.card-title .tag { white-space: nowrap; flex: none; }
/* Skonto-% vom Brutto, klein rechts neben dem Betrag (feste Breite, damit die Beträge bündig bleiben) */
.pct-hint { display: inline-block; width: 3.1em; margin-left: 4px; font-size: .7rem; font-weight: 500; color: var(--text-3); text-align: right; }
.src-tag {
  display: inline-block; font-size: .66rem; font-weight: 700; padding: 0 5px; border-radius: 4px; margin-left: 4px;
  background: var(--accent-soft); color: var(--accent); vertical-align: 1px;
}
.legend { margin: 12px 0 0; }
.ptable-filter { width: 260px; max-width: 100%; margin: 0; height: 36px; }

/* Dialoge */
.dialog {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: min(720px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog-sm { width: min(460px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(10, 15, 13, .45); backdrop-filter: blur(2px); }
.dialog h2 { font-size: 1.15rem; margin-bottom: 16px; }
.dialog .send-preview { margin-top: 16px; }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.dialog-actions .spacer { flex: 1; }
.danger-text { color: var(--danger); }
.danger-text:hover { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 760px) {
  .card-head:has(.ptable-filter) { flex-wrap: wrap; }
  .ptable-filter { width: 100%; }
  .dialog { padding: 18px; }
}

/* PDF-Knopf, wenn im Projekt ein Suchfilter aktiv ist (Farbe wie die Filter-Färbung in Excel) */
.btn.btn-filter { background: #f4b183; border-color: #f4b183; color: #7f3200; }
.btn.btn-filter:hover { background: #efa06a; }

/* Zeilen, deren tats. Betrag nicht zur Summe zählt */
.src-tag.src-abzug { background: #fde2d0; color: #7f3200; }
.ptable td.abgezogen { text-decoration: line-through; color: var(--text-3); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: .88rem; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
/* Kartenansicht: leerer Skonto-%-Platzhalter braucht keinen Platz */
@media (max-width: 1340px) {
  .ptable .pct-hint:empty { width: 0; margin: 0; }
}

/* ===== Zeitraum-Filter (Projekte) ===== */
.zeitraum {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: -4px 0 18px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.zeitraum.aktiv { border-color: #f4b183; box-shadow: inset 4px 0 0 #f4b183; }
.zr-titel { font-weight: 600; font-size: .88rem; }
.zr-feld { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--text-2); }
.zr-feld input { height: 34px; width: 150px; }
.zr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.zr-chip {
  height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); font: inherit; font-size: .82rem; font-weight: 500; cursor: pointer;
}
.zr-chip:hover { color: var(--text); border-color: var(--border-strong); }
.zr-chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.zeitraum.aktiv .zr-chip.on { background: #f4b183; border-color: #f4b183; color: #7f3200; }
.zr-info { flex-basis: 100%; font-size: .8rem; color: #b45309; }
:root[data-theme="dark"] .zr-info { color: #f4b183; }
.tag.tag-zr { background: #fde2d0; color: #7f3200; border-color: #f4b183; }

/* ===== Einstellungen: Projekte & Datensicherung ===== */
.einst-zeile2 { margin-top: 20px; }
.proj-list li, .bk-list li { padding-top: 6px; padding-bottom: 6px; }
.proj-list small, .bk-list small { display: block; }
.bk-list { max-height: 360px; }
.icon-btn[disabled] { opacity: .35; cursor: not-allowed; }
label.btn { cursor: pointer; }
@media (max-width: 760px) {
  .zr-feld { flex: 1 1 140px; }
  .zr-feld input { width: 100%; }
}
/* Zeitraum-Schild in Überschriften darf am Handy umbrechen */
.card-title:has(.tag-zr) { flex-wrap: wrap; }
.card-title .tag.tag-zr { white-space: normal; }
/* lange Namen in den Einstellungs-Listen umbrechen statt die Karte zu verbreitern */
.einst-zeile2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.proj-list strong, .bk-list strong { overflow-wrap: anywhere; }
@media (max-width: 760px) { .einst-zeile2 { grid-template-columns: minmax(0, 1fr); } }
/* Firmen-Filter in der Filterleiste */
.zr-firma-feld select { height: 34px; width: 220px; max-width: 100%; }
.zr-firma-feld.on select { border-color: #f4b183; box-shadow: 0 0 0 2px rgba(244, 177, 131, .35); }
@media (max-width: 760px) { .zr-firma-feld { flex: 1 1 100%; } .zr-firma-feld select { width: 100%; } }

/* ===== Bereitschaft ===== */
.bw-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: -6px 0 16px; padding: 10px 14px;
  border: 1px solid #f4b183; background: #fde2d0; color: #7f3200; border-radius: var(--radius-sm); font-size: .88rem;
}
:root[data-theme="dark"] .bw-banner { background: rgba(244, 177, 131, .14); color: #f4b183; }
.bw-warn { color: #b45309; font-size: .84rem; margin: 10px 0; }
:root[data-theme="dark"] .bw-warn { color: #f4b183; }
.bw-rad { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -6px 0 16px; }
.bw-rad-titel { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-right: 4px; }
.bw-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px 4px 5px; border-radius: 999px; font-size: .84rem;
  border: 1px solid var(--border); background: var(--surface);
}
.bw-chip b {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: .72rem;
  background: var(--surface-2); color: var(--text-2);
}
.bw-chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.bw-chip.on b { background: var(--accent); color: var(--accent-text); }
.bw-pfeil { color: var(--text-3); font-size: .8rem; }
.bw-jetzt-karten { margin-bottom: 16px; gap: 16px; }
.bw-karte { display: flex; flex-direction: column; gap: 4px; padding-top: 14px; padding-bottom: 14px; }
.bw-karte strong { font-size: 1.25rem; }
.bw-jetzt-karten .bw-karte:first-child { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.bw-nav { justify-content: space-between; }
.bw-blaettern { display: flex; align-items: center; gap: 6px; }
.bw-blaettern .icon-btn { font-size: 1.3rem; line-height: 1; }
.bw-titel { min-width: 150px; text-align: center; font-size: 1rem; }
.bwtable { width: 100%; border-collapse: collapse; font-size: .92rem; }
.bwtable th {
  text-align: left; font-size: .7rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .02em;
  padding: 6px 8px; border-bottom: 1px solid var(--border-strong);
}
.bwtable td { padding: 9px 8px; border-bottom: 1px solid var(--border); }
.bwtable tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.bwtable tr.row-link { cursor: pointer; }
.bwtable tr.row-link:hover { background: var(--accent-soft); }
.bwtable tr.bw-jetzt { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.bwtable tr.bw-vorbei td { color: var(--text-3); }
.bwtable .bw-kw { width: 80px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bwtable .bw-datum { width: 210px; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-2); }
.bwtable th.bw-tag { text-align: center; width: 52px; }
.bwtable td.bw-tag { padding: 4px 2px; width: 52px; text-align: center; }
/* Tagesfelder: Feiertag rot, schulfrei gelb, Wochenende grau (gleiche Farben wie im PDF) */
.bw-t {
  display: inline-block; min-width: 44px; padding: 3px 2px; border-radius: 5px; font-size: .84rem; font-weight: 600;
  font-variant-numeric: tabular-nums; line-height: 1.2; color: var(--text); text-align: center;
}
.bw-t small { font-size: .72em; font-weight: 500; opacity: .75; }
.bw-t.ft { background: #fcebeb; color: #791f1f; box-shadow: inset 0 0 0 1px #f09595; }
.bw-t.sf { background: #faeeda; color: #633806; }
.bw-t.we { background: #f1efe8; color: #5f5e5a; }
:root[data-theme="dark"] .bw-t.ft { background: rgba(226, 75, 74, .22); color: #f7c1c1; box-shadow: inset 0 0 0 1px rgba(240, 149, 149, .5); }
:root[data-theme="dark"] .bw-t.sf { background: rgba(239, 159, 39, .2); color: #fac775; }
:root[data-theme="dark"] .bw-t.we { background: rgba(180, 178, 169, .14); color: var(--text-2); }
.bw-t.aus { opacity: .4; }
.bw-legende { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: .8rem; color: var(--text-2); }
.bw-legende span { display: inline-flex; align-items: center; gap: 6px; }
.bw-legende .bw-t, .bt-eintrag .bw-t { min-width: 0; width: 14px; height: 14px; padding: 0; border-radius: 3px; }
.bt-eintrag { display: flex; align-items: flex-start; gap: 10px; }
.bt-eintrag .bw-t { margin-top: 4px; flex: none; }
.bt-list { max-height: 460px; margin-top: 12px; }
.bw-personen li strong { font-weight: 600; }
@media (max-width: 760px) {
  .bw-jetzt-karten { grid-template-columns: 1fr; }
  .bw-nav { justify-content: flex-start; }
  .bwtable .bw-datum { width: auto; white-space: normal; }
  .bwtable td { padding: 8px 6px; }
  .bwtable th.bw-tag, .bwtable td.bw-tag { width: auto; padding: 3px 1px; }
  .bw-t { min-width: 0; width: 100%; font-size: .78rem; padding: 4px 0; }
  .bw-t small { display: none; }
  .bwtable .bw-kw { width: 44px; font-size: .78rem; }
  .bwtable .bw-person { font-size: .84rem; }
  .bwtable .bw-person .src-tag { display: none; }
}

/* ===== Einstellungen: Unter-Reiter ===== */
.einst-nav { margin-top: -6px; }
.einst-schmal { max-width: 820px; }
.einst-seite .card-title + .muted.small { margin-top: -6px; }
.bt-kopf { flex-wrap: wrap; }
.bt-kopf .bw-blaettern { margin-left: auto; margin-right: 8px; }
.bt-jahr { min-width: 48px; text-align: center; font-size: 1.05rem; }
.bt-tabelle { margin-top: 10px; }
.bt-tabelle .bt-datum { white-space: nowrap; color: var(--text-2); font-variant-numeric: tabular-nums; }
.bt-tabelle .bt-tage { text-align: right; width: 60px; color: var(--text-2); }
.bt-tabelle .bt-aktion { width: 44px; text-align: right; padding: 2px 0; }
.bt-art { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.bt-art.ft { background: #fcebeb; color: #791f1f; }
.bt-art.sf { background: #faeeda; color: #633806; }
:root[data-theme="dark"] .bt-art.ft { background: rgba(226, 75, 74, .22); color: #f7c1c1; }
:root[data-theme="dark"] .bt-art.sf { background: rgba(239, 159, 39, .2); color: #fac775; }
.rh-jetzt {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; margin: 12px 0 4px;
  border-radius: var(--radius-sm); background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent);
}
.rh-jetzt strong { font-size: 1.15rem; color: var(--accent); }
.rh-liste { max-height: none; }
.rh-personen { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 14px 12px; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.rh-personen legend { font-size: .8rem; color: var(--text-2); padding: 0 4px; }
.rh-personen .check { margin-top: 8px; }
.rh-ergebnis { margin: 0; font-weight: 600; color: var(--accent); }
.rh-ergebnis.fehler { color: var(--danger); }
@media (max-width: 760px) {
  .bt-kopf .bw-blaettern { margin-left: 0; }
  .bt-tabelle .bt-tage { display: none; }
  .bt-tabelle .bt-datum { white-space: normal; font-size: .8rem; }
  .rh-personen { grid-template-columns: 1fr; }
}

/* ===== Anleitung (Einstellungen → Bereitschaft) ===== */
.hilfe { margin-top: 20px; padding: 0; }
.hilfe summary {
  display: flex; align-items: center; gap: 14px; padding: 16px 20px; cursor: pointer; list-style: none;
}
.hilfe summary::-webkit-details-marker { display: none; }
.hilfe summary::after { content: '▾'; margin-left: auto; color: var(--text-3); transition: transform .2s; }
.hilfe[open] summary::after { transform: rotate(180deg); }
.hilfe summary > span:nth-child(2) { display: flex; flex-direction: column; gap: 2px; }
.hilfe summary small { font-size: .8rem; }
.hilfe-icon {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.hilfe-inhalt {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px 28px;
  padding: 4px 20px 20px; border-top: 1px solid var(--border);
}
.hilfe-inhalt section { padding-top: 14px; }
.hilfe-inhalt h3 { font-size: .95rem; margin: 0 0 6px; color: var(--accent); }
.hilfe-inhalt p, .hilfe-inhalt li { font-size: .88rem; line-height: 1.55; color: var(--text-2); margin: 0 0 8px; }
.hilfe-inhalt strong { color: var(--text); }
.hilfe-inhalt ol, .hilfe-inhalt ul { margin: 0 0 8px; padding-left: 20px; }
.hilfe-farbe { min-width: 0; padding: 1px 7px; font-size: .78rem; }

/* ===== Vertretung für einen einzelnen Tag ===== */
.bwtable td.bw-tag { cursor: pointer; }
.bwtable td.bw-tag:hover .bw-t { box-shadow: inset 0 0 0 1px var(--border-strong); }
.bw-t.vt { box-shadow: inset 0 0 0 2px #7f77dd !important; }
.bw-legende .bw-t.vt { background: #eeedfe; }
.bw-vt {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: .74rem; font-weight: 600;
  background: #eeedfe; color: #3c3489; box-shadow: inset 0 0 0 1px #afa9ec; white-space: nowrap;
}
:root[data-theme="dark"] .bw-vt { background: rgba(127, 119, 221, .2); color: #cecbf6; box-shadow: inset 0 0 0 1px rgba(175, 169, 236, .5); }
:root[data-theme="dark"] .bw-legende .bw-t.vt { background: rgba(127, 119, 221, .2); }
.bw-vt-muster { padding: 0 5px; border-radius: 4px; box-shadow: inset 0 0 0 2px #7f77dd; }
@media (max-width: 760px) {
  .bw-vt { display: block; width: auto; white-space: normal; margin: 3px 0 0; font-size: .68rem; line-height: 1.3; border-radius: 8px; }
}

/* Pflicht-Anteil neben der USt in der Projekt-Zusammenfassung (wie Skonto-% in den Projekttabellen) */
.pct-hint.pflicht-hint { width: 6.6em; margin-left: 6px; }
@media (max-width: 1340px) { .ptable .pflicht-hint:empty { width: 0; margin: 0; } }
