/* ============================================================
   BELEGE-APP — Design System Stylesheet
   Richtung A: Calm Financial / Green Accent
   Source: docs/design-system-belege.md + design_handoff_ausgaben_app/README.md
   Standalone HTML wins on discrepancies.
   ============================================================ */

/* ============================================================
   1. CSS VARIABLES — TOKENS
   ============================================================ */

:root {
  /* --- Colors --- */
  --color-bg:               #E7E5DF;   /* page background / outer canvas */
  --color-surface:          #FFFFFF;   /* cards, list rows */
  --color-surface-warm:     #FBFAF8;   /* export rail, hover bg, month-switcher hover */
  --color-tint-green-row:   #EAF1ED;   /* selected beleg row */
  --color-tint-green-chip:  #E7F1EC;   /* "erfasst" chip bg */
  --color-tint-amber-chip:  #F8EEDC;   /* "zu prüfen" chip bg */
  --color-hairline:         #ECE9E2;   /* topbar border, kpi gaps, card borders */
  --color-hairline-row:     #F1EEE7;   /* between beleg rows */
  --color-border:           #E2DFD7;   /* inputs, secondary buttons */
  --color-accent:           #2F6D58;   /* primary buttons, logo bg, active accents */
  --color-accent-hover:     #275B49;   /* primary button hover / CTA hover */
  --color-warning:          #B5791F;   /* "zu prüfen" chip text, "Offene Belege" value */
  --color-text:             #1B1D1B;   /* primary body text */
  --color-text-muted:       #6B6960;   /* subtitles, descriptions */
  --color-text-muted-alt:   #55534D;   /* category, date cells */
  --color-text-label:       #84827A;   /* kpi labels, column heads */
  --color-text-faint:       #B0ADA3;   /* sub-lines, list count */
  --color-text-faint-alt:   #A09E94;   /* placeholder text, icons */
  --color-mobile-bezel:     #15140F;   /* phone frame */

  /* --- Category colors (dots, bars, progress) --- */
  --cat-infrastruktur:      #2A50DC;
  --cat-saas:               #2F6D58;
  --cat-hardware:           #D97706;
  --cat-reisen:             #B0ADA3;   /* use at opacity 0.45 for empty/zero */
  --cat-gebuehren:          #7C3AED;   /* Gebühren/Behörden — violet */
  --cat-schutzrechte:       #0891B2;   /* Schutzrechte — cyan-blue */
  --cat-buero:              #65A30D;   /* Bürobedarf — olive-green */
  --cat-sonstiges:          #9CA3AF;   /* Sonstiges — neutral gray */

  /* --- Typography --- */
  --font-sans:    'Figtree', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;

  /* --- Spacing scale: 4 · 8 · 12 · 16 · 22 · 24 · 28 --- */
  --sp-1:   4px;
  --sp-2:   8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  22px;
  --sp-6:  24px;
  --sp-7:  28px;

  /* --- Border radius --- */
  --radius-card:    16px;   /* outer card / main cards */
  --radius-hero:    18px;   /* mobile hero (standalone wins over README 16px) */
  --radius-inner:   12px;   /* inner cards (checklist) */
  --radius-btn:      9px;   /* buttons, search, month-switcher */
  --radius-chip:     6px;   /* status chips erfasst / review */
  --radius-badge:    7px;   /* other badges */
  --radius-pill:    99px;   /* category dots, pills, FAB */
  --radius-bar:     7px;    /* chart bars top corners: 7px 7px 0 0 */
  --radius-logo:     8px;   /* logo mark */

  /* --- Shadows --- */
  --shadow-card:   0 1px 2px rgba(0,0,0,.06), 0 18px 50px rgba(40,38,30,.10);
  --shadow-bezel:  0 20px 50px rgba(40,38,30,.18);
  --shadow-fab:    0 8px 18px rgba(47,109,88,.35);
}


/* ============================================================
   2. RESET + BASE
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}


/* ============================================================
   3. TYPOGRAPHY UTILITIES
   ============================================================ */

/* Eyebrow / micro-label — IBM Plex Mono, uppercase */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent);
}

/* Generic mono utility */
.mono {
  font-family: var(--font-mono);
}

/* Tabular numerics utility */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Muted text */
.text-muted   { color: var(--color-text-muted); }
.text-label   { color: var(--color-text-label); }
.text-faint   { color: var(--color-text-faint); }
.text-accent  { color: var(--color-accent); }
.text-warning { color: var(--color-warning); }


