:root {
    --primario: #4f46e5;
    --primario-oscuro: #4338ca;
    --primario-claro: #eef2ff;
    --fondo: #f4f5fb;
    --superficie: #ffffff;
    --borde: #e2e5f0;
    --texto: #1e2233;
    --texto-suave: #64708c;
    --texto-tenue: #9aa3b9;
    --exito: #16a34a;
    --exito-claro: #dcfce7;
    --alerta: #dc2626;
    --alerta-claro: #fee2e2;
    --atencion: #d97706;
    --atencion-claro: #fef3c7;
    --sombra: 0 10px 30px rgba(30, 34, 51, 0.07);
    --sombra-chica: 0 2px 8px rgba(30, 34, 51, 0.06);
    --radio: 12px;
    --radio-chico: 8px;
    --transicion: all 0.18s ease;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--fondo);
    color: var(--texto);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Barra superior ---------- */

.barra-superior {
    background: #151a2e;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}

.barra-inner {
    max-width: 1150px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 19px;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    letter-spacing: 0.2px;
}

.logo-marcador {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primario), #7c3aed);
    color: #ffffff;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.nav {
    display: flex;
    gap: 6px;
}

.nav-link {
    color: #b6bdd4;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transicion);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.nav-link.activo {
    background: rgba(99, 91, 255, 0.22);
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(99, 91, 255, 0.35);
}

.nav-salir {
    color: #fda4af;
}

.nav-salir:hover {
    background: rgba(220, 38, 38, 0.15);
    color: #fecaca;
}

/* ---------- Contenido ---------- */

.contenedor {
    width: 100%;
    max-width: 1150px;
    margin: 0 auto;
    padding: 34px 24px 20px;
    flex: 1;
}

.contenedor-estrecho {
    max-width: 640px;
}

h1 {
    font-size: 25px;
    color: var(--texto);
    letter-spacing: -0.3px;
}

.saludo {
    color: var(--texto-suave);
    margin: 6px 0 26px;
    font-size: 15px;
}

.saludo strong {
    color: var(--texto);
}

.encabezado-fila {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.encabezado-fila h1 {
    margin: 0;
}

/* ---------- Tarjetas (dashboard) ---------- */

.tarjetas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.tarjeta {
    background: var(--superficie);
    border-radius: var(--radio);
    padding: 22px 24px;
    box-shadow: var(--sombra-chica);
    border: 1px solid var(--borde);
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
    overflow: hidden;
    transition: var(--transicion);
}

.tarjeta::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primario);
}

.tarjeta:hover {
    transform: translateY(-3px);
    box-shadow: var(--sombra);
}

.tarjeta-valor {
    font-size: 32px;
    font-weight: 700;
    color: var(--primario);
    line-height: 1.1;
}

.tarjeta-etiqueta {
    color: var(--texto-suave);
    font-size: 13px;
    font-weight: 500;
}

