/* ==================== Reset & Basis ==================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --clr-bg: #f0f2f5;
    --clr-surface: #ffffff;
    --clr-primary: #2563eb;
    --clr-primary-hover: #1d4ed8;
    --clr-secondary: #64748b;
    --clr-accent: #0ea5e9;
    --clr-text: #1e293b;
    --clr-text-muted: #64748b;
    --clr-border: #e2e8f0;
    --clr-danger: #ef4444;
    --clr-success: #22c55e;
    --clr-warning: #f59e0b;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 12px rgba(0, 0, 0, .04);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, .1);
    --transition: .2s ease;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--clr-bg);
    color: var(--clr-text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ==================== Layout ==================== */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--clr-primary);
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--clr-text-muted);
    font-size: 1.05rem;
    margin-top: .25rem;
}

/* ==================== Cards ==================== */
.card {
    background: var(--clr-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--clr-text);
    border-bottom: 2px solid var(--clr-primary);
    padding-bottom: .5rem;
    display: inline-block;
}

.card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1.5rem 0 .75rem;
}

/* ==================== Auftrag-Block ==================== */
.auftrag {
    background: var(--clr-bg);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    position: relative;
    border: 1px solid var(--clr-border);
    transition: border-color var(--transition);
}

.auftrag:hover {
    border-color: var(--clr-primary);
}

.auftrag-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.auftrag-header span {
    font-weight: 600;
    font-size: .95rem;
    color: var(--clr-primary);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--clr-danger);
    font-size: 1.3rem;
    cursor: pointer;
    padding: .25rem .5rem;
    border-radius: 6px;
    transition: background var(--transition);
}

.btn-remove:hover {
    background: rgba(239, 68, 68, .1);
}

/* ==================== Formulare ==================== */
.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 160px;
    margin-bottom: .75rem;
}

.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    margin-bottom: .35rem;
}

.form-group input[type="checkbox"] {
    margin-right: .4rem;
    transform: translateY(1px);
}

input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    font-size: .95rem;
    color: var(--clr-text);
    background: var(--clr-surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.zeit-hinweis {
    font-size: .78rem;
    color: var(--clr-text-muted);
    margin-top: .2rem;
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .65rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
}

.btn:active {
    transform: scale(.97);
}

.btn-primary {
    background: var(--clr-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--clr-primary-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--clr-primary);
    border: 1.5px dashed var(--clr-primary);
}

.btn-secondary:hover {
    background: rgba(37, 99, 235, .06);
}

.btn-large {
    width: 100%;
    justify-content: center;
    padding: .85rem;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    border-radius: var(--radius);
}

.icon {
    font-size: 1.2rem;
    line-height: 1;
}

/* ==================== Tage-Display ==================== */
.tage-display {
    padding: .6rem .75rem;
    border-radius: 8px;
    background: var(--clr-bg);
    font-weight: 600;
    color: var(--clr-primary);
    font-size: 1rem;
    border: 1px solid var(--clr-border);
    text-align: center;
}

/* ==================== Ergebnis ==================== */
.ergebnis-section {
    animation: fadeIn .4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ergebnis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.ergebnis-karte {
    background: linear-gradient(135deg, #eef2ff, #e0f2fe);
    border-radius: 10px;
    padding: 1.25rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.ergebnis-label {
    font-size: .8rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.ergebnis-wert {
    font-size: 2rem;
    font-weight: 700;
    color: var(--clr-primary);
    line-height: 1.1;
}

.ergebnis-einheit {
    font-size: .8rem;
    color: var(--clr-text-muted);
}

/* ==================== Tabelle ==================== */
.aufschluesselung {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

thead {
    background: var(--clr-bg);
}

th, td {
    padding: .65rem .75rem;
    text-align: left;
    border-bottom: 1px solid var(--clr-border);
}

th {
    font-weight: 600;
    color: var(--clr-text-muted);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .3px;
}

tbody tr:hover {
    background: #f8fafc;
}

td:last-child,
th:last-child {
    text-align: right;
}

/* ==================== Ampel ==================== */
.ampel {
    display: inline-flex;
    align-items: center;
    padding: .6rem 1.25rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1rem;
}

.ampel.gruen  { background: rgba(34,197,94,.12); color: #16a34a; }
.ampel.gelb   { background: rgba(245,158,11,.12); color: #d97706; }
.ampel.rot    { background: rgba(239,68,68,.12);  color: #dc2626; }

.ampel-hinweis {
    margin-top: .5rem;
    font-size: .9rem;
    color: var(--clr-text-muted);
}

/* ==================== Footer ==================== */
footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--clr-text-muted);
    font-size: .82rem;
}

/* ==================== Termine ==================== */
.termine-section details summary {
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.termine-section details summary::-webkit-details-marker {
    display: none;
}
.termine-section details summary h2::after {
    content: ' ▶';
    font-size: .75em;
    color: var(--clr-text-muted);
    margin-left: .5rem;
}
.termine-section details[open] summary h2::after {
    content: ' ▼';
}
.termine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .5rem;
    margin-bottom: 1.25rem;
}

.termin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--clr-bg);
    border-radius: 8px;
    padding: .5rem .75rem;
    font-size: .85rem;
    border: 1px solid var(--clr-border);
}

.termin-fach {
    font-weight: 600;
    color: var(--clr-text);
    flex: 1;
}

.termin-datum {
    color: var(--clr-text-muted);
    margin: 0 .5rem;
    white-space: nowrap;
}

.termin-tage {
    font-weight: 600;
    color: var(--clr-primary);
    white-space: nowrap;
    font-size: .8rem;
}

.fristen-info {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    padding: .75rem 1rem;
    background: linear-gradient(135deg, #eef2ff, #e0f2fe);
    border-radius: 8px;
    font-size: .9rem;
}

.frist {
    color: var(--clr-text);
}

.ergebnis-karte.highlight-warn {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
}

.ergebnis-karte.highlight-warn .ergebnis-wert {
    color: #b45309;
}

.ergebnis-karte.highlight-entlastung {
    background: linear-gradient(135deg, #ecfdf5, #a7f3d0);
}
.ergebnis-karte.highlight-entlastung .ergebnis-wert {
    color: #047857;
}

/* ==================== Entlastung ==================== */
.entlastung-info {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border-radius: 10px;
    border-left: 4px solid #047857;
}
.entlastung-info h3 {
    margin: 0 0 .5rem;
    color: #047857;
    font-size: 1rem;
}
.entlastung-erklaerung {
    margin: 0 0 .5rem;
    font-size: .85rem;
    color: var(--clr-text-muted);
}
.entlastung-detail {
    margin: 0;
    font-weight: 600;
    color: #047857;
}

/* ==================== Line Chart ==================== */
.chart-container {
    margin-top: 1.5rem;
}

.chart-wrap {
    width: 100%;
    aspect-ratio: 500 / 200;
    background: var(--clr-surface);
    border-radius: 8px;
    border: 1px solid var(--clr-border);
}

.line-chart {
    width: 100%;
    height: 100%;
    display: block;
}

/* ==================== Responsive ==================== */
@media (max-width: 600px) {
    .container { padding: 1rem .75rem 2rem; }
    header h1  { font-size: 1.5rem; }
    .form-row  { flex-direction: column; gap: 0; }
    .ergebnis-grid { grid-template-columns: 1fr 1fr; }
    .termine-grid { grid-template-columns: 1fr; }
    .fristen-info { flex-direction: column; gap: .5rem; }
}
