/* ==========================================================
   MVM Simulator — Shared Stylesheet
   ========================================================== */

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

:root {
    --evm-blue:    #2980a8;   /* brighter teal-blue from real EVM photo */
    --evm-blue-d:  #134761;
    --evm-cream:   #efe7d2;
    --evm-cream-2: #f5efe4;
    --evm-shell:   #f8f3e8;
    --evm-text:    #1a1a1a;
    --evm-led-bg:  #2b0606;
    --evm-led:     #ff2222;
    --evm-shadow:  0 6px 18px rgba(0,0,0,.18);
    --evm-border:  #b8a98c;
    --busy:        #2bdc4a;
    --bal-red:     #6f1818;
}

html, body {
    background: linear-gradient(135deg,#e7eaf0,#cfd5df);
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    color: var(--evm-text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--evm-blue); }

/* ============== SETUP PAGE ============== */
.setup-wrap {
    max-width: 920px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}
.setup-wrap h1 {
    font-size: 1.7rem;
    color: var(--evm-blue-d);
    margin-bottom: 6px;
    text-align: center;
}
.setup-wrap .sub {
    text-align: center;
    color: #555;
    margin-bottom: 24px;
    font-size: .95rem;
}
.card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--evm-shadow);
    margin-bottom: 18px;
}
.row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.candidate-row {
    display: grid;
    grid-template-columns: 36px 1fr 90px 90px;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed #ddd;
}
.candidate-row .num {
    font-weight: 700;
    color: var(--evm-blue);
    text-align: center;
}
.candidate-row input[type=text] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cfd1d5;
    border-radius: 8px;
    font-size: 1rem;
}
.candidate-row .symbol-pick {
    height: 50px;
    border: 1px solid #cfd1d5;
    border-radius: 8px;
    background: var(--evm-cream-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--evm-blue-d);
}
.candidate-row .symbol-pick svg,
.candidate-row .symbol-pick img { width: 36px; height: 36px; object-fit: contain; }
.candidate-row .symbol-pick.empty { color: #aaa; font-size: .8rem; }
.candidate-row button.del {
    background: #f4dada;
    color: #8b1a1a;
    border: none;
    padding: 9px 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}
button.primary {
    background: var(--evm-blue);
    color: #fff;
    border: none;
    padding: 12px 22px;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 3px 8px rgba(0,67,101,.3);
}
button.primary:hover { background: var(--evm-blue-d); }
button.ghost {
    background: #fff;
    border: 1.5px solid var(--evm-blue);
    color: var(--evm-blue);
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

/* Mode tabs (Normal / Manipulate) */
.mode-tabs {
    display: flex;
    gap: 4px;
    background: #fff;
    padding: 4px;
    border-radius: 12px;
    box-shadow: var(--evm-shadow);
    margin-bottom: 14px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}
.mode-tab {
    flex: 1;
    padding: 10px 14px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
    border-radius: 8px;
    font-size: .95rem;
    color: #555;
    transition: background .15s, color .15s;
}
.mode-tab.active {
    background: var(--evm-blue);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,67,101,.3);
}
.mode-tab:not(.active):hover { background: #f5efe4; }

/* Manipulation pattern picker */
.manipulate-panel {
    background: #fff5e8 !important;
    border: 1.5px solid #f0c890 !important;
}
.manipulate-panel h3 { color: #a23 !important; }
.pattern-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    max-height: 360px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid #e8d8b8;
    border-radius: 10px;
    background: #fff;
}
.pattern-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    background: #fff;
}
.pattern-item:hover { border-color: var(--evm-blue); background: #f8fbff; }
.pattern-item.selected {
    border-color: #d97600;
    background: #fff8e8;
    box-shadow: 0 0 0 2px rgba(217,118,0,.15);
}
.pattern-item input[type=radio] { margin-top: 4px; flex-shrink: 0; }
.pattern-meta { flex: 1; }
.pattern-title {
    font-weight: 700;
    color: #1a1a1a;
    font-size: .92rem;
    margin-bottom: 4px;
}
.pattern-num {
    display: inline-block;
    background: #1f6f95;
    color: #fff;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: .75rem;
    margin-right: 6px;
}
.pattern-tag {
    font-size: .68rem;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    font-weight: 600;
    vertical-align: middle;
}
.pattern-tag.tag-voter { background: #e8f5e8; color: #2a7d2a; }
.pattern-tag.tag-agent { background: #fde8e8; color: #a23; }
.pattern-desc {
    font-size: .82rem;
    color: #555;
    line-height: 1.4;
}

/* Slot count setting */
.slot-setting {
    margin-top: 18px;
    padding: 14px 16px;
    background: var(--evm-cream-2);
    border: 1px solid #e0d8c5;
    border-radius: 10px;
}
.slot-setting label {
    display: block;
    margin-bottom: 8px;
    color: #333;
}
.slot-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.slot-input-row input[type=number] {
    width: 90px;
    padding: 9px 12px;
    border: 1px solid #cfd1d5;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
}
.slot-input-row .slot-hint {
    color: #666;
    font-size: .85rem;
}

/* Symbol picker modal */
.modal-bg {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 16px;
}
.modal-bg.show { display: flex; }
.modal-bg .modal {
    background: #fff;
    border-radius: 14px;
    max-width: 720px;
    width: 100%;
    max-height: 86vh;
    overflow-y: auto;
    padding: 20px;
}
.modal h3 {
    margin-bottom: 12px;
    color: var(--evm-blue-d);
}
.symbol-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px,1fr));
    gap: 10px;
}
.symbol-cell {
    border: 1.5px solid #cfd1d5;
    border-radius: 10px;
    padding: 10px 6px;
    cursor: pointer;
    text-align: center;
    color: var(--evm-blue-d);
    background: var(--evm-cream-2);
    transition: transform .12s, border-color .12s;
}
.symbol-cell:hover {
    border-color: var(--evm-blue);
    transform: translateY(-2px);
}
.symbol-cell svg,
.symbol-cell img { width: 56px; height: 56px; object-fit: contain; }
.symbol-cell .lbl {
    font-size: .75rem;
    color: #333;
    margin-top: 4px;
    line-height: 1.1;
}

/* Generated links */
.unit-link {
    background: var(--evm-cream);
    border: 1px solid var(--evm-border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 14px;
}
.unit-link h4 { color: var(--evm-blue-d); margin-bottom: 6px; }
.unit-link .url-box {
    display: flex; gap: 8px; align-items: center;
    margin-top: 8px;
}
.unit-link input.url {
    flex: 1;
    padding: 8px;
    border: 1px solid #cfd1d5;
    border-radius: 6px;
    font-family: monospace;
    font-size: .85rem;
    background: #fff;
}
.qr-row { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.qr-box {
    background: #fff;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 8px;
}
.qr-box canvas, .qr-box img { display:block; }

/* ============== CONTROL UNIT (photo-accurate replica) ============== */
.evm-stage {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 16px 10px 40px;
    gap: 14px;
}

/* The body of the EVM — pure white/cream, soft rounded corners like in photo */
.cu-real {
    width: 100%;
    max-width: 360px;
    background: #f8f3e8;
    border-radius: 26px;
    border: 1px solid #d8cfb8;
    box-shadow:
        0 22px 44px -10px rgba(0,0,0,.28),
        0 6px 14px rgba(0,0,0,.12),
        0 2px 0 rgba(255,255,255,.7),
        inset 0 1px 0 rgba(255,255,255,.95),
        inset 0 -2px 6px rgba(0,0,0,.08),
        inset 0 0 0 1px rgba(255,255,255,.6);
    overflow: hidden;
    position: relative;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

/* ----- TOP cream area: brand row + LED ----- */
.cu-top-cream {
    background: #f8f3e8;
    padding: 16px 18px 22px;
}
.cu-brand-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}
.cu-brand-text {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    font-size: .82rem;
    font-weight: 700;
    color: #1a1a1a;
}
.cu-brand-logo {
    color: #1a1a1a;
    font-size: .9rem;
    margin-top: 2px;
    transform: rotate(-90deg);
    display: inline-block;
}
.cu-brand-line { line-height: 1.1; }
.cu-model {
    font-weight: 800;
    font-size: 1rem;
    color: #111;
    border: 1.8px solid #2c2c2c;
    padding: 1px 8px 2px;
    border-radius: 4px;
    letter-spacing: 1px;
    background: #f8f3e8;
}

/* "Control Unit" title under brand row */
.cu-cu-title {
    font-size: .92rem;
    font-weight: 800;
    color: #134761;
    letter-spacing: .3px;
    margin: 4px 0 8px;
}

/* LED row with green On + red Busy LEDs flanking the display */
.cu-led-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.cu-led-labels {
    display: flex;
    justify-content: space-between;
    padding: 4px 4px 0;
    font-size: .68rem;
    font-weight: 600;
    color: #444;
    letter-spacing: .5px;
}
.cu-status-led {
    width: 11px; height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: inset 0 1px 1px rgba(0,0,0,.4);
}
.cu-status-led.on {
    background: #2bdc4a;
    box-shadow: 0 0 8px rgba(43,220,74,.7), inset 0 0 2px rgba(255,255,255,.5);
}
.cu-status-led.busy {
    background: #5a0d0d;
}
.cu-status-led.busy.active {
    background: #ff2828;
    box-shadow: 0 0 8px rgba(255,40,40,.85), inset 0 0 2px rgba(255,200,200,.5);
}
.cu-ind-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #1a1a1a;
    box-shadow: inset 0 1px 1px rgba(255,255,255,.3);
    flex-shrink: 0;
}
.cu-led-frame {
    flex: 1;
    background: #050505;
    border-radius: 4px;
    padding: 8px 12px;
    box-shadow:
        inset 0 4px 8px rgba(0,0,0,1),
        inset 0 -2px 4px rgba(0,0,0,.8),
        inset 1px 0 2px rgba(0,0,0,.6),
        inset -1px 0 2px rgba(0,0,0,.6),
        0 1px 0 rgba(255,255,255,.5);
    border: 1px solid #1a1a1a;
    text-align: center;
}
.cu-led-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    height: 42px;
    transition: opacity .25s;
}
.cu-led-display.blink { opacity: .25; }

/* SVG 7-segment digit */
.seg-digit {
    width: auto;
    height: 100%;
    display: block;
}
.seg-digit .seg {
    fill: rgba(0,255,40,.10);
    transition: fill .08s;
}
.seg-digit .seg.on {
    fill: #00ff2a;
    filter: drop-shadow(0 0 2px rgba(0,255,42,.85)) drop-shadow(0 0 4px rgba(0,255,42,.5));
}

/* ----- BLUE BANDS ----- */
.cu-band-thick {
    background: #2980a8;
    height: 70px;
    box-shadow:
        inset 0 4px 8px rgba(0,0,0,.28),
        inset 0 -3px 6px rgba(0,0,0,.20),
        inset 0 1px 0 rgba(255,255,255,.14);
}

/* Cream ECI strip */
.cu-cream { background: #f8f3e8; }
.cu-eci-strip {
    padding: 14px 16px;
    text-align: center;
}
.cu-eci {
    font-weight: 900;
    font-size: 1.08rem;
    color: #1a1a1a;
    letter-spacing: .2px;
}

/* ============== SLIDING DOOR COMPARTMENT (fixed height) ============== */
.cu-cover-area {
    position: relative;
    height: 158px;
    background: #efe7d2;
    overflow: hidden;
    border-top: 1px solid #b8a98c;
    border-bottom: 1px solid #b8a98c;
}
.cu-cover-inside {
    position: absolute;
    inset: 0;
    padding: 14px 18px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 1;
    transition: padding .3s ease;
}
/* When door is open, reserve space on the right for the door tab so the
   visible buttons appear centered in the LEFT portion of the compartment. */
.cu-cover-area.door-open .cu-cover-inside {
    padding-right: 60px;
}

/* The blue door panel that slides */
.cu-door {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(180deg, #2c87b3 0%, #1f6f95 50%, #1a5f80 100%);
    z-index: 2;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    box-shadow:
        inset 0 4px 10px rgba(0,0,0,.32),
        inset 0 -3px 6px rgba(0,0,0,.22),
        inset -4px 0 8px rgba(0,0,0,.22),
        inset 4px 0 8px rgba(0,0,0,.18),
        inset 0 1px 0 rgba(255,255,255,.18),
        0 -2px 4px rgba(0,0,0,.10);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .3s cubic-bezier(.4,1.4,.5,1);
}
.cu-door:active { cursor: grabbing; }

/* Wood-like vertical grain stripes (subtle) */
.cu-door::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(90deg,
            rgba(255,255,255,0) 0px,
            rgba(255,255,255,0) 16px,
            rgba(255,255,255,.05) 16px,
            rgba(255,255,255,.05) 17px);
    pointer-events: none;
}

/* Vertical chrome handle on LEFT of door — visible at right edge when door slid open */
.cu-door-handle {
    position: absolute;
    left: 14px;
    top: 22%;
    bottom: 22%;
    width: 8px;
    border-radius: 4px;
    background:
        linear-gradient(90deg,
            #6e6e6e 0%,
            #d8d2c3 30%,
            #ffffff 50%,
            #d8d2c3 70%,
            #6e6e6e 100%);
    box-shadow:
        0 0 4px rgba(0,0,0,.5),
        inset 0 1px 1px rgba(255,255,255,.6);
    z-index: 3;
}

/* "SLIDE ➜" hint text — visible only when door is closed */
.cu-door-text {
    color: rgba(248,243,232,.75);
    font-weight: 800;
    font-size: .9rem;
    letter-spacing: 4px;
    margin-left: 28px;
    transition: opacity .2s;
    pointer-events: none;
}
.cu-door.open .cu-door-text { opacity: 0; }

/* Real button look — chunky rounded rectangle, blue, white text */
.cu-real-btn {
    background: linear-gradient(180deg, #2c87b3 0%, #1f6f95 60%, #1a5f80 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
    box-shadow:
        0 4px 0 #134761,
        0 6px 14px rgba(0,0,0,.32),
        0 8px 18px -4px rgba(0,0,0,.22),
        inset 0 2px 1.5px rgba(255,255,255,.45),
        inset 0 -2px 3px rgba(0,0,0,.22),
        inset 1px 0 1px rgba(255,255,255,.15),
        inset -1px 0 1px rgba(0,0,0,.18);
    letter-spacing: .3px;
    transition: transform .08s, box-shadow .08s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.cu-real-btn:active {
    transform: translateY(3px);
    box-shadow:
        0 1px 0 #134761,
        0 2px 4px rgba(0,0,0,.32),
        inset 0 1px 1px rgba(255,255,255,.18),
        inset 0 -1px 2px rgba(0,0,0,.18);
}
.cu-real-btn:disabled { opacity: .45; cursor: not-allowed; }

.cu-cs-btn {
    padding: 12px 18px;
    font-size: .9rem;
    border-radius: 12px;
}
.cu-cs-slot {
    width: 6px;
    height: 18px;
    background: #f8f3e8;
    border-radius: 1px;
    margin-left: 6px;
    box-shadow: inset 0 0 2px rgba(0,0,0,.4);
}

/* Bottom bar with Total + dots + Ballot — ALWAYS VISIBLE like real EVM */
.cu-bottom-bar {
    background: #f8f3e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 22px 26px;
    border-top: 1px solid #d8cfb8;
    box-shadow:
        inset 0 2px 3px rgba(255,255,255,.6),
        inset 0 -2px 5px rgba(0,0,0,.06);
}
.cu-total-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    padding: 0;
    font-size: .85rem;
    font-weight: 800;
    letter-spacing: .5px;
    background:
        radial-gradient(circle at 35% 28%, rgba(255,255,255,.45) 0%, rgba(255,255,255,0) 45%),
        linear-gradient(180deg, #3289b0 0%, #1f6f95 55%, #1a5f80 100%);
}
.cu-ballot-btn {
    padding: 14px 28px;
    border-radius: 14px;
    font-size: .95rem;
    font-weight: 800;
    letter-spacing: 1px;
    background:
        radial-gradient(ellipse at 50% 18%, rgba(255,255,255,.5) 0%, rgba(255,255,255,0) 55%),
        linear-gradient(180deg, #3289b0 0%, #1f6f95 55%, #1a5f80 100%);
}
.cu-dots {
    display: grid;
    grid-template-columns: 8px 8px;
    grid-template-rows: 8px 8px;
    gap: 6px;
}
.cu-dot {
    width: 6px;
    height: 6px;
    background: #cfc8b9;
    border-radius: 50%;
    box-shadow: inset 0 1px 1px rgba(0,0,0,.3);
    transition: background .25s, box-shadow .25s;
}
.cu-dot.on-green { background: #2bdc4a; box-shadow: 0 0 6px #2bdc4a, inset 0 0 2px #ffffff80; }
.cu-dot.on-red   { background: #e02020; box-shadow: 0 0 6px #e02020, inset 0 0 2px #ffffff80; }
.cu-dot.on-amber { background: #f0a020; box-shadow: 0 0 6px #f0a020, inset 0 0 2px #ffffff80; }

/* (Compartment label inside the sliding-door area) */
.cu-cover-label {
    font-size: .68rem;
    font-weight: 700;
    color: #6a5f3f;
    letter-spacing: 1.2px;
    text-align: center;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #d1c5a3;
}
.cu-secret-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    justify-items: center;
    padding: 4px 4px 0;
}
.cu-secret-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    padding: 0;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .3px;
    color: #1a1a1a;
    background:
        radial-gradient(circle at 35% 28%, rgba(255,255,255,.95) 0%, rgba(255,255,255,.0) 38%),
        linear-gradient(180deg, #ffffff 0%, #f0eee5 60%, #cdc7b4 100%);
    border: 1px solid #b6ac90;
    box-shadow:
        0 4px 0 rgba(0,0,0,.22),
        0 6px 14px rgba(0,0,0,.28),
        0 8px 20px -4px rgba(0,0,0,.18),
        inset 0 2px 1.5px rgba(255,255,255,.95),
        inset 0 -3px 4px rgba(0,0,0,.14),
        inset 0 0 0 1px rgba(255,255,255,.5);
    transition: transform .08s, box-shadow .08s;
}
.cu-secret-btn:active {
    transform: translateY(3px);
    box-shadow:
        0 1px 0 rgba(0,0,0,.2),
        0 2px 4px rgba(0,0,0,.25),
        inset 0 1px 2px rgba(0,0,0,.14),
        inset 0 0 0 1px rgba(255,255,255,.4);
}
.cu-secret-btn.cu-result-btn {
    background:
        radial-gradient(circle at 35% 28%, rgba(255,255,255,.85) 0%, rgba(255,255,255,.0) 40%),
        linear-gradient(180deg, #ffd84a 0%, #f5b918 55%, #c4900d 100%);
    color: #1a1a1a;
    border: 1px solid #a07410;
    box-shadow:
        0 4px 0 #6e5108,
        0 6px 14px rgba(0,0,0,.32),
        0 8px 20px -4px rgba(0,0,0,.20),
        inset 0 2px 1.5px rgba(255,255,255,.65),
        inset 0 -3px 4px rgba(0,0,0,.18),
        inset 0 0 0 1px rgba(255,235,170,.5);
}
.cu-secret-btn.cu-result-btn:active {
    transform: translateY(3px);
    box-shadow:
        0 1px 0 #6e5108,
        0 2px 4px rgba(0,0,0,.32),
        inset 0 1px 2px rgba(0,0,0,.22),
        inset 0 0 0 1px rgba(255,235,170,.4);
}
.cu-secret-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ============== AUX panel (status + results below) ============== */
.cu-aux {
    width: 100%;
    max-width: 360px;
}
.cu-status {
    text-align: center;
    padding: 11px 12px;
    background: #fff;
    border-radius: 10px;
    font-weight: 600;
    border: 1px solid #d8d2c3;
    margin-bottom: 10px;
    font-size: .9rem;
}
.cu-status.ready  { color: #1f7e1f; background: #e8f7e8; border-color: #b8e0b8; }
.cu-status.idle   { color: #555; }
.cu-status.closed { color: #8b1a1a; background: #fae8e8; border-color: #e0b8b8; }

.cu-results {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    border: 1px solid #d8d2c3;
    display: none;
    margin-bottom: 10px;
}
.cu-results.show { display: block; }
.cu-results h3 { color: #134761; margin-bottom: 10px; font-size: 1rem; }
.cu-results ol { padding-left: 0; list-style: none; }
.cu-results li {
    display: grid;
    grid-template-columns: 24px 36px 1fr 50px;
    gap: 8px;
    align-items: center;
    padding: 6px 2px;
    border-bottom: 1px solid #eee;
    font-size: .9rem;
}
.cu-results li svg,
.cu-results li img { width: 28px; height: 28px; object-fit: contain; color: #1f6f95; }
.cu-results .vc {
    text-align: right;
    font-weight: 800;
    color: #134761;
    font-family: "Courier New", monospace;
}
.cu-results .winner {
    background: #fff8d8;
    border-left: 4px solid #d4a900;
    padding-left: 4px;
    border-radius: 4px;
}
.cu-totals {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 2px solid #ccc;
    text-align: right;
    font-weight: 700;
    color: #134761;
    font-size: .9rem;
}
.cu-eid {
    text-align: center;
    font-size: .72rem;
    color: #888;
    padding: 4px;
}

/* ============== BALLOT UNIT (photo-accurate replica) ============== */
.bu-shell {
    width: 100%;
    max-width: 380px;
    background: #ece6d3;          /* cream body, matches photo */
    border-radius: 16px;
    border: 1px solid #b8a98c;
    padding: 0;
    box-shadow:
        0 22px 44px -10px rgba(0,0,0,.28),
        0 6px 14px rgba(0,0,0,.12),
        0 2px 0 rgba(255,255,255,.7),
        inset 0 1px 0 rgba(255,255,255,.95),
        inset 0 -2px 6px rgba(0,0,0,.08),
        inset 0 0 0 1px rgba(255,255,255,.5);
    overflow: hidden;
}
.bu-top {
    background: #ece6d3;
    display: grid;
    grid-template-columns: 1fr 1fr 90px;
    align-items: center;
    padding: 10px 12px;
    font-size: .75rem;
    color: #1a1a1a;
    font-weight: 600;
    border-bottom: 1px solid #b8a98c;
}
.bu-top > div { display: flex; align-items: center; gap: 4px; }
.bu-led {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #b8b8b8;
    box-shadow: inset 0 1px 1px rgba(0,0,0,.3);
    display: inline-block;
}
.bu-led.green-on  { background: #2bdc4a; box-shadow: 0 0 6px #2bdc4a, inset 0 0 2px #ffffff80; }
.bu-led.red-on    { background: #d92020; box-shadow: 0 0 6px #d92020, inset 0 0 2px #ffffff80; }
.bu-ind-icon {
    width: 14px; height: 8px;
    border: 1px solid #555;
    border-radius: 1px;
    background: #ece6d3;
    display: inline-block;
    margin-left: 4px;
}

.bu-clear-tab {
    background: linear-gradient(180deg, #2c87b3, #1f6f95);
    color: #fff;
    padding: 5px 14px 5px 22px;
    font-size: .75rem;
    font-weight: 700;
    border-radius: 4px;
    position: relative;
    text-align: center;
    letter-spacing: 1px;
    box-shadow: 0 2px 0 #134761;
    justify-self: end;
}
.bu-clear-tab::before {
    content: "";
    position: absolute;
    left: 7px; top: 50%;
    width: 0; height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #fff;
    transform: translateY(-50%);
}

/* List of 16 candidate slots */
.bu-list {
    background: #ffffff;
}
.bu-row {
    display: grid;
    grid-template-columns: 1fr 50px 22px 60px;
    align-items: stretch;
    border-bottom: 1px solid #b8a98c;
    min-height: 46px;
    background: #ece6d3;   /* cream shows through in button column */
}
.bu-row:last-child { border-bottom: none; }

/* Candidate name strip — looks like the paper slip in real EVM */
.bu-row .nm {
    padding: 8px 12px;
    font-weight: 700;
    font-size: .95rem;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    background: #fff;
    border-right: 1px solid #b8a98c;
}

/* Symbol cell — cream background per photo */
.bu-row .sym {
    background: #f5efe1;
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a;
    border-right: 1px solid #b8a98c;
}
.bu-row .sym svg,
.bu-row .sym img { width: 36px; height: 36px; object-fit: contain; }

/* LED column — cream background, dark red dot */
.bu-row .led {
    background: #ece6d3;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bu-row .led .dot {
    width: 11px; height: 11px;
    border-radius: 50%;
    background: #5a0d0d;
    box-shadow:
        inset 0 1px 1.5px rgba(0,0,0,.6),
        inset 0 -1px 1px rgba(255,80,80,.15);
}
.bu-row .led .dot.glow {
    background: #ff2828;
    box-shadow:
        0 0 8px rgba(255,40,40,.85),
        inset 0 0 3px rgba(255,200,200,.6);
}
.bu-row .led .dot.confirmed {
    background: #ff2828;
    box-shadow:
        0 0 14px rgba(255,40,40,1),
        0 0 22px rgba(255,40,40,.6),
        inset 0 0 4px #ffe5e5;
    animation: confirmPulse 1.8s ease-out;
}
@keyframes confirmPulse {
    0%, 60% { transform: scale(1.3); }
    100%    { transform: scale(1); }
}

/* Button column — vote button is an oval pill on cream backdrop.
   The 4th grid cell of bu-row inherits the row's cream background. */
.bu-row > .vbtn {
    align-self: center;
    justify-self: center;
    width: 46px;
    height: 28px;
    background:
        radial-gradient(ellipse at 50% 18%, rgba(255,255,255,.55) 0%, rgba(255,255,255,0) 55%),
        linear-gradient(180deg, #3289b0 0%, #1f6f95 55%, #1a5f80 100%);
    border: none;
    cursor: pointer;
    border-radius: 14px;
    box-shadow:
        0 3px 0 #0d3d57,
        0 5px 10px rgba(0,0,0,.32),
        0 7px 14px -3px rgba(0,0,0,.22),
        inset 0 2px 1.5px rgba(255,255,255,.5),
        inset 0 -3px 4px rgba(0,0,0,.25),
        inset 1px 0 1px rgba(255,255,255,.15),
        inset -1px 0 1px rgba(0,0,0,.18);
    transition: transform .08s, box-shadow .08s;
    -webkit-tap-highlight-color: transparent;
}
.bu-row > .vbtn:active {
    transform: translateY(2px);
    box-shadow:
        0 1px 0 #0d3d57,
        0 2px 3px rgba(0,0,0,.32),
        inset 0 1px 2px rgba(0,0,0,.22),
        inset 0 -1px 2px rgba(0,0,0,.18);
}
.bu-row > .vbtn:disabled {
    cursor: not-allowed;
    opacity: .45;
    filter: saturate(.55);
}

.bu-row.empty .nm  { background: #fff; }
.bu-row.empty .sym { background: #f5efe1; }
.bu-row.empty .led .dot { opacity: .55; }
.bu-row.empty > .vbtn { opacity: .35; pointer-events: none; }

.bu-foot {
    background: #ece6d3;
    text-align: center;
    padding: 12px 10px;
    font-weight: 700;
    color: #1a1a1a;
    font-size: .92rem;
    border-top: 1px solid #b8a98c;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.85);
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    z-index: 99;
    opacity: 0;
    transition: opacity .25s;
    font-weight: 600;
    pointer-events: none;
}
.toast.show { opacity: 1; }

.flash-vote {
    animation: flashv .8s;
}
@keyframes flashv {
    0%   { background: #fff8d8; }
    100% { background: #fff; }
}

@media (max-width: 380px) {
    .candidate-row { grid-template-columns: 28px 1fr 70px 70px; }
    .bu-row { grid-template-columns: 1fr 48px 20px 48px; }
}