/* ============================================================
   4. SCROLLBAR (webkit)
   ============================================================ */

::-webkit-scrollbar {
  height: 12px;
  width: 12px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  background: #c7c4bc;
  border-radius: 8px;
  border: 3px solid var(--color-bg);
}


/* ============================================================
   5. BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 120ms ease, border-color 120ms ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Primary — green */
.btn-primary {
  background: var(--color-accent);
  color: #FFFFFF;
  border: none;
}

.btn-primary:hover {
  background: var(--color-accent-hover);
}

/* Secondary — white with border */
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface-warm);
  border-color: var(--color-accent);
}

/* Small variant */
.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}


/* ============================================================
   6. CARD
   ============================================================ */

.card {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  color: var(--color-text);
}

/* Inner cards (e.g. checklist) */
.card-inner {
  background: var(--color-surface);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-inner);
  padding: var(--sp-4);
}


/* ============================================================
   7. INPUT
   ============================================================ */

.input {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-size: 13.5px;
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color 120ms ease;
  width: 100%;
}

.input::placeholder {
  color: var(--color-text-faint);
}

.input:focus {
  border-color: var(--color-accent);
  outline: none;
}

/* Search input wrapper (includes icon space) */
.search-wrap {
  position: relative;
  width: 240px;
}

.search-wrap .input {
  padding-left: 36px;
}

.search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-faint-alt);
  pointer-events: none;
  font-size: 15px;
}


/* ============================================================
   8. STATUS CHIPS
   ============================================================ */

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-chip);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1;
}

/* "zu prüfen" — amber */
.chip-review {
  background: var(--color-tint-amber-chip);
  color: var(--color-warning);
}

/* "erfasst" — green */
.chip-erfasst {
  background: var(--color-tint-green-chip);
  color: var(--color-accent);
}

/* KI-Auswertung läuft (Capture, async) — dezenter Amber-Hinweis im Card-Look */
.detail-ai-pending {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-warning);
  background: var(--color-tint-amber-chip);
}

/* Unterseiten-Shell (base.html) — gleiche Designsprache wie das Dashboard:
   warme Fläche, zentrierte Card-Topbar, dann der Inhalt darunter. */
.sub-shell {
  min-height: 100vh;
  box-sizing: border-box;
  background: var(--color-bg);
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.sub-topbar {
  width: 100%;
  max-width: 760px;
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border-bottom: none;   /* .topbar bringt sonst eine untere Hairline (war als Card-Sektion gedacht) */
}
.sub-topbar .topbar-right { flex-wrap: wrap; justify-content: flex-end; }
.sub-main { width: 100%; max-width: 760px; }
.sub-main .detail-shell { max-width: 100%; padding-left: 0; padding-right: 0; }
@media (max-width: 768px) {
  .sub-shell { padding: 14px 12px; gap: 14px; }
}

/* Papierkorb (verworfene Belege) */
.vw-card { padding: var(--sp-5) var(--sp-6); }   /* .card hat selbst kein Padding */
.vw-head { display: flex; align-items: baseline; justify-content: space-between; }
.vw-count { color: var(--color-text-faint); font-size: 13px; }
.vw-hint { color: var(--color-text-muted); font-size: 13px; margin: 4px 0 18px; }
.vw-list { display: flex; flex-direction: column; }
.vw-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-hairline-row);
}
.vw-row:last-child { border-bottom: none; }
.vw-info { flex: 1 1 auto; min-width: 0; }
.vw-vendor { font-weight: 600; color: var(--color-text); }
.vw-meta { color: var(--color-text-faint); font-size: 13px; }
.vw-amount { flex: 0 0 auto; color: var(--color-text); }
.vw-actions { display: flex; gap: 8px; align-items: center; }
.vw-actions form { margin: 0; }
.vw-empty { color: var(--color-text-faint); font-size: 14px; padding: 8px 0; }

/* KPI chip variant (slightly smaller padding) */
.kpi-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-chip);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--color-tint-amber-chip);
  color: var(--color-warning);
}

/* Trend chip (green "+N%") */
.trend-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--color-tint-green-chip);
  color: var(--color-accent);
  font-size: 12px;
  font-weight: 600;
}


