/* Klettergebiet-Finanzen — Stylesheet */
:root {
    --stone-50: #fafaf9;
    --stone-100: #f5f5f4;
    --stone-200: #e7e5e4;
    --stone-300: #d6d3d1;
    --stone-400: #a8a29e;
    --stone-500: #78716c;
    --stone-600: #57534e;
    --stone-700: #44403c;
    --stone-800: #292524;
    --stone-900: #1c1917;
    --emerald-50: #ecfdf5;
    --emerald-100: #d1fae5;
    --emerald-200: #a7f3d0;
    --emerald-600: #059669;
    --emerald-700: #047857;
    --emerald-800: #065f46;
    --amber-50: #fffbeb;
    --amber-100: #fef3c7;
    --amber-700: #b45309;
    --amber-800: #92400e;
    --red-50: #fef2f2;
    --red-200: #fecaca;
    --red-700: #b91c1c;
    --red-800: #991b1b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--stone-50);
    color: var(--stone-800);
    line-height: 1.5;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Topbar */
.topbar {
    background: linear-gradient(90deg, var(--stone-800), var(--stone-700));
    color: var(--stone-50);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.brand-icon {
    font-size: 2rem;
    color: var(--emerald-200);
}

.brand-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.brand-sub {
    font-size: 0.8rem;
    color: var(--stone-300);
}

.nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav a {
    color: var(--stone-200);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.15s;
}

.nav a:hover {
    color: white;
}

.nav-user {
    color: var(--stone-400);
    font-size: 0.9rem;
    padding-left: 1rem;
    border-left: 1px solid var(--stone-600);
}

.nav-logout {
    color: var(--stone-400) !important;
    font-size: 0.9rem;
}

/* Main */
.main {
    padding: 2rem 1rem;
    min-height: calc(100vh - 200px);
}

/* Footer */
.footer {
    border-top: 1px solid var(--stone-200);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--stone-400);
    background: white;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--stone-200);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card.no-padding { padding: 0; overflow: hidden; }

.card h2 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--stone-800);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h2 { margin: 0; }

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--stone-900);
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--stone-200);
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--stone-500);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-einnahme .stat-value { color: var(--emerald-700); }
.stat-ausgabe .stat-value { color: var(--amber-800); }
.stat-bilanz-pos { background: var(--emerald-50); border-color: var(--emerald-200); }
.stat-bilanz-pos .stat-value { color: var(--emerald-800); }
.stat-bilanz-neg { background: var(--red-50); border-color: var(--red-200); }
.stat-bilanz-neg .stat-value { color: var(--red-800); }
.stat-count .stat-value { color: var(--stone-700); }

/* Grid 2-col */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.table th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: var(--stone-50);
    color: var(--stone-600);
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--stone-200);
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--stone-100);
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover { background: var(--stone-50); }

.table-list td { vertical-align: top; }

.text-right { text-align: right; }

.row-note {
    font-size: 0.85rem;
    color: var(--stone-500);
    font-style: italic;
    margin-top: 0.25rem;
}

.row-inactive { opacity: 0.5; }

.row-actions {
    white-space: nowrap;
    text-align: right;
}

.row-actions a, .icon-btn {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    margin: 0 0.1rem;
    color: var(--stone-400);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.15s;
}

.row-actions a:hover, .icon-btn:hover {
    color: var(--stone-700);
    background: var(--stone-100);
}

.icon-btn[title="Löschen"]:hover {
    color: var(--red-700);
    background: var(--red-50);
}

/* Tags */
.tag {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    background: var(--stone-100);
    color: var(--stone-700);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.tag-einnahme { background: var(--emerald-100); color: var(--emerald-800); }
.tag-ausgabe  { background: var(--amber-100); color: var(--amber-800); }
.tag-admin    { background: var(--stone-800); color: white; }

.amount-einnahme { color: var(--emerald-700); font-weight: 600; }
.amount-ausgabe  { color: var(--amber-800); font-weight: 600; }

.badge-receipt {
    display: inline-block;
    margin-left: 0.5rem;
    color: var(--stone-500);
}

/* Forms */
.form { display: flex; flex-direction: column; gap: 1rem; }

.form label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form label > span,
.form-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--stone-700);
}

.form input[type=text],
.form input[type=email],
.form input[type=password],
.form input[type=date],
.form input[type=file],
.form select,
.form textarea {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--stone-300);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    background: white;
    transition: all 0.15s;
}

