/* =========================================================
   Fraktions-Mandatstracker - Stylesheet
   Aesthetik: Deutsche Verwaltung, gehoben, nicht spielerisch
   ========================================================= */

:root {
    /* Farbpalette: gedeckt, ernsthaft */
    --c-bg: #f5f3ee;              /* warmes Cremepapier */
    --c-bg-alt: #ebe7df;
    --c-card: #ffffff;
    --c-ink: #1a1d24;             /* fast schwarz, leicht warm */
    --c-ink-muted: #5a5f6a;
    --c-line: #d6d2c8;            /* Trennlinien wie auf Papier */
    --c-line-soft: #ece8df;

    --c-primary: #1e3a5f;         /* Dunkelblau, würdig */
    --c-primary-hover: #15293f;
    --c-primary-soft: #e8eef5;

    --c-accent: #8b1e1e;          /* Bordeaux für Akzente, Fehler */
    --c-success: #15803d;
    --c-success-soft: #dcfce7;
    --c-warn: #a16207;
    --c-warn-soft: #fef3c7;
    --c-danger: #b91c1c;
    --c-danger-soft: #fee2e2;

    /* Typografie */
    --f-serif: 'Source Serif Pro', 'Georgia', 'Liberation Serif', serif;
    --f-sans: 'Source Sans 3', 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --f-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

    /* Spacing-System */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;
    --sp-7: 3rem;
    --sp-8: 4rem;

    /* Schatten — sehr subtil */
    --shadow-sm: 0 1px 2px rgba(26, 29, 36, 0.04);
    --shadow-md: 0 2px 8px rgba(26, 29, 36, 0.06), 0 1px 2px rgba(26, 29, 36, 0.04);
    --shadow-lg: 0 8px 24px rgba(26, 29, 36, 0.08);

    /* Radien — zurückhaltend */
    --r-sm: 3px;
    --r-md: 5px;
    --r-lg: 8px;
}

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+Pro:wght@400;600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap');

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--f-sans);
    color: var(--c-ink);
    background: var(--c-bg);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4 {
    font-family: var(--f-serif);
    font-weight: 600;
    color: var(--c-ink);
    margin: 0;
    line-height: 1.25;
    letter-spacing: -0.01em;
}
h1 { font-size: 1.875rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; margin-top: var(--sp-5); margin-bottom: var(--sp-3); }

p { margin: 0 0 var(--sp-4); }
a { color: var(--c-primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--c-primary-hover); text-decoration: underline; }
.muted { color: var(--c-ink-muted); }
.r { text-align: right; }
.center { text-align: center; }

/* === Topbar === */
.topbar {
    background: var(--c-card);
    border-bottom: 1px solid var(--c-line);
    box-shadow: var(--shadow-sm);
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--sp-3) var(--sp-5);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--sp-5);
}
.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    color: var(--c-ink);
    font-family: var(--f-serif);
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 36px; height: 36px;
    background: var(--c-primary);
    position: relative;
    border-radius: var(--r-sm);
    flex-shrink: 0;
}
.brand-mark::before, .brand-mark::after {
    content: ''; position: absolute;
    background: var(--c-bg);
}
.brand-mark::before {
    top: 8px; left: 8px; width: 8px; height: 8px;
}
.brand-mark::after {
    bottom: 8px; right: 8px; width: 8px; height: 8px;
}
.brand-mark.large { width: 64px; height: 64px; border-radius: var(--r-md); }
.brand-mark.large::before { top: 14px; left: 14px; width: 14px; height: 14px; }
.brand-mark.large::after { bottom: 14px; right: 14px; width: 14px; height: 14px; }
.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.brand-text strong { font-size: 1.1rem; font-weight: 700; }
.brand-text small { color: var(--c-ink-muted); font-size: 0.8rem; font-family: var(--f-sans); }

.mainnav {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    justify-content: flex-start;
    padding-left: var(--sp-3);
}
.mainnav a {
    padding: var(--sp-2) var(--sp-3);
    color: var(--c-ink-muted);
    border-radius: var(--r-sm);
    font-weight: 500;
    font-size: 0.925rem;
    transition: all 0.15s;
    white-space: nowrap;
}
.mainnav a:hover {
    color: var(--c-ink);
    background: var(--c-bg-alt);
    text-decoration: none;
}
.mainnav a.active {
    color: var(--c-primary);
    background: var(--c-primary-soft);
    font-weight: 600;
}

.userbox {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    font-size: 0.9rem;
}
.userlabel { color: var(--c-ink-muted); }
.logout { color: var(--c-ink-muted); }
.logout:hover { color: var(--c-accent); }

/* === Container === */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: var(--sp-6) var(--sp-5);
    flex: 1;
}