/* ============================================================
   9. CATEGORY DOT
   ============================================================ */

.dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  display: inline-block;
}

.dot-infrastruktur { background: var(--cat-infrastruktur); }
.dot-saas          { background: var(--cat-saas); }
.dot-hardware      { background: var(--cat-hardware); }
.dot-reisen        { background: var(--cat-reisen); opacity: 0.45; }
.dot-gebuehren     { background: var(--cat-gebuehren); }
.dot-schutzrechte  { background: var(--cat-schutzrechte); }
.dot-buero         { background: var(--cat-buero); }
.dot-sonstiges     { background: var(--cat-sonstiges); }


/* ============================================================
   10. LOGO MARK
   ============================================================ */

.logo {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-logo);
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  text-decoration: none;
}


/* ============================================================
   11. TOPBAR LAYOUT
   ============================================================ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px var(--sp-7);
  border-bottom: 1px solid var(--color-hairline);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

/* Month-switcher pill */
.month-switcher {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  font-size: 13.5px;
  font-weight: 500;
  color: #3a382f;
  cursor: pointer;
  background: transparent;
  transition: background 120ms ease;
}

.month-switcher:hover {
  background: var(--color-surface-warm);
}


/* ============================================================
   12. KPI ROW + KPI CARDS
   ============================================================ */

/* KPI row grid — 4 equal columns, 1px gaps (color shows through) */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--color-hairline);
  border-bottom: 1px solid var(--color-hairline);
}

.kpi-card {
  background: var(--color-surface);
  padding: var(--sp-5) var(--sp-6);   /* 22px 24px */
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-label);
  margin-bottom: var(--sp-3);
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  margin-bottom: var(--sp-2);
}

.kpi-value--amber {
  color: var(--color-warning);
}

.kpi-sub {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-label);
}

/* Progress bar inside KPI card */
.kpi-progress-track {
  height: 4px;
  background: var(--color-hairline);
  border-radius: var(--radius-pill);
  margin-top: 10px;
  overflow: hidden;
}

.kpi-progress-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-pill);
}


/* ============================================================
   13. BODY SPLIT (main content area below KPI row)
   ============================================================ */

.body-split {
  display: grid;
  grid-template-columns: 1fr 340px;
}

.body-left {
  border-right: 1px solid var(--color-hairline);
}

.body-right {
  /* export rail */
  background: var(--color-surface-warm);
}


/* ============================================================
   14. LIST COLUMN GRID (column headers + beleg rows)
   ============================================================ */

/* Shared grid for column header and every beleg row */
.list-grid {
  display: grid;
  grid-template-columns: 14px 1fr 130px 76px 104px 102px;
  gap: 14px;
  align-items: center;
}

/* Column header row */
.col-head {
  padding: 10px var(--sp-7);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-text-label);
  letter-spacing: 0.04em;
}

/* Beleg list row */
.beleg-row {
  padding: var(--sp-4) var(--sp-7);   /* 16px 28px */
  border-bottom: 1px solid var(--color-hairline-row);
  background: var(--row-bg, var(--color-surface));
  box-shadow: var(--row-accent, inset 0 0 0 0 transparent);
  cursor: pointer;
  transition: background 120ms ease;
}

.beleg-row--active {
  --row-bg: var(--color-tint-green-row);
  --row-accent: inset 3px 0 0 var(--color-accent);
}

.beleg-row:not(.beleg-row--active):hover {
  background: var(--color-surface-warm);
}

/* Händler name + sub-line */
.handler-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}

.handler-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-faint);
  margin-top: 2px;
}

/* Kategorie cell */
.cell-kategorie {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted-alt);
}

/* Datum cell */
.cell-datum {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted-alt);
}

/* Betrag / amount cell */
.cell-brutto {
  font-size: 14.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  text-align: right;
}


/* ============================================================
   15. CHART SECTION
   ============================================================ */

.chart-section {
  padding: var(--sp-6) var(--sp-7);   /* 24px 28px */
  border-bottom: 1px solid var(--color-hairline);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.chart-sum {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

/* Vertical bar chart */
.bars-container {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  height: 132px;
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
}

.bar-value {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

.bar-fill {
  width: 100%;
  max-width: 52px;
  border-radius: 7px 7px 0 0;
}

.bar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-label);
  text-align: center;
  white-space: nowrap;
}


/* ============================================================
   16. EXPORT RAIL (right column)
   ============================================================ */

.export-rail {
  padding: var(--sp-6);   /* 24px */
  background: var(--color-surface-warm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.rail-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

.rail-subtitle {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-text-label);
  margin-top: 4px;
}

/* Progress section inside rail */
.progress-section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-label);
  margin-bottom: var(--sp-3);
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.progress-track {
  flex: 1;
  height: 4px;
  background: var(--color-hairline);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-pill);
}

