/* ─── Design-System ────────────────────────────────────────────────────────
   Neutral, ruhig, fuer jede Branche brauchbar. Die Hauptfarbe kommt aus den
   Einstellungen und wird von /farben.css als --accent nachgeladen. Wer das
   Aussehen fuer einen Kunden anpasst, aendert in der Regel nur die Variablen
   in diesem Block.                                                          */
:root {
    --bg:          #f0f2f5;
    --surface:     #ffffff;
    --surface-2:   #f7f8fa;
    --border:      #dde1e8;
    --border-dark: #c5cad4;
    --text-primary:   #1a1d23;
    --text-secondary: #5a6275;
    --text-muted:     #9aa0ae;
    --accent:      #059669;
    --accent-dark: #047857;
    --accent-soft: #ecfdf5;
    --accent-rand: #a7f3d0;
    --header-bg:   #064e3b;
    --header-text: #ffffff;
    --green:       #16a34a;
    --green-bg:    #f0fdf4;
    --red:         #dc2626;
    --red-bg:      #fef2f2;
    --amber:       #d97706;
    --amber-bg:    #fffbeb;
    --radius:      6px;
    --radius-sm:   4px;
    --shadow:      0 1px 3px rgba(0,0,0,.08);
    --shadow-md:   0 4px 16px rgba(0,0,0,.12);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text-primary); font-size: 14px; line-height: 1.5; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Header ── */
