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

:root {
    /* Темная тема */
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --bg-hover: #333;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --border: #333;
    --border-hover: #444;
    --primary: #4a9eff;
    --primary-hover: #5aaeff;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px 0 rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px 0 rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 100%;
    margin: 0;
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 1rem;
    text-align: center;
}

.event-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

@media (min-width: 640px) {
    .event-title {
        font-size: 2.5rem;
    }
}

.event-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.info-banner {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

.nominations-nav {
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-secondary);
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Если номинаций две, делаем их по ширине страницы */
.nominations-nav.two-nominations {
    overflow-x: hidden;
}

.nominations-nav.two-nominations .nomination-btn {
    flex: 1;
    min-width: 0;
}

.nominations-nav::-webkit-scrollbar {
    height: 4px;
}

.nominations-nav::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.nominations-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.nomination-btn {
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: center;
}

@media (min-width: 640px) {
    .nomination-btn {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }
}

.nomination-btn:hover {
    color: var(--text-secondary);
    border-bottom-color: var(--border);
}

.nomination-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.main-content {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
    background: var(--bg-primary);
}

@media (min-width: 640px) {
    .main-content {
        padding: 2rem 1.5rem;
    }
}

.nomination-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    text-align: center;
}

@media (min-width: 640px) {
    .nomination-title {
        font-size: 1.875rem;
    }
}

.candidates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (min-width: 640px) {
    .candidates-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1.5rem;
    }
}

.candidate-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.candidate-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.candidate-card.voted {
    border-color: var(--primary);
    border-width: 2px;
}

.candidate-card.voted::after {
    content: '✓';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--primary);
    color: var(--text-primary);
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    z-index: 10;
}

.candidate-photo {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--bg-tertiary);
    display: block;
}

@media (min-width: 640px) {
    .candidate-photo {
        height: 240px;
    }
}

.candidate-info {
    padding: 1rem;
    text-align: center;
}

.candidate-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

@media (min-width: 640px) {
    .candidate-name {
        font-size: 1rem;
    }
}

.candidate-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

@media (min-width: 640px) {
    .candidate-description {
        font-size: 0.875rem;
    }
}

.btn {
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-primary {
    background: var(--primary);
    color: var(--text-primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.btn-warning {
    background: var(--warning);
    color: var(--text-primary);
    border-color: var(--warning);
}

.btn-warning:hover {
    background: #f6a20b;
    border-color: #f6a20b;
}

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

.stats-button-container {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: slideUp 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover {
    color: var(--text-primary);
}

.modal-content h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.modal-candidate {
    text-align: center;
    margin: 1.5rem 0;
}

.modal-candidate img {
    width: 180px;
    height: 220px;
    object-fit: cover;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.modal-candidate .candidate-name {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.modal-candidate .candidate-description {
    font-size: 0.875rem;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 0.875rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

/* Toast уведомления */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: #10b981;
}

.toast.error {
    background: #ef4444;
}

/* Статистика */
.statistics-section {
    animation: fadeIn 0.2s;
}

.statistics-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.stats-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s;
}

/* Tab buttons в админке должны быть по ширине */
.admin-main-tabs .tab-btn,
.stats-tabs .tab-btn,
.admin-tabs .tab-btn {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.tab-btn:hover {
    color: var(--text-secondary);
}

.tab-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
    border-bottom-width: 2px;
    font-weight: 600;
    background: transparent;
}

.stats-content {
    margin-bottom: 2rem;
}

.stat-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.stat-nomination {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.stat-candidate {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.stat-candidate:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.stat-candidate-rank {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 2rem;
    text-align: center;
}

.stat-candidate-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

@media (min-width: 640px) {
    .stat-candidate-name {
        font-size: 1rem;
    }
}

.stat-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.stat-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.stat-candidate-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.stat-candidate-votes {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-candidate-percentage {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Детальная статистика */
.detailed-vote {
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    border-left: 3px solid var(--primary);
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.detailed-vote:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.vote-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.vote-user {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.vote-candidate {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.vote-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
}

/* Загрузка */
.loading {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.spinner {
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Админка */
.admin-section {
    animation: fadeIn 0.2s;
}

.admin-nomination-section {
    margin-bottom: 2rem;
}

.admin-candidate-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s;
}

.admin-candidate-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-tertiary);
}

.modal-large {
    max-width: 600px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-secondary);
}

.form-group input[type="file"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
}

.form-group input[type="file"]:hover {
    border-color: var(--border-hover);
}

#previewImage {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

/* Полноэкранный просмотр изображения */
.image-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.95);
    pointer-events: none;
}

.image-modal-content img {
    pointer-events: auto;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: zoom-in;
    transition: transform 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.image-modal-content img.zoomed {
    cursor: zoom-out;
    transform: scale(2);
}

.close-image {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    font-size: 2rem;
    font-weight: 400;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    z-index: 1001;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.close-image:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
}

.export-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 2rem;
    text-align: center;
}

/* Админка - вкладки */
.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.admin-tab-content {
    margin-top: 1rem;
}

.admin-nomination-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    flex-wrap: wrap;
}

.admin-nomination-tabs .tab-btn {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.admin-nomination-tabs-content {
    margin-top: 1rem;
}

.admin-nomination-tab-panel {
    margin-top: 1rem;
}

.stat-nomination-panel {
    margin-top: 1rem;
}