.tarjeta.vencer::after { background: var(--atencion); }
.tarjeta.vencer .tarjeta-valor { color: var(--atencion); }
.tarjeta.expirada::after { background: var(--alerta); }
.tarjeta.expirada .tarjeta-valor { color: var(--alerta); }
.tarjeta.admins::after { background: #0ea5e9; }
.tarjeta.admins .tarjeta-valor { color: #0284c7; }
.tarjeta.hoy::after { background: #0d9488; }
.tarjeta.hoy .tarjeta-valor { color: #0f766e; }
.tarjeta.api::after { background: #7c3aed; }
.tarjeta.api .tarjeta-valor { color: #6d28d9; }

/* ---------- Estadísticas de la API ---------- */

.panel-estadisticas {
    margin-bottom: 28px;
}

.panel-estadisticas h2 {
    margin-bottom: 18px;
}

.estadisticas-fila {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.estadistica-caja {
    background: var(--superficie);
    border-radius: var(--radio);
    padding: 22px;
    box-shadow: var(--sombra-chica);
    border: 1px solid var(--borde);
}

.estadistica-caja h3 {
    font-size: 15px;
    margin-bottom: 16px;
    color: var(--texto);
}

.vacio {
    color: var(--texto-tenue);
    font-size: 13.5px;
}

.tabla-estadisticas {
    min-width: 0;
}

.tabla-estadisticas tbody td {
    padding: 12px 14px;
}

.tabla-estadisticas tbody tr:hover {
    box-shadow: inset 3px 0 0 var(--primario);
}

.col-num {
    text-align: center;
    white-space: nowrap;
}

.contador-api {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--primario-claro);
    color: var(--primario-oscuro);
    font-weight: 700;
    font-size: 13px;
}

.fecha-ultima {
    font-size: 12.5px;
    color: var(--texto-suave);
    white-space: nowrap;
}

.grafico-dias {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    height: 170px;
    padding: 10px 6px 0;
}

.columna-dia {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
}

.columna-valor {
    font-size: 12px;
    font-weight: 700;
    color: var(--texto-suave);
}

.columna-barra {
    width: 100%;
    max-width: 42px;
    min-height: 4px;
    border-radius: 6px 6px 3px 3px;
    background: linear-gradient(180deg, #7c3aed, #4f46e5);
}

.columna-etiqueta {
    font-size: 10.5px;
    color: var(--texto-tenue);
    white-space: nowrap;
}

/* ---------- Panel aviso ---------- */

.panel-aviso {
    background: var(--superficie);
    border-radius: var(--radio);
    padding: 24px;
    box-shadow: var(--sombra-chica);
    border: 1px solid var(--borde);
}

.panel-aviso h2 {
    font-size: 17px;
    margin-bottom: 8px;
}

.panel-aviso p {
    color: var(--texto-suave);
    font-size: 14.5px;
    line-height: 1.7;
}

.panel-aviso a {
    color: var(--primario);
    font-weight: 600;
    text-decoration: none;
}

.panel-aviso a:hover {
    text-decoration: underline;
}

/* ---------- Formularios ---------- */

.campo {
    margin-bottom: 18px;
}

.campo label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--texto);
    margin-bottom: 7px;
}

.campo input[type='text'],
.campo input[type='email'],
.campo input[type='password'],
.campo input[type='date'],
.campo select,
.input-archivo {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--borde);
    border-radius: var(--radio-chico);
    font-size: 14.5px;
    background: var(--superficie);
    color: var(--texto);
    transition: var(--transicion);
    font-family: inherit;
}

.campo input:focus,
.campo select:focus,
.input-archivo:focus {
    outline: none;
    border-color: var(--primario);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

.campo input:disabled {
    background: #f1f3f9;
    color: var(--texto-tenue);
    cursor: not-allowed;
}

.input-archivo {
    padding: 9px;
    border-style: dashed;
    background: #fafbff;
    cursor: pointer;
}

.ayuda {
    font-weight: 400;
    color: var(--texto-tenue);
    font-size: 12px;
}

.acciones-formulario {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.form-perfil {
    background: var(--superficie);
    border-radius: var(--radio);
    padding: 26px;
    box-shadow: var(--sombra-chica);
    border: 1px solid var(--borde);
}

.titulo-formulario {
    font-size: 16px;
    color: var(--texto);
    border-top: 1px solid var(--borde);
    padding-top: 20px;
    margin-top: 24px;
    margin-bottom: 18px;
}

/* ---------- Botones ---------- */

.boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: none;
    border-radius: var(--radio-chico);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transicion);
    font-family: inherit;
}

.boton-primario {
    background: linear-gradient(135deg, var(--primario), var(--primario-oscuro));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
}

.boton-primario:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.34);
}

.boton-secundario {
    background: var(--superficie);
    color: var(--texto-suave);
    border: 1px solid var(--borde);
}

.boton-secundario:hover {
    background: var(--fondo);
    color: var(--texto);
}

.boton-peligro {
    background: var(--alerta);
    color: #ffffff;
}

.boton-peligro:hover {
    background: #b91c1c;
}

.boton-chico {
    padding: 6px 13px;
    font-size: 12.5px;
    border-radius: 7px;
}

.boton-ancho {
    width: 100%;
}

/* ---------- Alertas ---------- */

.alerta {
    padding: 12px 15px;
    border-radius: var(--radio-chico);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.alerta p + p {
    margin-top: 4px;
}

.alerta-error {
    background: var(--alerta-claro);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alerta-exito {
    background: var(--exito-claro);
    color: #15803d;
    border: 1px solid #bbf7d0;
}

/* ---------- Tabla de licencias ---------- */

.tabla-barra {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.tabla-conteo {
    background: var(--superficie);
    border: 1px solid var(--borde);
    color: var(--texto-suave);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 999px;
    box-shadow: var(--sombra-chica);
}

.tabla-conteo::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--exito);
    margin-right: 8px;
    vertical-align: 1px;
}

.tabla-leyenda {
    font-size: 12px;
    color: var(--texto-tenue);
}

.tabla-envoltura {
    background: var(--superficie);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    border: 1px solid var(--borde);
    overflow-x: auto;
}

.tabla {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    min-width: 760px;
}

.tabla thead th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #aab3d4;
    padding: 16px 22px;
    background: linear-gradient(135deg, #1c2138, #151a2e);
    border-bottom: 2px solid rgba(255, 255, 255, 0.04);
    white-space: nowrap;
    font-weight: 600;
}

.tabla thead th:first-child {
    border-top-left-radius: 12px;
}

.tabla thead th:last-child {
    border-top-right-radius: 12px;
}

.tabla tbody td {
    padding: 18px 22px;
    border-bottom: 1px solid #eef0f7;
    vertical-align: middle;
}

.tabla tbody tr:last-child td {
    border-bottom: none;
}

.tabla tbody tr {
    transition: background 0.16s ease, box-shadow 0.16s ease;
}

.tabla tbody tr:hover {
    background: #f7f8fd;
    box-shadow: inset 3px 0 0 var(--primario);
}

.col-acciones {
    text-align: right;
    width: 60px;
    white-space: nowrap;
}

/* ---------- Cliente (avatar + nombre + clave) ---------- */

.cliente {
    display: flex;
    align-items: center;
    gap: 13px;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    object-fit: contain;
    border: 1px solid var(--borde);
    background: #fff;
    box-shadow: 0 3px 10px rgba(30, 34, 51, 0.08);
    flex-shrink: 0;
}

.avatar-inicial {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    border: none;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.cliente-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.restaurante {
    font-weight: 700;
    font-size: 14.5px;
    color: var(--texto);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.clave {
    font-family: Consolas, 'Cascadia Mono', 'Courier New', monospace;
    font-size: 11.5px;
    letter-spacing: 0.7px;
    color: var(--texto-tenue);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

/* ---------- Plan ---------- */

.tag-plan {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
}

.plan-gratuito {
    background: #dff1fe;
    color: #0369a1;
}

.plan-mes {
    background: #ede9fe;
    color: #6d28d9;
}

.plan-anio {
    background: #fef1d6;
    color: #b45309;
}

.plan-duracion {
    display: block;
    font-size: 11.5px;
    color: var(--texto-tenue);
    margin-top: 4px;
    font-weight: 500;
}

/* ---------- Vigencia ---------- */

.dias-info {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--texto-suave);
    white-space: nowrap;
}

.progreso {
    margin-top: 7px;
    height: 8px;
    width: 120px;
    min-width: 90px;
    background: #e8eaf3;
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progreso-barra {
    height: 100%;
    border-radius: 999px;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.progreso-activa {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.progreso-proxima {
    background: linear-gradient(90deg, #facc15, #d97706);
}

.progreso-expirada {
    background: repeating-linear-gradient(
        45deg,
        #ef4444 0 6px,
        #dc2626 6px 12px
    );
    background-size: 200% 100%;
    animation: desplazar 12s linear infinite;
}

@keyframes desplazar {
    from { background-position: 0 0; }
    to { background-position: -120px 0; }
}

/* ---------- Vence ---------- */

.fecha-vence {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--texto);
    white-space: nowrap;
}

.celda-vence .dias-restantes {
    display: block;
    font-size: 11.5px;
    color: var(--texto-suave);
    margin-top: 3px;
    white-space: nowrap;
}

.celda-vence .dias-tarde {
    color: var(--alerta);
    font-weight: 600;
}

/* ---------- Badge de estado ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 13px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.punto {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge-activa {
    background: var(--exito-claro);
    color: #15803d;
}

.badge-activa .punto {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.badge-proxima {
    background: var(--atencion-claro);
    color: #b45309;
}

.badge-proxima .punto {
    background: #eab308;
    animation: pulsar 1.1s ease-in-out infinite;
}

.badge-expirada {
    background: var(--alerta-claro);
    color: #b91c1c;
}

.badge-expirada .punto {
    background: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}

@keyframes pulsar {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: 0.6; }
}

/* ---------- Botón de acciones ---------- */

.boton-icono {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid #fecaca;
    background: #fff;
    border-radius: 10px;
    color: var(--alerta);
    cursor: pointer;
    transition: var(--transicion);
}

.boton-icono:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    transform: scale(1.08);
    box-shadow: 0 3px 8px rgba(220, 38, 38, 0.15);
}

.icono-eliminar {
    width: 16px;
    height: 16px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/%3E%3C/svg%3E") center / contain no-repeat;
}

.form-inline {
    display: inline;
}

/* ---------- Login ---------- */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(1000px 500px at 85% -10%, rgba(79, 70, 229, 0.25), transparent),
        radial-gradient(800px 400px at -10% 110%, rgba(124, 58, 237, 0.22), transparent),
        #0e1124;
}

.login-card {
    background: var(--superficie);
    border-radius: 18px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
    padding: 0;
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.login-marca {
    background: linear-gradient(135deg, var(--primario), #7c3aed);
    padding: 30px 28px 26px;
    text-align: center;
}

.login-marca-icono .logo-marcador {
    width: 52px;
    height: 52px;
    font-size: 24px;
    background: rgba(255, 255, 255, 0.16);
    box-shadow: none;
    margin-bottom: 12px;
}

.login-logo {
    font-size: 25px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.4px;
}

.login-subtitulo {
    color: rgba(255, 255, 255, 0.82);
    margin-top: 6px;
    font-size: 13.5px;
}

.login-card form {
    padding: 26px 28px 30px;
}

.login-card .alerta {
    margin: 20px 28px 0;
}

/* ---------- Pie de página ---------- */

.pie-pagina {
    padding: 18px 24px;
    text-align: center;
    color: var(--texto-tenue);
    font-size: 12.5px;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
    .contenedor {
        padding: 22px 16px 12px;
    }

    .barra-inner {
        padding: 10px 16px;
        justify-content: center;
    }

    .encabezado-fila {
        flex-direction: column;
        align-items: flex-start;
    }

    .estadisticas-fila {
        grid-template-columns: 1fr;
    }

    .grafico-dias {
        height: 150px;
    }

    .tabla-estadisticas {
        min-width: 0;
    }

    .tabla-estadisticas thead th {
        display: table-cell;
    }

    .tabla-estadisticas tbody td {
        display: table-cell;
        padding: 12px 14px;
        text-align: left;
        padding-left: 14px;
    }

    .tabla-estadisticas tbody td::before {
        content: none;
    }

    .tabla-estadisticas tbody tr {
        display: table-row;
        border-bottom: 1px solid #eef0f7;
        padding: 0;
    }

    .tabla-estadisticas tbody tr:hover {
        box-shadow: inset 3px 0 0 var(--primario);
    }

    .tabla {
        min-width: 0;
    }

    .tabla thead {
        display: none;
    }

    .tabla tbody tr {
        display: block;
        border-bottom: 1px solid var(--borde);
        padding: 10px 0;
    }

    .tabla tbody tr:hover {
        box-shadow: inset 3px 0 0 var(--primario);
    }

    .tabla tbody td {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 10px;
        border: none;
        padding: 7px 16px;
        text-align: right;
        position: relative;
        padding-left: 120px;
    }

    .tabla tbody td::before {
        content: attr(data-etiqueta);
        position: absolute;
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--texto-tenue);
    }

    .cliente {
        justify-content: flex-end;
    }

    .col-acciones {
        justify-content: flex-end;
        padding-left: 16px;
    }

    .col-acciones::before {
        content: none;
    }

    .clave {
        max-width: 150px;
    }
}