:root {
  --bg: #f4f5f7; --panel: #ffffff; --text: #1f2430; --muted: #6b7280; --border: #e3e5ea;
  --primary: #4338ca; --primary-hover: #3730a3; --primary-soft: #eef0ff;
  --ok: #15803d; --ok-soft: #e8f6ed; --warn: #b45309; --warn-soft: #fdf3e2; --err: #b91c1c; --err-soft: #fdecec;
  --side: #161a2b; --side-text: #c9cbe0; --side-active: #2a2f4a;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg);
       color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
small, .muted { color: var(--muted); }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: var(--side); color: var(--side-text); flex-shrink: 0; padding: 18px 12px;
           position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 16px; display: block; }
.sidebar .brand small { display: block; color: var(--side-text); font-weight: 400; font-size: 12px; }
.sidebar .gruppe { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #8186a6;
                   margin: 16px 10px 4px; }
.sidebar a { display: block; color: var(--side-text); padding: 7px 10px; border-radius: 7px; }
.sidebar a:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.sidebar a.aktiv { background: var(--primary); color: #fff; }
.main { flex: 1; min-width: 0; }
.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 10px 28px;
          background: var(--panel); border-bottom: 1px solid var(--border); }
.topbar form { margin: 0; }
.content { padding: 24px 28px 60px; max-width: 1400px; }
.kopf { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px;
        flex-wrap: wrap; }