.form input:focus,
.form select:focus,
.form textarea:focus {
    outline: none;
    border-color: var(--emerald-600);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.form textarea { resize: vertical; }

.form-card { max-width: 600px; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    border-top: 1px solid var(--stone-100);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

/* Type toggle */
.type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.type-toggle label {
    cursor: pointer;
    padding: 0.75rem;
    text-align: center;
    border-radius: 8px;
    background: var(--stone-100);
    color: var(--stone-600);
    font-weight: 500;
    transition: all 0.15s;
}

.type-toggle label input { display: none; }

.type-toggle label.active.einnahme {
    background: var(--emerald-700);
    color: white;
}

.type-toggle label.active.ausgabe {
    background: var(--amber-700);
    color: white;
}

/* Upload */
.upload-block {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.current-receipt {
    background: var(--stone-50);
    padding: 0.75rem;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
}

.checkbox {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--stone-600);
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--emerald-700);
    color: white;
}

.btn-primary:hover { background: var(--emerald-800); }

.btn-secondary {
    background: white;
    color: var(--stone-700);
    border: 1px solid var(--stone-300);
}

.btn-secondary:hover { background: var(--stone-50); }

.btn-link {
    background: none;
    color: var(--stone-500);
}

.btn-link:hover { color: var(--stone-700); }

.btn-block { width: 100%; }

.link {
    color: var(--emerald-700);
    text-decoration: none;
    font-weight: 500;
}

.link:hover { text-decoration: underline; }

.link-subtle {
    color: var(--stone-800);
    text-decoration: none;
}

.link-subtle:hover { color: var(--emerald-700); }

.link-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--stone-700);
    border-radius: 4px;
    font-family: inherit;
}

.link-btn:hover { background: var(--stone-100); }

.link-btn-danger { color: var(--red-700); }

.muted { color: var(--stone-400); }

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    padding: 1rem;
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--stone-200);
    margin-bottom: 1rem;
}

.filter-bar select,
.filter-bar input[type=date] {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--stone-300);
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
}

.filter-date {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--stone-600);
}

.filter-summary {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    background: var(--stone-50);
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--stone-200);
}

.empty-icon {
    font-size: 3rem;
    color: var(--stone-300);
    margin-bottom: 1rem;
}

.empty-state h2 {
    color: var(--stone-700);
    margin: 0 0 0.5rem 0;
}

.empty-state p {
    color: var(--stone-500);
    margin: 0 0 1.5rem 0;
}

/* Auth */
.auth-card {
    max-width: 420px;
    margin: 4rem auto;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-header h1 {
    margin: 0.5rem 0 0.25rem 0;
    font-size: 1.5rem;
    color: var(--stone-900);
}

.auth-header p {
    margin: 0;
    color: var(--stone-500);
    font-size: 0.9rem;
}

.auth-icon {
    font-size: 2.5rem;
    color: var(--emerald-700);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--stone-500);
    font-size: 0.9rem;
}

/* Flash */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.flash-success {
    background: var(--emerald-50);
    color: var(--emerald-800);
    border: 1px solid var(--emerald-200);
}

.flash-error {
    background: var(--red-50);
    color: var(--red-800);
    border: 1px solid var(--red-200);
}

/* Legend list */
.legend-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0 0;
    font-size: 0.9rem;
}

.legend-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--stone-100);
}

.legend-list li:last-child { border-bottom: none; }

/* Inline menu */
.inline-menu {
    position: relative;
    display: inline-block;
}

.inline-menu summary {
    list-style: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: var(--stone-500);
}

.inline-menu summary::-webkit-details-marker { display: none; }

.inline-menu summary:hover {
    background: var(--stone-100);
    color: var(--stone-800);
}

.inline-menu-content {
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    border: 1px solid var(--stone-200);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-width: 200px;
    padding: 0.25rem;
    z-index: 10;
}

.inline-menu-content form { margin: 0; }

/* User-Menü in der Topbar */
.user-menu {
    position: relative;
    margin-left: 0.5rem;
    padding-left: 1rem;
    border-left: 1px solid var(--stone-600);
}

.user-menu summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--stone-200);
    font-size: 0.95rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: background 0.15s;
}

.user-menu summary::-webkit-details-marker { display: none; }