.header {
  background: var(--header-bg); color: var(--header-text); padding: 0 1rem; height: 54px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.header-brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; color: #fff; }
.header-brand:hover { text-decoration: none; }
.header-brand svg { opacity: .9; flex-shrink: 0; }
.header-logo { height: 26px; width: auto; border-radius: 3px; background: #fff; padding: 2px; }
.header-rechts { display: flex; align-items: center; gap: .9rem; font-size: .85rem; }
.header-benutzer { display: flex; align-items: center; gap: .45rem; color: rgba(255,255,255,.9); }
.header-benutzer:hover { color: #fff; text-decoration: none; }
.header-rolle { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; background: rgba(255,255,255,.16); padding: 2px 6px; border-radius: 99px; }
.header-abmelden { background: none; border: none; cursor: pointer; color: rgba(255,255,255,.75); display: flex; padding: 4px; }
.header-abmelden:hover { color: #fff; }
.menue-knopf { display: none; background: none; border: none; color: #fff; padding: 4px; cursor: pointer; }

/* ── Shell ── */
.app-shell { display: flex; min-height: calc(100vh - 54px); }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 1.2rem .75rem; display: flex; flex-direction: column; gap: .15rem;
  position: sticky; top: 54px; height: calc(100vh - 54px); overflow-y: auto;
}
.sidebar-item {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: .88rem; font-weight: 500;
}
.sidebar-item:hover { background: var(--surface-2); color: var(--text-primary); text-decoration: none; }
.sidebar-item.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-trenner { height: 1px; background: var(--border); margin: .6rem .4rem; }
.sidebar-titel { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); padding: .4rem .75rem .2rem; }
.sidebar-fuss { margin-top: auto; font-size: 11px; color: var(--text-muted); padding: .5rem .75rem; line-height: 1.4; }

.main-content { flex: 1; overflow-x: hidden; padding: 1.2rem 1rem; max-width: 1180px; }

/* ── Seitentitel ── */
.seitenkopf { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.seitentitel { font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.seitentext { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.kopf-aktionen { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Meldungen ── */
.meldungen { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.meldung { padding: 9px 14px; border-radius: var(--radius); font-size: 13.5px; border: 1px solid; word-break: break-word; }
.meldung.erfolg { background: var(--green-bg); border-color: #bbf7d0; color: #15803d; }
.meldung.fehler { background: var(--red-bg); border-color: #fecaca; color: #b91c1c; }
.meldung.hinweis { background: var(--amber-bg); border-color: #fde68a; color: #b45309; }

/* ── Toolbar / Filter ── */
.toolbar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.toolbar-group { display: flex; flex-direction: column; gap: 4px; }
.toolbar-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.toolbar-spacer { flex: 1; }

/* ── Karten ── */
.karten { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 14px; }
.karte { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.karte-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.karte-wert { font-size: 22px; font-weight: 800; letter-spacing: -.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.karte-zusatz { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }

.block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.block-kopf { padding: 11px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); }
.block-titel { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-secondary); }
.block-inhalt { padding: 16px; display: flex; flex-direction: column; gap: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }

/* ── Tabellen ── */
.table-container { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.table-container--anschluss { border-top: none; border-radius: 0 0 var(--radius) var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead th { background: var(--header-bg); color: var(--header-text); padding: 10px 14px; font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; border-right: 1px solid rgba(255,255,255,.12); }
.data-table thead th:last-child { border-right: none; }
.data-table thead th.th-right { text-align: right; }
.data-table thead th.th-mitte { text-align: center; }
.data-table tbody tr { border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:nth-child(even) td { background: var(--surface-2); }
.data-table tbody tr:hover td { background: var(--accent-soft); }
.data-table tbody td { padding: 9px 14px; vertical-align: middle; }
.data-table td.td-right { text-align: right; }
.data-table td.td-mitte { text-align: center; }
.td-haupt { font-weight: 600; }
.td-leise { color: var(--text-secondary); }
.td-nowrap { white-space: nowrap; }

/* Summenzeile einer Tabelle. Steht hier und nicht im Modul: Jedes Modul
   benutzt .data-table, und ohne diese Regel haengen die Totalzeilen
   ungestylt unter der Tabelle - in der Buchhaltung wie in den Rechnungen. */
.data-table tfoot td {
    padding: 10px 14px; font-weight: 700;
    background: var(--accent-soft); color: var(--accent-dark);
    border-top: 1px solid var(--accent-rand);
}
.data-table tfoot td.td-right,
.data-table tfoot td.spalte-klein { text-align: right; font-variant-numeric: tabular-nums; }
.zeile-zusatz { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.td-aktionen { display: flex; gap: 5px; justify-content: flex-end; }
.zeile-inaktiv td { opacity: .6; }

/* ── Abzeichen ── */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.badge-ja { background: var(--green-bg); color: #15803d; }
.badge-nein { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-info { background: var(--accent-soft); color: var(--accent-dark); }
.badge-warn { background: var(--amber-bg); color: var(--amber); }

/* ── Leerzustand ── */
.empty-state { text-align: center; padding: 42px 16px; color: var(--text-secondary); }
.empty-text { font-size: 14px; margin-bottom: 4px; }
.empty-text small { font-size: 12px; color: var(--text-muted); display: block; margin-top: 4px; }

/* ── Formulare ── */
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .4px; }
.optional { color: var(--text-muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.form-control { width: 100%; padding: 8px 10px; border: 1.5px solid var(--border-dark); border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font); color: var(--text-primary); background: var(--surface); min-height: 36px; }
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-rand); }
.form-control[type="color"] { padding: 3px; height: 36px; cursor: pointer; }
.form-hilfe { font-size: 11.5px; color: var(--text-muted); }
textarea.form-control { min-height: 64px; resize: vertical; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.formular-aktionen { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.formular-aktionen .rechts { margin-left: auto; }

/* ── Schaltflaechen ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 7px 13px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; border: 1px solid transparent; cursor: pointer; font-family: var(--font); white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border-dark); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text-primary); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: #f5c6cb; }
.btn-danger:hover { background: #f8d7da; color: var(--red); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); color: var(--text-primary); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-lg { padding: 10px 18px; font-size: 14px; }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Rechtematrix ── */
.matrix-kopf { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 22px 0 12px; }
.matrix-wahl { display: flex; align-items: center; gap: 8px; }
.matrix-wahl label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.matrix-wahl select { min-width: 210px; }
.rechte-tabelle td.recht-zelle { text-align: center; }
.rechte-tabelle input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.recht-punkt { display: inline-block; width: 9px; height: 9px; border-radius: 99px; background: var(--border-dark); }
.recht-punkt.an { background: var(--accent); }

/* ── Bloecke im Inhalt ── */
.hinweis-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; font-size: 13px; color: var(--text-secondary); }
.hinweis-box code, code { background: #eef1f5; border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-size: 12.5px; }
.liste-schlicht { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.liste-schlicht li { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.liste-text { display: flex; flex-direction: column; gap: 2px; }
.liste-text b { font-size: 13.5px; }
.liste-text span { font-size: 12px; color: var(--text-muted); }

/* ── Seitenwechsel ── */
.blaettern { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; font-size: 12.5px; color: var(--text-secondary); background: var(--surface); border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); }

/* ── Anmeldung ── */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--header-bg); }
.login-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md); width: 100%; max-width: 390px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-marke { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: var(--header-bg); }
.login-logo { max-height: 46px; margin-bottom: 2px; }
.login-form { display: flex; flex-direction: column; gap: 13px; }
.login-text { font-size: 13px; color: var(--text-secondary); margin-top: -8px; }
.login-fuss { font-size: 11.5px; color: var(--text-muted); text-align: center; }
.login-trenner { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; }
.login-trenner::before, .login-trenner::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ── Fehlerseite ── */
.fehler-shell { min-height: 60vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.fehler-box { text-align: center; max-width: 420px; }
.fehler-code { font-size: 46px; font-weight: 800; color: var(--text-muted); letter-spacing: -1px; }
.fehler-titel { font-size: 18px; font-weight: 700; margin: 4px 0 6px; }
.fehler-text { font-size: 13.5px; color: var(--text-secondary); margin-bottom: 16px; }

/* ── Kleinigkeiten ── */
.versteckt { display: none !important; }
.abstand-oben { margin-top: 12px; }
.trennlinie { height: 1px; background: var(--border); margin: 4px 0; }

@media print {
  .header, .sidebar, .kopf-aktionen, .toolbar, .btn, .meldungen { display: none !important; }
  .main-content { max-width: none; padding: 0; }
  .block, .table-container { box-shadow: none; border-color: #ccc; }
}

@media (max-width: 900px) {
  .grid-2, .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .menue-knopf { display: flex; }
  .sidebar {
    position: fixed; top: 54px; left: 0; z-index: 90; width: 240px;
    transform: translateX(-100%); transition: transform .18s ease-out;
    box-shadow: var(--shadow-md);
  }
  .sidebar.offen { transform: translateX(0); }
  .main-content { padding: 1rem .8rem; }
}

@media (max-width: 640px) {
  .header-rolle, .header-name { display: none; }
  .data-table thead th, .data-table tbody td { padding: 8px 10px; font-size: 12.5px; }
  .spalte-klein { display: none; }
  .seitenkopf { align-items: flex-start; }
}

/* ── Startseite: der Betrieb auf einen Blick ──
   Die Startseite zeigt keine Verwaltungszahlen mehr, sondern offene Posten
   und die Handlungen, die jemand taeglich macht. Siehe uebersicht.py. */
.karte-klickbar { text-decoration: none; display: block; transition: border-color .12s, box-shadow .12s; }
.karte-klickbar:hover { text-decoration: none; border-color: var(--border-dark); box-shadow: var(--shadow-md); }
.karte-wert.achtung { color: var(--amber); }

.start-raster { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; align-items: start; }

.aufgaben { list-style: none; margin: 0; }
.aufgabe {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 11px 14px; border-top: 1px solid var(--border); font-size: 14px;
}
.aufgabe:first-child { border-top: none; }
.aufgabe.dringend { border-left: 3px solid var(--amber); padding-left: 11px; }
.aufgabe-text { line-height: 1.4; }
.nichts-offen { color: var(--text-secondary); font-size: 14px; }

.schnellzugriff { display: flex; flex-wrap: wrap; gap: 8px; }
.schnellzugriff .btn { flex: 1 1 auto; justify-content: center; }

@media (max-width: 900px) {
    .start-raster { grid-template-columns: 1fr; }
}
