﻿:root {
    --crayon-red: #EF4444;
    --crayon-orange: #F97316;
    --crayon-yellow: #FBBF24;
    --crayon-green: #22C55E;
    --crayon-blue: #3B82F6;
    --crayon-purple: #A855F7;
    --crayon-pink: #EC4899;
    --paper: #FFFDF5;
    --chalkboard: #064E3B;
    --chalkboard-light: #065F46;
    --notebook-line: #E5E7EB;
    --sidebar-w: 240px;
    --radius: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
}

* { box-sizing: border-box; font-family: 'Nunito', 'Inter', system-ui, sans-serif; margin: 0; padding: 0; }

body {
    background: var(--paper);
    min-height: 100vh;
    color: #1F2937;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
}

/* ===== AUTH SCREEN ===== */
.auth-screen {
    display: none;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    position: fixed; top: 0; left: 0; width: 100%;
    background: linear-gradient(135deg, var(--chalkboard) 0%, #022c22 100%);
    z-index: 999;
    overflow: hidden;
}
.auth-screen.active { display: flex; }
.auth-screen::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        0deg, transparent, transparent 40px,
        rgba(255,255,255,0.03) 40px, rgba(255,255,255,0.03) 41px
    );
    pointer-events: none;
}

.auth-box {
    background: var(--paper);
    padding: 48px 40px;
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    width: 420px;
    max-width: 95%;
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    border: 4px solid white;
    outline: 3px dashed var(--crayon-yellow);
}
.auth-box::before {
    content: '✏️📚🎒';
    position: absolute;
    top: -50px; left: 50%;
    transform: translateX(-50%);
    font-size: 40px;
    animation: float 3s ease-in-out infinite;
}
.auth-box h2 {
    margin: 0 0 4px;
    color: var(--chalkboard);
    font-size: 28px;
    font-weight: 900;
    text-align: center;
}
.auth-box p {
    color: #6B7280;
    margin-bottom: 28px;
    text-align: center;
    font-size: 15px;
}
.auth-box input {
    width: 100%; padding: 14px 18px;
    border: 2px solid #E5E7EB;
    border-radius: var(--radius);
    font-size: 16px;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    transition: all 0.2s;
    background: white;
}
.auth-box input:focus {
    outline: none;
    border-color: var(--crayon-blue);
    box-shadow: 0 0 0 4px rgba(59,130,246,0.15);
}
.auth-box button {
    width: 100%; padding: 16px;
    background: linear-gradient(135deg, var(--crayon-green), #16A34A);
    color: white; border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(34,197,94,0.3);
    margin-top: 4px;
}
.auth-box button:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 24px rgba(34,197,94,0.4);
}
.auth-box button:active { transform: translateY(0) scale(0.98); }
.auth-error {
    color: var(--crayon-red);
    font-size: 14px; margin-top: 12px;
    display: none; padding: 12px 16px;
    background: #FEF2F2;
    border-radius: var(--radius);
    font-weight: 600;
}
.auth-error.show { display: block; }

/* ===== SIDEBAR ===== */
.app-layout { display: flex; width: 100%; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #1F2937 0%, #111827 100%);
    color: white;
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0;
    height: 100vh; z-index: 100;
    overflow-y: auto;
    border-right: 4px solid var(--crayon-yellow);
}
.sidebar-header {
    padding: 20px;
    background: linear-gradient(135deg, var(--crayon-blue), var(--crayon-purple));
    text-align: center;
    position: relative;
    overflow: hidden;
}
.sidebar-header::after {
    content: '📏✂️📐';
    position: absolute;
    bottom: 4px; right: 8px;
    font-size: 14px;
    opacity: 0.5;
}
.sidebar-logo { font-size: 40px; margin-bottom: 4px; }
.sidebar-title { font-size: 18px; font-weight: 800; }
.sidebar-subtitle { font-size: 12px; opacity: 0.8; font-weight: 600; }

