/* =====================================================================
   RDRT Pro - gemeinsames Erscheinungsbild (seit v1.5.0)
   Wird von head.php nach Bootstrap geladen. Farben nur ueber die
   Grundwerte unten verwenden, nie direkt - sonst bricht der Dunkelmodus.
   Rot = Aktionen und Warnungen, nicht Dekoration.
   ===================================================================== */

:root, [data-bs-theme="light"] {
    --rot: #c8283a;
    --rd: #1f5fbf;
    --bf: #c8283a;
    --ok: #1e8a4c;
    --warn: #c77700;
    --nav: #1b1f27;
    --flaeche: #eef0f3;
    --flaeche-2: #f6f7f9;
    --karte: #ffffff;
    --linie: #dde1e7;
    --text: #1d2330;
    --leise: #667085;
    --schatten: 0 10px 28px rgba(16, 24, 40, .07);
    --font-display: "Archivo", "Segoe UI", system-ui, sans-serif;
    --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", Consolas, monospace;
    --radius: 10px;
}
[data-bs-theme="dark"] {
    --rot: #ec4d5f;
    --rd: #5b93ec;
    --bf: #ec4d5f;
    --ok: #3fbf74;
    --warn: #e8a13a;
    --nav: #0f1218;
    --flaeche: #151922;
    --flaeche-2: #1a1f29;
    --karte: #1d222d;
    --linie: #2c3342;
    --text: #e6e9ef;
    --leise: #98a2b3;
    --schatten: 0 10px 28px rgba(0, 0, 0, .35);
    color-scheme: dark;
}

/* Bootstrap auf die Grundwerte umbiegen */
:root, [data-bs-theme] {
    --bs-body-bg: var(--flaeche);
    --bs-body-color: var(--text);
    --bs-body-font-family: var(--font-body);
    --bs-secondary-color: var(--leise);
    --bs-tertiary-bg: var(--flaeche-2);
    --bs-border-color: var(--linie);
    --bs-danger: var(--rot);
    --bs-danger-rgb: 200, 40, 58;
    --bs-primary: var(--rd);
    --bs-link-color: var(--rot);
    --bs-link-hover-color: var(--rot);
    --bs-emphasis-color: var(--text);
}
[data-bs-theme="dark"] { --bs-danger-rgb: 236, 77, 95; }

body { background: var(--flaeche); color: var(--text); font-family: var(--font-body); font-size: 15.5px; }
h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 { font-family: var(--font-display); text-wrap: balance; }
.num, td.text-end, .text-end.fw-bold { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: .85em; }
.text-muted { color: var(--leise) !important; }
.text-dark { color: var(--text) !important; }
.text-danger { color: var(--rot) !important; }
.bg-white, .bg-light { background-color: var(--karte) !important; color: var(--text); }
.border, .border-bottom, .border-top, .border-start, .border-end { border-color: var(--linie) !important; }
a { color: var(--rot); }

/* Karten: alle Seiten-Kartenklassen bekommen dasselbe Aussehen */
.card, .invoice-card, .edit-card, .admin-card, .user-table-card, .stat-card, .table-card,
.mahn-card, .kunden-card, .kpi-card, .settings-card, .history-card, .karte {
    background: var(--karte) !important;
    color: var(--text);
    border: 1px solid var(--linie) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--schatten) !important;
}

/* Knoepfe: eine Form fuer alle */
.btn { border-radius: 999px; font-weight: 600; padding-left: 1.1rem; padding-right: 1.1rem; }
.btn-sm { padding-left: .8rem; padding-right: .8rem; }
.btn-danger { background: var(--rot); border-color: var(--rot); }
.btn-danger:hover, .btn-danger:focus { background: color-mix(in srgb, var(--rot) 85%, #000); border-color: color-mix(in srgb, var(--rot) 85%, #000); }
.btn-outline-danger { color: var(--rot); border-color: var(--rot); }
.btn-outline-danger:hover { background: var(--rot); border-color: var(--rot); }
.btn-light, .btn-white { background: var(--karte); border: 1px solid var(--linie); color: var(--text); }
.btn-light:hover, .btn-white:hover { background: var(--flaeche-2); border-color: var(--leise); color: var(--text); }
.btn-outline-dark, .btn-outline-secondary { color: var(--text); border-color: var(--linie); }
.btn-outline-dark:hover, .btn-outline-secondary:hover { background: var(--flaeche-2); color: var(--text); border-color: var(--leise); }
.btn-dark { background: var(--text); border-color: var(--text); color: var(--karte); }
.btn-group > .btn { border-radius: 0; }
.btn-group > .btn:first-child { border-radius: 999px 0 0 999px; }
.btn-group > .btn:last-child { border-radius: 0 999px 999px 0; }
.btn-group > .btn:only-child { border-radius: 999px; }
.btn:focus-visible, .form-control:focus, .form-select:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--rot) 30%, transparent) !important; }

