:root {
    --azul: #17458f;
    --azul-oscuro: #0d2a5c;
    --azul-claro: #eaf0fa;
    --amarillo: #ffc400;
    --amarillo-suave: #fff6db;
    --texto: #16202e;
    --texto-suave: #5b6b80;
    --borde: #dfe5ee;
    --fondo: #f5f7fb;
    --blanco: #ffffff;
    --ok: #0f7b4f;
    --ok-fondo: #e6f6ee;
    --error: #b3261e;
    --error-fondo: #fdecea;
    --aviso: #8a5a00;
    --aviso-fondo: #fff5e0;
    --radio: 12px;
    --sombra: 0 1px 2px rgba(16, 32, 56, .06), 0 8px 24px rgba(16, 32, 56, .06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--texto);
    background: var(--fondo);
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--azul); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 .8rem; }

code, .mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .92em;
}

.contenedor {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ---------------- Barra pública ---------------- */

.barra {
    background: var(--azul);
    color: #fff;
    padding: .9rem 0;
}

.barra .contenedor {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.marca {
    font-weight: 700;
    letter-spacing: .2px;
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}

.marca .punto {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--amarillo);
    box-shadow: 0 0 0 3px rgba(255, 196, 0, .25);
}

.barra a.enlace-barra {
    color: #dce6f7;
    text-decoration: none;
    font-size: .9rem;
}

.barra a.enlace-barra:hover { color: #fff; }

.pie {
    border-top: 1px solid var(--borde);
    margin-top: 2.5rem;
    padding: 1.2rem 0 2rem;
    color: var(--texto-suave);
    font-size: .85rem;
}

/* ---------------- Tarjetas y formularios ---------------- */

.tarjeta {
    background: var(--blanco);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.tarjeta.estrecha { max-width: 460px; margin-inline: auto; }

.campo { margin-bottom: .9rem; }

label {
    display: block;
    font-weight: 600;
    font-size: .85rem;
    margin-bottom: .3rem;
}

.hint {
    color: var(--texto-suave);
    font-size: .8rem;
    margin-top: .25rem;
}

input[type="text"], input[type="url"], input[type="password"], input[type="number"],
input[type="search"], select, textarea {
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--borde);
    border-radius: 9px;
    font: inherit;
    background: #fff;
    color: var(--texto);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(23, 69, 143, .35);
    border-color: var(--azul);
}

.fila { display: flex; gap: .8rem; flex-wrap: wrap; }
.fila > * { flex: 1 1 160px; }

.boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .62rem 1.05rem;
    border-radius: 9px;
    border: 1px solid transparent;
    background: var(--azul);
    color: #fff;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.boton:hover { background: var(--azul-oscuro); }
.boton.secundario { background: #fff; color: var(--azul); border-color: var(--borde); }
.boton.secundario:hover { background: var(--azul-claro); }
.boton.amarillo { background: var(--amarillo); color: #3b2c00; }
.boton.amarillo:hover { background: #e8b200; }
.boton.peligro { background: #fff; color: var(--error); border-color: #f2c9c6; }
.boton.peligro:hover { background: var(--error-fondo); }
.boton.chico { padding: .38rem .7rem; font-size: .85rem; font-weight: 500; }
.boton.bloque { width: 100%; }

.acciones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------------- Mensajes ---------------- */

.mensaje {
    border-radius: 10px;
    padding: .75rem .9rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    font-size: .92rem;
}
.mensaje.ok { background: var(--ok-fondo); color: var(--ok); border-color: #bfe6d2; }
.mensaje.error { background: var(--error-fondo); color: var(--error); border-color: #f3cbc7; }
.mensaje.aviso { background: var(--aviso-fondo); color: var(--aviso); border-color: #f3ddb0; }

/* ---------------- Tablas ---------------- */

.tabla-envoltura { overflow-x: auto; }

table.tabla {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: .9rem;
}

table.tabla th, table.tabla td {
    text-align: left;
    padding: .55rem .6rem;
    border-bottom: 1px solid var(--borde);
    vertical-align: middle;
}

table.tabla th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--texto-suave);
    background: #fbfcfe;
}

table.tabla tr:hover td { background: #fafcff; }

.etiqueta-estado {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.estado-ok { background: var(--ok-fondo); color: var(--ok); }
.estado-pendiente { background: var(--aviso-fondo); color: var(--aviso); }
.estado-off { background: #eef1f5; color: var(--texto-suave); }

/* ---------------- Panel de administración ---------------- */

.panel {
    display: grid;
    grid-template-columns: 232px 1fr;
    min-height: 100vh;
}

.lateral {
    background: var(--azul-oscuro);
    color: #cdd9ef;
    padding: 1rem .75rem;
}

.lateral .marca { margin-bottom: 1.2rem; font-size: 1.02rem; }

.lateral nav a {
    display: block;
    color: #c8d5ec;
    text-decoration: none;
    padding: .55rem .7rem;
    border-radius: 8px;
    font-size: .92rem;
    margin-bottom: .15rem;
}

.lateral nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.lateral nav a.activo { background: var(--amarillo); color: #3b2c00; font-weight: 700; }

.lateral .grupo {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #7f93b8;
    margin: 1.1rem .7rem .35rem;
}

.principal { padding: 1.4rem 1.6rem 3rem; }

.cabecera-seccion {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.1rem;
}

.cabecera-seccion p { color: var(--texto-suave); margin: 0; font-size: .9rem; }

.rejilla-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .9rem;
    margin-bottom: 1.2rem;
}

.stat {
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: .9rem 1rem;
    box-shadow: var(--sombra);
}

.stat .numero { font-size: 1.7rem; font-weight: 700; color: var(--azul); line-height: 1.1; }
.stat .titulo { font-size: .8rem; color: var(--texto-suave); text-transform: uppercase; letter-spacing: .4px; }

.barras {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    padding: .5rem 0;
}

.barras .barra-dia {
    flex: 1;
    background: linear-gradient(180deg, var(--azul) 0%, #3a6fc4 100%);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    position: relative;
}

.barras .barra-dia:hover::after {
    content: attr(data-dia) " · " attr(data-total);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--azul-oscuro);
    color: #fff;
    padding: .2rem .45rem;
    border-radius: 6px;
    font-size: .72rem;
    white-space: nowrap;
    z-index: 5;
}

.paginacion { display: flex; gap: .4rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }

/* ---------------- Configuración pública ---------------- */

.centrado { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.4rem 1rem; }

.codigo-placa {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--azul);
    background: var(--azul-claro);
    border-radius: 10px;
    padding: .35rem .7rem;
    display: inline-block;
}

.qr-vista {
    width: 148px;
    height: 148px;
    border: 1px solid var(--borde);
    border-radius: 10px;
    background: #fff;
    padding: 6px;
}

.lista-check { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
.lista-check li { padding: .3rem 0 .3rem 1.5rem; position: relative; }
.lista-check li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--ok);
    font-weight: 700;
}

/* ---------------- Editor de plantilla ---------------- */

.editor {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) 420px;
    gap: 1.2rem;
    align-items: start;
}

.hoja-preview {
    position: relative;
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: 8px;
    width: 100%;
    overflow: hidden;
}

.hoja-preview img.fondo { display: block; width: 100%; height: auto; }

.hoja-preview > .vacio { position: absolute; inset: 0; }

.hoja-preview .celda {
    position: absolute;
    border: 1px dashed rgba(23, 69, 143, .55);
    pointer-events: none;
}

.hoja-preview .qr-caja {
    position: absolute;
    border: 1px solid rgba(23, 69, 143, .9);
    background: rgba(255, 196, 0, .12);
    pointer-events: none;
}

.hoja-preview .qr-caja img { width: 100%; height: 100%; display: block; opacity: .85; }

.hoja-preview .etiqueta-celda {
    position: absolute;
    font-size: 10px;
    color: var(--azul);
    background: rgba(255, 255, 255, .85);
    padding: 0 3px;
    border-radius: 3px;
}

.vacio {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    color: var(--texto-suave);
    background: repeating-linear-gradient(45deg, #fafbfe, #fafbfe 12px, #f2f5fa 12px, #f2f5fa 24px);
    font-size: .9rem;
    text-align: center;
    padding: 1rem;
}

.aviso-tecnico {
    font-size: .82rem;
    color: var(--texto-suave);
    border-left: 3px solid var(--amarillo);
    padding-left: .7rem;
    margin: .6rem 0;
}

@media (max-width: 900px) {
    .panel { grid-template-columns: 1fr; }
    .lateral { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
    .lateral .grupo { display: none; }
    .lateral nav { display: flex; flex-wrap: wrap; gap: .3rem; }
    .lateral nav a { margin: 0; }
    .editor { grid-template-columns: 1fr; }
    .principal { padding: 1rem; }
}

@media print {
    .lateral, .barra, .acciones, .boton { display: none !important; }
    body { background: #fff; }
}
