:root {
    --primary: #bf2d27;
    --secondary: #9a221c;
    --accent: #dbab27;
    --accent-dark: #b8901f;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --light: #fdf9f8;
    --dark: #1a1012;
    --text: #333;
    --text-light: #6b6b6b;
    --shadow: 0 10px 40px rgba(191, 45, 39, 0.12);
    --shadow-hover: 0 15px 50px rgba(191, 45, 39, 0.22);
    --fs-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
    --fs-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
    --fs-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
    --fs-lg: clamp(1.125rem, 1rem + 0.6vw, 1.25rem);
    --fs-xl: clamp(1.25rem, 1.1rem + 0.8vw, 1.5rem);
    --fs-2xl: clamp(1.5rem, 1.2rem + 1.5vw, 2rem);
    --fs-3xl: clamp(1.875rem, 1.5rem + 2vw, 2.5rem);
    --space-sm: clamp(0.75rem, 0.6rem + 0.75vw, 1rem);
    --space-md: clamp(1rem, 0.8rem + 1vw, 1.5rem);
    --space-lg: clamp(1.5rem, 1.2rem + 1.5vw, 2rem);
    --space-xl: clamp(2rem, 1.5rem + 2.5vw, 3rem);
    --container-max: 1400px;
    --container-padding: clamp(1rem, 2vw + 0.5rem, 2.5rem);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #ffffff;
    color: var(--text);
    line-height: 1.6;
    font-size: var(--fs-base);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

.screen { display: none; animation: fadeInUp 0.5s ease; }
.screen.active { display: block; }

.navbar {
    position: fixed; top: 0; left: 0; right: 0;
    background: #ffffff;
    box-shadow: 0 2px 20px rgba(191, 45, 39, 0.08);
    z-index: 1000;
    padding: var(--space-sm) var(--container-padding);
    display: flex; justify-content: space-between; align-items: center;
    gap: var(--space-sm);
}

.logo { display: flex; align-items: center; gap: var(--space-sm); cursor: pointer; flex-shrink: 0; }
.logo-img { width: clamp(40px, 5vw + 20px, 60px); height: clamp(40px, 5vw + 20px, 60px); object-fit: contain; transition: transform 0.3s; }
.logo:hover .logo-img { transform: rotate(-10deg) scale(1.1); }
.logo-text { display: flex; flex-direction: column; min-width: 0; }
.logo-title { font-weight: bold; color: var(--primary); font-size: var(--fs-lg); line-height: 1.2; white-space: nowrap; }
.logo-subtitle { font-size: var(--fs-xs); color: var(--text-light); font-weight: 500; white-space: nowrap; }

/* До входа логотип статичен */
body:not(.logged-in) .logo { cursor: default; }
body:not(.logged-in) .logo:hover .logo-img { transform: none; }

.hamburger { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 8px; z-index: 1001; }
.hamburger span { width: 28px; height: 3px; background: var(--primary); border-radius: 3px; transition: all 0.3s; }
.hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 6px); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -6px); }

/* Меню скрыто до входа */
.nav-menu { display: none; gap: 5px; list-style: none; align-items: center; }
body.logged-in .nav-menu { display: flex; }