.kopf .aktionen { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu-toggle { display: none; }

/* Karten & Raster */
.karte { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
         box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.raster { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 18px; }
.raster-2 { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
       box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .wert { font-size: 22px; font-weight: 700; margin-top: 4px; }
.kpi .sub { color: var(--muted); font-size: 12px; }

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
     background: #fafbfc; }
tr:hover td { background: #fafbff; }
td.r, th.r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.summe td { font-weight: 700; border-top: 2px solid var(--text); background: #fafbfc; }
tr.zwischensumme td { font-weight: 600; background: #fafbfc; }
.tabelle-wrap { overflow-x: auto; }
.betrag.neg, .neg { color: var(--err); }
.pos { color: var(--ok); }

/* Formulare */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password], input[type=month],
input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfd3dc; border-radius: 7px; font: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type=checkbox] { width: auto; margin-right: 6px; }
input[type=color] { width: 60px; height: 36px; padding: 2px; border: 1px solid #cfd3dc; border-radius: 7px; }
.feld { margin-bottom: 14px; }
.feld .hilfe { color: var(--muted); font-size: 12px; margin-top: 3px; }
.feld .fehler, .errorlist { color: var(--err); font-size: 12px; margin: 4px 0 0; padding: 0; list-style: none; }
.formular-raster { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.inline-form input, .inline-form select { width: auto; }
.filter { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter input, .filter select { width: auto; min-width: 140px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 7px;
       border: 1px solid #cfd3dc; background: #fff; color: var(--text); font: inherit; font-weight: 600;
       cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--err); border-color: #f1c0c0; }
.btn-danger:hover { background: var(--err-soft); }
.btn-klein { padding: 4px 9px; font-size: 12px; }
.btn-link { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }

/* Meldungen & Badges */
.meldung { padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; border: 1px solid; }
.meldung.success { background: var(--ok-soft); border-color: #bfe5cc; color: #14532d; }
.meldung.error, .meldung.fehler { background: var(--err-soft); border-color: #f4c7c7; color: #7f1d1d; }
.meldung.warning, .meldung.warn { background: var(--warn-soft); border-color: #f2d7a8; color: #7c2d12; }
.meldung.info { background: var(--primary-soft); border-color: #d4d8fb; color: #312e81; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
         background: #eef0f3; color: #374151; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.punkt { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* Balkendiagramm */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding: 10px 0 0; }
.chart .monat { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart .balken { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.chart .b { width: 42%; border-radius: 4px 4px 0 0; min-height: 1px; }
.chart .b.e { background: #6366f1; } .chart .b.a { background: #f59e0b; }
.chart .lbl { font-size: 11px; color: var(--muted); margin-top: 4px; }
.legende { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legende span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px;
                        margin-right: 5px; vertical-align: middle; }
.legende .e::before { background: #6366f1; } .legende .a::before { background: #f59e0b; }
.fortschritt { height: 6px; background: #eef0f3; border-radius: 3px; overflow: hidden; }
.fortschritt div { height: 100%; background: var(--primary); }

/* Monatsmatrix Stores */
.matrix td { text-align: center; padding: 6px 4px; }
.matrix .zelle { display: block; padding: 4px; border-radius: 6px; font-size: 12px; }
.matrix .zelle.gebucht { background: var(--ok-soft); color: var(--ok); }
.matrix .zelle.entwurf { background: var(--warn-soft); color: var(--warn); }
.matrix .zelle.fehlt { color: #c0c4cc; }

/* Dokumente */
.brotkrumen { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.brotkrumen span.sep { color: var(--muted); }
.datei-icon { display: inline-block; width: 34px; font-size: 10px; font-weight: 700; text-align: center;
              border-radius: 4px; padding: 2px 0; background: #eef0f3; color: #374151; margin-right: 8px; }
.datei-icon.pdf { background: #fde8e8; color: #b91c1c; }
.datei-icon.ordner { background: #fef3c7; color: #92400e; }
.dropzone { border: 2px dashed #cfd3dc; border-radius: var(--radius); padding: 18px; text-align: center;
            color: var(--muted); background: #fafbfc; }
.dropzone.aktiv { border-color: var(--primary); background: var(--primary-soft); }
details summary { cursor: pointer; font-weight: 600; }

/* Positionen */
.positionen td { padding: 6px 4px; }
.positionen input, .positionen select { padding: 6px 7px; font-size: 13px; }
.positionen .geloescht { opacity: .35; }
.summenbox { display: flex; gap: 24px; justify-content: flex-end; padding: 10px 4px; font-size: 15px; }
.summenbox b { font-variant-numeric: tabular-nums; }

/* Login */
.login-seite { min-height: 100vh; display: flex; align-items: center; justify-content: center;
               background: linear-gradient(135deg, #161a2b, #312e81); padding: 16px; }
.login-box { background: #fff; padding: 32px; border-radius: 14px; width: 100%; max-width: 380px;
             box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-box h1 { margin-bottom: 18px; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 6px; }

@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; width: 250px; }
  .sidebar.offen { left: 0; }
  .menu-toggle { display: inline-flex; margin-right: auto; }
  .content { padding: 16px; }
  .raster-2 { grid-template-columns: 1fr; }
  .topbar { padding: 10px 16px; }
}
@media print {
  .sidebar, .topbar, .aktionen, .filter, .btn, form { display: none !important; }
  .content { padding: 0; } .karte { box-shadow: none; border: 0; }
}

/* Organigramm */
.org { overflow-x: auto; padding: 8px 0 24px; }
.org ul { position: relative; display: flex; justify-content: center; margin: 0; padding: 22px 0 0; }
.org li { list-style: none; position: relative; padding: 22px 8px 0; text-align: center; display: flex;
          flex-direction: column; align-items: center; }
.org li::before, .org li::after { content: ""; position: absolute; top: 0; right: 50%; width: 50%; height: 22px;
                                  border-top: 2px solid #c3c8d4; }
.org li::after { right: auto; left: 50%; border-left: 2px solid #c3c8d4; }
.org li:only-child::before, .org li:only-child::after { display: none; }
.org li:only-child { padding-top: 0; }
.org li:first-child::before, .org li:last-child::after { border: 0 none; }
.org li:last-child::before { border-right: 2px solid #c3c8d4; border-radius: 0 8px 0 0; }
.org li:first-child::after { border-radius: 8px 0 0 0; }
.org ul ul::before { content: ""; position: absolute; top: 0; left: 50%; height: 22px; border-left: 2px solid #c3c8d4; }
.org > ul { padding-top: 0; width: max-content; min-width: 100%; }
.knoten { display: block; width: 200px; background: var(--panel); border: 1px solid var(--border);
          border-top: 5px solid var(--farbe, var(--primary)); border-radius: 10px; padding: 10px 12px;
          box-shadow: var(--shadow); color: var(--text); text-align: left; transition: transform .12s, box-shadow .12s; }
.knoten:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16,24,40,.14); }
.knoten .titel { font-weight: 700; font-size: 14px; line-height: 1.25; }
.knoten .kuerzel { float: right; font-size: 10px; font-weight: 700; color: var(--muted); }
.knoten .leitung { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; }
.knoten .leitung small { display: block; color: var(--muted); font-size: 11px; }
.knoten .offen { color: var(--warn); font-size: 12px; margin-top: 8px; }
.knoten .zahlen { margin-top: 8px; font-size: 11px; color: var(--muted); display: flex; gap: 10px; }
.knoten.firma { background: var(--side); color: #fff; border-top-color: var(--primary); text-align: center; }
.knoten.firma .titel { font-size: 15px; }
.knoten.inaktiv { opacity: .5; }
.org-add { margin-top: 6px; font-size: 11px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex-shrink: 0;
          border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12px; }
.avatar.gross { width: 54px; height: 54px; font-size: 19px; }
.avatar.leer { background: #f1f2f4; color: #9aa0ab; }
.person-karte { display: flex; gap: 12px; align-items: center; }
.zuweisen select { padding: 4px 6px; font-size: 13px; width: auto; max-width: 230px; }
.liste-punkte { margin: 0; padding-left: 18px; }
.liste-punkte li { margin-bottom: 4px; }

/* Signatur-Vorschau: App-Tabellenstil nicht auf die Mail-Signatur anwenden */
.sig-vorschau { border: 1px dashed var(--border); border-radius: 10px; padding: 16px; background: #fff; overflow-x: auto; }
.sig-vorschau table { width: auto; }
.sig-vorschau td { padding: 0; border: 0; }
.sig-vorschau tr:hover td { background: none; }
