:root {
    --surface-0: #f6f8fa;
    --surface-1: #ffffff;
    --surface-2: #f3f4f6;
    --surface-3: #eaeef2;
    --text-strong: #111827;
    --text-soft: #4b5563;
    --text-faint: #6b7280;
    --line-soft: #d8dee4;
    --accent: #2563eb;
    --accent-strong: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, 0.1);
    --success: #1f883d;
    --warning: #9a6700;
    --danger: #d1242f;
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
    --surface-0: #0d1117;
    --surface-1: #161b22;
    --surface-2: #21262d;
    --surface-3: #30363d;
    --text-strong: #f0f6fc;
    --text-soft: #c9d1d9;
    --text-faint: #8b949e;
    --line-soft: #30363d;
    --accent: #58a6ff;
    --accent-strong: #79c0ff;
    --accent-soft: rgba(88, 166, 255, 0.14);
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.35);
}

body {
    padding: 0;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 32rem),
        var(--surface-0);
    color: var(--text-strong);
    line-height: 1.55;
}

.container {
    max-width: 1240px;
    min-height: 100vh;
    padding: 0 24px 40px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

header {
    position: sticky;
    top: 0;
    z-index: 40;
    margin: 0 -24px 28px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--line-soft);
    background: color-mix(in srgb, var(--surface-1) 86%, transparent);
    backdrop-filter: blur(18px);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 18px;
    max-width: 1240px;
    margin: 0 auto;
}

.brand-link {
    color: var(--text-strong);
    text-decoration: none;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-right: 8px;
    border-radius: 8px;
    background: var(--text-strong);
    color: var(--surface-1);
    font-weight: 800;
}

header h1 {
    display: inline-flex;
    align-items: center;
    margin: 0;
    font-size: 19px;
    letter-spacing: 0;
}

nav {
    flex: 1 1 auto;
}

.nav-primary,
.nav-user-menu,
.tab-bar,
.action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.nav-user-menu {
    justify-content: flex-end;
}

.nav-user {
    padding: 7px 10px;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    background: var(--surface-1);
    color: var(--text-soft);
    font-size: 13px;
}

.btn,
button.btn,
a.btn {
    min-height: 38px;
    padding: 8px 13px;
    border-radius: 8px;
    border-color: var(--line-soft);
    background: var(--surface-1);
    color: var(--text-soft);
    text-decoration: none;
    font-weight: 600;
}

.btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--text-strong);
}

.btn.is-active,
.btn-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
}

.btn-primary:hover {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
    color: #ffffff;
}

.btn-danger {
    border-color: color-mix(in srgb, var(--danger) 45%, var(--line-soft));
    color: var(--danger);
}

.notification-btn {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border: 2px solid var(--surface-1);
    border-radius: 999px;
    background: var(--danger);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 15px;
    text-align: center;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-title {
    margin: 0;
    font-size: 32px;
    line-height: 1.15;
}

.page-subtitle {
    margin: 6px 0 0;
    color: var(--text-faint);
}

.dashboard-grid,
.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 16px 0 22px;
}

.stat-box,
.metric-card,
.card,
.filter-panel,
.chart-panel,
.legal-section,
.form-panel,
.detail-panel {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface-1);
    box-shadow: var(--shadow-soft);
}

.stat-box,
.metric-card {
    position: relative;
    min-height: 112px;
    padding: 16px;
    overflow: hidden;
}

.metric-card::after,
.stat-box::after {
    content: "";
    position: absolute;
    inset: auto 14px 12px auto;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--accent-soft);
}

.metric-card.is-danger::after {
    background: color-mix(in srgb, var(--danger) 14%, transparent);
}

.metric-card.is-warning::after {
    background: color-mix(in srgb, var(--warning) 18%, transparent);
}

.metric-card.is-success::after {
    background: color-mix(in srgb, var(--success) 14%, transparent);
}

.stat-label,
.metric-label {
    color: var(--text-faint);
    font-size: 13px;
    font-weight: 700;
}

.stat-value,
.metric-value {
    margin-top: 8px;
    color: var(--text-strong);
    font-size: 34px;
    font-weight: 800;
    line-height: 1;
}