.user-menu summary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.user-menu[open] summary {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.user-menu-arrow {
    font-size: 0.75rem;
    color: var(--stone-400);
    transition: transform 0.15s;
}

.user-menu[open] .user-menu-arrow {
    transform: rotate(180deg);
}

.user-menu-content {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    background: white;
    border: 1px solid var(--stone-200);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-width: 220px;
    padding: 0.25rem;
    z-index: 100;
}

.user-menu-info {
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--stone-100);
    margin-bottom: 0.25rem;
}

.user-menu-fullname {
    color: var(--stone-900);
    font-weight: 600;
    font-size: 0.9rem;
}

.user-menu-email {
    color: var(--stone-500);
    font-size: 0.8rem;
    margin-top: 0.15rem;
    word-break: break-all;
}

.user-menu-content a {
    display: block;
    padding: 0.5rem 0.85rem;
    color: var(--stone-700) !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.user-menu-content a:hover {
    background: var(--stone-100);
    color: var(--stone-900) !important;
}

.user-menu-logout {
    color: var(--red-700) !important;
    border-top: 1px solid var(--stone-100);
    margin-top: 0.25rem;
}

.user-menu-logout:hover {
    background: var(--red-50) !important;
    color: var(--red-800) !important;
}


/* Responsive */
@media (max-width: 640px) {
    .nav-user { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .page-header h1 { font-size: 1.25rem; }

    /* Filterbar kompakter */
    .filter-bar {
        gap: 0.5rem;
    }
    .filter-bar select,
    .filter-bar input[type=date] {
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Filter-Summary in Spalten */
    .filter-summary {
        flex-direction: column;
        gap: 0.4rem;
    }

    /* Tabellen als Karten */
    .table-responsive thead {
        display: none;
    }

    .table-responsive,
    .table-responsive tbody,
    .table-responsive tr,
    .table-responsive td {
        display: block;
        width: 100%;
    }

    .table-responsive tr {
        padding: 0.85rem 1rem;
        border-bottom: 1px solid var(--stone-100);
    }

    .table-responsive tr:hover {
        background: transparent;
    }

    .table-responsive td {
        padding: 0.3rem 0;
        border: none;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 1rem;
        text-align: right;
    }

    .table-responsive td::before {
        content: attr(data-label);
        font-weight: 500;
        color: var(--stone-500);
        font-size: 0.85rem;
        text-align: left;
        flex-shrink: 0;
    }

    /* Spalten ohne Label (z.B. Aktionen) */
    .table-responsive td:not([data-label])::before {
        content: '';
    }

    /* Beschreibung soll voll ausnutzen, da meist länger */
    .table-responsive td[data-label="Beschreibung"] {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
        padding-top: 0.2rem;
        padding-bottom: 0.4rem;
    }

    .table-responsive td[data-label="Beschreibung"]::before {
        margin-bottom: 0.2rem;
    }

    /* Betrag auffällig */
    .table-responsive td[data-label="Betrag"] {
        font-size: 1.05rem;
        padding-top: 0.4rem;
        margin-top: 0.3rem;
        border-top: 1px dashed var(--stone-100);
    }

    /* Aktionen-Reihe linksbündig statt rechts */
    .table-responsive td.row-actions {
        justify-content: flex-end;
        padding-top: 0.4rem;
    }

    /* Topbar kompakter */
    .topbar-inner {
        padding: 0.75rem 1rem;
    }

    .nav {
        gap: 0.5rem;
        font-size: 0.9rem;
    }

    .brand-sub {
        display: none;
    }
}

/* Kurzes Datum auf Mobile (Standard: nur lange Variante zeigen) */
.date-short { display: none; }
.date-full  { display: inline; }

/* Auf Mobile: Layout umschalten */
@media (max-width: 640px) {
    /* Spalte "Erfasst von" verstecken */
    .hide-mobile { display: none; }

    /* Datum verkürzen: nur Tag.Monat. */
    .date-full  { display: none; }
    .date-short { display: inline; }

    /* Beträge nicht umbrechen */
    .amount-einnahme,
    .amount-ausgabe {
        white-space: nowrap;
    }

    /* Tabellenzellen etwas kompakter */
    .table-compact th,
    .table-compact td {
        padding: 0.5rem 0.4rem;
        font-size: 0.85rem;
    }
}
