/* ============================================================
   WuS Office – App CSS  (Light Theme, angeglichen an Shop/Portal)
   ============================================================ */

:root {
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    /* Transitions */
    --transition-base: 200ms ease;
    --transition-fast: 150ms ease;

    /* Light Theme (an Shop angeglichen) */
    --bg:            #f1f5f9;
    --bg-soft:       #f8fafc;
    --bg-card:       #ffffff;
    --card-bg:       #ffffff; /* Alias für Shop-/Portal-Views */
    --bg-card-hover: #f8fafc;
    --bg-panel:      #ffffff;

    --text:          #1a1a2e;
    --text-muted:    #64748b;

    --border:        #e2e8f0;
    --border-hover:  #cbd5e1;

    --accent:        #860000;
    --accent-hover:  #6a0000;
    --accent-dark:   #4f0000;
    --accent-light:  rgba(134,0,0,0.08);

    --success: #16a34a;
    --warning: #f59e0b;
    --danger:  #ef4444;

    --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
    --shadow:    0 1px 4px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-md: 0 4px 12px rgba(15,23,42,0.08), 0 2px 4px rgba(15,23,42,0.04);
    --shadow-lg: 0 12px 30px rgba(15,23,42,0.10), 0 4px 10px rgba(15,23,42,0.06);

    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.card:hover { border-color: var(--border-hover); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-base), border-color var(--transition-fast), color var(--transition-fast);
    border: 1px solid transparent;
    text-decoration: none;
    line-height: 1.2;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(134,0,0,0.18);
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-ghost {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-muted);
}
.btn-ghost:hover {
    background: var(--bg-soft);
    color: var(--text);
    border-color: var(--border-hover);
}

.btn-outline {
    background: transparent;
    border-color: var(--accent);
    color: var(--accent);
}
.btn-outline:hover { background: var(--accent); color: #fff; }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }

.btn-sm        { padding: 0.32rem 0.7rem; font-size: 0.8rem; }
.btn-lg        { padding: 0.7rem 1.4rem; font-size: 0.95rem; }

/* ---- Form ---- */
.form-input {
    width: 100%;
    padding: 0.55rem 0.85rem;
    background: #ffffff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 0.9rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:hover { border-color: var(--border-hover); }
.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(134,0,0,0.08);
}
.form-input::placeholder { color: #94a3b8; }
.form-input[disabled],
.form-input[readonly] { background: var(--bg-soft); color: var(--text-muted); }

select.form-input {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%2364748b' stroke-width='1.5'%3e%3cpath d='M1 1.5l5 5 5-5'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 12px;
    padding-right: 2rem;
    -webkit-appearance: none;
    appearance: none;
}
select.form-input option { background: #ffffff; color: var(--text); }

textarea.form-input { resize: vertical; min-height: 80px; font-family: inherit; }

label.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.3rem;
}
.form-group { margin-bottom: 1rem; }
.required-star { color: var(--accent); margin-left: 2px; }

/* ---- Alert / Flash ---- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    border: 1px solid;
    margin-bottom: 1rem;
}
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-error   { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ---- Table ---- */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th {
    padding: 0.7rem 0.9rem;
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1.5px solid var(--border);
    white-space: nowrap;
    background: var(--bg-soft);
    position: sticky;
    top: 0;
    z-index: 2;
}
.table td {
    padding: 0.8rem 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:nth-child(even) td { background: var(--bg-soft); }
.table tbody tr:hover td { background: rgba(134, 0, 0, 0.06); }

/* ---- Scroll-Container für Tabellen (ermöglicht Sticky-Header) ---- */
.table-wrap {
    overflow: auto;
    max-height: calc(100vh - 240px);
    border-radius: var(--radius-md);
}

/* ---- Listen-Schnellsuche ---- */
.list-search {
    position: relative;
    margin-bottom: 1rem;
    max-width: 360px;
}
.list-search i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}
.list-search input {
    width: 100%;
    padding: 0.55rem 0.75rem 0.55rem 2.1rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-soft);
    color: var(--text);
}
.list-search input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg);
}
.filter-hidden { display: none !important; }
.list-empty { padding: 1.5rem; text-align: center; color: var(--text-muted); font-size: 0.875rem; grid-column: 1 / -1; }