/* Format buttons (DATEV, CSV, PDF) */
.format-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  background: var(--color-surface);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-muted-alt);
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}

.format-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.format-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.format-btns {
  display: flex;
  gap: 8px;
}

/* Check items in checklist card */
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}

.check-icon--ok   { color: var(--color-accent); }
.check-icon--warn { color: var(--color-warning); }
.check-text--warn { color: var(--color-warning); }

/* Progress bar label + amount (export rail category rows) */
.progress-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-text-muted-alt);
  width: 90px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-amount {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-label);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Closed-state banner inside export rail */
.rail-closed-state {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 20%, transparent);
  border-radius: var(--radius-card);
  padding: 10px 14px;
}

/* CTA button stretches full width inside rail */
.rail-cta {
  width: 100%;
  justify-content: center;
}


/* ============================================================
   17. ACCESSIBILITY — FOCUS STATES
   ============================================================ */

/* Visible focus ring for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Remove outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}


/* ============================================================
   18. PAGE SHELL LAYOUT
   ============================================================ */

/* App shell: centered column with gap between stacked cards */
.page-shell {
  min-height: 100vh;
  box-sizing: border-box;
  padding: 56px;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
}

/* Main app card (desktop, 1180px max) */
.app-card {
  width: 100%;
  max-width: 1180px;
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  color: var(--color-text);
}

/* Simple nav bar variant (used in the existing app shell) */
.app-nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-hairline);
  padding: 12px var(--sp-7);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text);
  text-decoration: none;
}

.app-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-7);
}


/* ============================================================
   19. RESPONSIVE — MOBILE BREAKPOINT
   ============================================================ */

@media (max-width: 768px) {
  .page-shell {
    padding: 16px;
    gap: 16px;
  }

  .body-split {
    grid-template-columns: 1fr;
  }

  .body-right {
    border-top: 1px solid var(--color-hairline);
    border-right: none;
  }

  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px;
  }

  .topbar-right {
    flex-wrap: wrap;
  }

  .search-wrap {
    width: 100%;
  }

  .list-grid {
    /* Simplified mobile list: dot, händler, amount, chip */
    grid-template-columns: 9px 1fr 90px;
  }

  /* Hide date + category columns on mobile */
  .col-datum,
  .col-kategorie,
  .cell-kategorie,
  .cell-datum {
    display: none;
  }
}

@media (max-width: 480px) {
  .kpi-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   20. DETAIL / EDIT PANEL (R5)
   ============================================================ */

/* Page shell — centered single-column layout */
.detail-shell {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  padding: var(--sp-6) var(--sp-4);
}

/* Back link */
.detail-back-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  opacity: 0.85;
  transition: opacity 0.15s;
}
.detail-back-link:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Header card: vendor name + status chip side-by-side */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6);
}
.detail-header-left { flex: 1; min-width: 0; }
.detail-header-right { flex-shrink: 0; padding-top: 2px; }

.detail-vendor {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail-beleg-id {
  font-size: 12px;
  color: var(--color-text-faint);
  margin: 3px 0 0;
  font-family: var(--font-mono);
}

/* Verworfen chip — faded, distinct from review/erfasst */
.chip-verworfen {
  background: #F3F2EF;
  color: var(--color-text-label);
  border-radius: var(--radius-chip);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  letter-spacing: 0.02em;
  opacity: 0.75;
}
.chip-default {
  background: var(--color-hairline);
  color: var(--color-text-muted);
  border-radius: var(--radius-chip);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
}

/* Section title inside cards */
.detail-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-label);
  margin: 0 0 var(--sp-4);
}

/* ── Edit form ─────────────────────────────────────────────────────────── */
.detail-form-card {
  padding: var(--sp-5) var(--sp-6);
}
.detail-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* One field row */
.detail-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.detail-field--locked {
  position: relative;
}
.detail-field--locked::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-warning);
  border-radius: 99px;
  opacity: 0.45;
}

