/* --- Global Styles --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background: #2e1065;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    color: white;
}

/* --- Watermark --- */
.watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    opacity: 0.1;
    pointer-events: none;
    z-index: 1000;
    text-align: center;
}

.watermark p:first-child { font-size: 8rem; font-weight: 800; color: #fff; line-height: 1; }
.watermark p:last-child { font-size: 2rem; font-weight: bold; color: #fff; }

/* --- Overlays --- */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.98);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.overlay.active { display: flex; }

.overlay-content {
    background: #1e293b;
    padding: 30px 20px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    max-width: 500px;
    width: 90%;
    text-align: center;
    position: relative;
    max-height: 95vh;
    overflow-y: auto;
}

@media (max-width: 600px) {
    .overlay { padding: 15px; }
    .overlay-content { padding: 25px 15px; width: 95%; box-shadow: 0 10px 30px rgba(0,0,0,0.8); }
    .disclaimer-box h2 { font-size: 1.2rem; }
    .disclaimer-text { font-size: 0.85rem; }
}

/* --- Mobile Navigation Button --- */
.mobile-results-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(37, 99, 235, 0.9);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: bold;
    font-size: 0.9rem;
    z-index: 1000;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.close-results-btn {
    display: none;
    width: 100%;
    padding: 12px;
    background: rgba(239, 68, 68, 0.8);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    color: white;
    border: none;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: bold;
    cursor: pointer;
}

/* --- Small Floating Toggle Button --- */
.mobile-results-toggle {
    display: none;
    position: fixed;
    bottom: 15px;
    right: 15px;
    background: rgba(37, 99, 235, 0.95);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 10px 18px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 0.75rem;
    z-index: 1500;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    transition: transform 0.2s;
}
.mobile-results-toggle:active { transform: scale(0.95); }

.close-results-btn {
    display: none;
    width: 100%;
    padding: 10px;
    background: rgba(239, 68, 68, 0.85);
    backdrop-filter: blur(5px);
    color: white;
    border: none;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: bold;
    font-size: 0.8rem;
    cursor: pointer;
}

/* --- Mobile Stack with Slide-Up Overlay --- */
@media (max-width: 600px) {
    .split-layout { display: flex; flex-direction: column; overflow-y: auto; background: #2e1065; padding: 10px; gap: 10px; }
    .panel { width: 100% !important; height: auto !important; padding: 0 !important; }

    /* Machine Units - Highly Condensed */
    .tab-content { display: none !important; } 
    .tab-content.active { display: flex !important; flex-direction: column !important; align-items: center !important; gap: 8px !important; padding: 5px !important; }
    
    .vvpat-unit { 
        width: 100% !important; 
        height: auto !important; 
        max-width: 320px; 
        padding: 5px !important; 
        border-width: 3px !important;
        margin-bottom: 0 !important;
    }
    .vvpat-top { height: 32px !important; margin-bottom: 5px !important; }
    .vvpat-status-display { font-size: 0.85rem !important; }
    .vvpat-window { height: 110px !important; margin-top: 5px !important; border-width: 2px !important; }
    .vvpat-slip-container { transform: scale(0.6) translateX(-85%) !important; }
    .vvpat-bottom-panel { margin-top: 10px !important; gap: 40px !important; }
    .led { width: 22px !important; height: 16px !important; }

    .balloting-unit { 
        width: 100% !important; 
        max-width: 380px; 
        border-radius: 8px !important;
        border-width: 3px !important;
    }
    .bu-header { padding: 6px 12px !important; }
    .candidate-row { padding: 5px 8px !important; }
    .can-symbol-img { width: 28px !important; height: 28px !important; }
    .can-name-text { font-size: 0.75rem !important; }
    .blue-btn { width: 44px !important; height: 26px !important; }

    .evm-panel { padding-bottom: 80px !important; }

    /* Slide-up Results Overlay (Hidden by Default) */
    .results-panel { 
        position: fixed !important; 
        top: 100%; 
        left: 0; 
        width: 100vw !important; 
        height: 90vh !important; 
        background: rgba(15, 23, 42, 0.95) !important; 
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        backdrop-filter: blur(20px) saturate(180%);
        border-top: 1.5px solid rgba(255, 255, 255, 0.15);
        border-radius: 25px 25px 0 0;
        transition: top 0.5s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 2500;
        padding: 30px 20px !important;
        overflow-y: auto !important;
        display: block !important;
        box-shadow: 0 -20px 60px rgba(0,0,0,0.9);
    }

    .results-panel.open { top: 10vh; }
    
    .mobile-results-toggle { display: block !important; }
    .close-results-btn { display: block !important; position: sticky; top: -10px; z-index: 2600; }
}

/* Landscape Tablet Adjustments */
@media (min-width: 601px) and (max-width: 1100px) {
    .tab-content { gap: 10px; padding: 10px; }
    .vvpat-unit { width: 220px; height: 280px; }
    .balloting-unit { width: 360px; }
}



.rotate-icon { font-size: 4rem; margin-bottom: 20px; animation: rotate 2s linear infinite; }
@keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* --- Auth Box --- */
.auth-box { max-width: 400px; }
.auth-emblem { width: 80px; margin-bottom: 20px; filter: invert(1); }
.input-group { margin: 20px 0; }
.input-group input {
    width: 100%;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid #334155;
    background: #0f172a;
    color: white;
    font-size: 1.1rem;
    text-align: center;
}

.auth-footer { font-size: 0.7rem; color: #64748b; margin-top: 20px; text-transform: uppercase; }

/* --- Disclaimer Box --- */
.disclaimer-box { text-align: left; }
.disclaimer-box h2 { text-align: center; margin-bottom: 20px; color: #ef4444; }
.disclaimer-text { color: #94a3b8; font-size: 0.95rem; line-height: 1.6; margin-bottom: 25px; }
.disclaimer-text ul { margin: 15px 0; padding-left: 20px; }

/* --- Buttons --- */
.primary-btn {
    width: 100%;
    padding: 15px;
    border-radius: 10px;
    border: none;
    background: #2563eb;
    color: white;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.primary-btn:hover { background: #1d4ed8; transform: translateY(-2px); }
.primary-btn:active { transform: translateY(0); }

/* --- Main Layout --- */
.split-layout {
    display: flex;
    height: 100vh;
}

.hidden { display: none !important; }

.panel {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.evm-panel {
    background: #4c1d95;
    border-right: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
}

.panel-header {
    background: rgba(15, 23, 42, 0.3);
    padding: 15px;
    display: flex;
    justify-content: center;
}

/* --- Tab System --- */
.tab-navigation { display: flex; gap: 10px; }
.tab-btn { padding: 10px 20px; border-radius: 5px; border: none; cursor: pointer; font-weight: bold; background: rgba(255,255,255,0.1); color: #94a3b8; }
.tab-btn.active { background: white; color: #2563eb; }

.tab-content {
    display: none;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 30px;
    padding: 20px;
}

.tab-content.active { display: flex; }

/* --- VVPAT Unit --- */
.vvpat-unit {
    width: 250px;
    height: 320px;
    background: #e2e8f0;
    border: 5px solid #64748b;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    padding: 10px;
    position: relative;
}

.vvpat-top { height: 45px; background: #334155; border-radius: 5px; display: flex; justify-content: center; align-items: center; border: 2px solid #1e293b; }
.vvpat-status-display { color: #22c55e; font-family: monospace; font-size: 1rem; font-weight: bold; text-shadow: 0 0 5px rgba(34, 197, 94, 0.5); }
.vvpat-window { height: 160px; background: #020617; margin-top: 10px; border: 3px solid #1e293b; overflow: hidden; position: relative; }
.vvpat-slip-container {
    width: 170px;
    background: white;
    position: absolute;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 10px;
    border-radius: 2px;
    box-shadow: 0 0 15px rgba(0,0,0,0.7);
}
.vvpat-slip-container.visible { top: 15px; }

.vvpat-slip-header { font-size: 0.5rem; color: #1e293b; text-align: center; border-bottom: 1px solid #cbd5e1; padding-bottom: 5px; font-weight: bold; }
.vvpat-slip-content { display: flex; flex-direction: column; align-items: center; padding: 10px; }
.vvpat-slip-symbol { width: 45px; height: 45px; object-fit: contain; }
.vvpat-slip-name { color: #020617; font-weight: 800; font-size: 0.8rem; margin-top: 8px; }

.vvpat-bottom-panel { display: flex; gap: 20px; justify-content: center; margin-top: 15px; }
.led { width: 20px; height: 20px; border-radius: 50%; background: #020617; border: 2px solid #1e293b; transition: all 0.3s; }
.led.green.active { background: #22c55e; box-shadow: 0 0 10px #22c55e; }
.led.red.active { background: #ef4444; box-shadow: 0 0 10px #ef4444; }

/* --- Balloting Unit --- */
.balloting-unit {
    width: 420px;
    background: #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    border: 4px solid #475569;
}

.bu-header { background: #94a3b8; padding: 10px; display: flex; align-items: center; gap: 15px; border-bottom: 2px solid #475569; }
.bu-header span { font-weight: bold; font-size: 0.8rem; color: #1e293b; }

.candidate-row { display: flex; align-items: center; background: white; padding: 8px; border-bottom: 1px solid #e2e8f0; color: #1e293b; }
.can-index { width: 35px; text-align: center; font-weight: bold; border-right: 1px solid #e2e8f0; }
.can-name-symbol { flex: 1; display: flex; align-items: center; gap: 12px; padding-left: 15px; }
.can-symbol-img { width: 32px; height: 32px; object-fit: contain; }
.can-name-text { font-weight: 800; font-size: 0.85rem; }

.can-vote-area { display: flex; align-items: center; gap: 15px; padding-right: 10px; }
.vote-led { width: 14px; height: 14px; border-radius: 50%; background: #334155; }
.vote-led.active { background: #ef4444; box-shadow: 0 0 8px #ef4444; }
.blue-btn { width: 50px; height: 30px; border-radius: 15px; background: #2563eb; cursor: pointer; border: 1px solid #1d4ed8; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: all 0.1s; }
.blue-btn:active { transform: scale(0.9); background: #1d4ed8; }

/* --- Results Panel --- */
.results-panel { background: #1e1b4b; padding: 20px; display: flex; flex-direction: column; overflow: hidden; }
.results-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #2563eb; padding-bottom: 15px; margin-bottom: 15px; }
.header-main h2 { font-size: 1.3rem; font-weight: 900; }
.header-main p { font-size: 0.7rem; color: #64748b; font-weight: bold; letter-spacing: 1px; }

.total-count-box { background: #1e293b; padding: 10px 20px; border-radius: 12px; text-align: center; border: 1px solid #334155; }
.total-count-box .label { font-size: 0.65rem; display: block; color: #64748b; font-weight: 800; margin-bottom: 2px; }
.total-count-box .count { font-size: 1.5rem; font-weight: 900; color: #22c55e; }

.ranking-container { flex: 1; display: flex; flex-direction: column; min-height: 0; margin-bottom: 15px; }
.ranking-container h3 { font-size: 0.8rem; color: #64748b; margin-bottom: 8px; text-transform: uppercase; border-left: 3px solid #2563eb; padding-left: 8px; }

.ranking-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; scrollbar-width: none; }
.ranking-list::-webkit-scrollbar { display: none; }

.rank-item { display: flex; align-items: center; background: #1e293b; padding: 6px 12px; border-radius: 8px; border: 1px solid transparent; transition: all 0.2s; }
.rank-item:hover { transform: translateX(5px); border-color: #2563eb; }

.rank-num { width: 24px; height: 24px; background: #2563eb; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 0.65rem; font-weight: bold; margin-right: 12px; }
.rank-symbol { width: 22px; height: 22px; background: white; border-radius: 4px; padding: 2px; margin-right: 12px; }
.rank-info { flex: 1; }
.rank-name { font-weight: 800; font-size: 0.8rem; }
.rank-sub { font-size: 0.6rem; color: #64748b; font-weight: bold; }
.rank-perc { font-size: 0.95rem; font-weight: 900; color: #22c55e; }

.results-audit h3 { font-size: 0.8rem; color: #64748b; margin-bottom: 8px; text-transform: uppercase; border-left: 3px solid #ef4444; padding-left: 8px; }
.audit-log { background: #020617; padding: 10px; border-radius: 8px; height: 100px; overflow-y: auto; font-size: 0.65rem; border: 1px solid #1e293b; scrollbar-width: thin; scrollbar-color: #1e293b #020617; }
.audit-entry { padding: 4px 0; border-bottom: 1px solid #1e293b; line-height: 1.4; color: #94a3b8; }
.audit-entry .tamper { color: #ef4444; font-weight: bold; }

.admin-link { text-align: center; margin-top: 10px; }
.admin-link a { color: #64748b; text-decoration: none; font-size: 0.7rem; font-weight: bold; text-transform: uppercase; padding: 5px 15px; border: 1px solid #334155; border-radius: 20px; transition: all 0.2s; }
.admin-link a:hover { color: white; border-color: white; background: #334155; }

.malfunction-warning {
    position: fixed; bottom: 20px; left: 20px; 
    background: rgba(239, 68, 68, 0.2); border: 1px solid #ef4444; border-radius: 5px;
    padding: 8px 15px; font-size: 0.7rem; color: #fecaca; font-weight: bold;
    display: none; z-index: 500;
}
.mal-active #mal-warning { display: block; }
