/* ---------- Grundlayout ---------- */
* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    background: #f0f2f5;
    color: #2c3e50;
    line-height: 1.4;
}

.app-container {
    width: 80%;
    max-width: 1400px;
    margin: 24px auto;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 48px);
}

.app-header {
    background: linear-gradient(135deg, #2d8cf0 0%, #1f6fd0 100%);
    color: #fff;
    padding: 20px 28px;
}
.app-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.app-main { padding: 20px 28px; flex: 1; }

..app-footer {
    padding: 14px 28px;
    font-size: 0.82rem;
    color: #6b7280;
    border-top: 1px solid #eef1f6;
    background: #fafbfd;
    text-align: center;
}
.app-footer .footer-content { line-height: 1.6; }
.app-footer a {
    color: #2d8cf0;
    text-decoration: none;
    font-weight: 500;
    transition: color .15s;
}
.app-footer a:hover {
    color: #1f6fd0;
    text-decoration: underline;
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e5e8ee;
    margin-bottom: 18px;
}
.tab-button {
    padding: 10px 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.95rem;
    color: #556;
    border-radius: 6px 6px 0 0;
    transition: background .15s, color .15s;
}
.tab-button:hover { background: #f0f4fa; }
.tab-button.active {
    background: #fff;
    color: #2d8cf0;
    font-weight: 600;
    border-bottom: 2px solid #2d8cf0;
    margin-bottom: -2px;
}

/* ---------- Layout Tabelle + Sidebar ---------- */
.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 24px;
    align-items: start;
}

.table-area { min-width: 0; }

/* ---------- Tabelle ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eef1f6;
    font-size: 0.92rem;
}
th {
    background: #f7f9fc;
    font-weight: 600;
    color: #556;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}
tbody tr { transition: background .12s; cursor: pointer; }
tbody tr:hover { background: #f7faff; }

.einnahme { text-align: right; color: #1e8e3e; font-variant-numeric: tabular-nums; }
.ausgabe  { text-align: right; color: #d93025; font-variant-numeric: tabular-nums; }

tr.selected { background: #e3efff !important; }
tr.selected td { color: #1f4a8a; font-weight: 500; }

tr.storniert td { text-decoration: line-through; color: #9aa3ad; }
tr.gegenbuchung td { font-style: italic; }

/* ---------- Sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 18px; }
.sidebar-block {
    background: #f7f9fc;
    border: 1px solid #eef1f6;
    border-radius: 10px;
    padding: 16px;
}
.sidebar-block h3 {
    margin: 0 0 12px 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
}
.action-buttons { display: flex; flex-direction: column; gap: 8px; }

.saldo {
    font-size: 1.4rem;
    font-weight: 600;
    color: #1e8e3e;
    text-align: center;
    padding: 8px 0;
}
.saldo.negativ { color: #d93025; }

/* ---------- Buttons ---------- */
.btn {
    padding: 10px 14px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform .05s, box-shadow .15s, background .15s;
    text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn:hover  { box-shadow: 0 2px 6px rgba(0,0,0,0.12); }

.btn-primary   { background:#2d8cf0; color:#fff; }
.btn-primary:hover { background:#1f6fd0; }

.btn-secondary { background:#e5e8ee; color:#2c3e50; }
.btn-secondary:hover { background:#d7dce4; }

.btn-danger    { background:#d93025; color:#fff; }
.btn-danger:hover { background:#b1271d; }

/* ---------- Modal ---------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(30,40,60,0.5);
    z-index: 1000;
    overflow: auto;
}
.modal-content {
    background: #fff;
    margin: 8% auto;
    padding: 28px 32px;
    width: 90%;
    max-width: 480px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    animation: fadeIn .2s ease-out;
}
@keyframes fadeIn {
    from { opacity:0; transform:translateY(-15px); }
    to   { opacity:1; transform:translateY(0); }
}
#modal-title { margin-top: 0; color: #2d8cf0; }

.close-button {
    float: right; font-size: 26px; font-weight: bold;
    color: #aaa; cursor: pointer; line-height: 1;
}
.close-button:hover { color: #333; }

.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #556;
}
.form-group input[type="date"],
.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #d1d7e0;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus {
    outline: none;
    border-color: #2d8cf0;
    box-shadow: 0 0 0 3px rgba(45,140,240,.15);
}
.radio-group label {
    display: inline-block;
    margin-right: 18px;
    font-weight: normal;
}
#beleg-nr-anzeige {
    font-weight: 600; color:#2d8cf0;
    font-size: 1.1rem; margin: 0; padding: 4px 0;
}
.button-group { display:flex; gap:10px; margin-top: 20px; }
.button-group .btn { flex: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .app-container { width: 96%; }
    .content-wrapper { grid-template-columns: 1fr; }
}

/* Sortierbare Spalten-Header */
th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background .12s;
    position: relative;
}
th.sortable:hover {
    background: #eef3fb;
    color: #2d8cf0;
}
th.sorted {
    color: #2d8cf0;
    background: #eef3fb;
}

/* ---------- Filter-Panel ---------- */
.filter-panel {
    background: #f7f9fc;
    border: 1px solid #eef1f6;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    justify-content: space-between;
}
.filter-fields {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}
.filter-group.filter-grow { flex: 1; min-width: 220px; }
.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
}
.filter-group input {
    padding: 8px 10px;
    border: 1px solid #d1d7e0;
    border-radius: 6px;
    font-size: 0.92rem;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.filter-group input:focus {
    outline: none;
    border-color: #2d8cf0;
    box-shadow: 0 0 0 3px rgba(45,140,240,.15);
}
.filter-actions {
    display: flex;
    gap: 8px;
}
.filter-active-info {
    background: #fff8e1;
    border: 1px solid #ffe082;
    color: #795548;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

/* ---------- Modal wide ---------- */
.modal-content.modal-wide {
    max-width: 720px;
}

/* ---------- Kontenverwaltung ---------- */
.konten-layout {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 24px;
    margin-top: 16px;
}
.konten-liste-wrapper {
    background: #f7f9fc;
    border: 1px solid #eef1f6;
    border-radius: 8px;
    max-height: 360px;
    overflow-y: auto;
}
.konten-liste {
    list-style: none;
    margin: 0;
    padding: 6px;
}
.konten-liste li {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s;
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.konten-liste li:hover { background: #eef3fb; }
.konten-liste li.selected {
    background: #2d8cf0;
    color: #fff;
    font-weight: 500;
}
.konten-liste li .buchung-count {
    font-size: 0.8rem;
    opacity: 0.7;
}
.konten-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.action-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.action-section h4 {
    margin: 0 0 4px 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
}

/* ---------- Header mit Logo ---------- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
    background: #fff;
    padding: 4px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

/* ---------- Einstellungen Modal ---------- */
.einstellungen-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 16px;
    max-height: 65vh;
    overflow-y: auto;
    padding-right: 6px;
}
.einstellungen-section {
    background: #f7f9fc;
    border: 1px solid #eef1f6;
    border-radius: 10px;
    padding: 16px;
}
.einstellungen-section h3 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    color: #2d8cf0;
    font-weight: 600;
}

/* Logo-Bereich */
.logo-area {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 16px;
    align-items: start;
}
.logo-preview {
    width: 180px;
    height: 180px;
    background: #fff;
    border: 2px dashed #d1d7e0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview .placeholder { color: #9aa3ad; font-size: 0.9rem; }
.logo-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Farbprofil */
.color-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
#setting-header-farbe {
    width: 70px; height: 42px;
    border: 1px solid #d1d7e0;
    border-radius: 6px;
    cursor: pointer;
    background: #fff;
}
.preset-colors { display: flex; gap: 6px; flex-wrap: wrap; }
.color-preset {
    width: 32px; height: 32px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #d1d7e0;
    border-radius: 50%;
    cursor: pointer;
    transition: transform .1s, box-shadow .1s;
    padding: 0;
}
.color-preset:hover { transform: scale(1.15); box-shadow: 0 0 0 2px #2d8cf0; }

/* Backup */
.backup-row { display: flex; gap: 10px; flex-wrap: wrap; }
.hint {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #795548;
    background: #fff8e1;
    border: 1px solid #ffe082;
    padding: 8px 12px;
    border-radius: 6px;
}

/* Coloris-Integration */
#setting-header-farbe {
    padding: 10px 12px;
    padding-left: 44px; /* Platz für Farb-Thumb */
    border: 1px solid #d1d7e0;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fff;
    font-family: ui-monospace, Menlo, monospace;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    width: 180px;
}

/* ---------- Gesamtübersicht-Tab ---------- */
.tab-gesamt {
    border-left: 2px solid #eef1f6;
    margin-left: 8px;
    padding-left: 18px !important;
    font-style: italic;
}
.tab-gesamt.active { font-style: normal; }

/* Gesamtsaldo-Banner */
.gesamt-banner {
    background: linear-gradient(135deg, #eef3fb 0%, #f7faff 100%);
    border: 1px solid #d1e0f4;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.gesamt-banner .label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #556;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}
.gesamt-banner .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e8e3e;
    font-variant-numeric: tabular-nums;
}
.gesamt-banner .value.negativ { color: #d93025; }

/* Salden-Tabelle */
.salden-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.salden-table th {
    background: #f7f9fc;
    font-weight: 600;
    color: #556;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eef1f6;
}
.salden-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eef1f6;
    font-size: 0.95rem;
}
.salden-table tr:last-child td { border-bottom: none; }
.salden-table td:last-child {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.gesamt-subtitle {
    margin: 20px 0 10px 0;
    font-size: 1rem;
    color: #556;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---------- Druck-Layout ---------- */
@media print {
    @page { size: A4 landscape; margin: 12mm; }

    body { background: #fff !important; color: #000 !important; }

    .app-container {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    /* Unsichtbare Bereiche */
    .sidebar,
    .filter-panel,
    .app-footer,
    .tabs,
    .close-button,
    .modal { display: none !important; }

    .content-wrapper { grid-template-columns: 1fr !important; }

    /* Header: einfarbig statt Gradient */
    .app-header {
        background: none !important;
        color: #000 !important;
        border-bottom: 2px solid #333;
        padding: 6mm 0 4mm 0 !important;
    }
    .app-header h1 { color: #000 !important; font-size: 16pt !important; }
    .header-logo { max-height: 18mm !important; }

    /* Tabellen kompakter */
    .buchungstabelle, .salden-table {
        box-shadow: none !important;
        font-size: 9pt !important;
    }
    .buchungstabelle th,
    .buchungstabelle td,
    .salden-table th,
    .salden-table td {
        padding: 4px 6px !important;
        border: 1px solid #bbb !important;
    }
    .buchungstabelle th, .salden-table th {
        background: #eaeef5 !important;
        color: #000 !important;
    }
    tr { page-break-inside: avoid; }
    thead { display: table-header-group; } /* Kopfzeile auf jeder Seite */

    .gesamt-banner {
        background: none !important;
        border: 1px solid #333 !important;
    }
    .gesamt-banner .value { color: #000 !important; }

    .filter-active-info { display: none !important; }

    /* Links ohne Unterstreichung */
    a { color: #000 !important; text-decoration: none !important; }
}

/* ---------- Login-Seite ---------- */
body.login-body {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 100vh; background: #f0f2f5; margin: 0;
}
.login-box {
    background: #fff; padding: 36px; border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,.1); width: 380px;
}
.login-box h1 { margin: 0 0 20px 0; text-align: center; color: #2d8cf0; }
.login-box .form-group { margin-bottom: 14px; }
.login-box input {
    width: 100%; padding: 10px 12px; border: 1px solid #d1d7e0;
    border-radius: 6px; box-sizing: border-box; font-size: 14px;
}
.login-box input:focus { outline: none; border-color: #2d8cf0; box-shadow: 0 0 0 3px rgba(45,140,240,.15); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.error-msg { color: #d93025; margin-top: 12px; text-align: center; font-size: 0.9rem; }
.login-hint { font-size: 0.8rem; color: #888; text-align: center; margin-top: 18px; }
.login-hint code { background: #eef3fb; padding: 2px 6px; border-radius: 4px; color: #2d8cf0; }

/* ---------- User-Badge im Header ---------- */
.user-badge {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,.15);
    padding: 6px 12px; border-radius: 999px;
    color: #fff; font-size: 0.88rem;
    margin-right: 12px;
}
.user-role {
    padding: 2px 8px; border-radius: 999px;
    font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .5px;
}
.user-role.role-admin { background: #dc2626; }
.user-role.role-edit  { background: #16a34a; }
.user-role.role-read  { background: #64748b; }

.btn-icon {
    background: rgba(255,255,255,.15); border: none; color: #fff;
    width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
    font-size: 16px; transition: background .15s;
}
.btn-icon:hover { background: rgba(255,255,255,.3); }

/* Rollen-gesteuertes Ausblenden */
.admin-only, .edit-only { display: none; }
body.role-admin .admin-only,
body.role-admin .edit-only,
body.role-edit  .edit-only { display: block; }

/* ---------- Benutzerverwaltung ---------- */
.users-layout { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.users-liste-wrapper { max-height: 420px; overflow-y: auto; }
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td {
    padding: 10px 12px; text-align: left;
    border-bottom: 1px solid #eef1f6; font-size: 0.92rem;
}
.users-table th { background: #f7f9fc; font-size: 0.75rem; text-transform: uppercase; color: #556; }
.users-actions { display: flex; gap: 10px; justify-content: flex-end; }
.hint-inline { color: #888; font-weight: normal; font-size: 0.8rem; }

/* Coloris nie als fullscreen overlay */
#clr-picker {
    display: none !important;
}
#clr-picker.clr-open {
    display: block !important;
}

/* Erstellt-von-Spalte */
td.created-by {
    color: #6b7280;
    font-size: 0.85rem;
    font-variant: small-caps;
}

/* ---------- Info-Tab ---------- */
.tab-info {
    font-style: italic;
    color: #6b7280;
}
.tab-info.active { color: #2d8cf0; font-style: normal; }

.info-tab {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.info-hero {
    background: linear-gradient(135deg, #eef3fb 0%, #f7faff 100%);
    border: 1px solid #d1e0f4;
    border-radius: 10px;
    padding: 20px 24px;
}
.info-hero h2 {
    margin: 0 0 6px 0;
    color: #2d8cf0;
    font-size: 1.4rem;
}
.info-lead {
    margin: 0;
    color: #556;
    font-size: 0.95rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.info-card {
    background: #fff;
    border: 1px solid #eef1f6;
    border-radius: 10px;
    padding: 16px 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    transition: box-shadow .15s, transform .15s;
}
.info-card:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.info-card h3 {
    margin: 0 0 10px 0;
    font-size: 1rem;
    color: #2d8cf0;
    font-weight: 600;
}
.info-card ul {
    margin: 0;
    padding-left: 18px;
    color: #374151;
    font-size: 0.9rem;
    line-height: 1.55;
}
.info-card ul li { margin-bottom: 4px; }
.info-card-wide { grid-column: 1 / -1; }

.info-hint {
    margin: 10px 0 0 0;
    font-size: 0.82rem;
    color: #6b7280;
    font-style: italic;
}

.info-footer {
    text-align: center;
    padding: 14px 0 4px 0;
    color: #6b7280;
    font-size: 0.85rem;
}
.info-footer a {
    color: #2d8cf0;
    text-decoration: none;
    font-weight: 500;
}
.info-footer a:hover { text-decoration: underline; }


.backup-list { margin-top: 10px; max-height: 240px; overflow-y: auto;
    border: 1px solid #eef1f6; border-radius: 6px; background: #fff; }
.backup-list-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.backup-list-table th, .backup-list-table td {
    padding: 6px 10px; border-bottom: 1px solid #eef1f6; text-align: left; }
.backup-list-table th { background: #f7f9fc; color: #556; font-size: 0.7rem;
    text-transform: uppercase; letter-spacing: .5px; position: sticky; top: 0; }
.backup-list-table tr:last-child td { border-bottom: none; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }


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

/* Body darf nicht horizontal scrollen (Table hat eigenes Scroll-Container) */
html, body {
    max-width: 100%;
    overflow-x: clip; /* statt hidden – erlaubt Scroll in inneren Containern */
}

/* Tab-Leiste horizontal scrollbar */
.tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { height: 6px; }
.tabs::-webkit-scrollbar-thumb { background: #d1d7e0; border-radius: 3px; }
.tab-button { white-space: nowrap; flex-shrink: 0; }

/* Table-Area als Scroll-Container */
.table-area {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

/* ---------- Tablet / kleineres Laptop ---------- */
@media (max-width: 1100px) {
    .app-container { width: 94%; }
}

/* ---------- Tablet (unter 900px) ---------- */
@media (max-width: 900px) {
    .app-container { width: 100%; margin: 0; border-radius: 0; min-height: 100vh; }
    .app-main { padding: 14px 14px; }
    .content-wrapper { grid-template-columns: 1fr; gap: 14px; }

    /* Sidebar unter die Tabelle */
    .sidebar { flex-direction: row; flex-wrap: wrap; gap: 10px; }
    .sidebar-block { flex: 1 1 240px; min-width: 0; }

    .filter-panel { flex-direction: column; align-items: stretch; gap: 12px; }
    .filter-fields { width: 100%; }
    .filter-actions { width: 100%; justify-content: stretch; }
    .filter-actions .btn { flex: 1; }

    /* Tabellen: horizontal scrollbar erzwingen */
    .table-area table {
        width: auto;
        min-width: 100%;
    }
    .table-area th, .table-area td { white-space: nowrap; }
    .table-area td:nth-child(3), /* Beschreibung darf umbrechen */
    .table-area td.beschreibung-col { white-space: normal; }
}

/* ---------- Handy (unter 700px) ---------- */
@media (max-width: 700px) {
    .app-header {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 10px;
    }
    .app-header h1 {
        font-size: 1.05rem;
        flex: 1 1 100%;
        order: 1;
        margin: 0;
    }
    .user-badge {
        order: 2;
        font-size: 0.75rem;
        padding: 4px 10px;
        gap: 6px;
        margin: 0;
    }
    .header-logo {
        order: 3;
        height: 36px !important;
        margin-left: auto;
    }

    .filter-group { min-width: 0; }
    .filter-group.filter-grow { min-width: 0; flex: 1 1 100%; }

    .sidebar { flex-direction: column; }
    .sidebar-block { flex: 1 1 100%; }
    .action-buttons { flex-direction: column; }

    .tab-button { padding: 9px 13px; font-size: 0.88rem; }

    /* Modals: fullscreen */
    .modal-content {
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 100vh;
        border-radius: 0 !important;
        padding: 18px !important;
    }
    .modal-content.modal-wide { max-width: 100% !important; }

    /* Touch-freundliche Buttons */
    .btn { min-height: 42px; padding: 10px 14px; }
    .btn-sm { min-height: 32px; padding: 6px 12px; }
    .btn-icon { width: 38px; height: 38px; font-size: 15px; }

    /* Gesamtübersicht */
    .gesamt-banner { flex-direction: column; align-items: flex-start; padding: 14px 16px; }
    .gesamt-banner .value { font-size: 1.4rem; }

    /* Einstellungen */
    .logo-area { grid-template-columns: 1fr; gap: 12px; }
    .logo-preview { width: 140px; height: 140px; margin: 0 auto; }

    /* Konten-Verwaltung */
    .konten-layout { grid-template-columns: 1fr; }

    /* Info-Tab: 1 Karte pro Reihe */
    .info-grid { grid-template-columns: 1fr; }

    .app-footer { padding: 12px 14px; font-size: 0.75rem; line-height: 1.4; }
}

/* ---------- Small Phones (unter 500px): KARTEN-LAYOUT ---------- */
@media (max-width: 500px) {

    /* Buchungstabellen werden zu Karten */
    .buchungstabelle thead { display: none; }
    .buchungstabelle,
    .buchungstabelle tbody,
    .buchungstabelle tr,
    .buchungstabelle td { display: block; width: 100%; }

    .buchungstabelle tr {
        background: #fff;
        border: 1px solid #eef1f6;
        border-radius: 8px;
        padding: 10px 12px;
        margin-bottom: 10px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    }
    .buchungstabelle td {
        border: none;
        padding: 3px 0 !important;
        white-space: normal;
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 8px;
        font-size: 0.88rem;
    }
    .buchungstabelle td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: .4px;
        flex-shrink: 0;
    }
    /* Beschreibung nimmt die volle Breite */
    .buchungstabelle td.beschreibung-col {
        flex-direction: column;
        align-items: stretch;
    }
    .buchungstabelle td.beschreibung-col::before {
        margin-bottom: 2px;
    }

    /* Einnahme/Ausgabe rechts, farbig */
    .buchungstabelle td.einnahme,
    .buchungstabelle td.ausgabe {
        font-weight: 600;
    }

    /* Stornierte Zeilen */
    .buchungstabelle tr.storniert {
        opacity: 0.55;
    }
    .buchungstabelle tr.storniert td { text-decoration: line-through; }

    /* Gegenbuchungs-Zeilen */
    .buchungstabelle tr.gegenbuchung {
        border-left: 3px solid #dc2626;
    }

    /* Ausgewählte Zeile */
    .buchungstabelle tr.selected {
        border-color: #2d8cf0;
        background: #eef3fb !important;
        box-shadow: 0 0 0 2px rgba(45,140,240,.2);
    }
    .buchungstabelle tr.selected td,
    .buchungstabelle tr.selected td::before { color: #1e4a8a; }

    /* Salden-Tabelle bleibt normale Tabelle aber kompakt */
    .salden-table th, .salden-table td { padding: 8px 10px !important; font-size: 0.85rem; }

    /* Users-Tabelle: auch Karten */
    .users-table thead { display: none; }
    .users-table, .users-table tbody, .users-table tr, .users-table td { display: block; width: 100%; }
    .users-table tr {
        background: #fff; border: 1px solid #eef1f6; border-radius: 8px;
        padding: 10px 12px; margin-bottom: 10px;
    }
    .users-table td {
        border: none; padding: 3px 0 !important;
        display: flex; justify-content: space-between; align-items: center; gap: 8px;
    }
    .users-table td::before {
        content: attr(data-label);
        font-weight: 600; color: #6b7280; font-size: 0.75rem;
        text-transform: uppercase; letter-spacing: .4px;
    }
}

.table-area {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
}

/* ===== Mobile Scroll-Fix ===== */
@media (max-width: 900px) {

    /* KEIN overflow:hidden auf Vorfahren, sonst kann Scroll nicht wirken */
    html, body { overflow-x: auto !important; }
    .app-container,
    .app-main,
    .content-wrapper,
    .table-area,
    #tab-content-container {
        overflow-x: visible !important;
        overflow-y: visible !important;
        max-width: 100%;
    }

    /* Tabellen-Container = der EINE Scroll-Container */
    .table-area {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Tabellen dürfen breiter als der Viewport werden */
    .table-area table {
        width: max-content !important;
        min-width: 100% !important;
    }
    .table-area th,
    .table-area td {
        white-space: nowrap !important;
    }

    /* Tab-Leiste */
    .tabs {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
    }
    .tab-button {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }
}