:root {
    --red: #e60005;
    --red-dark: #b30004;
    --red-soft: #fdecec;
    --ink: #1c1f23;
    --ink-soft: #5b636d;
    --line: #e2e6ea;
    --bg: #f4f6f8;
    --card: #ffffff;
    --green: #14804a;
    --green-soft: #e7f5ee;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: var(--red-dark); }

/* ---------------------------------------------------------------- Kopfzeile */
.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: .75rem 1.5rem;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: .625rem;
    text-decoration: none;
    color: var(--ink);
    font-weight: 700;
}

.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--red);
    position: relative;
    flex: none;
}

.brand-mark::before,
.brand-mark::after {
    content: "";
    position: absolute;
    background: #fff;
    border-radius: 1px;
}

.brand-mark::before { inset: 11px 5px; }
.brand-mark::after { inset: 5px 11px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { font-size: .68rem; font-weight: 600; color: var(--red); letter-spacing: .08em; }

.mainnav { display: flex; gap: .25rem; flex: 1; }

.mainnav a {
    padding: .45rem .85rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--ink-soft);
    font-weight: 600;
}

.mainnav a:hover { background: var(--bg); color: var(--ink); }
.mainnav a.is-active { background: var(--red-soft); color: var(--red-dark); }

.usermenu { display: flex; align-items: center; gap: .5rem; }
.username { font-size: .85rem; color: var(--ink-soft); }
.username em { font-style: normal; color: var(--red-dark); font-weight: 700; }

/* ---------------------------------------------------------------- Layout */
.shell {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 3rem;
    flex: 1;
}

.shell-centered {
    max-width: 26rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.footer {
    display: flex;
    justify-content: space-between;
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: 1rem 1.5rem 2rem;
    color: #98a1ac;
    font-size: .8rem;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.page-head h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.02em; }
.page-head p { margin: .25rem 0 0; color: var(--ink-soft); }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Karten */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

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

.card-head h2 { margin: 0; font-size: 1.05rem; }
.card-tight { padding: 0; overflow: hidden; }

/* ---------------------------------------------------------------- Kennzahlen */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: .875rem;
    margin-bottom: 1.25rem;
}

.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .95rem 1.1rem;
    box-shadow: var(--shadow);
}

.stat .label { font-size: .78rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin-top: .15rem; }
.stat .value small { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.stat-accent { border-color: #f6c8c9; background: linear-gradient(180deg, #fff 0%, var(--red-soft) 100%); }
.stat-accent .value { color: var(--red-dark); }

/* ---------------------------------------------------------------- Tabellen */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

th, td {
    padding: .65rem .85rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-soft);
    background: #fafbfc;
    font-weight: 700;
}

tbody tr:hover { background: #fbfcfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 15rem; }
tfoot td { font-weight: 700; background: #fafbfc; border-top: 2px solid var(--line); }
.muted { color: var(--ink-soft); }

.empty {
    padding: 2.5rem 1.25rem;
    text-align: center;
    color: var(--ink-soft);
}

.empty strong { display: block; color: var(--ink); margin-bottom: .35rem; }

/* ---------------------------------------------------------------- Badges */
.badge {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    background: var(--bg);
    color: var(--ink-soft);
    border: 1px solid var(--line);
}

.badge-red { background: var(--red-soft); color: var(--red-dark); border-color: #f6c8c9; }
.badge-green { background: var(--green-soft); color: var(--green); border-color: #bfe3d0; }
.badge-night { background: #eef0fb; color: #3b4bab; border-color: #d4d9f5; }

/* ---------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1rem;
    border-radius: 9px;
    border: 1px solid transparent;
    font-size: .875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    background: var(--card);
    color: var(--ink);
    border-color: var(--line);
    transition: background .12s ease, border-color .12s ease;
}

.btn:hover { background: #f7f9fa; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-sm { padding: .32rem .6rem; font-size: .8rem; }
.btn-danger { color: var(--red-dark); border-color: #f2cccd; background: #fff; }
.btn-danger:hover { background: var(--red-soft); }
.btn-block { width: 100%; justify-content: center; }

/* ---------------------------------------------------------------- Formulare */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.field { display: flex; flex-direction: column; gap: .3rem; }
.field-wide { grid-column: 1 / -1; }

label { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=datetime-local], select {
    padding: .55rem .7rem;
    border: 1px solid var(--line);
    border-radius: 9px;
    font-size: .92rem;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
    width: 100%;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(230, 0, 5, .12);
}

.hint { font-size: .78rem; color: var(--ink-soft); }

.checkline { display: flex; align-items: center; gap: .5rem; }
.checkline input { width: auto; }
.checkline label { font-weight: 500; color: var(--ink); }

.form-actions {
    display: flex;
    gap: .6rem;
    align-items: center;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}

/* ---------------------------------------------------------------- Monatswahl */
.period-form {
    display: flex;
    gap: .5rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.period-form .field { min-width: 8rem; }

/* ---------------------------------------------------------------- Meldungen */
.alert {
    padding: .7rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: .9rem;
    border: 1px solid;
}

.alert-success { background: var(--green-soft); border-color: #bfe3d0; color: var(--green); }
.alert-error { background: var(--red-soft); border-color: #f6c8c9; color: var(--red-dark); }

/* ---------------------------------------------------------------- Login */
.auth-card { text-align: left; }
.auth-head { text-align: center; margin-bottom: 1.5rem; }

.auth-head .logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--red);
    margin: 0 auto .75rem;
    position: relative;
}

.auth-head .logo::before,
.auth-head .logo::after { content: ""; position: absolute; background: #fff; border-radius: 2px; }
.auth-head .logo::before { inset: 20px 9px; }
.auth-head .logo::after { inset: 9px 20px; }
.auth-head h1 { margin: 0; font-size: 1.3rem; }
.auth-head p { margin: .25rem 0 0; color: var(--ink-soft); font-size: .9rem; }
.auth-card .field + .field { margin-top: .875rem; }
.auth-card .btn { margin-top: 1.25rem; }

/* ---------------------------------------------------------------- Details */
.pill-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.inline-form { display: inline; }

.context-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem .9rem;
    border-radius: 10px;
    background: #fff6e5;
    border: 1px solid #f5dcae;
    color: #8a5a00;
    font-size: .875rem;
    margin-bottom: 1rem;
}

@media (max-width: 720px) {
    .topbar { gap: .75rem; padding: .65rem 1rem; }
    .mainnav { order: 3; width: 100%; flex: none; }
    .shell { padding: 1.25rem 1rem 2rem; }
    .username { display: none; }
}