/* Meldungen: ein schmaler Streifen mit farbiger Kante */
.alert {
    background: var(--karte) !important;
    color: var(--text) !important;
    border: 1px solid var(--linie) !important;
    border-left: 4px solid var(--leise) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--schatten) !important;
    font-weight: 600;
    text-align: left !important;
    padding: .6rem 1rem;
}
.alert-success { border-left-color: var(--ok) !important; }
.alert-danger { border-left-color: var(--rot) !important; }
.alert-warning { border-left-color: var(--warn) !important; }
.alert-info, .alert-primary { border-left-color: var(--rd) !important; }
.alert.auto-weg { transition: opacity .4s; }
.alert.auto-weg.weg { opacity: 0; }

/* Formulare */
.form-control, .form-select { border-radius: 8px; background-color: var(--flaeche-2); border: 1px solid var(--linie); color: var(--text); }
.form-control:focus, .form-select:focus { background-color: var(--karte); border-color: var(--rot); color: var(--text); }
.form-control.bg-light, .form-select.bg-light { background-color: var(--flaeche-2) !important; }
.form-control::placeholder { color: var(--leise); }
label, .form-label { color: var(--leise); }

/* Tabellen */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-hover-bg: color-mix(in srgb, var(--rot) 5%, transparent); --bs-table-hover-color: var(--text); --bs-table-border-color: var(--linie); }
.table > thead th, .table-light th, thead.table-light th {
    background: var(--karte) !important; color: var(--leise) !important;
    font-size: .75rem; text-transform: uppercase; letter-spacing: .6px; font-weight: 700;
    border-bottom: 1px solid var(--linie);
}
.table-light { --bs-table-bg: var(--karte); --bs-table-color: var(--leise); }
.table-responsive > .table > thead th { position: sticky; top: 0; z-index: 1; }
.table td { vertical-align: middle; }

/* Abzeichen */
.badge.bg-light { background: var(--flaeche-2) !important; color: var(--text) !important; border: 1px solid var(--linie); }

/* Status: ueberall gleich */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; text-decoration: none; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
a.status:hover { filter: brightness(.92); }
.status-offen { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.status-bezahlt { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.status-sammel { color: var(--leise); background: color-mix(in srgb, var(--leise) 14%, transparent); }
.status-ueber { color: var(--rot); background: color-mix(in srgb, var(--rot) 14%, transparent); }

/* Bereich: RD / BF */
.bereich, .badge-bereich { font: 700 .72rem var(--font-mono); padding: 2px 7px; border-radius: 5px; letter-spacing: .5px; text-transform: uppercase; border: 0 !important; }
.bereich-rd, .badge-bereich.bg-rd { color: var(--rd) !important; background: color-mix(in srgb, var(--rd) 13%, transparent) !important; }
.bereich-bf, .badge-bereich.bg-bf { color: var(--bf) !important; background: color-mix(in srgb, var(--bf) 13%, transparent) !important; }

/* Filterleiste: Segmente */
.segment { display: inline-flex; border: 1px solid var(--linie); border-radius: 999px; overflow: hidden; background: var(--karte); }
.segment a { font-weight: 600; font-size: .88rem; color: var(--leise); text-decoration: none; padding: 6px 14px; }
.segment a + a { border-left: 1px solid var(--linie); }
.segment a.an { background: var(--text); color: var(--karte); }
.segment a:hover:not(.an) { color: var(--text); background: var(--flaeche-2); }
.filter-pill { display: inline-block; padding: 6px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600; text-decoration: none; border: 1px solid var(--linie) !important; background: var(--karte) !important; color: var(--leise) !important; }
.filter-pill.active { background: var(--text) !important; color: var(--karte) !important; border-color: var(--text) !important; }

/* Kennzahlen */
.kpi { padding: 16px 18px; display: grid; gap: 2px; height: 100%; align-content: start; }
.kpi .label { color: var(--leise); font-size: .85rem; font-weight: 600; }
.kpi .wert { font: 800 1.7rem var(--font-display); font-variant-numeric: tabular-nums; }
.kpi .neben { font-size: .85rem; color: var(--leise); }
.kpi.akzent { border-left: 4px solid var(--rot) !important; }
.kpi svg { margin-top: 6px; }

/* Listen in Karten */
.karte-kopf { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--linie); gap: 10px; }
.karte-kopf h3, .karte-kopf h5 { font-size: 1rem; margin: 0; }
.karte-kopf a { margin-left: auto; font-weight: 600; font-size: .9rem; text-decoration: none; }
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: grid; grid-template-columns: 70px 1fr auto auto; gap: 12px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--linie); }
.liste li.zwei-spalten { grid-template-columns: 1fr auto; }
.liste li:last-child { border-bottom: 0; }
.liste .wer { font-weight: 600; min-width: 0; }
.liste .wer small { display: block; color: var(--leise); font-weight: 400; }
.liste a { color: inherit; text-decoration: none; }
@media (max-width: 420px) {
    .liste li { grid-template-columns: 1fr auto; }
    .liste li .mono, .liste li .bereich { display: none; }
}

