/* =========================================================
   GRUNDEINSTELLUNGEN
========================================================= */

* {
    box-sizing: border-box;
}

/*
   Das native hidden-Attribut muss immer Vorrang vor Layout-Regeln
   wie .item { display:grid } oder .grid { display:grid } haben.
   Dadurch werden für die gewählte Fallart nicht freigegebene
   Leistungen vollständig ausgeblendet statt nur deaktiviert.
*/
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: system-ui, Arial, sans-serif;
    background: #f4f6f8;
    color: #17202a;
}


/* =========================================================
   TOPBAR
========================================================= */

.topbar {
    background: #17202a;
    color: #fff;
    padding: 14px 24px;

    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar strong {
    font-size: 1.05rem;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar a {
    color: #fff;
    text-decoration: none;
}

.topbar a:hover {
    text-decoration: underline;
}


/* =========================================================
   SEITENINHALT
========================================================= */

.container {
    max-width: 1200px;
    margin: 28px auto;
    padding: 0 18px;
}


/* =========================================================
   KARTEN
========================================================= */

.card {
    background: #fff;
    border: 1px solid #dfe4ea;
    border-radius: 10px;

    padding: 20px;
    margin-bottom: 20px;

    box-shadow: 0 2px 8px #0000000b;
}

.card h1,
.card h2,
.card h3 {
    margin-top: 0;
}

.card h2 {
    margin-bottom: 20px;
}


/* =========================================================
   GRID
========================================================= */

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.grid3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-items: end;
}


/* =========================================================
   FORMULARFELDER
========================================================= */

.field {
    min-width: 0;
}

.field label {
    display: block;

    font-weight: 650;

    margin-bottom: 6px;
}


/*
   Normale Eingabefelder.

   Wichtig:
   Checkboxen werden hier ausdrücklich ausgeschlossen.
*/

.field input:not([type="checkbox"]),
.field select,
.field textarea {
    display: block;

    width: 100%;

    padding: 10px;

    border: 1px solid #cbd3da;
    border-radius: 6px;

    background: #fff;
    color: #17202a;

    font: inherit;
}


/* Fokus */

.field input:not([type="checkbox"]):focus,
.field select:focus,
.field textarea:focus {
    outline: none;

    border-color: #1769aa;

    box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12);
}


/* Deaktivierte Felder */

.field input:disabled {
    background: #f7f8fa;
    color: #68737d;
    cursor: default;
}


/* Textarea */

.field textarea {
    min-height: 90px;
    resize: vertical;
}


/* =========================================================
   CHECKBOXEN
========================================================= */

.field input[type="checkbox"] {
    appearance: auto;

    width: 18px;
    height: 18px;

    min-width: 18px;

    margin: 0;

    padding: 0;

    cursor: pointer;

    flex: 0 0 auto;
}


/*
   Label mit Checkbox:
   Checkbox und Text stehen nebeneinander.
*/

.field label:has(input[type="checkbox"]) {
    display: flex;

    align-items: center;

    gap: 9px;

    min-height: 42px;

    margin: 0;

    cursor: pointer;
}


/* =========================================================
   LEISTUNGEN
========================================================= */

.item {
    display: grid;

    grid-template-columns:
        minmax(280px, 1fr)
        130px
        150px;

    gap: 16px;

    align-items: end;

    margin-bottom: 14px;
}

.item:last-child {
    margin-bottom: 0;
}


/* =========================================================
   ZUSCHLÄGE
========================================================= */

/*
   Jede grid3-Zeile innerhalb der Zuschlagskarte
   bekommt etwas Abstand zur nächsten Zeile.
*/

.card .grid3 {
    margin-bottom: 14px;
}

.card .grid3:last-child {
    margin-bottom: 0;
}


/*
   Damit Checkbox + Zuschlagsbezeichnung
   vertikal sauber mit Faktor und Preis stehen.
*/