.metric-hint {
    margin-top: 10px;
    color: var(--text-faint);
    font-size: 13px;
}

.filter-panel {
    padding: 15px;
    margin-bottom: 18px;
}

.filter-panel__title {
    font-size: 15px;
}

.filter-chip,
.pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--line-soft);
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
}

.entry-card-list {
    display: grid;
    gap: 10px;
}

.entry-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 15px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface-1);
    color: inherit;
    text-decoration: none;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}

.entry-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.entry-card__title {
    margin: 0;
    font-size: 17px;
}

.entry-card__meta,
.entry-card__footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    color: var(--text-faint);
    font-size: 13px;
}

.status-pill,
.status-OFFEN,
.status-IN_ARB,
.status-ERLED {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 800;
}

.status-OFFEN {
    background: color-mix(in srgb, var(--warning) 13%, transparent);
    color: var(--warning);
    border-color: color-mix(in srgb, var(--warning) 35%, transparent);
}

.status-IN_ARB {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.status-ERLED {
    background: color-mix(in srgb, var(--success) 13%, transparent);
    color: var(--success);
    border-color: color-mix(in srgb, var(--success) 35%, transparent);
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.chart-panel {
    padding: 16px;
}

table {
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface-1);
}

th,
td {
    border-width: 0 0 1px;
    border-color: var(--line-soft);
    padding: 10px 12px;
}

th {
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 12px;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

input,
select,
textarea {
    min-height: 40px;
    border-color: var(--line-soft);
    border-radius: 8px;
    background: var(--surface-1);
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid var(--accent-soft);
    border-color: var(--accent);
}

.field-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.form-panel,
.detail-panel {
    padding: 18px;
    margin: 14px 0;
}

.site-footer {
    margin-top: 46px;
    padding: 18px 0 0;
}

.version-tag {
    position: fixed;
    right: 14px;
    bottom: 8px;
    color: var(--text-faint);
    font-size: 11px;
    user-select: none;
}

.fab-new-entry {
    position: fixed;
    right: 22px;
    bottom: 30px;
    z-index: 35;
    display: none;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 999px;
    background: var(--accent);
    color: #ffffff;
    font-size: 30px;
    font-weight: 400;
    text-decoration: none;
    box-shadow: 0 14px 32px rgba(37, 99, 235, 0.35);
}

.legal-page {
    max-width: 940px;
    margin: 0 auto;
}

.legal-page > h2 {
    margin-bottom: 8px;
    font-size: 32px;
}

.legal-page > h3 {
    margin: 22px 0 10px;
    padding-top: 18px;
    border-top: 1px solid var(--line-soft);
    font-size: 20px;
}

.legal-page p,
.legal-page li {
    color: var(--text-soft);
    line-height: 1.7;
}

.legal-toc {
    padding: 16px;
    margin: 16px 0 20px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface-1);
}

.legal-toc ol {
    columns: 2;
    margin: 8px 0 0;
    padding-left: 20px;
}

.legal-toc a {
    color: var(--accent);
    text-decoration: none;
}

.legal-section {
    padding: 18px;
    margin: 14px 0;
}

.legal-section h3 {
    margin-top: 0;
}

.login-card {
    max-width: 420px;
    margin: 44px auto;
    padding: 24px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface-1);
    box-shadow: var(--shadow-soft);
}

@media (max-width: 860px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav-user-menu {
        justify-content: flex-start;
    }

    .dashboard-grid,
    .stats,
    .chart-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .entry-card {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 0 14px 84px;
    }

    header {
        margin: 0 -14px 18px;
        padding: 12px 14px;
    }

    .page-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-title {
        font-size: 27px;
    }

    .dashboard-grid,
    .stats,
    .chart-grid,
    .field-row {
        grid-template-columns: 1fr;
    }

    .btn,
    button.btn,
    a.btn {
        min-height: 44px;
        padding: 10px 14px;
    }

    .nav-primary,
    .nav-user-menu {
        width: 100%;
    }

    .legal-toc ol {
        columns: 1;
    }

    .fab-new-entry {
        display: inline-flex;
    }

    .version-tag {
        display: none;
    }
}
