* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    color: #333;
}

/* ============ LOGIN PAGE ============ */
.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 450px;
}

.login-box {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 10px;
    font-size: 2em;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.login-btn:hover {
    transform: translateY(-2px);
}

.error-message {
    display: none;
    margin-top: 15px;
    padding: 12px;
    background: #ffe0e0;
    color: #d00;
    border-radius: 6px;
    text-align: center;
}

.login-info {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    font-size: 0.9em;
    color: #666;
    text-align: center;
}

.login-note {
    font-style: italic;
    color: #888;
}

/* ============ NAVBAR ============ */
.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-content h2 {
    margin: 0;
    font-size: 1.5em;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logout-btn {
    padding: 8px 20px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: white;
    color: #667eea;
}

/* ============ ADMIN PANEL ============ */
.admin-container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
}

.ward-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.ward-tab {
    padding: 12px 25px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.ward-tab:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.ward-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.view-tab {
    margin-left: auto;
}

.config-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.config-section h2 {
    margin-bottom: 10px;
    color: #667eea;
}

.ward-info {
    color: #666;
    margin-bottom: 30px;
}

.candidate-setup, .vote-controls, .statistics {
    margin-bottom: 40px;
}

.candidate-setup h3, .vote-controls h3, .statistics h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.3em;
}

.empty-message {
    color: #999;
    font-style: italic;
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    border-radius: 8px;
}

.info-text {
    color: #666;
    margin-bottom: 20px;
    font-size: 0.95em;
}

.ward-settings {
    background: #e8f4f8;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
    border: 2px solid #bee5eb;
}

.ward-settings h3 {
    margin-bottom: 15px;
    color: #0c5460;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.setting-row label {
    font-weight: 500;
    color: #333;
}

.setting-row input {
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    width: 150px;
    font-size: 1em;
}

.current-max {
    color: #666;
    font-size: 0.95em;
}

.current-max span {
    font-weight: bold;
    color: #0c5460;
}

.ballot-unit-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    border: 2px solid #e9ecef;
}

.unit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #dee2e6;
}

.unit-label {
    font-weight: bold;
    font-size: 1.1em;
    color: #333;
}

.unit-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.unit-actions {
    display: flex;
    gap: 10px;
}

.candidate-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
}

.candidate-number {
    font-weight: bold;
    color: #667eea;
    min-width: 100px;
}

.candidate-name {
    flex: 1;
}

.delete-btn {
    padding: 8px 15px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
}

.delete-btn:hover {
    background: #d63031;
}

.add-candidate-form {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.add-candidate-form input {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
}

.add-candidate-form input[type="number"] {
    flex: 1;
}

.add-btn {
    padding: 12px 25px;
    background: #51cf66;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.add-btn:hover {
    background: #37b24d;
}

.vote-control-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    border: 2px solid #e9ecef;
}

.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.candidate-label {
    font-weight: bold;
    font-size: 1.1em;
    color: #333;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 30px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #51cf66;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(30px);
}

.control-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
}

.input-group input {
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1em;
}

.control-actions {
    display: flex;
    gap: 10px;
}

.boost-btn, .stop-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.boost-btn {
    background: #ffd43b;
    color: #333;
}

.boost-btn:hover {
    background: #fab005;
    transform: translateY(-2px);
}

.stop-btn {
    background: #ff6b6b;
    color: white;
}

.stop-btn:hover {
    background: #d63031;
    transform: translateY(-2px);
}

/* ============ CANDIDATES GRID ============ */
.candidates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.candidate-card {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.3s;
}

.candidate-card.highlighted {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    border-color: #ffc107;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.candidate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e9ecef;
}

.candidate-num {
    font-weight: bold;
    color: #333;
    font-size: 0.95em;
}

.highlight-badge {
    background: #ffc107;
    color: #333;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: bold;
}

.candidate-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.candidate-controls .input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.candidate-controls .input-group label {
    font-size: 0.8em;
    color: #666;
}

.candidate-controls .input-group input {
    padding: 6px 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.9em;
}

.candidate-controls .secondary-input {
    background: #f8f9fa;
}

.slow-toggle {
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
}

.toggle-switch.small {
    width: 40px;
    height: 20px;
}

.toggle-switch.small .toggle-slider:before {
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
}

.toggle-switch.small input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.candidate-actions {
    margin-top: 10px;
}

.boost-btn.small {
    padding: 6px 12px;
    font-size: 0.85em;
    width: 100%;
}

.unit-meta {
    display: flex;
    align-items: center;
    gap: 15px;
}

.meta-info {
    font-size: 0.9em;
    color: #666;
    background: #e9ecef;
    padding: 4px 10px;
    border-radius: 4px;
}

.preview-note {
    text-align: center;
    color: #999;
    font-style: italic;
    margin-top: 15px;
    font-size: 0.9em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
}

.stat-value {
    font-size: 2.5em;
    font-weight: bold;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 1em;
    opacity: 0.9;
}

/* ============ USER VIEW ============ */
.user-container {
    max-width: 1600px;
    margin: 20px auto;
    padding: 0 20px;
}

.ward-info-banner {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-around;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.info-item {
    text-align: center;
}

.info-item .label {
    display: block;
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.info-item .value {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

.booths-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.booth {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.booth:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.booth-header {
    font-weight: bold;
    color: #667eea;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
    font-size: 1.1em;
}

.machines-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.machine {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
}

.machine-header {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 8px;
    font-weight: 600;
}

.voting-table {
    width: 100%;
    border-collapse: collapse;
}

.voting-table th {
    background: #667eea;
    color: white;
    padding: 8px;
    font-size: 0.85em;
    font-weight: 600;
}

.voting-table td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid #e9ecef;
}

.candidate-cell {
    font-weight: bold;
    color: #333;
    font-size: 1.1em;
}

.light-cell {
    width: 60px;
}

.voting-light {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #dee2e6;
    margin: 0 auto;
    transition: all 0.3s;
}

.voting-light.blinking {
    background: #ff4444;
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.8);
}

.voting-light.blink-on {
    background: #ff4444;
    box-shadow: 0 0 20px rgba(255, 68, 68, 1);
}

.voting-light.blink-off {
    background: #dee2e6;
    box-shadow: none;
}

/* Highlighted candidate row */
.highlighted-row {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
}

.highlighted-row .candidate-cell {
    color: #856404;
    font-weight: bold;
}

.highlighted-candidate {
    position: relative;
}

.highlighted-candidate::after {
    content: '★';
    margin-left: 5px;
    color: #ffc107;
    font-size: 0.9em;
}

/* ============ USER VIEW PREVIEW ============ */
.user-view-header {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.preview-ward {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.preview-ward h3 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.preview-booths {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .nav-content h2 {
        font-size: 1.2em;
    }
    
    .ward-tabs {
        flex-direction: column;
    }
    
    .ward-tab {
        width: 100%;
        text-align: center;
    }
    
    .control-inputs {
        grid-template-columns: 1fr;
    }
    
    .add-candidate-form {
        flex-direction: column;
    }
    
    .add-candidate-form input[type="number"] {
        width: 100%;
    }
    
    .ward-info-banner {
        flex-direction: column;
        gap: 15px;
    }
    
    .booths-grid, .preview-booths {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 25px;
    }
    
    .login-box h1 {
        font-size: 1.5em;
    }
}