.grid3 > .field:first-child {
    align-self: end;
}


/* =========================================================
   BUTTONS
========================================================= */

.btn {
    display: inline-block;

    border: 0;
    border-radius: 6px;

    padding: 10px 15px;

    background: #1769aa;
    color: #fff;

    text-decoration: none;

    font: inherit;
    font-weight: 600;

    cursor: pointer;
}

.btn:hover {
    filter: brightness(0.95);
}

.btn.secondary {
    background: #65727e;
}

.btn.success {
    background: #287d3c;
}


/* Buttonbereich */

.actions {
    display: flex;

    gap: 8px;

    flex-wrap: wrap;

    margin-top: 16px;
}


/* =========================================================
   TABELLEN
========================================================= */

table {
    width: 100%;

    border-collapse: collapse;
}

th,
td {
    padding: 9px;

    border-bottom: 1px solid #e5e7eb;

    text-align: left;
}

th {
    background: #f0f3f5;
    font-weight: 650;
}

.right {
    text-align: right;
}


/* =========================================================
   MELDUNGEN
========================================================= */

.alert {
    padding: 12px;

    border-radius: 7px;

    background: #fff3cd;

    margin-bottom: 15px;
}

.error {
    background: #fde2e1;
}


/* =========================================================
   MUTED / HINWEISTEXT
========================================================= */

.muted {
    color: #68737d;
    font-size: 0.92rem;
}


/* =========================================================
   LOGIN
========================================================= */

.login {
    max-width: 430px;

    margin: 80px auto;
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 850px) {

    .container {
        margin-top: 18px;
        padding: 0 12px;
    }


    .card {
        padding: 16px;
    }


    .grid,
    .grid3,
    .item {
        grid-template-columns: 1fr;
    }


    .topbar {
        flex-wrap: wrap;

        gap: 8px;

        padding: 12px 16px;
    }


    .topbar nav {
        flex-wrap: wrap;
    }


    /*
       Auf dem Handy braucht die Checkbox-Zeile
       keine feste Mindesthöhe.
    */

    .field label:has(input[type="checkbox"]) {
        min-height: auto;
    }


    /*
       Zwischen den Feldern einer grid3-Zeile
       etwas zusätzlicher Abstand.
    */

    .grid3 {
        gap: 10px;
    }


    .item {
        gap: 10px;

        padding-bottom: 14px;

        border-bottom: 1px solid #e5e7eb;
    }


    .actions {
        flex-direction: column;
    }


    .actions .btn {
        width: 100%;

        text-align: center;
    }

}


/* =========================================================
   SEHR KLEINE DISPLAYS
========================================================= */

@media (max-width: 480px) {

    body {
        font-size: 15px;
    }


    .container {
        padding: 0 8px;
    }


    .card {
        border-radius: 8px;

        padding: 14px;
    }


    .topbar {
        padding: 11px 12px;
    }

}

/* =========================================================
   BEHANDLUNGSFÄLLE
========================================================= */

.case-card {
    border-left: 4px solid #1769aa;
}

.case-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.case-basic-data {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 24px;
}

.case-header [data-case-title] {
    margin-bottom: 0;
}

.case-section-title {
    margin-top: 26px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}

.case-remove {
    flex: 0 0 auto;
}