/* Label */
.detail-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-label);
  display: flex;
  align-items: center;
  gap: 5px;
}
.detail-label--checkbox {
  flex-direction: row;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
}

/* Lock glyph + hint */
.detail-lock {
  font-size: 11px;
  opacity: 0.7;
  cursor: help;
}
.detail-lock-hint {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-warning);
  opacity: 0.8;
  font-style: italic;
}

/* Input override for detail context */
.detail-input {
  font-size: 14px;
  color: var(--color-text);
  padding: 8px var(--sp-3);
  height: 38px;
}
.detail-input--mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* Input + suggestion button row */
.detail-input-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.detail-input-row .detail-input {
  flex: 1;
}
.detail-vat-hint {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 11px;
  padding: 5px 10px;
  color: var(--color-accent);
  border-color: var(--color-accent);
  opacity: 0.9;
}
.detail-vat-hint:hover {
  background: var(--color-tint-green-chip);
  opacity: 1;
}

/* Checkbox */
.detail-checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

/* Submit row */
.detail-actions-row {
  display: flex;
  justify-content: flex-end;
  padding-top: var(--sp-2);
  border-top: 1px solid var(--color-hairline);
  margin-top: var(--sp-2);
}

/* ── Conflict banner ───────────────────────────────────────────────────── */
.detail-conflict-msg {
  background: #FEF3CD;
  border: 1px solid #FBBF24;
  border-radius: var(--radius-btn);
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  font-weight: 500;
  color: #92400E;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.detail-conflict-reload {
  color: var(--color-accent);
  font-weight: 600;
  text-decoration: underline;
  margin-left: auto;
}

/* ── System info card ──────────────────────────────────────────────────── */
.detail-sysinfo-card {
  padding: var(--sp-4) var(--sp-6);
}
.detail-sysinfo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3) var(--sp-5);
  margin: 0;
}
.detail-sysinfo-full {
  grid-column: 1 / -1;
}
.detail-sysinfo-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: 2px;
}
.detail-sysinfo-value {
  font-size: 12px;
  color: var(--color-text-muted);
  word-break: break-all;
}
.detail-sysinfo-mono {
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ── Lifecycle actions card ────────────────────────────────────────────── */
.detail-lifecycle-card {
  padding: var(--sp-4) var(--sp-6);
}
.detail-lifecycle-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
}

/* Danger button */
.btn-danger {
  background: #FEF2F2;
  color: #B91C1C;
  border: 1px solid #FECACA;
  border-radius: var(--radius-btn);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-danger:hover {
  background: #FEE2E2;
  border-color: #FCA5A5;
}

/* Prominent action (Als geprüft markieren) */
.detail-action-geprueft {
  font-size: 13px;
}

/* ── Mobile responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .detail-shell {
    padding: var(--sp-4) var(--sp-3);
    gap: var(--sp-4);
  }
  .detail-form-card,
  .detail-sysinfo-card,
  .detail-lifecycle-card,
  .detail-header {
    padding: var(--sp-4);
  }
  .detail-header {
    flex-direction: column;
    gap: var(--sp-2);
  }
  .detail-sysinfo-grid {
    grid-template-columns: 1fr;
  }
  .detail-input-row {
    flex-direction: column;
    align-items: stretch;
  }
  .detail-vat-hint {
    width: 100%;
    text-align: center;
  }
  .detail-actions-row {
    justify-content: stretch;
  }
  .detail-actions-row .btn {
    width: 100%;
  }
  .detail-field--locked::before {
    left: -8px;
  }
}


/* ============================================================
   21. SHARED FORM SHELL (login, new, capture) — R7
   ============================================================ */

/* Centered single-column form layout on the bg canvas */
.form-shell {
  min-height: calc(100vh - 57px); /* subtract app-nav */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--sp-7) var(--sp-4);
}

.form-card {
  width: 100%;
  max-width: 520px;
}

/* Card header: back link + title + subtitle */
.form-card-header {
  padding: var(--sp-6) var(--sp-6) 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--color-hairline);
  padding-bottom: var(--sp-5);
  margin-bottom: 0;
}

.form-card-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
  margin: var(--sp-2) 0 0;
}

.form-card-subtitle {
  font-size: 13px;
  margin-top: 2px;
}

