:root {
    --bg: #f7fbfd;
    --surface: #ffffff;
    --surface-blue: #eefaff;
    --line: #d8e7ee;
    --blue: #134266;
    --cyan: #22b8d6;
    --teal: #51c3c8;
    --green: #0c9155;
    --green-light: #7bd341;
    --orange: #f3921f;
    --text: #133150;
    --muted: #647789;
    --danger: #c93636;
    --shadow: 0 20px 60px rgba(19, 66, 102, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        linear-gradient(90deg, rgba(34, 184, 214, 0.12) 1px, transparent 1px),
        linear-gradient(180deg, rgba(34, 184, 214, 0.10) 1px, transparent 1px),
        var(--bg);
    background-size: 42px 42px;
}

button,
input {
    font: inherit;
}

button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: 0 18px;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.52;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 244px;
    padding: 24px 18px;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 10px 0 40px rgba(19, 66, 102, 0.08);
}

.sidebar-brand {
    display: block;
    padding: 8px;
    border-radius: 8px;
    background: white;
}

#logo {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    min-height: 46px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0 14px;
    color: var(--blue);
    font-weight: 800;
    text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
    border-color: rgba(34, 184, 214, 0.38);
    background: var(--surface-blue);
}

.nav-link.active {
    color: var(--green);
}

.status-pill {
    margin-top: auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 9px 12px;
    color: var(--muted);
    background: white;
    text-align: center;
    white-space: nowrap;
}

.status-pill[data-state="online"] {
    color: var(--green);
    border-color: rgba(12, 145, 85, 0.34);
}

.status-pill[data-state="offline"] {
    color: var(--danger);
    border-color: rgba(201, 54, 54, 0.34);
}

.app-shell {
    min-height: 100vh;
    margin-left: 244px;
    padding: 34px clamp(22px, 4vw, 52px);
}

.app-header {
    max-width: 1180px;
    margin: 0 auto 24px;
}

.eyebrow,
.section-label {
    margin: 0 0 6px;
    color: var(--orange);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    color: var(--blue);
    line-height: 1;
}

h1 {
    font-size: clamp(34px, 5vw, 64px);
}

h2 {
    font-size: clamp(28px, 3vw, 44px);
}

.subtitle {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: clamp(17px, 2vw, 22px);
}

main {
    max-width: 1180px;
    margin: 0 auto;
}

.page {
    display: none;
}

.active-page {
    display: block;
}

.draw-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.primary-action {
    min-width: 220px;
    min-height: 58px;
    color: #06221b;
    background: linear-gradient(135deg, var(--green-light), #c4f36d);
    font-size: 18px;
    font-weight: 950;
    box-shadow: 0 14px 30px rgba(123, 211, 65, 0.28);
}

.meta-line {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px 18px;
    color: var(--muted);
    font-weight: 700;
}

#stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: min(64vh, 620px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 64px 32px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.96)),
        url("/evento.jpeg") center / cover;
    box-shadow: var(--shadow);
}

#stage::before,
#stage::after,
.circuit-line {
    content: "";
    position: absolute;
    border: 3px solid var(--cyan);
    opacity: 0.45;
    pointer-events: none;
}

#stage::before {
    width: 280px;
    height: 170px;
    top: 42px;
    right: -80px;
    border-left: 0;
    border-radius: 0 8px 8px 0;
}

#stage::after {
    width: 220px;
    height: 150px;
    bottom: 34px;
    left: -62px;
    border-right: 0;
    border-radius: 8px 0 0 8px;
}

.circuit-line {
    width: 18px;
    height: 18px;
    top: 58px;
    left: 70px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow:
        98px 20px 0 -3px var(--blue),
        168px 20px 0 -3px white,
        236px 20px 0 -3px var(--cyan),
        304px 20px 0 -3px var(--orange);
}

#countdown {
    position: absolute;
    inset: 50%;
    width: 190px;
    height: 190px;
    margin: -95px 0 0 -95px;
    color: rgba(34, 184, 214, 0.18);
    font-size: 166px;
    font-weight: 950;
    line-height: 190px;
    text-align: center;
    transition: opacity 220ms ease;
    pointer-events: none;
}