.case-add-card {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.case-add-hint {
    margin: 0;
    flex: 1 1 420px;
}


@media (max-width: 850px) {

    .case-basic-data {
        grid-template-columns: 1fr;
    }

    .case-header {
        align-items: stretch;
        flex-direction: column;
    }

    .case-remove {
        width: 100%;
    }

    .case-add-card .btn {
        width: 100%;
        text-align: center;
    }
}

.case-remove[hidden] {
    display: none;
}


/* =========================================================
   ADMINISTRATION
========================================================= */

.btn.danger {
    background: #b42318;
}

.admin-logo-box {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    margin: 16px 0 24px;
    padding: 14px;
    border: 1px solid #dfe4ea;
    border-radius: 8px;
    background: #f8fafb;
}

.admin-logo-preview {
    display: block;
    max-width: 220px;
    max-height: 100px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.admin-delete-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
}

.admin-delete-logo input {
    width: 18px;
    height: 18px;
}

.admin-table-actions {
    white-space: nowrap;
}

.admin-inline-form {
    display: inline-block;
    margin: 0 0 0 6px;
}

.admin-btn-small {
    padding: 7px 10px;
    font-size: 0.9rem;
}

.logo-preview{
    margin-top:12px;
}

.logo-preview img{
    display:block;
    max-width:420px;
    width:100%;
    height:auto;
    object-fit:contain;
}

@media (max-width: 850px) {
    .admin-table-actions {
        white-space: normal;
    }

    .admin-inline-form {
        display: block;
        margin: 6px 0 0;
    }

    .admin-table-actions .btn {
        width: 100%;
        text-align: center;
    }
}

/* =========================================================
   RECHNUNGSÜBERSICHT
========================================================= */

.invoice-number {
    display: inline-block;
    padding: 6px 11px;
    border-radius: 7px;
    background: #eef3f7;
    color: #17212b;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
}

.invoice-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    white-space: nowrap;
}

.invoice-edit {
    background: #eef3f7;
    color: #17212b;
    border: 1px solid #d8e0e7;
}

.invoice-edit:hover {
    background: #e1e8ee;
}

.invoice-pdf {
    background: #1976b9;
    color: #ffffff;
}

.invoice-pdf:hover {
    background: #12659f;
}

.invoice-total {
    font-weight: 700;
    white-space: nowrap;
}

.empty-value {
    color: #9aa3ab;
}

.invoice-table th:last-child,
.invoice-table td:last-child {
    text-align: right;
}

.invoice-table td {
    vertical-align: middle;
}

.invoice-table-wrapper {
    overflow-x: auto;
}

.invoice-empty-row {
    text-align: center;
    padding: 30px;
}


/* =========================================================
   RECHNUNG BEARBEITEN
========================================================= */

.edit-invoice-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.edit-invoice-label {
    font-size: 13px;
    color: #66727d;
    margin-bottom: 5px;
}

.edit-invoice-number {
    display: inline-block;
    padding: 7px 12px;
    background: #eef3f7;
    border-radius: 7px;
    font-size: 16px;
}


/* =========================================================
   FOOTER
========================================================= */

.site-footer {
    max-width: 1200px;
    margin: 4px auto 28px;
    padding: 0 18px;
    text-align: center;
    color: #68737d;
    font-size: 0.85rem;
}

.site-footer a {
    color: inherit;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}


/* =========================================================
   LEISTUNGSARTEN / GEBÜHREN-ZUORDNUNG
========================================================= */

