:root {
    --bg-main: #101317;
    --bg-panel: #181d24;
    --bg-board: #eef2f6;
    --text-main: #f4f7fb;
    --text-muted: #9aa7b6;
    --seat-empty: #c9d3df;
    --seat-occupied: #2f9e69;
    --aisle-bg: #f7c948;
    --student-moving: #2563eb;
    --student-pickup: #f97316;
    --student-waiting: #dc2626;
    --student-seated: #147d4f;
    --border: #2b3440;
    --tick-speed: 55ms;
}

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

body {
    min-height: 100vh;
    background: var(--bg-main);
    color: var(--text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
}

.sidebar {
    display: flex;
    align-items: center;
    gap: 24px;
    width: 100%;
    min-height: 86px;
    padding: 14px 22px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
    z-index: 5;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 230px;
}

.logo strong {
    display: block;
    font-size: 18px;
    letter-spacing: 0;
}

.logo p {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 12px;
}

.mobile-toggle {
    display: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #111827;
    color: var(--text-main);
    padding: 6px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 150px;
}

.control-group label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

select,
input[type="range"] {
    width: 100%;
}

select {
    min-height: 34px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #101317;
    color: var(--text-main);
}

input[type="range"] {
    accent-color: #60a5fa;
}

.range-value {
    color: var(--text-muted);
    font-size: 12px;
    text-align: right;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn {
    min-height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: 6px;
    color: white;
    font-weight: 800;
    cursor: pointer;
}

.btn:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.btn-primary { background: #2563eb; }
.btn-secondary { background: #586174; }
.btn-danger { background: #dc2626; }

.simulation-area {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 22px;
}

.dashboard {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 18px;
}

.stat-card {
    min-width: 150px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-panel);
    text-align: center;
}

.stat-label {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 800;
}

.stat-value {
    display: block;
    margin-top: 3px;
    color: white;
    font-size: 20px;
    font-weight: 900;
}

.progress-bar {
    width: 100%;
    height: 7px;
    margin-top: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #303a46;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: var(--seat-occupied);
    transition: width 0.25s ease;
}

.cafeteria-wrapper {
    width: max-content;
    margin: 0 auto;
    padding: 18px;
    border: 1px solid #5b6675;
    border-radius: 8px;
    background: #dfe6ee;
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.35);
}

.service-zone,
.back-wall {
    width: 100%;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #243041;
    font-size: 13px;
    font-weight: 900;
}

.service-zone {
    margin-bottom: 10px;
    background: #fed7aa;
    border: 1px solid #fb923c;
}

.back-wall {
    margin-top: 10px;
    background: #d8dee7;
    border: 1px solid #aeb8c6;
}

.cafeteria-grid {
    display: grid;
    grid-template-columns: repeat(25, 22px);
    grid-template-rows: repeat(25, 22px);
    gap: 3px;
    position: relative;
    padding: 4px;
    border-radius: 6px;
    background: var(--bg-board);
}

.cell {
    width: 22px;
    height: 22px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.seat {
    border: 1px solid #9aa7b6;
    border-radius: 4px;
    background: var(--seat-empty);
    transition: background 0.15s ease;
}

.seat.occupied {
    background: var(--seat-occupied);
    border-color: #147d4f;
}

.aisle {
    border-radius: 3px;
    background: repeating-linear-gradient(
        to bottom,
        #facc15 0,
        #facc15 8px,
        #eab308 8px,
        #eab308 13px
    );
}

.row-label {
    position: absolute;
    left: -22px;
    color: #475467;
    font-size: 10px;
    font-weight: 800;
}

.entry-marker {
    color: #713f12;
    font-size: 8px;
    font-weight: 900;
}

.student {
    width: 14px;
    height: 14px;
    position: absolute;
    z-index: 2;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.28);
    transition: left var(--tick-speed) linear, top var(--tick-speed) linear, background 0.12s ease;
}

.student-moving { background: var(--student-moving); }
.student-pickup { background: var(--student-pickup); }
.student-waiting { background: var(--student-waiting); }
.student-seated { background: var(--student-seated); }
.student-queue { background: var(--student-waiting); }

.legend {
    min-height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 10px;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-main);
    font-size: 12px;
}

.blob {
    width: 13px;
    height: 13px;
    border-radius: 3px;
}

.blob.empty-seat { background: var(--seat-empty); }
.blob.seated { background: var(--seat-occupied); border-radius: 50%; }
.blob.moving { background: var(--student-moving); border-radius: 50%; }
.blob.pickup { background: var(--student-pickup); border-radius: 50%; }
.blob.waiting { background: var(--student-waiting); border-radius: 50%; }
.blob.aisle-legend { background: var(--aisle-bg); }

@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    .app-container {
        min-height: 100vh;
        height: auto;
    }

    .sidebar {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }

    .sidebar-top {
        width: 100%;
    }

    .mobile-toggle {
        display: block;
    }

    .controls {
        display: none;
    }

    .controls.active {
        display: flex;
    }

    .dashboard {
        flex-wrap: wrap;
    }
}
