/* Belegfinder v2 – Oberfläche */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --accent: #0f766e;
  --accent-hover: #0d655e;
  --accent-weak: #d9f2ee;
  --accent-text: #0b5a54;
  --danger: #b91c1c;
  --danger-weak: #fee2e2;
  --warn: #b45309;
  --warn-weak: #fff3e0;
  --info: #1d4ed8;
  --info-weak: #e8f0fe;
  --ok: #047857;
  --ok-weak: #e3f6ee;
  --neutral: #475569;
  --neutral-weak: #eef2f6;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 236px;
  --drawer-w: 560px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #111a2b;
    --surface-2: #16213a;
    --surface-3: #1c2a45;
    --border: #233350;
    --border-strong: #324768;
    --text: #e6edf7;
    --text-2: #c3cfdf;
    --muted: #8a9bb3;
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-weak: #0f3b3a;
    --accent-text: #9ff0e6;
    --danger: #f87171;
    --danger-weak: #3b1414;
    --warn: #fbbf24;
    --warn-weak: #3a2a0c;
    --info: #60a5fa;
    --info-weak: #13244a;
    --ok: #34d399;
    --ok-weak: #0d3328;
    --neutral: #b7c3d4;
    --neutral-weak: #1c2a45;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
    --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.8);
  }
}

* { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.xs { font-size: .78rem; }
.mono { font-family: var(--mono); font-size: .85em; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boot { padding: 48px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

/* Layout */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent); flex: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M9 8h10l5 5v11a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1z' fill='none' stroke='%23fff' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M12 17l3 3 6-6' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 100%;
}
.brand-title { font-weight: 700; font-size: 1.05rem; }
.brand-sub { font-size: .75rem; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--text-2);
  font-weight: 500; font-size: .95rem;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-weak); color: var(--accent-text); }
.nav a .icon { width: 18px; height: 18px; opacity: .85; }
.nav .count { margin-left: auto; font-size: .75rem; background: var(--surface-3); color: var(--text-2); padding: 1px 8px; border-radius: 99px; }
.nav .count.warn { background: var(--warn-weak); color: var(--warn); }
.sidebar-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--border); font-size: .82rem; color: var(--muted); }
.sidebar-foot .user { color: var(--text); font-weight: 600; }
.main { min-width: 0; padding: 22px 26px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; gap: 4px; overflow-x: auto; z-index: 20; }
  .brand { padding: 0 8px 0 0; }
  .brand-sub, .sidebar-foot, .nav a span.label { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { padding: 8px; }
  .nav .count { margin-left: 4px; }
  .main { padding: 14px 14px 80px; }
  :root { --drawer-w: 100vw; }
}

