* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-light: #dbeafe;
    --accent: #7c3aed;
    --success: #059669;
    --success-light: #d1fae5;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --u2-color: #db2777;
    --u2-bg: #fce7f3;
    --u3-color: #7c3aed;
    --u3-bg: #ede9fe;
    --ue3-color: #059669;
    --ue3-bg: #d1fae5;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
}
header h1 { font-size: 1.3rem; font-weight: 700; }
.kgj-badge {
    background: rgba(255,255,255,0.2);
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}
.phase-indicator {
    margin-left: auto;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0.9;
}

main { max-width: 1600px; margin: 0 auto; padding: 1.5rem; }

/* Sidebar */
.queue-sidebar {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    bottom: 1.5rem;
    width: 400px;
    background: var(--card-bg);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
}
.queue-sidebar .queue-container {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    flex-direction: column;
    flex-wrap: nowrap;
    min-height: 0;
    min-width: 0;
}
.queue-sidebar .queue-children-list {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.25rem;
    padding: 0.5rem;
    min-width: 0;
    overflow-y: auto;
    flex: 1;
}
.queue-sidebar .queue-child {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: auto;
    max-width: 100%;
    min-width: 0;
}
.queue-sidebar .queue-child-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 0;
    min-width: 0;
}
.queue-sidebar .queue-child-details {
    white-space: nowrap;
    flex-shrink: 0;
    text-align: right;
}
.queue-sidebar .queue-header {
    flex-shrink: 0;
    padding: 0.6rem 0.75rem;
    gap: 0.4rem;
    justify-content: space-between;
    flex-wrap: wrap;
}
.queue-sidebar .queue-header h2 {
    font-size: 0.85rem;
}
.queue-sidebar .queue-count {
    margin-left: auto;
}
.queue-sidebar .queue-header .btn {
    margin-left: auto;
}
/* When sidebar is visible, offset main content */
body.sidebar-open main {
    margin-right: calc(400px + 3rem);
}

