:root {
    --primary: #800000;
    /* Maroon */
    --primary-dark: #5c0000;
    /* Dark Maroon */
    --primary-light: #a52a2a;
    /* Light Maroon */
    --secondary: #64748b;
    /* Slate Gray (Text/Icons) */
    --accent: #D4AF37;
    /* Gold (Icons/Borders) */
    --success: #15803d;
    /* Green */
    --warning: #b45309;
    /* Amber */
    --danger: #b91c1c;
    /* Red */
    --bg-color: #f8fafc;
    /* Light Gray/White Background */
    --bg-secondary: #ffffff;
    /* Pure White Cards */
    --text-primary: #1e293b;
    /* Dark Text */
    --text-secondary: #475569;
    /* Medium Text */
    --glass: rgba(255, 255, 255, 0.9);
    /* White Glass */
    --glass-border: rgba(212, 175, 55, 0.3);
    /* Gold Border */
    --shadow: 0 10px 25px -5px rgba(128, 0, 0, 0.1), 0 8px 10px -6px rgba(128, 0, 0, 0.1);
    /* Maroon Shadow */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
}

.glass {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
}

/* Screens */
.screen {
    display: none !important;
}

.screen.active {
    display: flex !important;
}

/* Login Screen - Full page overlay */
#loginScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #4a0404 100%);
    z-index: 9999;
    overflow: hidden;
    /* Ensure logo doesn't overflow if scale is huge */
}

/* Big Background Logo on Maroon */
#loginScreen::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    /* Big size */
    height: 600px;
    background-image: url('sslg_logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.1;
    /* Very subtle texture */
    pointer-events: none;
    z-index: 0;
}

.login-container {
    position: relative;
    /* Ensure it stays above the watermark */
    width: 100%;
    max-width: 400px;
    padding: 20px;
    z-index: 2;
}

