/* =========================================================
   Heinz Allround-Service Buchhaltung
   Farben & Logo passend zur Website (styles.css)
   ========================================================= */

:root {
    --green: #76B82A;
    --green-dark: #5A8F1F;
    --green-darker: #3F6814;
    --orange: #E8800C;
    --text: #1a1a1a;
    --text-muted: #5a5a5a;
    --bg: #ffffff;
    --bg-alt: #f4f6f1;
    --bg-dark: #1f2a17;
    --border: #e3e6df;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --radius: 4px;
    --income: #5A8F1F;
    --expense: #c0392b;
    --warn: #E8800C;
    --nav-w: 240px;
    --topbar-h: 72px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg-alt);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    z-index: 100;
}

.menu-toggle {
    display: none;
    background: none;
    border: 0;
    width: 40px;
    height: 40px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 0;
}
.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    margin: 0 auto;
    transition: .2s;
}

/* Logo wie auf der Website */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    font-size: 1.05rem;
    text-decoration: none;
}
.brand:hover { text-decoration: none; }

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--green);
    color: #fff;
    font-weight: 800;
    font-size: 1.3rem;
    border-radius: var(--radius);
    line-height: 1;
}

.logo-text { line-height: 1.2; }
.logo-text strong { font-weight: 700; color: var(--green-dark); }

.topbar-context {
    margin-left: auto;
    font-size: .85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .12em;
    font-weight: 700;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar-username {
    font-size: .9rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* ---------- Auth-Seiten (Login / erste Einrichtung) ---------- */
.auth-body {
    background: var(--bg-alt);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-card {
    background: #fff;
    border: 1px solid var(--border);
    border-top: 4px solid var(--green);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
    margin-bottom: 32px;
}
.auth-card h1 {
    font-size: 1.6rem;
    margin: 0 0 1rem;
}
.auth-card .muted { margin-bottom: 1.5rem; }
.auth-form { max-width: 100%; }
.auth-form label { font-size: .9rem; }
.auth-submit { width: 100%; padding: 13px 24px; font-size: .95rem; }

@media (max-width: 480px) {
    .auth-card { padding: 28px 22px; }
    .topbar-username { display: none; }
}

/* ---------- Sidenav ---------- */
.sidenav {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: var(--nav-w);
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 20px 0;
    overflow-y: auto;
}
.sidenav a {
    display: block;
    padding: 12px 24px;
    color: var(--text);
    text-decoration: none;
    border-left: 3px solid transparent;
    font-weight: 500;
    font-size: .95rem;
    transition: all .15s ease;
}
.sidenav a:hover {
    background: var(--bg-alt);
    border-left-color: var(--green);
    color: var(--green-dark);
    text-decoration: none;
}

/* ---------- Content ---------- */
.content {
    margin-left: var(--nav-w);
    padding: calc(var(--topbar-h) + 28px) 32px 40px;
    max-width: 1200px;
}

h1 {
    margin: 0 0 1.2rem;
    font-size: clamp(1.7rem, 3.5vw, 2.4rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
}
h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.muted { color: var(--text-muted); }
.eyebrow {
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .8rem;
    font-weight: 700;
    color: var(--green-dark);
    margin: 0 0 1rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}
.page-header h1 { margin: 0; }

/* ---------- KPI Grid ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.kpi {
    background: #fff;
    border: 1px solid var(--border);
    border-top: 3px solid var(--green);
    border-radius: var(--radius);
    padding: 20px 22px;
}
.kpi-label {
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
}
.kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.kpi-sub {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.kpi-value.income { color: var(--income); }
.kpi-value.expense { color: var(--expense); }
.kpi-value.warn { color: var(--warn); }

/* ---------- Chart Grid ---------- */
.chart-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 22px;
    margin-bottom: 22px;
}
.chart-card { margin-bottom: 0; }
.chart-wrap {
    position: relative;
    height: 320px;
}
@media (max-width: 900px) {
    .chart-grid { grid-template-columns: 1fr; }
    .chart-wrap { height: 280px; }
}

/* ---------- Cards ---------- */
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    margin-bottom: 22px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------- Tables ---------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.data-table th {
    background: var(--bg-alt);
    text-align: left;
    padding: 12px 16px;
    font-size: .78rem;
    color: var(--green-darker);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    font-size: .95rem;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-alt); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Status Badges ---------- */
.status {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    background: #e5e7eb;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.status-bezahlt { background: rgba(118,184,42,0.18); color: var(--green-darker); }
.status-offen { background: rgba(232,128,12,0.18); color: var(--orange); }
.status-entwurf { background: #e5e7eb; color: #374151; }
.status-storniert { background: rgba(192,57,43,0.15); color: #c0392b; }
.status-angenommen { background: rgba(118,184,42,0.18); color: var(--green-darker); }
.status-abgelehnt { background: rgba(192,57,43,0.15); color: #c0392b; }

/* ---------- Forms ---------- */
.form { max-width: 760px; }
.form fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 26px;
    margin: 0 0 22px;
    background: #fff;
}
.form legend {
    font-weight: 700;
    padding: 0 8px;
    color: var(--green-darker);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .8rem;
}
.form label {
    display: block;
    font-size: .9rem;
    color: var(--text);
    margin-bottom: 14px;
    font-weight: 600;
}
.form label.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 500;
}
.form input, .form select, .form textarea {
    display: block;
    width: 100%;
    padding: 11px 14px;
    margin-top: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    font-weight: 400;
    background: #fff;
    color: var(--text);
    transition: border-color .2s, box-shadow .2s;
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(118,184,42,0.18);
}
.form textarea { resize: vertical; min-height: 70px; }

.row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.col-3 { flex: 0 0 calc(25% - 12px); min-width: 100px; }
.col-6 { flex: 0 0 calc(50% - 8px); min-width: 140px; }
.col-9 { flex: 1 1 calc(75% - 4px); min-width: 200px; }
.col-12 { flex: 1 1 100%; }

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: .9rem;
    border: 2px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    transition: all .2s ease;
    text-decoration: none !important;
    line-height: 1.2;
    font-family: inherit;
}
.btn:hover {
    background: var(--bg-alt);
    border-color: var(--green);
    color: var(--green-darker);
    text-decoration: none;
}
.btn-primary {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
}
.btn-primary:hover {
    background: var(--green-dark);
    border-color: var(--green-dark);
    color: #fff;
}
.btn-small { padding: 7px 14px; font-size: .82rem; }
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---------- Flash Messages ---------- */
.flash {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: .95rem;
    border-left: 3px solid;
}
.flash-success {
    background: rgba(118,184,42,0.1);
    color: var(--green-darker);
    border-left-color: var(--green);
}
.flash-error {
    background: rgba(192,57,43,0.08);
    color: #991b1b;
    border-left-color: #c0392b;
}
.flash-info {
    background: #fff8e6;
    color: var(--text-muted);
    border-left-color: var(--orange);
}

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
    .menu-toggle { display: flex; }
    .sidenav {
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 90;
        box-shadow: 4px 0 12px rgba(0,0,0,0.1);
    }
    body.nav-open .sidenav { transform: translateX(0); }
    .content {
        margin-left: 0;
        padding: calc(var(--topbar-h) + 18px) 18px 28px;
    }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .kpi { padding: 16px 18px; }
    .kpi-value { font-size: 1.3rem; }
    .data-table { font-size: .85rem; }
    .data-table th, .data-table td { padding: 10px 12px; }
    .topbar-context { display: none; }
    .col-3, .col-6, .col-9 { flex: 1 1 100%; }
    .card { padding: 18px 20px; }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .brand .logo-text { display: none; }
}
