* {
    box-sizing: border-box;
}

:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-strong: #0f172a;
    --ink: #182233;
    --muted: #64748b;
    --line: #dbe5f0;
    --primary: #0f6bba;
    --primary-dark: #0a4f8d;
    --success: #17824b;
    --warning: #f5b02e;
    --danger: #c43b3b;
    --radius: 8px;
    --shadow: 0 18px 45px rgba(15, 23, 42, .12);
    --font: Arial, Helvetica, sans-serif;
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(15, 107, 186, .12), transparent 32rem),
        linear-gradient(180deg, #f8fbff, var(--bg));
}

body.app-dark {
    color: #fff;
    background:
        radial-gradient(circle at 18% 5%, rgba(55, 151, 220, .25), transparent 34rem),
        linear-gradient(135deg, #07111f 0%, #0f2037 58%, #07111f 100%);
}

img {
    max-width: 100%;
}

a {
    color: inherit;
}

button,
input,
textarea,
select {
    font: inherit;
}

label {
    display: inline-block;
    margin: 0 0 6px;
    font-weight: 800;
    color: #334155;
}

input,
textarea,
select {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    font-size: 15px;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(15, 107, 186, .75);
    box-shadow: 0 0 0 4px rgba(15, 107, 186, .12);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: var(--radius);
    padding: 11px 15px;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
    transition: transform .14s ease, filter .14s ease, box-shadow .14s ease;
}

.btn:hover {
    filter: brightness(.98);
    box-shadow: 0 10px 24px rgba(15, 23, 42, .12);
}

.btn:active {
    transform: translateY(1px) scale(.99);
}

.primary {
    background: var(--primary);
    color: #fff;
}

.danger {
    background: var(--danger);
    color: #fff;
}

.muted {
    background: #e7edf5;
    color: #182233;
}

.ok {
    background: var(--success);
    color: #fff;
}

.warn {
    background: var(--warning);
    color: #3b2b00;
}

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

.topbar h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 42px);
    color: #102033;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nav a {
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: #334155;
    text-decoration: none;
    font-weight: 800;
}

.wrap {
    width: min(1120px, calc(100% - 32px));
    margin: 28px auto;
}

.shell {
    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(219, 229, 240, .9);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
}

.card h2 {
    margin: 0 0 16px;
    font-size: 22px;
    color: #102033;
}

.msg,
.alerta-nuevo {
    border-radius: var(--radius);
    padding: 13px 15px;
    margin: 14px 0;
    font-weight: 800;
}

.msg {
    background: #e9f5ff;
    border-left: 5px solid var(--primary);
}

.alerta-nuevo {
    display: none;
    background: #fff5d9;
    border-left: 5px solid var(--warning);
}

.help {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
    margin: -4px 0 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
}

th,
td {
    padding: 11px 9px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
}

.off {
    opacity: .55;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.admin-page input,
.admin-page textarea,
.admin-page select {
    margin-bottom: 13px;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.personal-page .wrap {
    max-width: 920px;
}

.personal-page .card {
    background: rgba(255, 255, 255, .94);
}

.personal-page select {
    font-size: 18px;
}

.personal-page .actual {
    font-size: clamp(52px, 9vw, 82px);
    line-height: 1;
    font-weight: 900;
    color: var(--primary);
    letter-spacing: 1px;
}

.personal-page .cola-numero {
    margin: 0;
    font-size: clamp(42px, 7vw, 64px);
    line-height: 1;
    font-weight: 900;
    color: #102033;
}

.personal-page .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.personal-page .actions .btn {
    min-height: 56px;
    font-size: 17px;
}

.parpadeo {
    animation: pulse .7s ease-in-out 3;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); color: var(--success); }
    100% { transform: scale(1); }
}

.totem-page {
    min-height: 100vh;
}

.totem-page .wrap {
    width: min(1080px, calc(100% - 34px));
    margin: 0 auto;
    padding: 34px 0;
}

.totem-page .header {
    display: grid;
    justify-items: center;
    gap: 12px;
    text-align: center;
    margin-bottom: 28px;
}

.totem-page .header img {
    width: 132px;
    height: 132px;
    object-fit: contain;
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 18px 42px rgba(0, 0, 0, .28);
}

.totem-page .header h1 {
    margin: 0;
    font-size: clamp(38px, 6vw, 70px);
    line-height: 1;
}

.totem-page .header p {
    margin: 0;
    color: #cde3ff;
    font-size: clamp(22px, 3vw, 34px);
    font-weight: 800;
}

.totem-page .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.turnoBtn {
    width: 100%;
    min-height: 158px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 12px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .14), transparent),
        linear-gradient(135deg, #1482d0, #0a5caa);
    color: #fff;
    font-size: clamp(28px, 4.2vw, 42px);
    line-height: 1.05;
    font-weight: 900;
    box-shadow: 0 18px 38px rgba(0, 0, 0, .34);
    cursor: pointer;
    padding: 18px;
}

.turnoBtn:active {
    transform: scale(.985);
}

.ticket {
    display: none;
}

.visor-page {
    overflow: hidden;
}