.login-box {
    padding: 40px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--accent);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.login-box::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    background-image: url('sslg_logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

.login-header,
#loginForm,
.login-footer {
    position: relative;
    z-index: 1;
}

.login-icon {
    display: none;
}

.login-header h1 {
    font-size: 1.5rem;
    margin-bottom: 5px;
    color: var(--primary);
    font-weight: 700;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.input-icon {
    position: relative;
}

.input-icon i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.input-icon input {
    padding-left: 45px;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 15px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--primary);
}

.btn-sm {
    padding: 8px 15px;
    font-size: 0.8rem;
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.3s;
}

.btn-sm:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-block {
    width: 100%;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 15px;
    min-height: 20px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Main App Layout */
#mainApp {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-radius: 0;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    /* Maroon */
    color: white;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 25px;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-icon {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    background: white;
    /* White bg for logo */
    color: var(--primary);
    /* Maroon Icon */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.logo-text h2 {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--accent);
    /* Gold text */
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 5px;
    transition: all 0.3s;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    transform: translateX(5px);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent);
    /* Gold */
    border-left: 4px solid var(--accent);
    /* Gold */
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.user-info i {
    font-size: 1.5rem;
    color: var(--primary-light);
}

.btn-logout {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px;
    min-height: 100vh;
}

.content-section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.section-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-header h1 i {
    color: var(--primary-light);
}

.section-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    padding: 25px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.stat-icon.green {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.stat-icon.purple {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.stat-info h3 {
    font-size: 1.8rem;
    font-weight: 700;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Cards */
.card {
    border-radius: 16px;
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--glass-border);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h3 i {
    color: var(--primary-light);
}

.card-body {
    padding: 20px 25px;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 12px 15px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--glass-border);
}

.table td {
    padding: 15px;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: rgba(124, 58, 237, 0.05);
}

.text-center {
    text-align: center;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-draft {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}

.badge-active {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.badge-closed {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Action Buttons */
.action-btns {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.action-btn:hover {
    background: var(--primary);
    color: white;
}

.action-btn.danger:hover {
    background: var(--danger);
}

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-info h4 {
    font-size: 0.95rem;
    margin-bottom: 5px;
}

.setting-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--primary);
    border-color: var(--primary);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(24px);
    background: white;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-large .modal-content {
    max-width: 900px;
}

.modal-small .modal-content {
    max-width: 450px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 25px;
    border-top: 1px solid var(--glass-border);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.checkbox-group {
    margin-top: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input {
    width: 18px;
    height: 18px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    background: var(--bg-secondary);
    padding: 5px;
    border-radius: 12px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
}

.tab-btn:hover:not(.active) {
    background: rgba(124, 58, 237, 0.1);
    color: var(--text-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.tab-header h4 {
    font-size: 1rem;
}

/* Positions List */
.positions-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.position-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--glass-border);
}

.position-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.position-header h4 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.position-header h4 i {
    color: var(--primary-light);
}

.position-meta {
    display: flex;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.candidates-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.candidate-card {
    background: var(--bg-color);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    border: 1px solid var(--glass-border);
    position: relative;
}

.candidate-photo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-secondary);
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.candidate-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.candidate-photo i {
    font-size: 2rem;
    color: var(--text-secondary);
}

.candidate-name {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 3px;
}

.candidate-party {
    font-size: 0.75rem;
    color: var(--primary-light);
}

.candidate-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 5px;
}

.candidate-actions button {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.7rem;
}

.candidate-actions button:hover {
    background: var(--primary);
    color: white;
}

/* Results */
.results-summary {
    display: flex;
    gap: 15px;
}

.result-position {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    border: 1px solid var(--glass-border);
}

.result-position h4 {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-position h4 i {
    color: var(--primary-light);
}

.result-candidate {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 10px;
    background: var(--bg-color);
}

.result-candidate.winner {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0.05) 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.result-rank {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
}

.result-candidate.winner .result-rank {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.result-info {
    flex: 1;
}

.result-info .name {
    font-weight: 500;
}

.result-info .party {
    font-size: 0.8rem;
    color: var(--primary-light);
}

.result-votes {
    text-align: right;
}

.result-votes .count {
    font-size: 1.2rem;
    font-weight: bold;
}

.result-votes .percent {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.result-bar {
    width: 100px;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.result-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.result-candidate.winner .result-bar-fill {
    background: linear-gradient(90deg, var(--success) 0%, #34d399 100%);
}

/* Signatories */
.signatories-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.signatory-item {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.signatory-item h5 {
    margin-bottom: 15px;
    color: var(--primary-light);
}

/* Photo Upload */
.photo-upload {
    text-align: center;
    margin-bottom: 20px;
}

.photo-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-secondary);
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px dashed var(--glass-border);
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview i {
    font-size: 3rem;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .signatories-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Candidates Editor */
.form-section-title h3 {
    font-size: 1rem;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.candidates-grid-editor {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.candidate-editor-row {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.candidate-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.candidate-remove-btn {
    color: var(--danger);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0.7;
    transition: 0.2s;
}

.candidate-remove-btn:hover {
    opacity: 1;
}

.candidate-photo-upload {
    display: flex;
    align-items: center;
    gap: 15px;
}

.upload-preview {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-color);
    border: 2px dashed var(--glass-border);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-preview i {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.upload-btn-mini {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: rgba(124, 58, 237, 0.1);
    color: var(--primary-light);
    border: 1px solid var(--primary-light);
    border-radius: 6px;
    cursor: pointer;
}

.upload-btn-mini:hover {
    background: var(--primary);
    color: white;
}

/* =========================================
   Responsive Design (Mobile View)
   ========================================= */
@media (max-width: 768px) {

    /* Main Layout */
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 10px 15px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        background: var(--primary);
        /* Solid bg for visibility */
    }

    .main-content {
        margin-left: 0;
        padding: 15px;
        margin-top: 0;
    }

    /* Sidebar Elements */
    .sidebar-header {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
        width: auto;
        padding-right: 10px;
    }

    .logo-icon {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    .logo-text {
        display: none;
        /* Simplify header */
    }

    .sidebar-nav {
        display: flex;
        flex: 0;
        gap: 10px;
        flex-direction: row;
    }

    .nav-item {
        padding: 8px;
        margin-bottom: 0;
        border-radius: 8px;
        justify-content: center;
        width: 40px;
        height: 40px;
    }

    .nav-item span {
        display: none;
        /* Icons only for nav items */
    }

    .nav-item.active {
        border-left: none;
        border-bottom: 3px solid var(--accent);
        background: rgba(255, 255, 255, 0.1);
    }

    .sidebar-footer {
        display: none;
        /* Hide footer in mobile top bar */
    }

    /* Login Screen */
    .login-box {
        padding: 30px 20px;
        width: 90%;
        margin: 0 20px;
    }

    .login-box::before {
        width: 200px;
        height: 200px;
    }

    /* Grids & Cards */
    .stats-grid,
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .card {
        margin-bottom: 15px;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        margin: 40px auto;
        /* More top margin to clear header if fixed, or just safe area */
        padding: 15px;
        max-height: 85vh;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Tables */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .card-body {
        overflow-x: auto;
        /* Allow tables inside cards to scroll */
    }

    .table {
        min-width: 600px;
        /* Ensure table doesn't squash */
    }

    /* Adjust Fonts */
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }
}

/* =========================================
   Live Results View
   ========================================= */
.live-results-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, #4a0404 100%);
    z-index: 99999;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.live-results-view.active {
    transform: translateY(0);
}

.live-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--accent);
    margin-bottom: 20px;
}

.live-conf-title {
    display: flex;
    align-items: center;
    gap: 20px;
}

.live-conf-title img {
    height: 60px;
    width: auto;
    background: white;
    border-radius: 50%;
    border: 2px solid var(--accent);
    padding: 2px;
}

.live-conf-title h1 {
    font-size: 2rem;
    color: white;
    margin: 0;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
}

.live-conf-title p {
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: 2px;
}

.btn-close-live {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close-live:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.live-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    overflow-y: auto;
    padding-right: 5px;
    padding-bottom: 20px;
}

@media (max-width: 480px) {
    .live-grid {
        grid-template-columns: 1fr;
    }

    .live-conf-title h1 {
        font-size: 1.2rem;
    }

    .live-conf-title p {
        font-size: 0.8rem;
    }

    .live-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        align-items: center;
    }

    .live-conf-title {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .btn-close-live {
        width: 100%;
        justify-content: center;
    }
}

/* Position Card in Live View */
.live-position-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    border: 1px solid #eee;
    height: fit-content;
}

.live-position-header {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
    display: flex;
    justify-content: space-between;
}

/* Horizontal Bar Graph Item */
.live-candidate-item {
    margin-bottom: 12px;
}

.live-candidate-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}

.live-votes-count {
    color: var(--primary);
    font-weight: 800;
}

.live-bar-bg {
    width: 100%;
    height: 12px;
    background: #f1f5f9;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.live-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, #fcd34d 100%);
    border-radius: 10px;
    width: 0%;
    transition: width 1.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
}

.live-bar-fill.leader {
    background: linear-gradient(90deg, var(--primary) 0%, #a93226 100%);
}

.live-updated-at {
    text-align: right;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    margin-top: 10px;
    font-style: italic;
}