/* ---- Status-Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
}
.badge-laufend       { background: #dbeafe; color: #1d4ed8; }
.badge-neu           { background: #ede9fe; color: #6d28d9; }
.badge-abgeschlossen { background: #dcfce7; color: #166534; }
.badge-notfall       { background: #fee2e2; color: #b91c1c; }
.badge-bezahlt       { background: #fef3c7; color: #92400e; }
.badge-unterbrochen  { background: #e5e7eb; color: #374151; }
.badge-in_pruefung   { background: #fef9c3; color: #854d0e; }
.badge-bearbeitung   { background: #dbeafe; color: #1e40af; }
.badge-storniert     { background: #fee2e2; color: #991b1b; }

/* ---- Page header ---- */
.page-wrapper { padding: 1.5rem 1.5rem; max-width: 100%; }
.page-header  {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
    letter-spacing: -0.01em;
}
.page-sub { font-size: 0.875rem; color: var(--text-muted); margin: 0.25rem 0 0; }

/* ============================================================
   App-Shell: Topbar + Sidebar + Content
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
    min-height: 100svh; /* iOS: 100vh ist der GROSSE Viewport (unter der URL-Leiste) */
}

/* ── Sidebar ── */
.app-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #ffffff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    /* Ohne svh liegt der Sidebar-Footer (inkl. "Abmelden") auf dem iPhone
       unter der URL-Leiste und ist nicht antippbar. */
    height: 100svh;
    z-index: 45;
    transition: transform var(--transition-base);
}
.sidebar-logo {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0 1.1rem;
    height: 58px;
    border-bottom: 3px solid var(--accent);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}
.sidebar-logo .accent { color: var(--accent); }
.sidebar-logo i { color: var(--accent); font-size: 1.2rem; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.85rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.sidebar-group { display: flex; flex-direction: column; gap: 0.15rem; margin-top: 0.85rem; }
.sidebar-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    padding: 0 0.8rem 0.3rem;
}
.sidebar-link {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
    position: relative;
}
.sidebar-link i { width: 18px; text-align: center; font-size: 0.95rem; flex-shrink: 0; }
.sidebar-link:hover { background: var(--bg-soft); color: var(--text); }
.sidebar-link.active {
    background: var(--accent);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(134,0,0,0.25);
}
.sidebar-link.active:hover { background: var(--accent-hover); color: #ffffff; }
.sidebar-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
}
.sidebar-link.active .sidebar-badge { background: rgba(255,255,255,0.25); }

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 0.6rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

/* ── Content-Bereich ── */
.app-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ── Mobile-Topbar (nur auf Mobile sichtbar) ── */
.app-topbar {
    display: none;
    position: sticky; top: 0; z-index: 40;
    height: 54px;
    background: #ffffff;
    border-bottom: 3px solid var(--accent);
    padding: 0 0.85rem;
    align-items: center;
    gap: 0.75rem;
}
.topbar-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text);
    font-size: 1.05rem;
}
.topbar-toggle:hover { background: var(--bg-soft); }
.topbar-logo {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
}
.topbar-logo .accent { color: var(--accent); }
.topbar-spacer { flex: 1; }

/* ── Backdrop (Mobile, wenn Sidebar offen) ── */
.app-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 44;
    opacity: 0;
    transition: opacity var(--transition-base);
}

main { background: var(--bg); flex: 1; min-width: 0; }

/* Alte Nav-Klassen weiterhin nutzbar (Kompat-Aliase) */
.nav-link { /* alias für sidebar-link – falls noch irgendwo verwendet */ }

/* ── Mobile (<900px): Sidebar versteckt, Topbar sichtbar ── */
@media (max-width: 900px) {
    .app-sidebar {
        position: fixed; top: 0; left: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .app-sidebar.open { transform: translateX(0); }
    .app-topbar { display: flex; }
    .app-backdrop.open { display: block; opacity: 1; }
}

/* ── Sehr klein: Sidebar Vollbreite ── */
@media (max-width: 380px) {
    .app-sidebar { width: 88vw; }
}

/* ---- Modal ---- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.45);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    z-index: 50;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    max-height: 90svh; /* iOS Safari URL-Bar Bug */
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    color: var(--text);
}

/* ---- Responsive Form-Grids (für Forms mit 1fr 1fr Inline-Styles) ---- */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}
.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0 1rem;
}
/* PLZ/Ort und PLZ/Ort/Land — die schmale erste Spalte darf nicht mitschrumpfen,
   sonst bleiben bei 375px ~78px breite Felder übrig. */
.form-row-plz {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 0 1rem;
}
.form-row-plz-3 {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 0 0.65rem;
}