/* Cards & KPIs */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card h2 { margin-bottom: 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); cursor: pointer; text-align: left; transition: transform .08s, box-shadow .12s; position: relative; }
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.kpi.active { outline: 2px solid var(--accent); outline-offset: -2px; }
.kpi .kpi-label { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .kpi-value { font-size: 1.7rem; font-weight: 700; margin-top: 2px; line-height: 1.1; }
.kpi .kpi-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.kpi .dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.offen { background: var(--warn); } .dot.vorschlag { background: var(--info); } .dot.zugeordnet { background: var(--ok); }
.dot.kein_beleg { background: var(--neutral); } .dot.ignoriert { background: var(--border-strong); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 500; font-size: .88rem; line-height: 1.2; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .icon { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #04302d; } }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: var(--danger-weak); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 4px 8px; font-size: .8rem; }
.btn-icon { padding: 6px; }
.btn-icon .icon { width: 16px; height: 16px; }
.btn-block { width: 100%; justify-content: center; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--text-2); }
.field > span { font-weight: 500; }
.input, .select, .textarea {
  padding: 7px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: .9rem; min-width: 0;
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
.textarea { resize: vertical; min-height: 64px; }
.select { padding-right: 26px; }
.input-sm { padding: 5px 8px; font-size: .84rem; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.toggle { position: relative; width: 36px; height: 20px; border-radius: 99px; background: var(--border-strong); border: none; padding: 0; flex: none; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.toggle.on { background: var(--accent); }
.toggle.on::after { left: 18px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .input { min-width: 240px; flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 10px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); font-size: .8rem; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--accent-weak); border-color: var(--accent); color: var(--accent-text); }
.chip .x { opacity: .6; }

/* Zeitraum-Kalender */
.drp { position: relative; }
.drp .btn.drp-active { border-color: var(--accent); color: var(--accent-text); background: var(--accent-weak); }
.drp-x { margin-left: 6px; opacity: .7; font-size: .8rem; padding: 0 2px; }
.drp-x:hover { opacity: 1; }
.drp-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 12px; display: flex; gap: 14px; }
.drp-pop.right { left: auto; right: 0; }
.drp-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.drp-months { display: flex; gap: 18px; }
.drp-month { width: 238px; }
.drp-title { font-weight: 600; font-size: .88rem; text-align: center; margin-bottom: 6px; }
.drp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px 0; }
.drp-wd { font-size: .68rem; color: var(--muted); text-align: center; padding-bottom: 4px; }
.drp-day { height: 32px; border: none; background: transparent; border-radius: 8px; font-size: .84rem; color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.drp-day:hover { background: var(--surface-3); }
.drp-day.future { color: var(--muted); }
.drp-day.in { background: var(--accent-weak); color: var(--accent-text); border-radius: 0; }
.drp-day.start, .drp-day.end { background: var(--accent); color: #fff; font-weight: 600; }
.drp-day.start { border-radius: 8px 0 0 8px; }
.drp-day.end { border-radius: 0 8px 8px 0; }
.drp-day.start.end { border-radius: 8px; }
.drp-day.today { box-shadow: inset 0 0 0 1px var(--border-strong); }
@media (prefers-color-scheme: dark) { .drp-day.start, .drp-day.end { color: #04302d; } }
.drp-presets { display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--border); padding-left: 12px; min-width: 140px; }
.drp-presets .btn { justify-content: flex-start; }
@media (max-width: 760px) {
  .drp-pop { position: fixed; left: 12px; right: 12px; top: 12%; flex-direction: column; max-height: 80vh; overflow: auto; }
  .drp-months { flex-direction: column; gap: 8px; }
  .drp-month { width: 100%; }
  .drp-presets { border-left: none; border-top: 1px solid var(--border); padding: 10px 0 0; flex-direction: row; flex-wrap: wrap; }
}

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: .74rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.badge-offen { background: var(--warn-weak); color: var(--warn); }
.badge-vorschlag { background: var(--info-weak); color: var(--info); }
.badge-zugeordnet { background: var(--ok-weak); color: var(--ok); }
.badge-kein_beleg { background: var(--neutral-weak); color: var(--neutral); }
.badge-ignoriert { background: var(--surface-3); color: var(--muted); text-decoration: line-through; }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-accent { background: var(--accent-weak); color: var(--accent-text); }
.badge-danger { background: var(--danger-weak); color: var(--danger); }
.tag { font-size: .72rem; color: var(--muted); background: var(--surface-3); padding: 1px 6px; border-radius: 5px; white-space: nowrap; }

/* Table */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 600; font-size: .76rem; color: var(--muted); letter-spacing: .03em; text-transform: uppercase; padding: 10px 12px; border-bottom: 1px solid var(--border); z-index: 1; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr.selected td { background: var(--accent-weak); }
.table tbody tr.dim td { opacity: .6; }
.table .amount { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; font-weight: 600; }
.table .amount.pos { color: var(--ok); }
.vendor { font-weight: 600; }
.purpose { color: var(--muted); font-size: .8rem; margin-top: 1px; max-width: 520px; }
.doc-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.doc-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 6px; background: var(--surface-3); font-size: .78rem; max-width: 260px; }
.doc-chip.suggest { border: 1px dashed var(--border-strong); background: transparent; }
.doc-chip .icon { width: 12px; height: 12px; flex: none; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: .85rem; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: .85rem; color: var(--muted); justify-content: space-between; }
.bulkbar { position: sticky; bottom: 12px; display: flex; gap: 8px; align-items: center; padding: 10px 14px; margin-top: 12px; background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow-lg); flex-wrap: wrap; z-index: 5; }

/* Drawer */
.drawer-back { position: fixed; inset: 0; background: rgba(2, 6, 23, .35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: var(--drawer-w); max-width: 100vw; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 41; display: flex; flex-direction: column; animation: slidein .16s ease-out; }
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 12px; }
.drawer-body { padding: 16px 20px 32px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 18px; }
.drawer h1 { font-size: 1.15rem; }
.drawer .amount-big { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: .86rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.section-title h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }

/* Belegvorschau links neben dem Drawer (breite Bildschirme) */
.drawer-pdf { position: fixed; top: 0; bottom: 0; right: var(--drawer-w); width: min(820px, calc(100vw - var(--drawer-w) - 16px)); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 41; display: flex; flex-direction: column; animation: slidein .16s ease-out; }
.drawer-pdf-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.drawer-pdf iframe { flex: 1; width: 100%; border: none; background: #525659; }
.match-ok { color: var(--ok); font-weight: 600; }
.match-diff { color: var(--warn); font-weight: 600; }
.ai-verdict { margin-top: 6px; font-size: .8rem; padding: 4px 8px; border-radius: 6px; border-left: 3px solid; }
.ai-verdict.ai-yes { background: var(--ok-weak); color: var(--ok); border-color: var(--ok); }
.ai-verdict.ai-no { background: var(--danger-weak); color: var(--danger); border-color: var(--danger); }
.ai-verdict.ai-unsure { background: var(--info-weak); color: var(--info); border-color: var(--info); }

/* Kontierung */
.badge-pruefen { background: var(--warn-weak); color: var(--warn); }
.badge-kvorschlag { background: var(--info-weak); color: var(--info); }
.badge-geprueft { background: var(--ok-weak); color: var(--ok); }
.dot.pruefen { background: var(--warn); } .dot.kvorschlag { background: var(--info); } .dot.geprueft { background: var(--ok); }
.konto { font-family: var(--mono); font-weight: 700; font-size: .88rem; background: var(--surface-3); padding: 1px 6px; border-radius: 5px; }
.kform { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.kform .select, .kform .input { width: 100%; }
.hint-list { font-size: .82rem; color: var(--warn); background: var(--warn-weak); padding: 8px 10px; border-radius: 8px; display: flex; flex-direction: column; gap: 2px; }
.excerpt { white-space: pre-wrap; font-family: var(--mono); font-size: .74rem; max-height: 300px; overflow: auto; background: var(--surface-2); padding: 10px; border-radius: 8px; border: 1px solid var(--border); margin: 0; }
.konto-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; font-size: .78rem; color: var(--text-2); }
.konto-line:hover { text-decoration: none; }

/* Document cards */
.doc { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.doc.suggest { border-style: dashed; background: transparent; }
.doc.active { outline: 2px solid var(--accent); outline-offset: -1px; }
.doc .doc-thumb:hover { outline: 2px solid var(--accent); }
.doc-thumb { width: 56px; height: 72px; border-radius: 6px; object-fit: cover; object-position: top; background: var(--surface-3); border: 1px solid var(--border); cursor: zoom-in; }
.doc-title { font-weight: 600; font-size: .9rem; }
.doc-meta { color: var(--muted); font-size: .8rem; display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.doc-reasons { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.doc-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.score { font-size: .72rem; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); color: var(--text-2); }
.score.hi { background: var(--ok-weak); color: var(--ok); } .score.mid { background: var(--info-weak); color: var(--info); }

.docgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.docgrid .doc { grid-template-columns: 56px 1fr; }

/* Misc */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: .88rem; border: 1px solid; }
.alert-error { background: var(--danger-weak); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-warn { background: var(--warn-weak); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert-info { background: var(--info-weak); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert-ok { background: var(--ok-weak); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; opacity: .4; margin-bottom: 8px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }
.jobbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--accent-weak); color: var(--accent-text); font-size: .85rem; margin-bottom: 12px; }
.jobbar .progress { flex: 1; }

.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { pointer-events: auto; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .88rem; box-shadow: var(--shadow-lg); max-width: 520px; animation: slideup .18s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes slideup { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-back { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(760px, 100%); max-height: 92vh; display: flex; flex-direction: column; border: 1px solid var(--border); }
.modal.wide { width: min(1100px, 100%); height: 92vh; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.modal iframe { width: 100%; height: 100%; border: none; border-radius: 8px; background: var(--surface-3); flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); background: var(--surface-2); transition: border-color .12s, background .12s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-weak); color: var(--accent-text); }
.dropzone input { display: none; }

.months { display: flex; gap: 4px; align-items: flex-end; height: 56px; }
.months .m { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; height: 100%; position: relative; }
.months .bar { border-radius: 3px 3px 0 0; min-height: 2px; }
.months .bar.open { background: var(--warn); } .months .bar.ok { background: var(--ok); opacity: .7; }
.months .lbl { font-size: .62rem; color: var(--muted); text-align: center; margin-top: 2px; }

.timeline { font-size: .82rem; display: flex; flex-direction: column; gap: 6px; }
.timeline .t { display: grid; grid-template-columns: 120px 1fr; gap: 10px; color: var(--text-2); }
.timeline .t .ts { color: var(--muted); font-variant-numeric: tabular-nums; }
.rule-cond { font-family: var(--mono); font-size: .8rem; background: var(--surface-3); padding: 2px 6px; border-radius: 5px; }
kbd { font-family: var(--mono); font-size: .78em; background: var(--surface-3); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 16px; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-title { font-weight: 700; font-size: 1.2rem; }
.login-sub { color: var(--muted); font-size: .85rem; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.btn-google { justify-content: center; padding: 11px 16px; font-size: .95rem; font-weight: 600; gap: 10px; width: 100%; }
.login-hint { margin: -6px 0 0; font-size: .8rem; color: var(--muted); text-align: center; }
.login-details summary { cursor: pointer; color: var(--muted); font-size: .85rem; text-align: center; padding: 4px; }
.login-details[open] summary { margin-bottom: 10px; }

/* --- Portale (Rechnungsabruf über den Browser-Worker) --- */
.portal-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 18px; }
.portal-card { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: flex; flex-direction: column; gap: 8px; transition: transform .08s, box-shadow .12s; }
.portal-card:hover { box-shadow: var(--shadow); }
.portal-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak, rgba(99,102,241,.25)); }
.portal-card.off { opacity: .55; }
.portal-card .pc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.portal-card .pc-name { font-weight: 650; }
.portal-card .pc-counts { display: flex; gap: 10px; font-size: .8rem; color: var(--muted); flex-wrap: wrap; }
.portal-card .pc-counts b { color: var(--text); font-variant-numeric: tabular-nums; }
.portal-card .pc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.badge-login { background: var(--warn-weak); color: var(--warn); }
.badge-verbunden { background: var(--ok-weak); color: var(--ok); }
.badge-fehler { background: var(--danger-weak); color: var(--danger); }
.badge-geladen { background: var(--ok-weak); color: var(--ok); }
.badge-fehlt { background: var(--warn-weak); color: var(--warn); }
.badge-angefordert { background: var(--info-weak, var(--surface-3)); color: var(--info); }
.badge-manuell { background: var(--surface-3); color: var(--text-2); }
.badge-uebersprungen { background: var(--surface-3); color: var(--muted); }
.dot.geladen { background: var(--ok); } .dot.fehlt { background: var(--warn); } .dot.angefordert { background: var(--info); }
.dot.manuell { background: var(--border-strong); } .dot.fehler { background: var(--danger); } .dot.uebersprungen { background: var(--border); }
.remote { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 14px; }
.remote-screen { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; cursor: crosshair; aspect-ratio: 1280 / 900; }
.remote-screen img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; }
.remote-screen .remote-wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--surface-2); }
.remote-side { display: flex; flex-direction: column; gap: 10px; }
.remote-side .keys { display: flex; gap: 6px; flex-wrap: wrap; }
.remote-url { font-size: .72rem; color: var(--muted); word-break: break-all; }
.runlog { font-family: var(--mono); font-size: .72rem; white-space: pre-wrap; max-height: 260px; overflow: auto; background: var(--surface-2); padding: 10px; border-radius: 8px; }
@media (max-width: 900px) { .remote { grid-template-columns: 1fr; } }
/* Anmeldefenster (#/anmelden/<key>) */
.login-page { display: flex; flex-direction: column; height: 100vh; background: var(--bg); }
.login-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.login-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 12px; padding: 12px; min-height: 0; }
.login-screen { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; cursor: default; outline: none; min-height: 0; }
.login-screen.focused { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak, rgba(99,102,241,.25)); }
.login-screen img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: top left; user-select: none; }
.login-screen .remote-wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.login-hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: rgba(17,24,39,.8); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: .8rem; pointer-events: none; }
.login-side { display: flex; flex-direction: column; gap: 10px; }
.login-side .keys { display: flex; gap: 6px; flex-wrap: wrap; }
.login-needed { margin-bottom: 16px; }
.login-needed .ln-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.login-needed .ln-row:last-child { border-bottom: 0; }
@media (max-width: 900px) { .login-body { grid-template-columns: 1fr; } }

