:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --border: #cdd4dd;
  --text: #121922;
  --muted: #46515f;
  --label: #28313c;
  --primary: #1559c4;
  --primary-dark: #11489f;
  --danger: #c62f2f;
  --danger-dark: #a82626;
  --success: #1f8a4c;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.10), 0 1px 2px rgba(16, 24, 40, 0.06);
  --radius: 8px;
}

body { -webkit-font-smoothing: auto; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Login (moderne Optik mit schräger Teilung) ---------- */
.login-screen { min-height: 100vh; }
.login-wrap { display: flex; min-height: 100vh; width: 100%; }

/* Marken-Seite (links) */
.login-brand {
  flex: 1.1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 22% 18%, rgba(99,140,235,0.26) 0%, transparent 55%),
    linear-gradient(135deg, #243a73 0%, #1b2a55 55%, #111c3c 100%);
}
.login-brand-inner { position: relative; z-index: 1; max-width: 420px; }
.login-brand-roof {
  position: absolute;
  right: -120px;
  bottom: -10px;
  width: 1300px;
  height: auto;
  opacity: 0.13;
  z-index: 0;
  pointer-events: none;
}
@media (max-width: 1100px) { .login-brand-roof { width: 900px; right: -80px; } }
.login-brand-logo { width: 205px; max-width: 72%; margin-bottom: 32px; }
.login-brand h1 { font-size: 33px; line-height: 1.2; margin: 0 0 16px; font-weight: 700; letter-spacing: 0.2px; }
.login-brand p { font-size: 15px; color: #c8d2ea; margin: 0 0 28px; line-height: 1.65; }
.login-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.login-features li {
  position: relative; padding-left: 32px; color: #e6ebf7; font-size: 15px; line-height: 1.45;
}
.login-features li::before {
  content: "✓";
  position: absolute; left: 0; top: 1px;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #ffffff;
  background: rgba(127,168,255,0.30);
}

/* Formular-Seite (rechts) */
.login-form-panel {
  flex: 0.9;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: flex-start;   /* Formular etwas weiter nach links statt mittig */
  padding: 40px 32px 40px 9%;
}
.login-form { width: 100%; max-width: 360px; }
.login-form-logo { display: none; }
.login-form h2 { margin: 0 0 6px; font-size: 27px; color: var(--text); }
.login-sub { margin: 0 0 28px; color: var(--muted); font-size: 14px; }
.login-field { display: block; margin-bottom: 18px; }
.login-field > span { display: block; font-size: 13px; font-weight: 600; color: var(--label); margin-bottom: 6px; }
.login-field input { padding: 12px 14px; font-size: 15px; }
.login-submit { padding: 13px; font-size: 15px; margin-top: 4px; }
#login-error { margin-top: 12px; text-align: center; }

/* Schmaler Bildschirm: nur Formular auf heller Fläche, Logo darüber */
@media (max-width: 820px) {
  .login-wrap { display: block; background: var(--surface); }
  .login-brand { display: none; }
  .login-form-panel { min-height: 100vh; justify-content: center; padding: 40px 24px; }
  .login-form-logo { display: block; width: 160px; max-width: 60%; margin: 0 auto 26px; }
}

/* ---------- Layout ---------- */
.app-screen { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: #1e2e5d;
  color: #e3e9f2;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  flex-shrink: 0;
  /* bleibt beim Scrollen stehen – Navigation und Abmelden-Button immer sichtbar */
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  padding: 4px 6px 22px;
}
.brand img {
  display: block;
  width: 100%;
  max-width: 160px;
  margin: 0 auto;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a {
  color: #e3e9f2;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
  font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.07); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar .logout { margin-top: 12px; color: #e3e9f2; }
.sidebar .logout:hover { background: rgba(255,255,255,0.07); color: #fff; }

.content { flex: 1; padding: 28px 32px; overflow-x: auto; }

/* ---------- Typo / Header ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h2 { margin: 0; font-size: 22px; }
h3 { margin: 0 0 12px; font-size: 17px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #f0f2f5; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-dark); }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-block { width: 100%; margin-top: 8px; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Inputs ---------- */
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31,111,235,0.12);
}
textarea { resize: vertical; min-height: 70px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--label); font-weight: 600; margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .card-grid { grid-template-columns: 1fr; } .form-grid { grid-template-columns: 1fr; } }

/* ---------- Einstellungen: aufklappbare Oberpunkte (Akkordeon) ---------- */
.acc-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.acc-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  margin: 0;
  padding: 16px 20px;
  cursor: pointer;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}
.acc-head:hover { background: rgba(21, 89, 196, 0.05); }
.acc-sub { font-weight: 400; font-size: 13px; color: var(--muted); }
.acc-chevron { margin-left: auto; color: var(--muted); transition: transform 0.2s ease; }
.acc-chevron::before { content: '\25B8'; font-size: 15px; }
.acc-item.open .acc-chevron { transform: rotate(90deg); }
.acc-body { display: none; padding: 2px 20px 20px; }
.acc-item.open .acc-body { display: block; }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { font-size: 13px; color: var(--label); font-weight: 700; }
tbody tr:hover { background: #f7f9fb; cursor: default; }
tr.clickable { cursor: pointer; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }

/* ---------- Suche ---------- */
.search-bar { display: flex; gap: 10px; margin-bottom: 18px; }
.search-bar input { max-width: 360px; }

/* ---------- Positionen / Rechnung ---------- */
.position-row {
  display: grid;
  grid-template-columns: 26px 1fr 160px;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.position-row:last-child { border-bottom: none; }
.position-row input[type="checkbox"] { width: 18px; height: 18px; }
.position-row .pos-label { font-weight: 500; }
.position-row .amount-input { text-align: right; }
.position-row.disabled { opacity: 0.5; }
.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0 0;
  font-size: 18px;
  font-weight: 700;
}

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: #fafbfc;
  transition: all 0.15s;
  cursor: pointer;
}
.dropzone.dragover { border-color: var(--primary); background: rgba(31,111,235,0.06); color: var(--primary); }
.doc-list { list-style: none; padding: 0; margin: 14px 0 0; }
.doc-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px;
  background: #fff;
}
.doc-list li .doc-name { font-weight: 500; }
.doc-list li .doc-meta { font-size: 12px; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-bar { background: #e8f3ec; color: var(--success); }
.badge-ueberweisung { background: #e8eefb; color: var(--primary); }
.badge-aktiv { background: #e8f3ec; color: var(--success); }
.badge-storniert { background: #fdeaea; color: var(--danger); }
.badge-storno { background: #fbf0e0; color: #b9770e; }
tr.row-storniert td:not(:last-child) { color: var(--muted); text-decoration: line-through; }

/* ---------- Hinweis-Banner ---------- */
.notice { padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 14px; }
.notice-storno { background: #fbf0e0; border: 1px solid #f0d9b0; color: #8a5a0b; }

/* ---------- Toast ---------- */
.toast-container { position: fixed; top: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; }
.toast {
  background: #14202e; color: #fff; padding: 12px 18px; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2); font-size: 14px; max-width: 360px;
  animation: slideIn 0.2s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 1100; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  width: 100%; max-width: 440px; padding: 24px;
}
.modal h3 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Statistik-Kacheln ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
@media (max-width: 800px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.stat-value { font-size: 20px; font-weight: 700; color: var(--text); }
.stat-value.stat-big { font-size: 26px; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 2px; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.back-link { color: var(--primary); text-decoration: none; font-size: 14px; display: inline-block; margin-bottom: 12px; }
.back-link:hover { text-decoration: underline; }