/* ---- Generisches Card/Spalten-Layout ---- */
.split-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
}
.split-2-sidebar {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.25rem;
    align-items: start;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Utility ---- */
.hidden { display: none !important; }
.mb-4   { margin-bottom: 1rem; }
/* .hide-mobile hat bewusst KEINE Basisregel: als display:inline-flex hat sie
   ein <th> aus dem Tabellen-Box-Modell gerissen (shop/admin/produkte.php) und
   oberhalb 640px die Spalten verschoben. Versteckt wird nur noch unten. */

/* Scroll-to-top Button.
   Die Positionierung stand im Markup als Tailwind-Klassen (fixed bottom-5
   right-5 z-50), die es in diesem Projekt nie gab — der Button klebte
   dadurch statisch am Dokumentende.
   z-index bewusst unter Backdrop (44), Sidebar (45) und Modal (50). */
#scrollTopBtn {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 30;
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    box-shadow: var(--shadow-md);
}
#scrollTopBtn:hover {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
}

/* ============================================================
   Responsive — Breakpoint-Kanon
   ============================================================
   Es gelten genau drei Breakpoints (plus 380px nur für die Sidebar-Breite):

     900px  Sidebar wird Off-Canvas; Seitenlayouts stapeln;
            Touch-Targets und Eingabe-Schriftgröße greifen
     640px  Haupt-Mobilumschaltung: Tabelle → Karten, 2-spaltig → 1-spaltig
     480px  Schmales Handy: engste Abstände, letzte Grids auf 1 Spalte

   Custom Properties funktionieren in @media-Bedingungen NICHT — die Werte
   stehen deshalb bewusst als Zahlen da. Bitte keine neuen Zwischenwerte
   einführen; neue Regeln auf den nächstgrößeren Kanonwert aufrunden.
   ============================================================ */