/* === Page Header === */
.page-header {
    margin-bottom: var(--sp-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
    padding-bottom: var(--sp-4);
    border-bottom: 1px solid var(--c-line-soft);
}
.page-header h1 {
    margin-bottom: 0;
}
.page-header p {
    margin: var(--sp-1) 0 0;
}
.page-actions { display: flex; gap: var(--sp-2); }

/* === Cards === */
.card {
    background: var(--c-card);
    border: 1px solid var(--c-line);
    border-radius: var(--r-md);
    padding: var(--sp-5);
    margin-bottom: var(--sp-5);
    box-shadow: var(--shadow-sm);
}
.card.nopad { padding: 0; }
.card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-4);
    margin-bottom: var(--sp-4);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--c-line-soft);
}
.card-header h2 { margin: 0; }
.card-header .muted { font-size: 0.875rem; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-5);
    margin-bottom: var(--sp-5);
}
@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* Stats */
.card.stat {
    padding: var(--sp-5);
    position: relative;
    overflow: hidden;
}
.card.stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--c-line);
}
.card.stat.stat-active::before {
    background: var(--c-primary);
}
.stat-label {
    color: var(--c-ink-muted);
    font-size: 0.825rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--sp-3);
}
.stat-value {
    font-family: var(--f-serif);
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.1;
    margin-bottom: var(--sp-2);
    color: var(--c-ink);
    letter-spacing: -0.02em;
}
.stat-value-sm {
    font-family: var(--f-serif);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--sp-2);
    color: var(--c-ink);
}
.stat-meta {
    color: var(--c-ink-muted);
    font-size: 0.875rem;
}

/* === Tabellen === */
.t {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.925rem;
}
.t th {
    text-align: left;
    padding: var(--sp-3) var(--sp-3);
    color: var(--c-ink-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--c-line);
}
.t th.r { text-align: right; }
.t td {
    padding: var(--sp-3) var(--sp-3);
    border-bottom: 1px solid var(--c-line-soft);
    vertical-align: middle;
}
.t tbody tr:last-child td { border-bottom: none; }
.t tbody tr:hover { background: var(--c-bg-alt); }
.t .datum {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum';
    color: var(--c-ink-muted);
    white-space: nowrap;
}
.t.t-full {
    margin: 0;
}
.t.t-full th:first-child, .t.t-full td:first-child { padding-left: var(--sp-5); }
.t.t-full th:last-child, .t.t-full td:last-child { padding-right: var(--sp-5); }
.t.t-full thead tr { background: var(--c-bg-alt); }

.row-muted td { opacity: 0.55; }
.trow-total td {
    border-top: 2px solid var(--c-line);
    font-weight: 600;
    padding-top: var(--sp-4);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px var(--sp-2);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 3px;
    background: var(--c-bg-alt);
    color: var(--c-ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.badge-admin { background: var(--c-primary-soft); color: var(--c-primary); }
.badge-muted { background: transparent; color: var(--c-ink-muted); border: 1px solid var(--c-line); }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    font-family: var(--f-sans);
    font-size: 0.925rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--c-ink);
    background: var(--c-card);
    border: 1px solid var(--c-line);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover {
    background: var(--c-bg-alt);
    border-color: var(--c-ink-muted);
    text-decoration: none;
}
.btn-primary {
    background: var(--c-primary);
    color: white;
    border-color: var(--c-primary);
}
.btn-primary:hover {
    background: var(--c-primary-hover);
    border-color: var(--c-primary-hover);
    color: white;
}
.btn-danger {
    background: var(--c-danger);
    color: white;
    border-color: var(--c-danger);
}
.btn-danger:hover {
    background: #991616;
    color: white;
}
.btn-sm { padding: 4px var(--sp-3); font-size: 0.85rem; }
.btn-block { width: 100%; padding: var(--sp-3) var(--sp-4); }
.btn-link {
    background: transparent;
    border: none;
    color: var(--c-primary);
    padding: var(--sp-2);
    cursor: pointer;
    font-size: 0.9rem;
    text-align: left;
    width: 100%;
}
.btn-link:hover { background: var(--c-primary-soft); }
.btn-link-danger { color: var(--c-danger); }
.btn-link-danger:hover { background: var(--c-danger-soft); }

.actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.link {
    color: var(--c-primary);
    font-size: 0.875rem;
    font-weight: 500;
}

/* === Formulare === */
label {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    font-size: 0.875rem;
}
label > span:first-child {
    color: var(--c-ink);
    font-weight: 500;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], textarea, select {
    font-family: var(--f-sans);
    font-size: 0.95rem;
    padding: var(--sp-2) var(--sp-3);
    background: var(--c-card);
    border: 1px solid var(--c-line);
    border-radius: var(--r-sm);
    color: var(--c-ink);
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-soft);
}
textarea { font-family: var(--f-sans); resize: vertical; min-height: 80px; }
select { cursor: pointer; }