/* Form fields container */
.form-body {
  padding: var(--sp-5) var(--sp-6) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* Generic label used in form context */
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-label);
  display: block;
  margin-bottom: 5px;
}

/* Section divider label inside form body */
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-label);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--color-hairline);
  margin-top: var(--sp-1);
}

/* Actions row (cancel + submit) */
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--color-hairline);
  margin-top: var(--sp-2);
}

/* select element shares .input sizing */
select.input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23B0ADA3' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}


/* ============================================================
   22. LOGIN PAGE — R7
   ============================================================ */

.login-shell {
  min-height: calc(100vh - 57px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-7) var(--sp-4);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: var(--sp-7);
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

/* Logo + wordmark row */
.login-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.login-wordmark {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

/* Error banner */
.login-error {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--color-tint-amber-chip);
  border: 1px solid #E9C77B;
  border-radius: var(--radius-btn);
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-warning);
}

.login-error-icon {
  font-size: 15px;
  flex-shrink: 0;
}

/* Form layout */
.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.login-submit {
  width: 100%;
  height: 44px;  /* larger touch target */
  font-size: 15px;
}


/* ============================================================
   23. CAPTURE AREA — R7
   ============================================================ */

/* Tap/click zone — styled as a prominent upload CTA */
.capture-area {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.capture-drop-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 160px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-inner);
  background: var(--color-surface-warm);
  cursor: pointer;
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease;
}

.capture-drop-label:hover,
.capture-drop-label:focus-within {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 4%, var(--color-surface));
}

.capture-drop-icon {
  font-size: 36px;
  line-height: 1;
}

.capture-drop-primary {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

.capture-drop-hint {
  font-size: 12px;
}

/* Visually hidden but accessible file input */
.capture-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Selected file name feedback */
.capture-selected {
  font-size: 12px;
  min-height: 18px;
  text-align: center;
}


/* ============================================================
   24. CAPTURE FAB — R7
   ============================================================ */

/* Floating action button: fixed bottom-right, safe-area aware */
.fab-capture {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 50px;
  height: 50px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: #FFFFFF;
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-fab);
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
  /* min touch target 44px is met by 50px */
  z-index: 100;
}

.fab-capture:hover {
  background: var(--color-accent-hover);
  transform: scale(1.05);
}

.fab-capture:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* Hide FAB on large screens where the topbar CTA is sufficient */
@media (min-width: 769px) {
  .fab-capture {
    display: none;
  }
}


/* ============================================================
   25. MOBILE IMPROVEMENTS — R7
   ============================================================ */

@media (max-width: 768px) {
  /* Form shell: tighter padding on small screens */
  .form-shell {
    align-items: flex-start;
    padding: var(--sp-4) var(--sp-3);
  }

  .form-card-header,
  .form-body {
    padding-left: var(--sp-4);
    padding-right: var(--sp-4);
  }

  .login-card {
    padding: var(--sp-5);
  }

  /* Actions stack vertically on narrow screens */
  .form-actions {
    flex-direction: column-reverse;
    gap: var(--sp-2);
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Topbar capture shortcut visible on mobile */
  .topbar-capture-mobile {
    display: inline-flex;
  }

  /* App-nav wraps on very small phones */
  .app-nav {
    flex-wrap: wrap;
    gap: var(--sp-2);
  }
}


/* ============================================================
   26. DESKTOP / MOBILE LAYOUT TOGGLE
   ============================================================ */

/* Desktop layout: visible on ≥769px, hidden on ≤768px */
.desktop-only {
  display: block;
}

/* Mobile layout: hidden on ≥769px, visible on ≤768px */
.mobile-layout {
  display: none;
}

@media (max-width: 768px) {
  .desktop-only {
    display: none;
  }

  .mobile-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--color-surface-warm);
    color: var(--color-text);
    font-family: var(--font-sans);
    /* Room for fixed tab bar at bottom */
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}


/* ============================================================
   27. MOBILE HEADER
   ============================================================ */

.mob-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
}

@media (max-width: 768px) {
  .mob-header {
    display: flex;
  }
}

.mob-header-sub {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-label);
  margin-bottom: 2px;
}

.mob-header-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.15;
}

/* Avatar button + dropdown wrapper */
.mob-avatar-wrap {
  position: relative;
}

.mob-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease;
  /* min touch target: 44px via padding trick */
  padding: 0;
  /* ensure 44px click area via ::before */
  position: relative;
}