/* Handy-Karten (History) */
.mkarte { background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); padding: 11px 13px; display: grid; gap: 6px; }
.mkarte .oben, .mkarte .unten { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mkarte .kunde { font-weight: 700; }
.mkarte .unten { color: var(--leise); font-size: .85rem; }
.mkarte .unten b { color: var(--text); font-size: 1rem; font-variant-numeric: tabular-nums; }

/* Rechnung erstellen: Suche + letzte Kunden */
.chip { border: 1px dashed var(--linie); border-radius: 999px; padding: 3px 11px; color: var(--text); background: transparent; font-weight: 600; font-size: .85rem; cursor: pointer; }
.chip:hover { border-style: solid; border-color: var(--rot); }
.treffer { border: 1px solid var(--linie); border-radius: 8px; margin-top: 6px; overflow: hidden; max-height: 260px; overflow-y: auto; }
.treffer button { display: flex; width: 100%; justify-content: space-between; gap: 10px; padding: 7px 12px; font-size: .92rem; border: 0; border-bottom: 1px solid var(--linie); background: var(--karte); color: var(--text); text-align: left; }
.treffer button:last-child { border-bottom: 0; }
.treffer button:hover, .treffer button.markiert { background: color-mix(in srgb, var(--rot) 8%, var(--karte)); }
.treffer small { color: var(--leise); white-space: nowrap; }

/* Navigation */
.navbar-custom { background: var(--nav) !important; border-bottom: 1px solid rgba(255, 255, 255, .06); padding: .45rem 1rem; }
.navbar-custom .navbar-brand { font: 800 1.2rem var(--font-display); letter-spacing: .2px; color: #fff !important; display: flex; align-items: center; text-decoration: none; }
.navbar-custom .navbar-brand .text-danger { color: var(--rot) !important; }
.nav-logo-custom { height: 34px; width: auto; margin-right: 10px; border-radius: 6px; }
.navbar-custom .nav-link { color: #c5cad3 !important; font-weight: 600; font-size: .95rem; margin: 0 4px; border-bottom: 2px solid transparent; border-radius: 0; }
.navbar-custom .nav-link:hover { color: #fff !important; }
.navbar-custom .nav-link.active { color: #fff !important; border-bottom-color: var(--rot); }
.navbar-custom .dropdown-menu { background: var(--nav); border: 1px solid rgba(255, 255, 255, .1); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .3); margin-top: 8px; }
.navbar-custom .dropdown-item { color: rgba(255, 255, 255, .82) !important; padding: 8px 18px; background: transparent; border: 0; width: 100%; text-align: left; }
.navbar-custom .dropdown-item:hover, .navbar-custom .dropdown-item:focus { background: rgba(255, 255, 255, .08); color: #fff !important; }
.navbar-custom .dropdown-divider { border-color: rgba(255, 255, 255, .12); }
.user-pill { background: rgba(255, 255, 255, .08); border-radius: 999px; padding: 4px 14px 4px 4px !important; color: #fff !important; }

/* Modale und Dropdowns allgemein */
.modal-content { background: var(--karte); color: var(--text); border: 1px solid var(--linie); border-radius: var(--radius); }
.modal-header, .modal-footer { border-color: var(--linie); }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(1.8); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
