:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #0ea5a4;
    --danger: #dc2626;
    --ok-bg: #dcfce7;
    --ok-ink: #166534;
    --err-bg: #fee2e2;
    --err-ink: #991b1b;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

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

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: .75rem 1.25rem;
    box-shadow: var(--shadow);
}
.brand a { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.brand a:hover { text-decoration: none; }
.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.mainnav a {
    padding: .5rem .9rem;
    border-radius: 8px;
    color: var(--ink);
    font-weight: 500;
}
.mainnav a:hover { background: var(--bg); text-decoration: none; }
.mainnav a.is-active { background: var(--primary); color: #fff; }
.nav-logout { color: var(--muted) !important; }

/* Layout */
.container { max-width: 1100px; margin: 1.5rem auto; padding: 0 1.25rem; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.card-narrow { max-width: 380px; margin: 3rem auto; }

.muted { color: var(--muted); font-size: .9rem; }

/* Grids */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=number], input[type=date], select {
    width: 100%;
    padding: .5rem .6rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    background: #fff;
    color: var(--ink);
    margin-top: .15rem;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.mt { margin-top: 1rem; }

.contact-toggle {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .75rem 1rem;
    margin: 1.25rem 0;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.contact-toggle legend { font-weight: 600; font-size: .9rem; padding: 0 .4rem; }
label.radio { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; margin: 0; }
label.radio input { width: auto; margin: 0; }
.check-inline { display: flex; align-items: center; gap: .5rem; align-self: end; font-weight: 600; }
.check-inline input { width: auto; margin: 0; }
.training-box { border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem; margin: 1rem 0; }
.training-box legend { font-weight: 600; font-size: .9rem; padding: 0 .4rem; }
.training-min { margin-top: .6rem; max-width: 320px; }

/* Activity rows */
.activity-row {
    display: grid;
    grid-template-columns: 1fr 140px auto;
    gap: .5rem;
    align-items: center;
    margin-bottom: .5rem;
}
.minutes-field { position: relative; display: flex; align-items: center; }
.minutes-field .suffix { position: absolute; right: .6rem; color: var(--muted); font-size: .85rem; pointer-events: none; }
.minutes-field input { padding-right: 2.5rem; }
@media (max-width: 600px) {
    .activity-row { grid-template-columns: 1fr auto; }
    .minutes-field { grid-column: 1; }
}

.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }

/* Buttons */
.btn {
    display: inline-block;
    padding: .5rem .9rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-secondary:hover { filter: brightness(.95); }
.btn-danger { color: var(--danger); border-color: #f3c2c2; }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.btn-icon { padding: .4rem .6rem; }

/* Flash */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; }
.flash-success { background: var(--ok-bg); color: var(--ok-ink); }
.flash-error { background: var(--err-bg); color: var(--err-ink); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; text-align: center; }
.kpi-num { font-size: 1.7rem; font-weight: 700; color: var(--primary); }
.kpi-lbl { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.kpi-accent { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.kpi-accent .kpi-num { color: var(--accent); }
.note-parallel { margin-top: -1rem; margin-bottom: 1.5rem; }
.filter-check { align-self: end; padding-bottom: .5rem; }

/* Charts */
.chart { display: flex; flex-direction: column; gap: .55rem; }
.chart-row { display: grid; grid-template-columns: 150px 1fr 90px; gap: .6rem; align-items: center; }
.chart-label { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-track { background: var(--bg); border-radius: 6px; height: 22px; overflow: hidden; }
.chart-bar { background: linear-gradient(90deg, var(--primary), var(--accent)); height: 100%; border-radius: 6px; min-width: 2px; }
.chart-value { font-size: .82rem; color: var(--muted); text-align: right; }
@media (max-width: 600px) { .chart-row { grid-template-columns: 100px 1fr 70px; } }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.data th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-inactive { opacity: .55; }

/* Admin */
.admin-table input[type=text], .admin-table select, .admin-table input[type=number] { margin: 0; }
.admin-table .w-min { width: 70px; }
.inline-form { display: inline-flex; gap: .35rem; align-items: center; margin: 0; }
.row-form { display: contents; }
.actions-col { white-space: nowrap; }
.actions-col .inline-form { margin-right: .25rem; }
.add-form { margin-top: .75rem; display: flex; gap: .5rem; }
.add-form input { width: auto; flex: 1; min-width: 0; }

/* Umbenennen-Formular in den einfachen Listen soll die Namensspalte ausfüllen */
.admin-table td:not(.actions-col) .inline-form { display: flex; width: 100%; }
.admin-table td:not(.actions-col) .inline-form input[type=text] { flex: 1; min-width: 0; }

/* Kategorien / Personen / Arbeitsbereiche: je Container volle Breite (gestapelt). */
.admin-lists {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
    margin-bottom: 1.5rem;
}
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-on { background: var(--ok-bg); color: var(--ok-ink); }
.badge-off { background: #f1f5f9; color: var(--muted); }

/* Footer */
.pagefoot { text-align: center; color: var(--muted); font-size: .82rem; padding: 2rem 1rem; }

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a; --card: #1e293b; --ink: #e2e8f0; --muted: #94a3b8;
        --line: #334155; --ok-bg: #14532d; --ok-ink: #bbf7d0; --err-bg: #7f1d1d; --err-ink: #fecaca;
    }
    .topbar { background: #1e293b; }
    .brand a, .mainnav a { color: var(--ink); }
    input, select { background: #0f172a; }
    .btn { background: #1e293b; }
    .badge-off { background: #334155; }
}
