:root {
    --azul-claro: #008EC7;
    --azul-claro-hover: #0077a8;
    --azul-oscuro: #033852;
    --fondo: #f5f7fa;
    --texto: #1f2937;
    --borde: #e5e9ee;
}

* { box-sizing: border-box; }
body {
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--fondo);
    color: var(--texto);
    margin: 0;
    padding: 16px;
}
body.con-sidebar { padding: 0; }

h1 { font-size: 1.3rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.subtitulo { color: #6b7280; margin-top: 0; }
a { color: var(--azul-claro); }

/* ---------- Pantallas independientes (login, impresión, quiosco) ---------- */
.centrado {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: radial-gradient(circle at top left, #0a4a68, var(--azul-oscuro) 60%);
}
.tarjeta {
    background: #fff; border-radius: 16px; padding: 28px;
    box-shadow: 0 10px 30px rgba(3,56,82,.18); width: 100%; max-width: 420px;
}
/* Misma tarjeta, pero para secciones de informes que necesitan usar todo el
   ancho disponible (tablas de varias columnas, resúmenes en fila) — la
   .tarjeta normal se queda angosta a propósito para formularios tipo login. */
.tarjeta-ancha {
    background: #fff; border-radius: 16px; padding: 24px 28px;
    box-shadow: 0 1px 2px rgba(16,24,40,.05); border: 1px solid var(--borde);
    width: 100%; margin-bottom: 20px;
}

/* ---------- Formularios y botones (usados en toda la app) ---------- */
label { display: block; margin: 14px 0 4px; font-weight: 600; font-size: .87rem; color: #374151; }
input, select, button, textarea {
    width: 100%; padding: 11px 12px; font-size: .95rem; border-radius: 10px;
    border: 1px solid #d1d5db; margin-top: 2px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--azul-claro); box-shadow: 0 0 0 3px rgba(0,142,199,.15); }
button, a.boton {
    background: var(--azul-claro); color: #fff; border: none; font-weight: 600;
    margin-top: 18px; cursor: pointer; transition: background .15s, transform .05s;
}
button:hover, a.boton:hover { background: var(--azul-claro-hover); }
button:active, a.boton:active { transform: translateY(1px); }
button.secundario { background: #64748b; }
button.secundario:hover { background: #475569; }
button.peligro { background: #dc2626; }
button.peligro:hover { background: #b91c1c; }
button:disabled { background: #b6c0cc; cursor: not-allowed; }

a.boton, button.boton {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 16px; border-radius: 10px; text-decoration: none;
    width: auto; margin: 0; font-size: .9rem;
}

/* Botón de acciones destructivas (eliminar, anular...), mismo tamaño y
   forma que a.boton — para que nunca se vea descuadrado al lado de uno. */
button.boton-peligro, a.boton-peligro {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 16px; border-radius: 10px; text-decoration: none;
    width: auto; margin: 0; margin-top: 0; font-size: .9rem; font-weight: 600;
    border: none; cursor: pointer; background: #dc2626; color: #fff;
}
button.boton-peligro:hover, a.boton-peligro:hover { background: #b91c1c; }

.error { background: #fee2e2; color: #b91c1c; padding: 10px 14px; border-radius: 10px; }
.ok { background: #dcfce7; color: #166534; padding: 10px 14px; border-radius: 10px; }
.aviso { background: #fef7e0; color: #92620a; padding: 10px 14px; border-radius: 10px; }

/* ---------- Tablas ---------- */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 2px rgba(16,24,40,.05); }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--borde); font-size: .87rem; }
th { background: #f9fafb; font-weight: 600; color: #475569; text-transform: uppercase; font-size: .72rem; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }

/* ---------- Tarjetas de resumen / grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 14px; }
.tarjeta-mini {
    background: #fff; border: 1px solid var(--borde); border-radius: 14px; padding: 18px 20px;
    box-shadow: 0 1px 2px rgba(16,24,40,.04); transition: box-shadow .15s, transform .15s;
}
.tarjeta-mini:hover { box-shadow: 0 6px 18px rgba(16,24,40,.08); transform: translateY(-1px); }

.icono-chip {
    width: 40px; height: 40px; border-radius: 10px; display: flex;
    align-items: center; justify-content: center; margin-bottom: 12px;
}
.icono-chip svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
.icono-chip.celeste { background: #e6f4fb; color: var(--azul-claro); }
.icono-chip.verde   { background: #e7f7ee; color: #15803d; }
.icono-chip.ambar   { background: #fef3d6; color: #b45309; }
.icono-chip.gris    { background: #eef1f4; color: #475569; }
.icono-chip.morado  { background: #f1ebfd; color: #7c3aed; }

.barra-progreso { background: #e5e7eb; border-radius: 6px; overflow: hidden; height: 8px; }
.barra-progreso > div { background: var(--azul-claro); height: 100%; border-radius: 6px; }

.chip {
    display: inline-block; background: #e6f4fb; color: var(--azul-claro);
    padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 600; margin-left: 6px;
}
.muted { color: #6b7280; font-size: .85rem; }

/* ---------- App shell: menú lateral + contenido ---------- */
.app { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
    width: 250px; flex-shrink: 0;
    background: linear-gradient(180deg, var(--azul-oscuro) 0%, #04283a 100%);
    color: #fff; display: flex; flex-direction: column;
    padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .marca-sidebar { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.sidebar .marca-sidebar img { height: 34px; width: auto; }
.sidebar .marca-sidebar div { line-height: 1.2; }
.sidebar .marca-sidebar strong { display: block; font-size: .95rem; }
.sidebar .marca-sidebar span { font-size: .72rem; color: #9fc6da; }

.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.nav-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    border-radius: 10px; color: #cfe9f7; text-decoration: none;
    font-size: .89rem; font-weight: 500; transition: background .15s, color .15s;
}
.nav-link svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.activo { background: rgba(0,142,199,.28); color: #fff; }
.nav-link.deshabilitado { color: #567585; pointer-events: none; }
.nav-seccion {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #6b8ea3;
    padding: 16px 12px 4px;
}
.nav-subseccion {
    font-size: .74rem;
    font-weight: 600;
    color: #9db8c9;
    padding: 10px 12px 2px 16px;
}
.nav-link.nav-sub { padding-left: 26px; }
.nav-toggle { cursor: pointer; }
.nav-flecha { stroke: currentColor; fill: none; stroke-width: 2; transition: transform .15s; }
.nav-flecha.abierta { transform: rotate(180deg); }
.nav-submenu { display: flex; flex-direction: column; }
.nav-link-salir { margin-top: auto; color: #f3aeae; }
.nav-link-salir:hover { background: rgba(220,38,38,.18); color: #fff; }

.sidebar .pie-sidebar {
    border-top: 1px solid rgba(255,255,255,.12); padding-top: 14px; margin-top: 14px; font-size: .78rem; color: #9fc6da;
}
.sidebar .pie-sidebar strong { color: #fff; display: block; font-size: .85rem; margin-bottom: 2px; }
.sidebar .pie-sidebar a { color: #9fc6da; }

.contenido { flex: 1; padding: 30px 34px; max-width: 1280px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 14px; margin-bottom: 26px; }
.page-header h1 { font-size: 1.5rem; color: var(--azul-oscuro); }
.acciones-header { display: flex; gap: 8px; flex-wrap: wrap; }
.acciones-header a.boton, .acciones-header button { margin-top: 0; }

@media (max-width: 860px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; overflow-x: auto; padding: 12px; }
    .sidebar .marca-sidebar { padding: 0 12px 0 0; }
    .sidebar nav { flex-direction: row; flex: none; }
    .nav-link span.texto-nav { display: none; }
    .sidebar .pie-sidebar { display: none; }
    .contenido { padding: 20px; }
}

/* ---------- Barra de progreso de subida de archivos (reutilizable) ---------- */
.barra-subida {
    background: #0f766e;
    transition: width .2s;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: .78rem; font-weight: 600;
}
.barra-subida.procesando {
    width: 100% !important;
    background: repeating-linear-gradient(45deg, #0f766e, #0f766e 12px, #0d9488 12px, #0d9488 24px);
    background-size: 200% 100%;
    animation: mover-rayas 1s linear infinite;
}
@keyframes mover-rayas {
    from { background-position: 0 0; }
    to { background-position: 34px 0; }
}

/* ---------- Pantalla de conteo (celular/tablet) ---------- */
.combo-buscar { position: relative; }
.combo-lista {
    display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
    background: #fff; border: 1px solid var(--borde); border-radius: 10px; margin-top: 4px;
    max-height: 220px; overflow-y: auto; box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.combo-lista.abierta { display: block; }
.combo-opcion { padding: 10px 14px; cursor: pointer; font-size: .92rem; border-bottom: 1px solid #f1f5f9; }
.combo-opcion:last-child { border-bottom: none; }
.combo-opcion:hover, .combo-opcion.activa { background: #e6f4fb; }
.combo-vacio { padding: 10px 14px; color: #6b7280; font-size: .85rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.topbar a, .topbar button { width: auto; margin: 0; }
.codigo-grande { font-size: 1.4rem; padding: 16px; text-align: center; letter-spacing: 1px; }
.producto-encontrado { background: #fff; border-radius: 12px; padding: 16px; margin-top: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.historial { margin-top: 18px; }
.historial-item {
    display: flex; justify-content: space-between; align-items: center; background: #fff;
    padding: 9px 14px; border-radius: 10px; margin-bottom: 6px; font-size: .85rem;
    border: 1px solid var(--borde);
}

/* ---------- Barra superior del panel de superadministrador ---------- */
.super-topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: linear-gradient(90deg, var(--azul-oscuro) 0%, #04283a 100%);
    color: #fff; padding: 16px 28px; margin: -16px -16px 28px;
}
.super-topbar .marca-super { display: flex; align-items: center; gap: 12px; }
.super-topbar .marca-super img { height: 32px; }
.super-topbar .marca-super strong { display: block; font-size: 1rem; }
.super-topbar .marca-super span { font-size: .75rem; color: #9fc6da; }
.super-topbar a { color: #cfe9f7; font-size: .88rem; }
.super-contenido { padding: 0 16px 16px; max-width: 1280px; margin: 0 auto; }

@media print {
    .no-imprimir { display: none !important; }
    body { background: #fff; padding: 0; }
    .app { display: block; }
    .sidebar { display: none; }
    .contenido { padding: 0; max-width: none; }
    table { box-shadow: none; }
}