.formcard {
    padding: var(--sp-5);
}
.formgrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-4);
}
.formgrid label {
    flex-direction: column;
}
label.full {
    margin-bottom: var(--sp-4);
}
label.checkbox {
    flex-direction: row;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
}
label.checkbox input { width: auto; }
label.checkbox > span { color: var(--c-ink); font-weight: 500; }
label.checkbox small { display: block; flex-basis: 100%; color: var(--c-ink-muted); }

.formactions {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    padding-top: var(--sp-4);
    border-top: 1px solid var(--c-line-soft);
    margin-top: var(--sp-4);
}
.formactions .spacer { flex: 1; }

.filterbar {
    display: flex;
    gap: var(--sp-4);
    flex-wrap: wrap;
    align-items: flex-end;
    background: var(--c-card);
    border: 1px solid var(--c-line);
    border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-5);
}
.filterbar label { flex: 0 0 auto; min-width: 140px; }

/* === Empty State === */
.emptystate {
    text-align: center;
    padding: var(--sp-8) var(--sp-5);
    background: var(--c-card);
    border: 1px dashed var(--c-line);
    border-radius: var(--r-md);
    color: var(--c-ink-muted);
}
.emptystate p { margin-bottom: var(--sp-4); }

/* === Alerts === */
.alert {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-sm);
    border-left: 3px solid;
    margin-bottom: var(--sp-4);
    font-size: 0.925rem;
}
.alert-success { background: var(--c-success-soft); border-color: var(--c-success); color: #065f29; }
.alert-error { background: var(--c-danger-soft); border-color: var(--c-danger); color: #7f1d1d; }
.alert-warning { background: var(--c-warn-soft); border-color: var(--c-warn); color: #713f12; }
.alert-info { background: var(--c-primary-soft); border-color: var(--c-primary); color: var(--c-primary-hover); }

/* === Login === */
.loginbody {
    background: var(--c-bg);
    background-image:
        radial-gradient(circle at 20% 80%, rgba(30, 58, 95, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 80% 20%, rgba(139, 30, 30, 0.03) 0%, transparent 40%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
}
.loginwrap {
    width: 100%;
    max-width: 420px;
    text-align: center;
}
.logincard {
    background: var(--c-card);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    padding: var(--sp-7) var(--sp-6);
    box-shadow: var(--shadow-lg);
    text-align: left;
}
.loginbrand {
    text-align: center;
    margin-bottom: var(--sp-6);
}
.loginbrand .brand-mark { display: block; margin: 0 auto var(--sp-4); }
.loginbrand h1 {
    font-size: 1.625rem;
    margin-bottom: var(--sp-1);
}
.loginbrand p {
    color: var(--c-ink-muted);
    font-size: 0.95rem;
    margin: 0;
}
.loginform {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}
.loginfoot {
    margin-top: var(--sp-5);
    color: var(--c-ink-muted);
    font-size: 0.85rem;
    text-align: center;
}

/* === Dropdown === */
details.dropdown {
    position: relative;
    display: inline-block;
}
details.dropdown > summary {
    list-style: none;
    cursor: pointer;
}
details.dropdown > summary::-webkit-details-marker { display: none; }
details.dropdown[open] > summary {
    background: var(--c-bg-alt);
}
.dropdown-content {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--c-card);
    border: 1px solid var(--c-line);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    z-index: 10;
    padding: var(--sp-1);
}
.dropdown-item {
    display: block;
    padding: 0;
    border-radius: var(--r-sm);
}
.dropdown-item form {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2);
}
.dropdown-item input { flex: 1; min-width: 0; }
details.dropdown-item summary {
    padding: var(--sp-2) var(--sp-3);
    cursor: pointer;
    color: var(--c-primary);
    font-size: 0.9rem;
    border-radius: var(--r-sm);
    list-style: none;
}
details.dropdown-item summary::-webkit-details-marker { display: none; }
details.dropdown-item summary:hover { background: var(--c-primary-soft); }
details.dropdown-item[open] form { padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--c-line-soft); }

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

/* === Footer === */
.footer {
    margin-top: var(--sp-7);
    padding: var(--sp-5);
    border-top: 1px solid var(--c-line);
    background: var(--c-card);
    color: var(--c-ink-muted);
    font-size: 0.85rem;
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* === Responsive === */
@media (max-width: 700px) {
    .topbar-inner {
        grid-template-columns: 1fr auto;
        padding: var(--sp-3);
    }
    .mainnav {
        grid-column: 1 / -1;
        order: 3;
        margin: 0;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    .mainnav a { padding: var(--sp-2) var(--sp-3); font-size: 0.875rem; }
    .container { padding: var(--sp-4) var(--sp-3); }
    h1 { font-size: 1.5rem; }
    .stat-value { font-size: 1.5rem; }
    .t.t-full th:first-child, .t.t-full td:first-child { padding-left: var(--sp-3); }
    .t.t-full th:last-child, .t.t-full td:last-child { padding-right: var(--sp-3); }
}