.check-list {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.check-option {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    border: 1px solid #dfe4ea;
    border-radius: 8px;
    background: #f8fafb;
    cursor: pointer;
}

.check-option input {
    width: auto;
    margin: 0;
}

.fee-service-types-field .muted {
    margin-top: 9px;
}

/* =========================================================
   LEICHENSCHAU
========================================================= */

.death-exam-panel {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid #dfe6ec;
    border-radius: 14px;
    background: linear-gradient(180deg, #fbfcfd 0%, #f6f8fa 100%);
}

.section-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-heading-row .case-section-title {
    margin: 0 0 5px;
}

.section-heading-row .muted {
    margin: 0;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid #d7e1e8;
    border-radius: 999px;
    background: #fff;
    color: #4d5c68;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.option-box {
    margin-top: 14px;
    padding: 15px 16px;
    border: 1px solid #e0e6eb;
    border-radius: 11px;
    background: #fff;
}

.option-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    cursor: pointer;
}

.option-title input,
.checkbox-field input {
    width: auto;
    margin: 0;
}

.death-dependent {
    margin-top: 14px;
}

.calculation-note {
    margin-top: 16px;
    padding: 12px 14px;
    border-left: 3px solid #708293;
    border-radius: 8px;
    background: #eef3f6;
    color: #42515d;
    font-size: 0.9rem;
    line-height: 1.5;
}

.field small {
    display: block;
    margin-top: 6px;
    color: #74808a;
    line-height: 1.4;
}

@media (max-width: 720px) {
    .section-heading-row {
        flex-direction: column;
    }

    .death-exam-panel {
        padding: 16px;
    }
}

/* =========================================================
   LKW-TAUGLICHKEIT
========================================================= */

.lkw-package-note {
    margin: 18px 0 16px;
    padding: 16px 18px;
    border: 1px solid #dfe6ec;
    border-radius: 14px;
    background: linear-gradient(180deg, #fbfcfd 0%, #f7f9fb 100%);
}

.lkw-package-note .section-heading-row {
    margin-bottom: 0;
}

/* =========================================================
   TAGEBUCHNUMMER / TGB.-NR.
========================================================= */

.diary-number-control {
    display: flex;
    align-items: stretch;
    width: 100%;
    border: 1px solid #cbd3da;
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.diary-number-control:focus-within {
    border-color: #1769aa;
    box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12);
}

.diary-number-prefix {
    display: flex;
    align-items: center;
    padding: 10px 0 10px 10px;
    color: #17202a;
    font: inherit;
    font-weight: 700;
    white-space: nowrap;
}

.diary-number-control .diary-number-prefix[hidden] {
    display: none;
}

.field .diary-number-control input:not([type="checkbox"]) {
    min-width: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding-left: 3px;
}

.field .diary-number-control input:not([type="checkbox"]):focus {
    border-color: transparent;
    box-shadow: none;
}

/* Betriebs- und Sicherheitsfunktionen */
.nav-inline-form{display:inline-flex;margin:0 0 0 14px;vertical-align:middle}.nav-link-button{appearance:none;border:0;background:transparent;color:#fff;font:inherit;padding:0;cursor:pointer}.nav-link-button:hover{text-decoration:underline}.dashboard-heading{display:flex;align-items:center;justify-content:space-between;gap:18px}.filter-grid{display:grid;grid-template-columns:2fr repeat(4,minmax(140px,1fr));gap:14px;align-items:end}.filter-search-wide{min-width:240px}.filter-actions{grid-column:1/-1;margin-top:0}.invoice-status{display:inline-flex;align-items:center;padding:5px 9px;border-radius:999px;font-size:.82rem;font-weight:700;background:#eef2f6;color:#263645}.invoice-status-issued{background:#e7f1ff;color:#174a7a}.invoice-status-paid{background:#e8f7ee;color:#17623a}.invoice-status-cancelled{background:#fdecec;color:#8a2525}.invoice-status-draft{background:#fff6dc;color:#725611}.status-inline-form{display:flex;gap:7px;align-items:center;flex-wrap:wrap;margin-top:8px}.status-inline-form select{min-width:150px}.compact-actions{gap:6px;margin:0}.dashboard-result-count{margin:14px 0 0}.backup-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;align-items:end}.backup-form-grid .actions{grid-column:1/-1}.backup-danger-zone{border-color:#e7bcbc}code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.92em;background:#f2f4f7;padding:2px 5px;border-radius:5px}@media(max-width:900px){.filter-grid,.backup-form-grid{grid-template-columns:1fr 1fr}.filter-search-wide{grid-column:1/-1}}@media(max-width:640px){.dashboard-heading{align-items:flex-start;flex-direction:column}.filter-grid,.backup-form-grid{grid-template-columns:1fr}.filter-search-wide,.filter-actions,.backup-form-grid .actions{grid-column:auto}.nav-inline-form{margin-left:8px}}
.user-password-inline{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin-top:6px}.user-password-inline input{min-width:190px}