.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 10px 16px;
    background: transparent; border: none;
    color: #9CA3AF; font-size: 14px; font-weight: 700;
    cursor: pointer; transition: all 0.2s;
    text-align: left; font-family: 'Nunito', sans-serif;
    position: relative;
    margin: 2px 8px;
    border-radius: var(--radius);
    width: calc(100% - 16px);
}
.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: white;
    transform: translateX(4px);
}
.nav-item.active {
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
/* Each nav item gets its own crayon color */
.nav-item[data-tab='settings'].active { background: linear-gradient(135deg, var(--crayon-red), #DC2626); }
.nav-item[data-tab='vozhaty'].active { background: linear-gradient(135deg, var(--crayon-blue), #2563EB); }
.nav-item[data-tab='performers'].active { background: linear-gradient(135deg, var(--crayon-pink), #DB2777); }
.nav-item[data-tab='circles'].active { background: linear-gradient(135deg, var(--crayon-yellow), #D97706); color: #1F2937; }
.nav-item[data-tab='squads'].active { background: linear-gradient(135deg, var(--crayon-green), #16A34A); }
.nav-item[data-tab='schedule'].active { background: linear-gradient(135deg, var(--crayon-purple), #7C3AED); }

.nav-item .nav-icon { font-size: 20px; width: 28px; text-align: center; }
.nav-item .nav-count {
    margin-left: auto; background: rgba(255,255,255,0.15);
    padding: 2px 10px; border-radius: 20px; font-size: 12px;
    font-weight: 600;
}
.sidebar-footer {
    padding: 8px 0;
    border-top: 2px solid rgba(255,255,255,0.08);
}
.nav-item.logout { color: #6B7280; }
.nav-item.logout:hover { color: var(--crayon-red); background: rgba(239,68,68,0.1); }

/* ===== MAIN AREA ===== */
.main-area { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }

.top-bar {
    background: white;
    border-bottom: 3px solid var(--crayon-yellow);
    padding: 14px 28px;
    display: flex; align-items: center;
    justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
    background: linear-gradient(180deg, white 0%, var(--paper) 100%);
}
.top-bar-title {
    font-size: 22px; font-weight: 800;
    color: var(--chalkboard);
    display: flex; align-items: center; gap: 8px;
}
.top-bar-right { display: flex; align-items: center; gap: 12px; }

.content { padding: 24px 28px; max-width: 1600px; }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    display: flex; align-items: center; gap: 12px; padding: 14px 22px;
    border-radius: var(--radius-lg); background: white;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12);
    min-width: 300px; max-width: 420px;
    animation: bounceInRight 0.4s ease;
    font-size: 15px; font-weight: 700; font-family: 'Nunito', sans-serif;
    border: 2px solid;
}
.toast.success { border-color: var(--crayon-green); }
.toast.error { border-color: var(--crayon-red); }
.toast.warning { border-color: var(--crayon-yellow); }
.toast.info { border-color: var(--crayon-blue); }
.toast-icon { font-size: 20px; flex-shrink: 0; }

/* ===== PANELS ===== */
.panel { display: none; }
.panel.active { display: block; animation: fadeInUp 0.35s ease; }
.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.panel-header h3 {
    font-size: 22px; font-weight: 800;
    color: var(--chalkboard);
    display: flex; align-items: center; gap: 10px;
}

/* ===== CARDS ===== */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
    background: white; border-radius: var(--radius-lg); padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 2px solid var(--notebook-line);
    transition: all 0.2s; position: relative;
    overflow: hidden;
}
.card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    transform: translateY(-4px);
}
.card::before {
    content: '';
    position: absolute; top: 0; left: 0;
    width: 6px; height: 100%;
    border-radius: 0 4px 4px 0;
}
#panel-vozhaty .card::before { background: var(--crayon-blue); }
#panel-performers .card::before { background: var(--crayon-pink); }
#panel-circles .card::before { background: var(--crayon-yellow); }
#panel-squads .card::before { background: var(--crayon-green); }

.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.card-title { font-size: 16px; font-weight: 700; color: #1F2937; }
.card-badge {
    font-size: 12px; padding: 4px 12px; border-radius: 20px;
    font-weight: 700;
}
.card-badge.free { background: #DCFCE7; color: #166534; }
.card-badge.paid { background: #FEF3C7; color: #92400E; }
.card-badge.field-trip { background: #FFF7ED; color: #9A3412; }
.card-meta { font-size: 14px; color: #6B7280; display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.card-actions { display: flex; gap: 6px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--notebook-line); }

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 20px; border: none;
    border-radius: 50px;
    cursor: pointer; font-weight: 700; font-size: 14px;
    display: inline-flex; align-items: center; gap: 8px;
    transition: all 0.2s; font-family: 'Nunito', sans-serif;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}
.btn:active { transform: translateY(0) scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-primary { background: linear-gradient(135deg, var(--crayon-green), #16A34A); color: white; }
.btn-secondary { background: white; color: #4B5563; border: 2px solid var(--notebook-line); }
.btn-secondary:hover { border-color: var(--crayon-blue); color: var(--crayon-blue); }
.btn-danger { background: linear-gradient(135deg, var(--crayon-red), #DC2626); color: white; }
.btn-warning { background: linear-gradient(135deg, var(--crayon-orange), #EA580C); color: white; }
.btn-ghost { background: transparent; color: #6B7280; border: 2px solid var(--notebook-line); box-shadow: none; }
.btn-ghost:hover { background: #F3F4F6; color: #374151; transform: none; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.btn.loading { pointer-events: none; opacity: 0.7; position: relative; }
.btn.loading::after {
    content: ''; position: absolute;
    width: 18px; height: 18px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white; border-radius: 50%;
    animation: spin 0.6s linear infinite;
    right: 14px; top: 50%; transform: translateY(-50%);
}

/* ===== SETTINGS ===== */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.setting-item {
    background: white; padding: 20px; border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 2px solid var(--notebook-line); transition: all 0.2s;
}
.setting-item:hover { box-shadow: 0 6px 16px rgba(0,0,0,0.08); }
.setting-item label {
    display: block; font-weight: 700; margin-bottom: 8px;
    color: #4B5563; font-size: 13px;
}
.setting-item input, .setting-item select {
    width: 100%; padding: 12px 14px;
    border: 2px solid var(--notebook-line);
    border-radius: var(--radius);
    font-size: 16px; font-weight: 700;
    font-family: 'Nunito', sans-serif;
    transition: border-color 0.2s;
}
.setting-item input:focus, .setting-item select:focus {
    outline: none;
    border-color: var(--crayon-blue);
    box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
}

/* ===== SCHEDULE TABLE ===== */
.schedule-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.schedule-controls select, .schedule-controls label {
    padding: 8px 14px; border: 2px solid var(--notebook-line);
    border-radius: var(--radius); font-size: 14px;
    font-family: 'Nunito', sans-serif; font-weight: 600;
}

.schedule-table-wrap {
    overflow-x: auto; background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 2px solid var(--notebook-line);
}
.schedule-table { width: 100%; border-collapse: collapse; min-width: 800px; }
.schedule-table th {
    background: linear-gradient(135deg, var(--crayon-blue), #2563EB);
    padding: 14px 16px; font-weight: 700;
    font-size: 14px; color: white; text-align: left;
    border-bottom: 2px solid rgba(255,255,255,0.2);
    white-space: nowrap; position: sticky; top: 0; z-index: 2;
    font-family: 'Nunito', sans-serif;
}
.schedule-table th:first-child { border-radius: 12px 0 0 0; }
.schedule-table td { padding: 10px 14px; border-bottom: 1px solid var(--notebook-line); vertical-align: top; }
.schedule-table tr:hover td { background: #F0F9FF; }

.sched-cell {
    padding: 6px 12px; border-radius: var(--radius); font-size: 12px;
    cursor: pointer; transition: all 0.15s; display: block;
    margin-bottom: 4px; font-weight: 600;
}
.sched-cell.free { background: #DCFCE7; color: #166534; border-left: 4px solid var(--crayon-green); }
.sched-cell.paid { background: #FEF3C7; color: #92400E; border-left: 4px solid var(--crayon-yellow); }
.sched-cell.field-trip { background: #FFF7ED; color: #9A3412; border-left: 4px solid #F97316; }
.sched-cell:hover { transform: translateX(3px); }
.sched-cell .cell-name { font-weight: 700; }
.sched-cell .cell-time { font-size: 11px; opacity: 0.7; }
.sched-cell-empty {
    display: flex; align-items: center; justify-content: center;
    min-height: 36px;
    border: 2px dashed #D1D5DB; border-radius: var(--radius);
    cursor: pointer; transition: all 0.15s;
    color: #9CA3AF; font-size: 18px; font-weight: 700;
}
.sched-cell-empty:hover { border-color: var(--crayon-blue); color: var(--crayon-blue); background: #EFF6FF; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center; padding: 60px 20px; color: #9CA3AF;
    background: white; border-radius: var(--radius-lg);
    border: 2px dashed var(--notebook-line);
}
.empty-state .empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state h4 { font-size: 20px; color: #6B7280; margin-bottom: 8px; font-weight: 700; }
.empty-state p { font-size: 15px; max-width: 300px; margin: 0 auto 20px; }

/* ===== MODALS ===== */
.modal {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    justify-content: center; align-items: center; z-index: 1000;
}
.modal.active { display: flex; }
.modal-content {
    background: var(--paper); padding: 32px;
    border-radius: var(--radius-xl);
    width: 540px; max-width: 95%; max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: bounceIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 4px solid white;
    outline: 2px dashed var(--crayon-yellow);
}
.modal-content h3 {
    font-size: 22px; font-weight: 800; margin-bottom: 24px;
    color: var(--chalkboard);
    display: flex; align-items: center; gap: 10px;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--crayon-yellow);
}
.modal-content label {
    display: block; margin: 16px 0 8px;
    font-weight: 700; color: #4B5563; font-size: 14px;
}
.modal-content input, .modal-content select {
    width: 100%; padding: 12px 16px;
    border: 2px solid var(--notebook-line);
    border-radius: var(--radius);
    font-size: 15px; font-family: 'Nunito', sans-serif; font-weight: 600;
    transition: border-color 0.2s;
}
.modal-content input:focus, .modal-content select:focus {
    outline: none; border-color: var(--crayon-blue);
    box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
}
.modal-content input[type=number] { width: 120px; }
.modal-content input[type=checkbox] { width: auto; }
.modal-content .required { color: var(--crayon-red); }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.checkbox-item {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px; background: white;
    border-radius: var(--radius); font-size: 14px;
    cursor: pointer; transition: all 0.15s;
    border: 2px solid var(--notebook-line);
    font-weight: 600;
}
.checkbox-item:hover { border-color: var(--crayon-blue); background: #EFF6FF; }
.checkbox-item input { width: auto; }
.modal-buttons { display: flex; gap: 12px; margin-top: 28px; }
.modal-buttons button {
    flex: 1; padding: 14px; border: none;
    border-radius: 50px; cursor: pointer;
    font-weight: 700; font-size: 16px;
    font-family: 'Nunito', sans-serif;
    transition: all 0.2s;
}
.btn-save { background: linear-gradient(135deg, var(--crayon-green), #16A34A); color: white; box-shadow: 0 4px 12px rgba(34,197,94,0.3); }
.btn-save:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 6px 20px rgba(34,197,94,0.4); }
.btn-cancel { background: white; color: #6B7280; border: 2px solid var(--notebook-line); }
.btn-cancel:hover { background: #F3F4F6; }
.modal-close {
    position: absolute; top: 16px; right: 16px;
    background: white; border: 2px solid var(--notebook-line);
    width: 36px; height: 36px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center;
    justify-content: center; font-size: 20px; font-weight: 700;
    color: #6B7280; transition: all 0.15s;
}
.modal-close:hover { background: #FEE2E2; color: var(--crayon-red); border-color: var(--crayon-red); }

/* ===== TOGGLE ===== */
.toggle-label {
    display: flex; align-items: center; gap: 12px;
    cursor: pointer; padding: 12px 16px;
    background: white; border-radius: var(--radius);
    transition: all 0.15s; border: 2px solid var(--notebook-line);
    font-weight: 600;
}
.toggle-label:hover { border-color: var(--crayon-blue); }
.toggle-switch {
    width: 48px; height: 28px;
    background: #D1D5DB; border-radius: 14px;
    position: relative; transition: background 0.2s; flex-shrink: 0;
}
.toggle-switch::after {
    content: ''; position: absolute;
    width: 22px; height: 22px; background: white;
    border-radius: 50%; top: 3px; left: 3px;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-label input:checked + .toggle-switch { background: var(--crayon-green); }
.toggle-label input:checked + .toggle-switch::after { transform: translateX(20px); }
.toggle-label input { display: none; }

/* ===== USER AVATAR ===== */
.user-avatar-small {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--crayon-yellow), var(--crayon-orange));
    border-radius: 50%; display: flex; align-items: center;
    justify-content: center; font-weight: 800; color: white; font-size: 16px;
    box-shadow: 0 2px 8px rgba(251,191,36,0.3);
}
.user-name { font-weight: 700; color: #374151; font-size: 15px; }

/* ===== KEYFRAMES ===== */
@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes bounceInRight {
    0% { opacity: 0; transform: translateX(400px); }
    60% { transform: translateX(-20px); }
    100% { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-10px); }
}

/* ===== RESPONSIVE ===== */

.squad-body { display: none; padding: 16px; gap: 16px; overflow-x: auto; }
.squad-row.expanded .squad-body { display: flex; }
.squad-header { padding: 12px 20px; background: #F9FAFB; font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: background 0.2s; border-radius: 12px; }
.squad-header:hover { background: #F3F4F6; }
.squad-header::before { content: '' }

.day-card {
    flex: 1; min-width: 200px;
    background: #F9FAFB; border-radius: var(--radius);
    padding: 12px; border: 2px solid var(--notebook-line);
}
.day-card-title { font-weight: 700; font-size: 14px; color: #374151; margin-bottom: 10px; text-align: center; }
.day-card-body { display: flex; flex-direction: column; gap: 8px; }
.squad-vozhaty { font-weight: 400; color: #6B7280; font-size: 13px; }

.schedule-table tr:nth-child(even) td { background: #F9FAFB; }
.schedule-table tr:nth-child(odd) td { background: white; }
.schedule-table .time-cell { font-weight: 600; color: #6B7280; font-size: 12px; white-space: nowrap; width: 80px; padding-left: 16px; vertical-align: middle; }

.schedule-empty-msg { text-align: center; color: #9CA3AF; padding: 40px; font-size: 14px; }


@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-title, .sidebar-subtitle, .nav-item span:not(.nav-icon) { display: none; }
    .nav-item { justify-content: center; padding: 10px; width: 44px; margin: 2px auto; border-radius: 12px; }
    .sidebar-header { padding: 12px 8px; }
    .sidebar-logo { font-size: 24px; }
    .sidebar-header::after { display: none; }
    .main-area { margin-left: 60px; }
    .content { padding: 16px; }
    .top-bar { padding: 10px 16px; }
    .top-bar-title { font-size: 16px; }
    .cards-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .auth-box { padding: 32px 24px; }
}