.nav-menu a {
    color: var(--text); text-decoration: none; padding: 10px 14px; border-radius: 10px;
    font-weight: 500; transition: all 0.3s; display: flex; align-items: center; gap: 8px;
    font-size: var(--fs-sm); white-space: nowrap;
}
.nav-menu a:hover { background: var(--light); color: var(--primary); transform: translateY(-2px); }
.nav-menu a.active { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #ffffff; }

.nav-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.nav-btn {
    padding: 10px 18px; border: none; border-radius: 10px; cursor: pointer;
    font-weight: 600; transition: all 0.3s; font-size: var(--fs-sm);
    display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.nav-btn.primary { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #ffffff; }
.nav-btn.primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(191, 45, 39, 0.3); }

.theme-toggle {
    background: var(--light); border: none; width: 40px; height: 40px; border-radius: 50%;
    cursor: pointer; transition: all 0.3s; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.theme-toggle:hover { transform: rotate(180deg); background: var(--accent); }

main {
    margin-top: 80px; padding: var(--container-padding);
    max-width: var(--container-max); margin-left: auto; margin-right: auto; flex: 1; width: 100%;
}

.card {
    background: #ffffff; border-radius: 20px; padding: var(--space-lg);
    margin-bottom: var(--space-lg); box-shadow: var(--shadow); animation: fadeInUp 0.6s ease;
    border: 1px solid rgba(191, 45, 39, 0.08);
}
.card h2 { color: var(--primary); margin-bottom: var(--space-md); font-size: var(--fs-2xl); }

.login-card { max-width: 500px; margin: 40px auto; text-align: center; }
.login-header svg { margin-bottom: var(--space-md); }
.login-header h2 { color: var(--primary); margin-bottom: 10px; }
.login-header p { color: var(--text-light); margin-bottom: var(--space-lg); }

input[type="text"], input[type="file"] {
    width: 100%; padding: 16px; border: 2px solid #eee3e2; border-radius: 12px;
    font-size: var(--fs-base); margin-bottom: 15px; transition: all 0.3s; background: #ffffff;
}
input[type="text"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(191, 45, 39, 0.12); }

.btn-primary, .btn-secondary {
    width: 100%; padding: 16px; border: none; border-radius: 12px;
    font-size: var(--fs-base); font-weight: 600; cursor: pointer; transition: all 0.3s;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #ffffff; box-shadow: 0 4px 15px rgba(191, 45, 39, 0.3); }
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(191, 45, 39, 0.4); }
.btn-secondary { background: #f4efee; color: #5a4a42; margin-top: 15px; }
.btn-secondary:hover { background: #eee3e2; }

.error { color: var(--error); margin-top: 12px; font-size: var(--fs-sm); padding: 10px; background: #fff5f5; border-radius: 8px; border-left: 4px solid var(--error); }
.error:empty { display: none; }

.hero-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 55%, var(--accent) 160%);
    color: #ffffff; padding: clamp(1.5rem, 3vw + 1rem, 3rem); border-radius: 20px;
    margin-bottom: var(--space-lg); position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.hero-banner::before {
    content: ''; position: absolute; top: -50%; right: -10%;
    width: clamp(200px, 30vw, 400px); height: clamp(200px, 30vw, 400px);
    background: rgba(219, 171, 39, 0.18); border-radius: 50%; animation: pulse 4s ease-in-out infinite;
}
.hero-content { position: relative; z-index: 1; max-width: 100%; }
.hero-greeting { font-size: var(--fs-sm); opacity: 0.9; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.hero-title { font-size: var(--fs-3xl); margin-bottom: 15px; text-shadow: 2px 2px 8px rgba(0,0,0,0.25); line-height: 1.2; }
.hero-subtitle { font-size: var(--fs-base); opacity: 0.95; margin-bottom: 20px; line-height: 1.5; width: 100%; max-width: none; text-align: justify; }

.hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-md); }
.hero-stat {
    background: rgba(255,255,255,0.14); padding: clamp(12px, 1.5vw, 18px) clamp(14px, 1.8vw, 22px);
    border-radius: 15px; backdrop-filter: blur(10px); border: 1px solid rgba(219, 171, 39, 0.35);
    display: flex; flex-direction: column; gap: 6px; justify-content: center;
}
.hero-stat-value { font-size: var(--fs-2xl); font-weight: bold; color: var(--accent); line-height: 1.2; }
.hero-stat-value.hero-stat-text { font-size: var(--fs-base); font-weight: 600; color: #ffffff; }
.hero-stat-label { font-size: var(--fs-xs); opacity: 0.9; }
.hero-stat .hero-cta { padding: 10px 18px; font-size: var(--fs-sm); box-shadow: none; justify-content: center; }

.hero-cta {
    display: inline-flex; align-items: center; gap: 10px;
    background: var(--accent); color: var(--secondary);
    padding: clamp(12px, 1.5vw, 15px) clamp(25px, 3vw, 35px);
    border-radius: 50px; font-weight: bold; text-decoration: none;
    font-size: var(--fs-base); transition: all 0.3s;
    box-shadow: 0 5px 20px rgba(219, 171, 39, 0.4);
}
.hero-cta:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(219, 171, 39, 0.6); }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-md); margin-bottom: var(--space-lg); }
.quick-action {
    background: #ffffff; padding: var(--space-lg); border-radius: 20px; text-align: center;
    box-shadow: var(--shadow); cursor: pointer; transition: all 0.3s; border: 2px solid transparent;
}
.quick-action:hover { transform: translateY(-8px); box-shadow: var(--shadow-hover); border-color: var(--accent); }
.quick-action-icon { width: clamp(40px, 5vw, 60px); height: clamp(40px, 5vw, 60px); margin: 0 auto 15px; color: var(--primary); }
.quick-action h3 { color: var(--primary); margin-bottom: 8px; font-size: var(--fs-lg); }
.quick-action p { color: var(--text-light); font-size: var(--fs-sm); }

.section-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 25px; padding-bottom: 15px; border-bottom: 3px solid var(--accent);
    flex-wrap: wrap; gap: 10px;
}
.section-title { color: var(--primary); font-size: var(--fs-2xl); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-title-icon { width: 36px; height: 36px; color: var(--primary); flex-shrink: 0; }

.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.admin-grid .menu-btn { padding: 25px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.menu-btn {
    padding: 20px; border: 2px solid #eee3e2; border-radius: 15px;
    background: #ffffff;
    font-size: var(--fs-base); font-weight: 600; cursor: pointer; transition: all 0.3s;
    color: var(--primary); display: flex; align-items: center; gap: 10px;
}
.menu-btn:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 8px 25px rgba(191, 45, 39, 0.2); }
.danger-btn { background: #fff5f5; color: var(--error); border-color: #ffcccc; }
.danger-btn:hover { background: var(--error); color: #ffffff; border-color: var(--error); }

.record-item {
    background: #ffffff;
    padding: 18px; border-radius: 12px; margin-bottom: 12px;
    display: flex; justify-content: space-between; align-items: center;
    border-left: 5px solid var(--primary); transition: all 0.3s; flex-wrap: wrap; gap: 10px;
    box-shadow: 0 2px 10px rgba(191, 45, 39, 0.06);
}
.record-item:hover { transform: translateX(5px); box-shadow: 0 4px 15px rgba(191, 45, 39, 0.15); }
.record-info { flex: 1; min-width: 200px; }
.record-info strong { color: var(--primary); font-size: var(--fs-lg); }

.btn-cancel {
    background: var(--error); color: #ffffff; border: none;
    padding: 10px 20px; border-radius: 10px; cursor: pointer;
    font-size: var(--fs-sm); font-weight: 600; transition: all 0.3s;
}
.btn-cancel:hover { background: #cc0000; transform: scale(1.05); }

.schedule-item {
    background: #ffffff;
    padding: 18px; border-radius: 12px; margin-bottom: 12px;
    border-left: 5px solid var(--primary); transition: all 0.3s;
    box-shadow: 0 2px 10px rgba(191, 45, 39, 0.06);
}
.schedule-item:hover { transform: translateX(5px); box-shadow: 0 4px 15px rgba(191, 45, 39, 0.15); }
.schedule-item.full { border-left-color: var(--error); opacity: 0.75; }
.schedule-item .schedule-header strong { color: #000000; font-size: 18px; font-weight: 700; }
.schedule-header { display: flex; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 10px; align-items: center; }
.schedule-item .schedule-header .seats-info {
    font-size: 14px; color: #5a4a42; font-weight: 600;
    background: rgba(191, 45, 39, 0.06); padding: 6px 12px; border-radius: 8px; white-space: nowrap;
}
.schedule-item .schedule-meta { font-size: 16px; font-weight: 500; margin-top: 8px; color: #333; }

.seats-busy { color: #d32f2f; font-weight: 700; }
.seats-free { color: #2e7d32; font-weight: 700; }

.signup-option {
    background: #ffffff;
    padding: 18px; border-radius: 12px; margin-bottom: 12px;
    cursor: pointer; border: 2px solid #eee3e2; transition: all 0.3s;
}
.signup-option:hover { border-color: var(--primary); transform: translateX(5px); box-shadow: 0 4px 15px rgba(191, 45, 39, 0.15); }

.admin-stat {
    background: #ffffff;
    padding: 15px; border-radius: 10px; margin-bottom: 10px;
    display: flex; justify-content: space-between; align-items: center;
    border-left: 4px solid var(--accent); flex-wrap: wrap; gap: 10px;
    box-shadow: 0 2px 10px rgba(191, 45, 39, 0.06);
}
.progress-bar { width: 120px; height: 10px; background: #eee3e2; border-radius: 5px; overflow: hidden; display: inline-block; margin: 0 10px; vertical-align: middle; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 0.5s; }

.notification {
    position: fixed; top: 100px; right: 30px;
    background: #ffffff; padding: 20px 25px; border-radius: 15px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.2);
    display: flex; align-items: center; gap: 15px;
    min-width: 280px; max-width: calc(100vw - 60px);
    animation: slideInRight 0.5s ease; z-index: 2000;
    border-left: 5px solid var(--success);
}
.notification.warning { border-left-color: var(--warning); }
.notification.error { border-left-color: var(--error); }
.notification-icon { width: 36px; height: 36px; flex-shrink: 0; }
.notification-content { flex: 1; min-width: 0; }
.notification-title { font-weight: bold; color: var(--primary); margin-bottom: 3px; font-size: var(--fs-base); }
.notification-text { font-size: var(--fs-sm); color: var(--text-light); word-break: break-word; }
.notification-close { background: none; border: none; cursor: pointer; color: var(--text-light); transition: all 0.3s; width: 24px; height: 24px; flex-shrink: 0; }
.notification-close:hover { color: var(--error); transform: rotate(90deg); }

.school-footer {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #ffffff;
    padding: 0.12em var(--container-padding);
    text-align: center; margin-top: auto; border-top: 4px solid var(--accent); width: 100%;
}
.school-footer-text {
    font-size: clamp(14px, 1.2vw + 8px, 20px); font-weight: bold;
    line-height: 1.2; width: 100%; max-width: none; margin: 0 auto;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

@media (max-width: 768px) {
    body.logged-in .hamburger { display: flex; }
    .nav-menu {
        position: fixed; top: 0; right: -100%; width: 80%; max-width: 300px; height: 100vh;
        background: #ffffff; flex-direction: column; padding: 80px 20px 20px;
        box-shadow: -5px 0 20px rgba(0,0,0,0.1); transition: right 0.3s ease;
        z-index: 999; align-items: stretch; gap: 5px;
    }
    body.logged-in .nav-menu.active { right: 0; }
    .nav-menu a { padding: 15px; font-size: var(--fs-base); }
    .nav-btn span { display: none; }
    .nav-btn { padding: 10px; }
    .logo-subtitle { display: none; }
    main { margin-top: 70px; }
    .hero-stats { grid-template-columns: 1fr 1fr; }
    .hero-subtitle { text-align: left; }
    .quick-actions { grid-template-columns: 1fr; }
    .menu-grid { grid-template-columns: 1fr; }
    .record-item { flex-direction: column; align-items: flex-start; }
    .btn-cancel { width: 100%; }
    .notification { right: 10px; left: 10px; min-width: auto; top: 80px; }
    .school-footer-text { font-size: 13px; }
    .schedule-item .schedule-meta { font-size: 14px; }
    .schedule-item .schedule-header strong { font-size: 16px; }
}

@media (max-width: 480px) {
    .section-title { font-size: var(--fs-xl); }
    .hero-title { font-size: var(--fs-2xl); }
    .hero-stats { grid-template-columns: 1fr; }
}

/* Тёмная тема */
body.dark-theme { background: #170d0b; color: #e8e0da; }
body.dark-theme .card, body.dark-theme .quick-action, body.dark-theme .record-item,
body.dark-theme .schedule-item, body.dark-theme .signup-option, body.dark-theme .admin-stat {
    background: linear-gradient(135deg, #2a1512 0%, #1d100c 100%); color: #e8e0da;
    border-color: rgba(219, 171, 39, 0.15);
}
body.dark-theme .navbar { background: #1d100c; }
body.dark-theme .nav-menu { background: #1d100c; }
body.dark-theme .logo-title { color: var(--accent); }
body.dark-theme .logo-subtitle { color: #b7a79d; }
body.dark-theme .nav-menu a { color: #e8e0da; }
body.dark-theme input[type="text"] { background: #2a1512; color: #e8e0da; border-color: var(--primary); }
body.dark-theme .schedule-item .schedule-header strong { color: #ffffff; }
body.dark-theme .btn-secondary { background: #3a201b; color: #e8e0da; }
body.dark-theme .menu-btn { background: #2a1512; border-color: var(--primary); color: #e8e0da; }
body.dark-theme .theme-toggle { background: #3a201b; }
body.dark-theme .notification { background: #1d100c; color: #e8e0da; }
body.dark-theme .notification-title { color: var(--accent); }
body.dark-theme .error { background: #2a1a1a; }
body.dark-theme .hamburger span { background: var(--accent); }
body.dark-theme .schedule-item .schedule-header .seats-info { background: rgba(255, 255, 255, 0.1); color: #ccc; }
body.dark-theme .schedule-item .schedule-meta { color: #ccc; }
body.dark-theme .progress-bar { background: #3a201b; }
body.dark-theme .seats-busy { color: #ff6b66; }
body.dark-theme .seats-free { color: #7bd68a; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}