/* ============================================================
   buchhaltung.version.blue — handgeschrieben, kein Framework.
   Corporate Design version.blue: Deep Navy #282653 · Slate #3d6db2
   Warm Paper #f0eee5 · Gold #f0b000. Typografie wie die Website:
   Bricolage Grotesque (Display) + Manrope (Text), selbst gehostet.
   ============================================================ */

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/assets/fonts/BricolageGrotesque-600.woff2') format('woff2');
  font-weight: 500 700; font-display: swap;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/assets/fonts/BricolageGrotesque-800.woff2') format('woff2');
  font-weight: 750 900; font-display: swap;
}
@font-face {
  font-family: 'Manrope';
  src: url('/assets/fonts/Manrope-400.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Manrope';
  src: url('/assets/fonts/Manrope-600.woff2') format('woff2');
  font-weight: 600; font-display: swap;
}
@font-face {
  font-family: 'Manrope';
  src: url('/assets/fonts/Manrope-700.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}

:root {
  --ink: #131638;
  --ink-soft: #3a3d63;
  --paper: #f0eee5;
  --card: #ffffff;
  --navy: #282653;
  --navy-deep: #1a1840;
  --slate: #3d6db2;
  --slate-soft: #eef1fc;
  --gold: #f0b000;
  --danger: #a52a22;
  --warn: #8a6a1a;
  --ok: #1f9d6b;
  --muted: #7a7d9c;
  --line: rgba(40, 38, 83, .10);
  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;
  --shadow-s: 0 1px 2px rgba(19, 22, 56, .06), 0 4px 14px rgba(19, 22, 56, .05);
  --shadow-m: 0 2px 6px rgba(19, 22, 56, .08), 0 12px 32px rgba(19, 22, 56, .08);
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --sans: 'Manrope', system-ui, sans-serif;
  --sidenav-w: 264px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(61, 109, 178, .10), transparent 60%),
    radial-gradient(800px 420px at -10% 100%, rgba(240, 176, 0, .07), transparent 55%),
    var(--paper);
  min-height: 100vh;
}

h1, h2, h3 { font-family: var(--display); letter-spacing: -.015em; }
code { font-size: .85em; background: var(--slate-soft); padding: 1px 6px; border-radius: 6px; }

/* ---------- App-Gerüst: Sidebar (Desktop) / Bottom-Nav (Mobil) ---------- */

.shell { min-height: 100vh; }

.sidenav {
  position: fixed; z-index: 30;
  background: linear-gradient(175deg, var(--navy) 0%, var(--navy-deep) 90%);
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.brandmark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--gold); color: var(--navy);
  font-family: var(--display); font-weight: 800; font-size: 1.25rem;
  box-shadow: 0 2px 10px rgba(240, 176, 0, .35);
}
.brandtext { font-family: var(--display); font-weight: 600; font-size: 1.02rem; line-height: 1.15; }
.brandtext em { display: block; font-style: normal; font-weight: 400; font-size: .72rem; opacity: .55; letter-spacing: .04em; }

.navlinks { display: flex; }
.navitem {
  display: flex; align-items: center; gap: 12px;
  color: rgba(255, 255, 255, .72); text-decoration: none;
  border-radius: var(--radius-s);
  transition: background .15s ease, color .15s ease;
}
.navitem:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.navitem.active { background: rgba(255, 255, 255, .10); color: #fff; }
.navitem .ico { font-size: 1.15rem; line-height: 1; }
.navitem .lbl { font-weight: 600; font-size: .92rem; }

.ghost {
  background: transparent; border: 1px solid rgba(255, 255, 255, .25); color: rgba(255, 255, 255, .85);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; font-family: var(--sans); font-weight: 600;
  transition: border-color .15s ease, background .15s ease;
}
.ghost:hover { border-color: var(--gold); color: #fff; background: rgba(240, 176, 0, .12); }
.inline { display: inline; }

/* Desktop ≥ 900px: linke Sidebar, Topbar weg */
@media (min-width: 900px) {
  .topbar { display: none; }
  .sidenav {
    inset: 0 auto 0 0; width: var(--sidenav-w);
    display: flex; flex-direction: column;
    padding: 28px 18px 22px;
  }
  .sidenav .brand { padding: 0 10px 26px; }
  .navlinks { flex-direction: column; gap: 4px; }
  .navitem { padding: 11px 14px; position: relative; }
  .navitem.active::before {
    content: ''; position: absolute; left: -18px; top: 9px; bottom: 9px; width: 4px;
    background: var(--gold); border-radius: 0 4px 4px 0;
  }
  .navfoot { margin-top: auto; padding: 18px 10px 0; border-top: 1px solid rgba(255, 255, 255, .12); }
  .navfoot .ghost { width: 100%; }
  .content {
    margin-left: var(--sidenav-w);
    padding: 44px clamp(28px, 5vw, 72px) 64px;
    max-width: calc(var(--sidenav-w) + 1180px);
  }
  .page > h1 { font-size: 1.85rem; margin: 0 0 26px; }
  body { padding-bottom: 0; }
}

/* Mobil < 900px: Bottom-Nav + schmale Topbar */
@media (max-width: 899.98px) {
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 16px; background: var(--navy); color: #fff;
  }
  .sidenav {
    inset: auto 0 0 0;
    border-top: 1px solid rgba(255, 255, 255, .14);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidenav .brand, .navfoot { display: none; }
  .navlinks { width: 100%; }
  .navitem { flex: 1; flex-direction: column; gap: 3px; padding: 10px 0 8px; border-radius: 0; }
  .navitem .lbl { font-size: .65rem; font-weight: 600; }
  .navitem.active { background: transparent; color: var(--gold); }
  .content { padding: 16px; max-width: 720px; margin: 0 auto; }
  .page > h1 { font-size: 1.35rem; margin: 8px 0 16px; }
}

/* ---------- Karten & Einstiegsanimation ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-s);
  animation: rise .45s cubic-bezier(.2, .7, .3, 1) backwards;
}
.card:nth-child(2) { animation-delay: .05s; }
.card:nth-child(3) { animation-delay: .10s; }
.card:nth-child(4) { animation-delay: .15s; }
.card:nth-child(5) { animation-delay: .20s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .card { animation: none; } }

.card h2 { font-size: 1.12rem; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card.row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  text-decoration: none; color: inherit; padding: 16px 22px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card.row:hover { transform: translateY(-1px); box-shadow: var(--shadow-m); border-color: rgba(61, 109, 178, .35); }
.card.row .right { text-align: right; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.center { text-align: center; }

/* ---------- Kennzahlen ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  text-align: center; padding: 14px 6px; border-radius: var(--radius-s);
  background: var(--slate-soft); text-decoration: none; color: inherit;
  border: 1px solid transparent; transition: border-color .15s ease, transform .15s ease;
}
a.stat:hover { border-color: var(--slate); transform: translateY(-1px); }
.stat strong {
  display: block; font-family: var(--display); font-weight: 800; font-size: 1.45rem;
  font-variant-numeric: tabular-nums; color: var(--navy);
}
.stat span { font-size: .74rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.stat.warn { background: #fdf3d6; box-shadow: inset 0 0 0 1px var(--gold); }
.stat.warn strong { color: var(--warn); }

/* ---------- Tabellen ---------- */

.accounts { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.accounts td { padding: 10px 8px; border-top: 1px solid var(--line); }
.accounts tr:first-child td { border-top: 0; }
.accounts .num { text-align: right; white-space: nowrap; font-weight: 700; color: var(--navy); }

/* ---------- Formulare & Buttons ---------- */

label { display: block; margin-bottom: 14px; font-size: .86rem; font-weight: 700; color: var(--ink-soft); }
input, select {
  display: block; width: 100%; margin-top: 5px; padding: 12px 13px;
  font-size: 1rem; font-family: var(--sans);
  border: 1px solid #cfd2e2; border-radius: var(--radius-s); background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus { outline: none; border-color: var(--slate); box-shadow: 0 0 0 3px rgba(61, 109, 178, .18); }
label.lowconf input { border-color: var(--gold); background: #fffaf0; }
.conf { font-weight: 600; color: var(--muted); font-size: .76rem; }

.btn {
  display: inline-block; padding: 12px 22px; border: 0; border-radius: var(--radius-s);
  font-size: .98rem; font-weight: 700; font-family: var(--sans); cursor: pointer; text-decoration: none;
  background: var(--slate-soft); color: var(--navy); min-height: 48px;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-s); }
.btn.primary { background: var(--navy); color: #fff; width: 100%; box-shadow: 0 6px 18px rgba(40, 38, 83, .28); }
.btn.primary:hover { background: var(--navy-deep); }
.btn.danger { background: var(--danger); color: #fff; }
@media (min-width: 900px) { .btn.primary { width: auto; } }

/* ---------- Meldungen & Badges ---------- */

.alert { background: #fbeae8; color: var(--danger); padding: 13px 16px; border-radius: var(--radius-s); border-left: 4px solid var(--danger); }
.alert.fraud { border: 2px solid var(--danger); font-weight: 700; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(165, 42, 34, .12); } }
.warn-note { color: var(--warn); margin: 4px 0; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .71rem; font-weight: 700; letter-spacing: .02em;
  background: var(--slate-soft); color: var(--navy);
}
.badge.ok { background: #e0f2ea; color: var(--ok); }
.status-needs_review { background: #fdf3d6; color: var(--warn); }
.status-pending_approval { background: #e3ecf9; color: var(--slate); }
.status-approved, .status-paid { background: #e0f2ea; color: var(--ok); }
.status-rejected { background: #fbeae8; color: var(--danger); }

/* ---------- Filter-Chips ---------- */

.filter { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 12px; }
.chip {
  white-space: nowrap; padding: 9px 16px; border-radius: 999px;
  background: var(--card); color: inherit; text-decoration: none; font-size: .88rem; font-weight: 600;
  border: 1px solid var(--line); transition: border-color .15s ease;
}
.chip:hover { border-color: var(--slate); }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Login (anonyme Seiten) ---------- */

body.anon {
  background:
    radial-gradient(900px 480px at 80% -5%, rgba(61, 109, 178, .35), transparent 60%),
    radial-gradient(700px 380px at 10% 110%, rgba(240, 176, 0, .14), transparent 55%),
    linear-gradient(170deg, var(--navy) 0%, var(--navy-deep) 100%);
  display: grid; place-items: center; padding: 24px;
}
.anon-content { width: 100%; max-width: 400px; }
.auth { margin: 0; padding: 34px 30px; border-radius: var(--radius-l); box-shadow: var(--shadow-m); }
.auth h1 { margin: 0 0 6px; font-size: 1.5rem; }
.auth h1::before {
  content: 'B'; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px; margin-bottom: 18px;
  background: var(--gold); color: var(--navy);
  font-family: var(--display); font-weight: 800; font-size: 1.5rem;
}

/* ---------- Upload & Review ---------- */

.scanbutton {
  display: block; border: 2px dashed #b9bdd6; border-radius: var(--radius-m);
  padding: 34px 16px; text-align: center; font-size: 1.05rem; cursor: pointer;
  background: var(--slate-soft); margin-bottom: 14px; font-weight: 700; color: var(--navy);
  transition: border-color .15s ease, background .15s ease;
}
.scanbutton:hover { border-color: var(--slate); background: #e6ebfa; }
.scanbutton input { display: none; }
.preview { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.preview img { width: 88px; height: 88px; object-fit: cover; border-radius: var(--radius-s); border: 1px solid var(--line); }

.review-grid { display: grid; gap: 18px; }

/* Entscheidungsbereich (Freigabe/Ablehnung) */
.decision { margin-top: 20px; padding: 20px 22px; border-left: 4px solid var(--gold); }
.decision h2 { margin-bottom: 8px; }
.decision-sum {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 0 0 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
  color: var(--ink-soft); font-weight: 600;
}
.decision-sum strong {
  font-family: var(--display); font-weight: 800; font-size: 1.5rem;
  color: var(--navy); font-variant-numeric: tabular-nums;
}
.decision-row { display: flex; gap: 10px; margin-bottom: 10px; }
.decision-row input { flex: 1; margin-top: 0; }
.decision-row .btn { white-space: nowrap; min-width: 148px; min-height: 46px; }
.btn.approve { background: var(--ok); color: #fff; box-shadow: 0 4px 14px rgba(31, 157, 107, .3); }
.btn.approve:hover { background: #17855a; }
.btn.reject { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn.reject:hover { background: #fbeae8; box-shadow: none; }
@media (max-width: 560px) {
  .decision-row { flex-direction: column; }
  .decision-row .btn { width: 100%; }
}

/* Lieferantenformular */
.vendorform { margin-top: 14px; }
.automode { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px 16px 8px; margin: 0 0 16px; }
.automode legend { font-size: .82rem; font-weight: 700; color: var(--ink-soft); padding: 0 6px; }
label.radio { display: flex; align-items: center; gap: 10px; font-weight: 500; margin-bottom: 10px; }
label.radio input[type=radio] { width: auto; margin: 0; accent-color: var(--navy); }
.limitfield { width: 130px !important; display: inline-block; margin: 0 0 0 4px; padding: 7px 10px; }
details summary { cursor: pointer; }
details[open] summary { margin-bottom: 6px; }
.docview { width: 100%; min-height: 340px; border-radius: var(--radius-m); border: 1px solid var(--line); background: #fff; }
.docimg { min-height: 0; height: auto; display: block; box-shadow: var(--shadow-s); transition: box-shadow .15s ease; }
.docimg:hover { box-shadow: var(--shadow-m); }
.einvoice-note { background: var(--slate-soft); border-color: rgba(61, 109, 178, .3); }
.approval-actions { display: grid; gap: 10px; margin-top: 18px; }
.approval-actions form { display: flex; gap: 8px; }
.approval-actions input { flex: 1; margin-top: 0; }
.approval-actions .btn { white-space: nowrap; min-width: 150px; }

@media (min-width: 900px) {
  .review-grid { grid-template-columns: 1.25fr 1fr; align-items: start; }
  .docpane { position: sticky; top: 28px; }
  .docview { min-height: 78vh; box-shadow: var(--shadow-s); }
  .stats { max-width: 640px; }
  .approval-actions { grid-template-columns: 1fr 1fr; }
}