#winner-card {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    text-align: center;
}

.result {
    max-width: 100%;
    opacity: 0;
    overflow-wrap: anywhere;
    transition: opacity 320ms ease, transform 320ms ease;
}

.large {
    color: var(--blue);
    font-size: clamp(58px, 11vw, 138px);
    font-weight: 950;
    line-height: 0.95;
}

.medium {
    margin-top: 10px;
    color: var(--green);
    font-size: clamp(32px, 5vw, 72px);
    font-weight: 850;
    line-height: 1;
}

.small {
    margin-top: 22px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 18px;
    color: var(--blue);
    background: white;
    font-size: clamp(18px, 2vw, 28px);
    box-shadow: 0 10px 30px rgba(19, 66, 102, 0.10);
}

.monospace {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.config-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
    gap: 18px;
    margin-bottom: 18px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: clamp(22px, 3vw, 34px);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
}

.upload-form {
    display: grid;
    gap: 12px;
    max-width: 560px;
    margin-top: 26px;
}

.file-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 58px;
    border: 2px dashed rgba(34, 184, 214, 0.48);
    border-radius: 8px;
    padding: 0 16px;
    color: var(--blue);
    background: var(--surface-blue);
    font-weight: 800;
    cursor: pointer;
}

.file-picker input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
    pointer-events: none;
}

.secondary-action {
    min-height: 54px;
    color: white;
    background: var(--blue);
    font-weight: 850;
}

.danger-action {
    width: 100%;
    min-height: 50px;
    margin-top: 22px;
    color: white;
    background: var(--danger);
    font-weight: 900;
}

.compact-panel {
    align-self: start;
}

.status-list {
    display: grid;
    gap: 16px;
    margin: 24px 0 0;
}

.status-list div {
    border-top: 1px solid var(--line);
    padding-top: 16px;
}

.status-list dt {
    color: var(--muted);
    font-weight: 700;
}

.status-list dd {
    margin: 6px 0 0;
    color: var(--blue);
    font-size: 30px;
    font-weight: 950;
}

.history-panel {
    margin-top: 18px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    height: 46px;
    border-radius: 999px;
    color: white;
    background: var(--green);
    font-weight: 950;
}

.history-list {
    display: grid;
    gap: 10px;
    max-height: 360px;
    overflow: auto;
    padding-right: 4px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    background: var(--surface-blue);
}

.history-item strong,
.history-item span,
.history-item time {
    display: block;
}

.history-item strong {
    color: var(--blue);
    font-size: 18px;
}

.history-item span,
.history-item time {
    color: var(--muted);
    font-weight: 750;
}

.history-item time {
    flex: 0 0 auto;
}

.empty-state {
    margin: 0;
    border: 1px dashed rgba(34, 184, 214, 0.42);
    border-radius: 8px;
    padding: 18px;
    color: var(--muted);
    background: var(--surface-blue);
    font-weight: 750;
    text-align: center;
}

#message {
    min-height: 28px;
    margin: 18px 0 0;
    color: var(--muted);
    text-align: center;
    font-weight: 700;
}

#message[data-type="success"] {
    color: var(--green);
}

#message[data-type="error"] {
    color: var(--danger);
}

@media (max-width: 860px) {
    .sidebar {
        width: 132px;
        padding: 14px 10px;
    }

    .sidebar-brand {
        padding: 4px;
    }

    .sidebar-nav {
        grid-auto-flow: row;
    }

    .status-pill {
        display: none;
    }

    .app-shell {
        margin-left: 132px;
        padding: 22px 14px 34px;
    }

    .nav-link {
        justify-content: center;
        padding: 0 8px;
        font-size: 13px;
    }

    .draw-actions,
    .meta-line,
    .config-grid,
    .history-item {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .primary-action {
        width: 100%;
    }

    #stage {
        min-height: 500px;
        padding: 42px 18px;
    }
}