/* Upload */
.upload-section { margin-bottom: 1.5rem; }
.upload-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.upload-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
    border: 2px dashed var(--border);
    transition: all 0.3s;
}
.upload-card.uploaded { border-color: var(--success); border-style: solid; background: var(--success-light); }
.upload-icon { font-size: 2rem; margin-bottom: 0.3rem; }
.upload-card h3 { font-size: 1rem; margin-bottom: 0.2rem; }
.upload-card p { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 0.75rem; }
.upload-status { margin-top: 0.5rem; font-size: 0.8rem; color: var(--success); font-weight: 600; min-height: 1.2em; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: var(--secondary, #64748b); color: white; }
.btn-accent { background: var(--accent); color: white; font-size: 1rem; padding: 0.6rem 2rem; }
.btn-accent:hover { background: #6d28d9; }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.75rem; }

/* Warnings */
.warnings-banner {
    background: var(--warning-light);
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}
.warnings-banner h3 { color: var(--warning); font-size: 0.85rem; margin-bottom: 0.4rem; cursor: pointer; }
.warning-item { font-size: 0.75rem; padding: 0.2rem 0; color: #92400e; }
.warning-item::before { content: "⚠ "; }

/* Action bar */
.action-bar {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.queue-header {
    padding: 0.75rem 1.25rem;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.queue-header h2 { font-size: 0.95rem; }
.queue-count {
    font-size: 0.75rem;
    background: var(--primary);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-weight: 700;
}
.queue-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    min-height: 50px;
}
.queue-children-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
}
.queue-child {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1.5px solid var(--border);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}
.queue-child:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.queue-child.show-dropdown { z-index: 10000; }
.queue-child.geschwister { border-left: 3px solid var(--success); }
.queue-child .child-age-badge { font-size: 0.6rem; padding: 0.1rem 0.35rem; }
.queue-child-name { font-weight: 600; font-size: 0.8rem; white-space: nowrap; }
.queue-child-details { font-size: 0.65rem; color: var(--text-muted); white-space: nowrap; }
.queue-section-label { width: 100%; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.25rem; display: flex; align-items: center; gap: 0.5rem; }
.queue-section-label .select-all-link { font-size: 0.65rem; text-transform: none; letter-spacing: normal; font-weight: 500; color: var(--primary); text-decoration: none; }
.queue-section-label .select-all-link:hover { text-decoration: underline; }
.eligible-checkbox { display: flex; align-items: center; flex-shrink: 0; }
.eligible-checkbox input { width: 14px; height: 14px; cursor: pointer; accent-color: var(--primary); }
.queue-skip { width: 100%; text-align: center; margin-top: 0.5rem; }

/* Queue child appearing */
.queue-child.animate-in {
    animation: slideIn 0.4s ease forwards;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Queue dropdown */
.queue-child .assign-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 9999;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-width: 160px;
}
.queue-child.show-dropdown .assign-dropdown { display: block; }
.assign-dropdown-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.assign-dropdown-item:last-child { border-bottom: none; }
.assign-dropdown-item:hover { background: var(--primary-light); }

/* Waitlist search */
.queue-sidebar .queue-search {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    max-height: 2.5rem;
}
.queue-sidebar .queue-search input,
.queue-sidebar .queue-search select {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    height: 1.8rem;
    box-sizing: border-box;
}
.queue-sidebar .queue-search input { flex: 1; min-width: 0; }

/* Groups */
.groups-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

/* Group Card */
.group-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: border-color 0.3s;
}
.group-card.drop-target { border: 2px solid var(--primary); }

.group-header {
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.group-header.gf-I { background: linear-gradient(135deg, #ede9fe, #dbeafe); }
.group-header.gf-II { background: linear-gradient(135deg, #cffafe, #e0f2fe); }
.group-name { font-weight: 700; font-size: 1rem; }
.group-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    background: rgba(0,0,0,0.1);
}

/* Capacity */
.capacity-bar-container {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
}
.capacity-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.capacity-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    display: flex;
}
.capacity-bar-fill-u3 { background: var(--u3-color); transition: width 0.5s ease; }
.capacity-bar-fill-ue3 { background: var(--ue3-color); transition: width 0.5s ease; }
.capacity-bar-fill-over { background: var(--danger); }

/* Children */
.children-list { padding: 0.25rem 0; max-height: 450px; overflow-y: auto; }
.child-row {
    display: flex;
    align-items: center;
    padding: 0.35rem 1rem;
    gap: 0.5rem;
    transition: all 0.6s ease;
}
.child-row:hover { background: var(--bg); }

/* Fly animation clone */
.fly-clone {
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    background: white;
    overflow: hidden;
}

/* Legacy animate classes (kept for any remaining usage) */
.child-row.leaving { transition: all 0.7s ease; }
.child-row.moving { transition: all 0.7s ease; }

.child-row.has-warning { background: var(--warning-light); }
.child-row.needs-move { border-left: 3px solid #6366f1; }
.child-row.assigned-new {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
    animation: slideIn 0.4s ease;
}

.child-age-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    flex-shrink: 0;
    text-align: center;
}
.child-age-badge.u2 { background: var(--u2-bg); color: var(--u2-color); }
.child-age-badge.u3 { background: var(--u3-bg); color: var(--u3-color); }
.child-age-badge.ue3 { background: var(--ue3-bg); color: var(--ue3-color); }
.child-name { font-weight: 600; font-size: 0.8rem; flex: 1; }
.child-details {
    display: flex; gap: 0.4rem; align-items: center;
    font-size: 0.65rem; color: var(--text-muted);
}
.child-booking {
    padding: 0.05rem 0.3rem;
    background: var(--bg);
    border-radius: 3px;
    font-size: 0.65rem;
}
.child-leave-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
}
.child-leave-badge.school { background: var(--danger-light); color: var(--danger); }
.child-leave-badge.vorschule { background: #fef3c7; color: #92400e; }
.child-leave-badge.contract { background: #fef3c7; color: #92400e; }
.child-leave-badge.move { background: #e0e7ff; color: #3730a3; }
.child-row.vorschulkind { border-left: 3px solid #f59e0b; }

.child-warning-icon { color: var(--warning); cursor: help; font-size: 0.85rem; }

/* Tooltip */
.tooltip { position: relative; }
.tooltip .tooltip-text {
    display: none;
    background: var(--text);
    color: white;
    text-align: left;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.65rem;
    position: fixed;
    z-index: 50000;
    min-width: 180px;
    max-width: 320px;
    box-shadow: var(--shadow-lg);
    line-height: 1.3;
    pointer-events: none;
}
.tooltip:hover .tooltip-text { display: block; }

/* Group footer */
.group-footer {
    padding: 0.4rem 1rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.hours-select {
    padding: 0.1rem 0.25rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.7rem;
    background: white;
}

/* Group warnings */
.group-warnings {
    padding: 0.4rem 1rem;
    background: var(--warning-light);
    border-top: 1px solid var(--warning);
}
.group-warning-item { font-size: 0.65rem; color: #92400e; padding: 0.1rem 0; }

/* Assigned section in group */
.assigned-section {
    border-top: 2px dashed var(--primary);
    padding: 0.25rem 0;
}
.assigned-section-label {
    padding: 0.2rem 1rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Spots */
.spots-indicator {
    padding: 0.5rem 1rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    font-size: 0.7rem;
}
.spot-badge { display: flex; align-items: center; gap: 0.25rem; }
.spot-dot { width: 8px; height: 8px; border-radius: 50%; border: 2px dashed; }

/* Remove button in assigned children */
.remove-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 0.2rem;
    opacity: 0.6;
}
.remove-btn:hover { opacity: 1; }

/* Forecast */
.forecast-section { margin-top: 2rem; }
.forecast-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
}
.forecast-year {
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}
.forecast-year.forecast-danger { border-color: var(--danger); }
.forecast-year.forecast-action { border-color: var(--primary); }
.forecast-year.forecast-warning { border-color: #f59e0b; }
.forecast-year.forecast-ok { border-color: var(--success); }

.forecast-year-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.forecast-year-header h3 { font-size: 0.9rem; margin: 0; }
.forecast-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.forecast-badge-danger { background: #fef2f2; color: var(--danger); }
.forecast-badge-action { background: #eff6ff; color: var(--primary); }
.forecast-badge-warning { background: #fffbeb; color: #b45309; }
.forecast-badge-ok { background: #f0fdf4; color: var(--success); }

/* --- Forecast group cards --- */
.forecast-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
    padding: 0.75rem 1rem;
}
.forecast-group {
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    background: var(--bg);
    font-size: 0.75rem;
}
.forecast-group-issue { background: #fef2f2; }
.forecast-group-over { background: #fef2f2; border: 1px solid var(--danger); }
.forecast-group-name {
    font-weight: 700;
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}
.forecast-gf {
    font-weight: 400;
    font-size: 0.65rem;
    color: var(--text-muted);
}
.forecast-group-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 0.35rem;
    overflow: hidden;
}
.forecast-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s;
}
.forecast-bar-fill.over { background: var(--danger); }
.forecast-group-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.7rem;
}
.forecast-u3 { font-weight: 600; color: var(--u3-color); }
.forecast-u3-low { color: var(--danger); font-weight: 700; }
.forecast-over { color: var(--danger); font-weight: 700; }
.forecast-free { color: var(--success); }

/* --- Forecast tips --- */
.forecast-tips {
    padding: 0.5rem 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.forecast-tip {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.78rem;
    line-height: 1.4;
    border-radius: 6px;
    background: var(--bg);
}
.forecast-tip-badge {
    flex-shrink: 0;
    width: 1.3rem;
    height: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 800;
    margin-top: 0.05rem;
}
.forecast-tip-content { flex: 1; min-width: 0; }
.forecast-tip-title {
    display: block;
    font-weight: 700;
    font-size: 0.8rem;
    margin-bottom: 0.1rem;
}
.forecast-tip-msg {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.35;
}

/* Severity colors */
.forecast-tip-action { background: #f0f7ff; }
.forecast-tip-action .forecast-tip-title { color: var(--primary); }
.forecast-tip-action .forecast-tip-badge { background: var(--primary); color: white; }

.forecast-tip-danger { background: #fef2f2; }
.forecast-tip-danger .forecast-tip-title { color: var(--danger); }
.forecast-tip-danger .forecast-tip-badge { background: var(--danger); color: white; }

.forecast-tip-warning { background: #fffbeb; }
.forecast-tip-warning .forecast-tip-title { color: #92400e; }
.forecast-tip-warning .forecast-tip-badge { background: #f59e0b; color: white; }

.forecast-tip-info { background: var(--bg); }
.forecast-tip-info .forecast-tip-title { color: var(--text); }
.forecast-tip-info .forecast-tip-badge { background: var(--border); color: var(--text-muted); }

/* Expandable details */
.forecast-tip-clickable { cursor: pointer; }
.forecast-tip-clickable:hover { filter: brightness(0.97); }
.forecast-tip-toggle {
    display: inline-block;
    font-size: 0.68rem;
    opacity: 0.6;
    margin-top: 0.2rem;
}
.forecast-tip.expanded .forecast-tip-toggle { display: none; }
.forecast-tip-details {
    display: none;
    margin-top: 0.35rem;
    padding: 0.35rem 0.4rem;
    background: rgba(0,0,0,0.03);
    border-radius: 4px;
}
.forecast-tip.expanded .forecast-tip-details { display: block; }
.forecast-detail-child {
    display: flex;
    justify-content: space-between;
    padding: 0.15rem 0;
    font-size: 0.7rem;
    color: var(--text);
}
.forecast-detail-name { font-weight: 600; }
.forecast-detail-info { color: var(--text-muted); }

.hidden { display: none !important; }

@media (max-width: 1000px) {
    .groups-container { grid-template-columns: 1fr; }
    .upload-cards { grid-template-columns: 1fr; }
}