/* Auswahlliste (Select-Komponente, components.js) */
.sel { display: inline-flex; position: relative; max-width: 100%; }
.field .sel, .sel.block { display: flex; }
.sel-trigger { display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; text-align: left;
  padding-right: 8px !important; width: 100%; min-height: 34px; font: inherit; font-size: .9rem; transition: border-color .12s, background .12s; }
.sel-trigger.input-sm { min-height: 28px; font-size: .84rem; }
.sel-trigger:hover:not(:disabled) { border-color: var(--accent); }
.sel-trigger.open { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.sel-trigger:disabled { opacity: .55; cursor: not-allowed; }
.sel-trigger svg { width: 16px; height: 16px; flex: none; color: var(--muted); transition: transform .15s; }
.sel-trigger.open svg { transform: rotate(180deg); }
.sel-sizer { display: grid; min-width: 0; max-width: 300px; overflow: hidden; }
.field .sel-sizer, .sel.block .sel-sizer { max-width: none; }
.sel-sizer > span { grid-area: 1 / 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-sizer > span[aria-hidden] { visibility: hidden; height: 0; }
.sel-pop { position: fixed; z-index: 1000; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; max-width: min(420px, calc(100vw - 24px));
  animation: sel-in .12s ease-out; }
@keyframes sel-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.sel-search { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.sel-search svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.sel-search input { border: none; outline: none; background: transparent; color: var(--text); font: inherit; font-size: .88rem; width: 100%; }
.sel-list { overflow-y: auto; padding: 4px; }
.sel-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; border-radius: 8px;
  font-size: .88rem; color: var(--text); cursor: pointer; white-space: nowrap; }
.sel-opt .sel-label { overflow: hidden; text-overflow: ellipsis; }
.sel-opt.active { background: var(--surface-3); }
.sel-opt.selected { font-weight: 600; color: var(--accent-text); }
.sel-opt.selected svg { width: 15px; height: 15px; color: var(--accent); flex: none; }
.sel-opt.disabled { opacity: .45; cursor: not-allowed; }
.sel-group { padding: 8px 10px 4px; font-size: .7rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.sel-empty { padding: 10px; font-size: .85rem; color: var(--muted); }
