:root {
    --akzent: #2c3e50;
    --bg: #f4f6f8;
    --border: #dde3e8;
}
* { box-sizing: border-box; }
body {
    font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    margin: 0;
    color: #222;
}
a { color: var(--akzent); }
.layout { display: flex; min-height: 100vh; }

/* --- Sidebar / Navigation --- */
.sidebar {
    width: 220px;
    background: var(--akzent);
    color: #fff;
    padding: 20px 0;
    flex-shrink: 0;
}
.sidebar h1 { font-size: 16px; padding: 0 20px 20px; margin: 0; border-bottom: 1px solid rgba(255,255,255,0.15); }
.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    padding: 12px 20px;
    opacity: 0.85;
    font-size: 14px;
}
.sidebar a:hover, .sidebar a.active { opacity: 1; background: rgba(255,255,255,0.1); }
.nav-icon { width: 19px; height: 19px; flex-shrink: 0; }

/* Hamburger-Button: nur auf schmalen Bildschirmen sichtbar (siehe Media Query) */
.menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    background: var(--akzent);
    color: #fff;
    border: none;
    border-radius: 6px;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.menu-toggle svg { width: 22px; height: 22px; }
.sidebar-overlay { display: none; }

.content { flex: 1; padding: 30px; max-width: 1100px; min-width: 0; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 20px; overflow-x: auto; }
h2 { margin-top: 0; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; white-space: nowrap; }
table.list th { background: #f9fafb; font-weight: 600; }

.btn {
    display: inline-block;
    background: var(--akzent);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    min-height: 40px;
    line-height: 20px;
}
.btn.secondary { background: #7f8c9a; }
.btn.danger { background: #c0392b; }
.btn.small { padding: 6px 12px; font-size: 12px; min-height: 32px; }

form .field { margin-bottom: 14px; }
form label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
form input[type=text], form input[type=email], form input[type=password],
form input[type=date], form input[type=number], form select, form textarea {
    width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 5px; font-size: 16px;
}
form input[type=color] { width: 60px; height: 40px; padding: 2px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.aktiv, .badge.bezahlt, .badge.erledigt, .badge.abgerechnet { background: #e3f7e8; color: #1e7e34; }
.badge.offen, .badge.pausiert, .badge.in_bearbeitung, .badge.teilweise_abgerechnet, .badge.versendet { background: #fff3cd; color: #856404; }
.badge.gesperrt, .badge.ueberfaellig, .badge.storniert, .badge.widerrufen { background: #fde2e1; color: #c0392b; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.flash.success { background: #e3f7e8; color: #1e7e34; }
.flash.error { background: #fde2e1; color: #c0392b; }
.login-box { max-width: 340px; margin: 100px auto; padding: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.preview-frame { width: 100%; height: 700px; border: 1px solid var(--border); border-radius: 6px; }
.top-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.form-inline-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-inline-row .field { flex: 1; min-width: 220px; margin-bottom: 0; }

/* --- Tabs (z.B. Einstellungen) --- */
.tabs-nav { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid var(--border); flex-wrap: wrap; }
.tabs-nav button {
    background: none; border: none; padding: 10px 18px; font-size: 14px; cursor: pointer;
    color: #666; border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs-nav button.active { color: var(--akzent); border-bottom-color: var(--akzent); font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* --- Durchsuchbare Dropdowns (Kunde/Artikel) --- */
.searchable-select { display: flex; flex-direction: column; gap: 3px; }
.searchable-select-input {
    padding: 4px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: 4px;
    background: #fbfbfb;
}
.searchable-select-input:focus { outline: none; border-color: var(--akzent); background: #fff; }

/* --- Positionszeilen (Artikel-/Leistungseingabe) als übersichtliche Karten statt enger Tabelle --- */
.positionen-liste { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.position-zeile {
    border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; background: #fafbfc;
}
.position-zeile-oben { display: flex; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.position-zeile-oben .such-feld { flex: 0 0 260px; min-width: 200px; }
.position-zeile-oben .bezeichnung-feld { flex: 1; min-width: 220px; }
.position-zeile-unten { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.position-feld { display: flex; flex-direction: column; gap: 3px; }
.position-feld label, .such-feld label, .bezeichnung-feld label {
    font-size: 11px; color: #777; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
}
.position-feld input { width: 110px; }
.position-feld.schmal input { width: 78px; }
.position-zeilensumme {
    margin-left: auto; text-align: right; font-size: 13px; color: #444; padding-bottom: 8px; white-space: nowrap;
}
.position-zeilensumme .zeilensumme-wert { font-weight: 700; color: #222; }
.position-entfernen-btn {
    background: none; border: 1px solid var(--border); color: #999; border-radius: 6px;
    width: 34px; height: 34px; font-size: 15px; cursor: pointer; line-height: 1;
}
.position-entfernen-btn:hover { background: #fde2e1; color: #c0392b; border-color: #f3b8b5; }

@media (max-width: 700px) {
    .position-zeile-oben { flex-direction: column; }
    .position-zeile-oben .such-feld { flex: none; }
    .position-feld input { width: 100%; }
    .position-zeilensumme { margin-left: 0; width: 100%; }
}

/* --- Einstellungen: Sekundärnavigation (eigenes Menü pro Belegart) --- */
.settings-layout { display: flex; gap: 24px; align-items: flex-start; }
.settings-subnav { width: 190px; flex-shrink: 0; }
.settings-subnav a {
    display: block; padding: 10px 14px; border-radius: 6px; color: #333;
    text-decoration: none; font-size: 14px; margin-bottom: 2px;
}
.settings-subnav a:hover { background: #f4f6f8; }
.settings-subnav a.active { background: var(--akzent); color: #fff; font-weight: 600; }
.settings-content { flex: 1; min-width: 0; }
@media (max-width: 768px) {
    .settings-layout { flex-direction: column; }
    .settings-subnav { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
    .settings-subnav a { flex: 0 0 auto; margin-bottom: 0; }
}

/* ==================================================================
   MOBILE (<= 768px): Sidebar wird zum ausklappbaren Overlay-Menü
   ================================================================== */
@media (max-width: 768px) {
    .layout { display: block; }

    .menu-toggle { display: flex; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 260px;
        max-width: 80vw;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1000;
        overflow-y: auto;
        padding-top: 70px;
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 999;
    }
    .sidebar-overlay.open { display: block; }

    .content { padding: 70px 16px 24px; max-width: 100%; }

    .grid-2 { grid-template-columns: 1fr; }

    .login-box { margin: 40px auto; max-width: 100%; }

    table.list th, table.list td { font-size: 13px; padding: 8px 6px; }

    .btn { width: 100%; text-align: center; margin-bottom: 6px; }
    .btn.small { width: auto; }
    form { max-width: 100%; }
}

/* Kleine Handys: Sidebar etwas schmaler, Card-Innenabstand reduzieren */
@media (max-width: 400px) {
    .content { padding: 65px 10px 20px; }
    .card { padding: 14px; }
}

/* --- Passwortstärke-Anzeige (assets/js/passwort-staerke.js) --- */
.passwort-staerke { margin: 6px 0 14px; }
.passwort-staerke-balken { height: 5px; background: #eef1f4; border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.passwort-staerke-fuellung { height: 100%; width: 0; border-radius: 3px; transition: width 0.2s, background 0.2s; }
.passwort-staerke-text { font-size: 12px; font-weight: 600; }
.passwort-match-hinweis { font-size: 12px; margin: -8px 0 14px; min-height: 16px; }