.mob-avatar::before {
  content: '';
  position: absolute;
  inset: -5px;
}

.mob-avatar:hover {
  background: var(--color-accent-hover);
}

.mob-avatar:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* Dropdown menu */
.mob-avatar-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--color-surface);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-inner);
  box-shadow: 0 4px 16px rgba(40,38,30,.12);
  min-width: 128px;
  z-index: 200;
  overflow: hidden;
}

.mob-avatar-menu[hidden] {
  display: none;
}

.mob-avatar-menu-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  transition: background 120ms ease;
}

.mob-avatar-menu-item:hover {
  background: var(--color-surface-warm);
}

.mob-avatar-menu-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}


/* ============================================================
   28. MOBILE CONTENT AREA
   ============================================================ */

.mob-content {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .mob-content {
    display: flex;
  }
}


/* ============================================================
   29. MOBILE HERO CARD
   ============================================================ */

.mob-hero {
  margin: 8px 16px;
  background: var(--color-accent);
  border-radius: var(--radius-hero);   /* 18px per spec */
  padding: 20px;
  color: #FFFFFF;
  box-shadow: var(--shadow-fab);
}

.mob-hero-label {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.8;
  margin-bottom: 8px;
}

.mob-hero-value {
  font-size: 36px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.mob-hero-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 13px;
  opacity: 0.85;
}

.mob-hero-pill {
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}


/* ============================================================
   30. MOBILE MINI CATEGORY CHART
   ============================================================ */

.mob-chart {
  margin: 12px 16px;
  background: var(--color-surface);
  border-radius: 16px;
  padding: 14px 16px;
}

.mob-chart-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-label);
  font-family: var(--font-mono);
  margin-bottom: 12px;
}

.mob-chart-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.mob-chart-row:last-child {
  margin-bottom: 0;
}

.mob-chart-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.mob-chart-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted-alt);
  width: 70px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mob-chart-bar-track {
  flex: 1;
  height: 5px;
  background: var(--color-hairline);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.mob-chart-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  /* Use transform instead of width to keep animation on the compositor */
  transform-origin: left center;
  transition: transform 300ms ease;
}

.mob-chart-amount {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  text-align: right;
  min-width: 52px;
  flex-shrink: 0;
}


/* ============================================================
   31. MOBILE RECENT + BELEG ROWS
   ============================================================ */

.mob-recent-title {
  padding: 12px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-label);
  font-family: var(--font-mono);
}

.mob-beleg-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-hairline-row);
  transition: background 120ms ease;
}

.mob-beleg-row:hover {
  background: rgba(47, 109, 88, 0.04);
}

.mob-beleg-row:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.mob-beleg-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.mob-beleg-info {
  flex: 1;
  min-width: 0;
}

.mob-beleg-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mob-beleg-meta {
  font-size: 11.5px;
  color: var(--color-text-label);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mob-beleg-amount {
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  flex-shrink: 0;
}

/* Belege list tab header */
.mob-belege-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-hairline);
}


/* ============================================================
   32. MOBILE BOTTOM TAB BAR + FAB
   ============================================================ */

.mob-tab-bar {
  display: none;
}

@media (max-width: 768px) {
  .mob-tab-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-top: 1px solid var(--color-hairline);
    padding: 8px 0 calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 100;
  }
}

.mob-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-label);
  text-decoration: none;
  min-width: 48px;
  min-height: 48px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: var(--radius-btn);
  transition: color 120ms ease;
}

.mob-tab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.mob-tab--active {
  color: var(--color-accent);
  font-weight: 700;
}

.mob-tab-icon {
  width: 22px;
  height: 22px;
  stroke-width: 1.75;
}

/* FAB: center tab, lifted −26px above bar */
.mob-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: #FFFFFF;
  font-size: 26px;
  font-weight: 300;
  line-height: 1;
  text-decoration: none;
  box-shadow: var(--shadow-fab);
  margin-top: -26px;
  transition: background 120ms ease, transform 120ms ease;
  /* min touch target met by 50px */
}

.mob-fab:hover {
  background: var(--color-accent-hover);
  transform: scale(1.05);
}

.mob-fab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .mob-fab,
  .mob-chart-bar-fill,
  .mob-beleg-row,
  .mob-avatar {
    transition: none;
  }
}