.visor-page .layout {
    height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-rows: 92px minmax(0, 1fr) 58px;
    gap: 14px;
    padding: 14px;
}

.visor-page .header,
.visor-page .main,
.visor-page .side,
.visor-page .news {
    border: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .32);
}

.visor-page .header {
    grid-column: 1 / 3;
    background: rgba(13, 32, 56, .92);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 22px;
}

.visor-page .brand {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.visor-page .brand img {
    width: 68px;
    height: 68px;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    padding: 5px;
}

.visor-page .brand h1 {
    margin: 0;
    font-size: clamp(28px, 3.4vw, 42px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.visor-page .meta {
    text-align: right;
    font-size: 27px;
    font-weight: 900;
}

.visor-page .meta small {
    display: block;
    margin-top: 2px;
    color: #b9d5f5;
    font-size: 16px;
    font-weight: 800;
}

.visor-page .main {
    background: rgba(11, 25, 48, .88);
    border-radius: 12px;
    padding: 14px;
    display: block;
    min-height: 0;
}

.turnosPanel {
    display: grid;
    grid-template-columns: minmax(420px, .92fr) minmax(280px, .55fr);
    gap: 14px;
    min-height: 0;
}

.turnoActual {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, .55fr);
    align-items: center;
    gap: 20px;
    border-radius: 12px;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .18), transparent),
        linear-gradient(135deg, #0f6bba, #073d7c);
}

.turnoActual .label {
    margin-bottom: 6px;
    color: #d9ecff;
    font-size: 20px;
    font-weight: 800;
}

.turnoActual .codigo {
    font-size: clamp(62px, 7vw, 96px);
    line-height: .95;
    font-weight: 900;
    letter-spacing: 0;
}

.turnoActual .box {
    font-size: clamp(36px, 4.6vw, 58px);
    line-height: 1;
    font-weight: 900;
    text-align: right;
}

.llamadosCompactos {
    overflow: hidden;
    border-radius: 12px;
    padding: 14px;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .08);
}

.llamadosCompactos h2 {
    margin: 0 0 10px;
    color: #fff;
    font-size: 20px;
}

.llamadosCompactos #ultimos {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.videoBox {
    min-height: 0;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
}

.visor-page .main .videoBox {
    height: 100%;
    min-height: 100%;
}

.videoBox iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.visor-page .side {
    min-height: 0;
    overflow: hidden;
    background: rgba(13, 32, 56, .92);
    border-radius: 12px;
    padding: 14px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
}

.visor-page .side h2 {
    margin: 0 0 16px;
    font-size: 27px;
}

.visor-page .side .turnoActual {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 18px;
}

.visor-page .side .turnoActual .label {
    font-size: 18px;
}

.visor-page .side .turnoActual .codigo {
    font-size: clamp(54px, 5vw, 74px);
}

.visor-page .side .turnoActual .box {
    font-size: clamp(34px, 4vw, 48px);
    text-align: left;
}

.visor-page .item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .08);
}

.visor-page .item .num {
    font-size: 25px;
    font-weight: 900;
}

.visor-page .item .boxs {
    color: #cfe7ff;
    font-size: 18px;
    font-weight: 800;
    text-align: right;
}

.empty {
    color: #aac3e0;
    font-size: 22px;
    padding: 20px;
    text-align: center;
}

.visor-page .news {
    grid-column: 1 / 3;
    display: flex;
    align-items: center;
    overflow: hidden;
    border-radius: 8px;
    background: #0f6bba;
}

.marquee {
    white-space: nowrap;
    padding-left: 100%;
    font-size: 25px;
    font-weight: 900;
    animation: marq 28s linear infinite;
}

@keyframes marq {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}

.flash {
    animation: flash .6s ease-in-out 3;
}

@keyframes flash {
    50% { filter: brightness(1.75); }
}

@media (max-width: 860px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .grid,
    .form-row,
    .totem-page .grid {
        grid-template-columns: 1fr;
    }

    .shell {
        padding: 18px;
    }
}

@media (max-width: 980px) {
    .visor-page {
        overflow: auto;
    }

    .visor-page .layout {
        min-height: 100vh;
        height: auto;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .visor-page .header,
    .visor-page .news {
        grid-column: 1;
    }

    .visor-page .main {
        grid-template-rows: auto 340px;
    }

    .turnosPanel {
        grid-template-columns: 1fr;
    }

    .llamadosCompactos #ultimos {
        grid-template-columns: 1fr;
    }

    .turnoActual {
        grid-template-columns: 1fr;
    }

    .turnoActual .box {
        text-align: left;
    }
}

@media print {
    body > *:not(.ticket) {
        display: none !important;
    }

    .ticket {
        display: block;
        width: 72mm;
        padding: 6mm;
        background: #fff;
        color: #000;
        font-family: Arial, Helvetica, sans-serif;
        text-align: center;
    }

    .ticket h2 {
        margin: 0 0 8px;
        font-size: 18px;
    }

    .ticket .cod {
        margin: 10px 0;
        font-size: 42px;
        font-weight: 900;
    }

    .ticket p {
        margin: 4px 0;
        font-size: 13px;
    }
}