@media (max-width: 900px) {
    .form-row-3 { grid-template-columns: 1fr 1fr; }
    .split-2-sidebar { grid-template-columns: 1fr; }
    /* kein verschachteltes vertikales Scrollen auf Tablet/Mobile;
       horizontaler Scroll für breite Tabellen bleibt erhalten */
    .table-wrap { max-height: none; }

    /* --- Eingabefelder: 16px gegen den iOS-Auto-Zoom ---
       Safari zoomt beim Fokus in jedes Feld unter 16px hinein und danach
       NICHT wieder heraus. Das !important ist hier die einzige Ausnahme im
       Stylesheet und notwendig, weil die Gegenspieler ~14 Inline-Angaben in
       den Views sind (z. B. shop/warenkorb.php, shop/produkt.php). */
    .form-input,
    .list-search input,
    select, textarea,
    input[type="text"], input[type="email"], input[type="tel"],
    input[type="number"], input[type="password"], input[type="date"],
    input[type="search"], input[type="url"] {
        font-size: 16px !important;
    }

    /* --- Touch-Targets ---
       .btn-sm lag bei ~28px, das Minimum für sicheres Antippen liegt bei 44px;
       40px ist der Kompromiss für eine dichte Verwaltungsoberfläche. */
    .btn          { min-height: 40px; padding: 0.5rem 0.9rem; font-size: 0.85rem; }
    .btn-sm       { min-height: 40px; padding: 0.45rem 0.8rem; font-size: 0.85rem; }
    .icon-btn     { min-width: 44px; min-height: 44px; }
    .topbar-toggle{ width: 44px; height: 44px; }
}
@media (max-width: 640px) {
    .page-wrapper { padding: 1rem 0.75rem; }
    .hide-mobile { display: none !important; }
    .modal { padding: 1.1rem; border-radius: var(--radius-lg); }
    .split-2 { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
    .page-title { font-size: 1.15rem; }
    .list-search { max-width: none; }
}
@media (max-width: 480px) {
    .form-row-2 { grid-template-columns: 1fr; }
    .form-row-plz   { grid-template-columns: 90px 1fr; }
    .form-row-plz-3 { grid-template-columns: 1fr; }
    .page-wrapper { padding: 0.85rem 0.6rem; }
    .table th, .table td { padding: 0.5rem 0.55rem; }
}

/* ---- Icon-Button (Zeilenaktionen: Bearbeiten/Löschen) ----
   Ersetzt die rohen <button style="background:none;border:none;padding:.3rem">
   in den Tabellen, die auf ~26px kamen. */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    padding: 0.3rem 0.45rem;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn-danger { color: var(--danger); }
.icon-btn-danger:hover { background: #fee2e2; color: var(--danger); }

/* ============================================================
   Shop-Layout (öffentlicher Shop – nutzt App-Shell wie Office)
   ============================================================ */
/* Margin-/Padding-Reset, auf Shop- und Portal-Layout begrenzt: deren Views
   stylen rohe h1/h2/p-Tags inline und erwarten 0 Default-Margins.
   :where() hält die Spezifität bei 0, damit Klassen wie .btn gewinnen.
   .portal-body muss hier stehen — das Portal hatte diesen Reset vorher global
   in seinem Inline-<style>; ohne Ersatz bekämen alle Portalseiten die
   Browser-Standardabstände zurück. */
:where(.shop-body, .portal-body) * { margin: 0; padding: 0; }

.sidebar-logo img,
.topbar-logo img { width: 24px; height: 24px; object-fit: contain; flex-shrink: 0; }
.sidebar-logout:hover { background: #fee2e2; color: var(--danger); }

/* Warenkorb-Button (Shop-Topbar auf Mobile) */
.cart-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: background var(--transition-base);
}
.cart-btn:hover { background: var(--accent-hover); color: #fff; }
.cart-badge {
    background: #fff;
    color: var(--accent);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Shop-Footer */
.shop-footer {
    color: var(--text-muted);
    text-align: center;
    padding: 1rem;
    font-size: 0.78rem;
    border-top: 1px solid var(--border);
}
.shop-footer a { color: var(--text-muted); text-decoration: none; }
.shop-footer a:hover { color: var(--accent); }

/* ============================================================
   Kundenportal
   ============================================================
   Vorher lag hier eine ~225 Zeilen große Kopie des Designsystems inline in
   layouts/portal.php — jede Korrektur an app.css hat das Portal deshalb nie
   erreicht. Nur noch portal-spezifische Bausteine bleiben übrig.
   ============================================================ */
.topbar-user {
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 45vw;
}
.badge-neu-shop { background: #fef9c3; color: #854d0e; }

.portal-footer {
    color: var(--text-muted);
    text-align: center;
    padding: 1rem;
    font-size: 0.78rem;
    border-top: 1px solid var(--border);
}

/* Jahres-Zwischenüberschrift in den Beleglisten */
.beleg-jahr {
    font-size: 0.95rem; font-weight: 700; color: var(--text-muted);
    margin: 1.5rem 0 0.5rem; padding-left: 0.15rem;
    display: flex; align-items: center; gap: 0.5rem;
}
.beleg-jahr:first-of-type { margin-top: 0; }
.beleg-jahr .beleg-jahr-count {
    font-weight: 600; font-size: 0.78rem; color: var(--text-muted);
    background: var(--bg); border-radius: 999px; padding: 0.1rem 0.55rem;
}

/* ---- Beleg-Tabelle: Label links / Wert rechts, gestapelt auf Mobile ----
   Zweispaltige Variante für Belegzeilen. Für flache Datenlisten stattdessen
   .table-stack verwenden (siehe unten). */
@media (max-width: 640px) {
    .beleg-table thead { display: none; }
    .beleg-table, .beleg-table tbody, .beleg-table tr, .beleg-table td { display: block; width: 100%; }
    .beleg-table tr { padding: 0.55rem 0; border-bottom: 1px solid var(--border); }
    .beleg-table tr:last-child { border-bottom: none; }
    .beleg-table tbody tr:hover td,
    .beleg-table tbody tr:nth-child(even) td { background: transparent; }
    .beleg-table td {
        border: none; padding: 0.2rem 0.9rem;
        display: flex; justify-content: space-between; align-items: center;
        gap: 1rem; text-align: right; white-space: normal;
    }
    .beleg-table td::before {
        content: attr(data-label);
        font-weight: 600; color: var(--text-muted);
        font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em;
        text-align: left; flex-shrink: 0;
    }
    .beleg-table td.beleg-pdf-cell { justify-content: flex-end; padding-top: 0.5rem; }
    .beleg-table td.beleg-pdf-cell::before { display: none; }
    /* Sticky-Header ergibt in der gestapelten Ansicht keinen Sinn */
    .beleg-table th { position: static; }
}

/* ---- Mobile-Card-Tabelle: Tabellen mit Klasse .table-stack werden auf Mobile zu Cards ---- */
@media (max-width: 640px) {
    .table-stack thead { display: none; }
    .table-stack tbody tr {
        display: block;
        padding: 0.75rem 0.85rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        margin-bottom: 0.6rem;
        background: var(--bg-card);
    }
    .table-stack tbody tr:hover td,
    .table-stack tbody tr:nth-child(even) td { background: transparent; }
    .table-stack td { display: block; padding: 0.25rem 0; border: none; }
    .table-stack td:empty { display: none; }
    .table-stack td[data-label]::before {
        content: attr(data-label) ":";
        display: inline-block;
        min-width: 100px;
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        margin-right: 0.5rem;
    }
}
