/* XELA ERP — estilos base */
:root {
    --azul: #0d6efd;
    --azul-oscuro: #0a58ca;
    --texto: #1f2937;
    --gris: #6b7280;
    --borde: #d1d5db;
    --fondo: #f3f4f6;
    --blanco: #ffffff;
    --rojo: #b91c1c;
    --verde: #15803d;
    --ambar: #b45309;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--texto);
    background: var(--fondo);
}

a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Cabecera --- */
.cabecera {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
    padding: 0.75rem 1.5rem;
    background: var(--blanco);
    border-bottom: 1px solid var(--borde);
}
.cabecera__marca a { font-size: 1.1rem; color: var(--texto); letter-spacing: 0.05em; }
.cabecera__nav { display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem; }
.cabecera__nav > a,
.menu__resumen {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    color: var(--texto);
    font-size: 0.95rem;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
}
.cabecera__nav > a:hover,
.menu__resumen:hover { background: var(--fondo); text-decoration: none; }
.cabecera__nav > a.activo,
.menu__resumen.activo { background: #e8f0fe; color: var(--azul-oscuro); font-weight: 600; }
.menu { position: relative; }
.menu__resumen { list-style: none; user-select: none; }
.menu__resumen::-webkit-details-marker { display: none; }
.menu__flecha { font-size: 0.72rem; transition: transform 0.15s ease; }
.menu[open] .menu__flecha { transform: rotate(180deg); }
.menu__panel {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    z-index: 100;
    min-width: 210px;
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    background: var(--blanco);
    border: 1px solid var(--borde);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}
.menu__panel a {
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    color: var(--texto);
    font-size: 0.92rem;
}
.menu__panel a:hover { background: var(--fondo); text-decoration: none; }
.menu__panel a.activo { background: #e8f0fe; color: var(--azul-oscuro); font-weight: 600; }
.cabecera__usuario { margin-left: auto; display: flex; align-items: center; gap: 1rem; color: var(--gris); }
.inline { display: inline; }

@media screen and (max-width: 980px) {
    .cabecera { gap: 1rem; padding: 0.75rem 1rem; }
    .cabecera__nav { order: 3; width: 100%; gap: 0.15rem; }
    .menu__panel { left: auto; right: 0; }
}

@media (max-width: 520px) {
    .menu__panel {
        position: static;
        min-width: 0;
        margin-top: 0.25rem;
        border: 0;
        box-shadow: none;
        padding-left: 0.75rem;
    }
}

/* --- Contenido --- */
.contenido { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }
.pie { text-align: center; color: var(--gris); padding: 2rem 0; font-size: 0.85rem; }

/* --- Tarjetas --- */
.tarjeta {
    background: var(--blanco);
    border: 1px solid var(--borde);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.tarjeta h1, .tarjeta h2 { margin-top: 0; }

/* --- Formularios --- */
.campo { margin-bottom: 1rem; }
.campo label { display: block; font-weight: 600; margin-bottom: 0.25rem; font-size: 0.9rem; }
.campo input[type=text], .campo input[type=email], .campo input[type=password],
.campo input[type=number], .campo select, .campo textarea {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--borde);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--blanco);
}
.campo textarea { min-height: 80px; }
.campo .ayuda { color: var(--gris); font-size: 0.8rem; }
.campo .error { color: var(--rojo); font-size: 0.85rem; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.rejilla--3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* --- Botones --- */
.boton {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: var(--azul);
    color: var(--blanco);
    font-size: 0.95rem;
    cursor: pointer;
}
.boton:hover { background: var(--azul-oscuro); text-decoration: none; }
.boton--plano { background: transparent; color: var(--gris); border-color: var(--borde); }
.boton--peligro { background: var(--rojo); }
.boton--secundario { background: var(--blanco); color: var(--texto); border-color: var(--borde); }
.acciones { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* --- Avisos --- */
.aviso { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; }
.aviso--exito { background: #ecfdf5; border-color: #a7f3d0; color: var(--verde); }
.aviso--error { background: #fef2f2; border-color: #fecaca; color: var(--rojo); }
.aviso--info  { background: #eff6ff; border-color: #bfdbfe; color: var(--azul-oscuro); }

/* --- Tablas --- */
.tabla { width: 100%; border-collapse: collapse; background: var(--blanco); }
.tabla th, .tabla td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--borde); text-align: left; font-size: 0.92rem; }
.tabla th { background: #f9fafb; font-size: 0.8rem; text-transform: uppercase; color: var(--gris); }
.etiqueta { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; background: #e5e7eb; color: var(--texto); }
.etiqueta--cliente { background: #dbeafe; color: var(--azul-oscuro); }
.etiqueta--proveedor { background: #fef3c7; color: var(--ambar); }
.etiqueta--ambos { background: #ede9fe; color: #6d28d9; }

/* --- Login --- */
.login { max-width: 380px; margin: 4rem auto; }
.login h1 { text-align: center; }

/* --- Utilidades --- */
.texto-derecha { text-align: right; }
.mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.sutil { color: var(--gris); font-size: 0.85rem; }

/* --- OCR de justificantes (gastos) --- */
.ocr-caja { margin-top: 0.5rem; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.ocr-caja .ocr-estado { font-size: 0.82rem; }
.ocr-preview .ocr-mini { max-height: 90px; max-width: 140px; border: 1px solid var(--borde); border-radius: 6px; margin-top: 0.4rem; }
.ocr-rellenado { background: #fff7cc !important; transition: background 0.6s; }

/* --- RRHH --- */
.etiqueta--ok { background: #dcfce7; color: var(--verde); }
.etiqueta--baja { background: #f3f4f6; color: var(--gris); }
.etiqueta--media { background: #fef3c7; color: var(--ambar); }
.etiqueta--alta { background: #fee2e2; color: var(--rojo); }
.tarjeta--mini { padding: 1rem; margin-bottom: 0; }
.dato-grande { display: block; margin-top: 0.25rem; font-size: 1.55rem; }
.fichaje-acciones { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1rem 0; }
.filtros {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    align-items: end;
    margin: 1rem 0;
}
.filtros__acciones { display: flex; gap: 0.5rem; padding-bottom: 1rem; }
.detalle summary { cursor: pointer; color: var(--azul); font-size: 0.85rem; }
.detalle__datos {
    background: var(--fondo);
    padding: 0.6rem;
    border-radius: 6px;
    overflow: auto;
    font-size: 0.78rem;
}
.tarjeta-cabecera,
.tarjeta__cabecera { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.formulario__acciones { display: flex; gap: 0.6rem; margin-top: 1rem; }
.campo--fila { display: flex; flex-direction: column; gap: 0.25rem; }
.campo__chequeo { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.campo__error { color: var(--rojo); font-size: 0.85rem; margin: 0.25rem 0 0; }
.m-0 { margin: 0; }

@media (max-width: 640px) {
    .tarjeta-cabecera,
    .tarjeta__cabecera { flex-direction: column; }
    .filtros__acciones { padding-bottom: 0; }
}

/* --- Búsqueda y puntuación RRHH --- */
.tabla-scroll { overflow-x: auto; }
.buscador { display: flex; gap: 0.5rem; align-items: end; margin: 1rem 0; flex-wrap: wrap; }
.buscador .campo { margin-bottom: 0; min-width: 240px; flex: 1; }
.campo--ancho { grid-column: 1 / -1; }
.puntuacion { display: inline-flex; align-items: baseline; gap: 0.35rem; font-weight: 700; }
.puntuacion--buena { color: var(--verde); }
.puntuacion--media { color: var(--ambar); }
.puntuacion--alta { color: var(--rojo); }
.puntuacion__numero { font-size: 1.25rem; }
.puntuacion__texto { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.aviso--aviso { background: #fffbeb; border-color: #fde68a; color: var(--ambar); }

/* --- Firma pública de incidencias --- */
.firma-publica { max-width: 760px; margin: 2rem auto; }
.firma-publica__cabecera {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--borde);
}
.firma-publica__detalle {
    background: #f9fafb;
    border: 1px solid var(--borde);
    border-radius: 8px;
    padding: 1rem 1.1rem;
    margin: 1rem 0;
}
.firma-publica__detalle h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.firma-publica__detalle p { margin: 0; line-height: 1.55; }
.ficha-datos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.8rem 1rem;
    margin: 1rem 0;
}
.ficha-datos > div { display: flex; flex-direction: column; gap: 0.15rem; }
.ficha-datos strong { font-size: 0.95rem; }
.firma-canvas {
    display: block;
    width: 100%;
    height: 200px;
    background: var(--blanco);
    border: 2px dashed var(--borde);
    border-radius: 8px;
    touch-action: none;
    cursor: crosshair;
}
.firma-canvas:focus { outline: 2px solid var(--azul); outline-offset: 2px; }
.firma-acciones { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.firma-acciones .boton { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

@media (max-width: 640px) {
    .firma-publica { margin: 1rem auto; }
    .firma-publica__cabecera { flex-direction: column; }
}

/* --- Responsive extra: tablas, contenido y formularios --- */
html { -webkit-text-size-adjust: 100%; }
img, svg, video { max-width: 100%; height: auto; }

@media (min-width: 1600px) {
    .contenido { max-width: 1400px; }
}

@media screen and (max-width: 980px) {
    .contenido { margin: 1rem auto; padding: 0 0.75rem; }
    .tarjeta { padding: 1.1rem; }
    .tabla {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .tabla th, .tabla td { padding: 0.5rem 0.6rem; }
    .acciones { flex-wrap: wrap; }
    .datos-doc { grid-template-columns: 1fr; }
    h1 { font-size: 1.45rem; }
}

@media screen and (max-width: 560px) {
    .rejilla, .rejilla--3 { grid-template-columns: 1fr; }
    .tarjeta { padding: 0.9rem; }
    .acciones .boton { flex: 1 1 auto; text-align: center; }
    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.1rem; }
    .cabecera__usuario { font-size: 0.85rem; }
}

/* --- Navegación vertical y filtros en móvil --- */
@media screen and (max-width: 900px) {
    .cabecera__nav { flex-direction: column; align-items: stretch; gap: 0.1rem; }
    .cabecera__nav > a,
    .menu__resumen { width: 100%; justify-content: space-between; padding: 0.55rem 0.7rem; }
    .menu__panel {
        position: static;
        min-width: 0;
        margin: 0.1rem 0 0.35rem 0.6rem;
        border: 0;
        box-shadow: none;
        background: #f8fafc;
        padding: 0.25rem;
    }
}

@media screen and (max-width: 700px) {
    .tarjeta form[style*="display:flex"],
    .tarjeta div[style*="display:flex"] { flex-wrap: wrap; }
    .tarjeta form[style*="display:flex"] input[type=text],
    .tarjeta form[style*="display:flex"] input[type=search],
    .tarjeta form[style*="display:flex"] input[type=date],
    .tarjeta form[style*="display:flex"] select { flex: 1 1 100% !important; width: 100%; }
}

/* Logo de empresa: nunca superar el ancho de su columna */
.logo-caja img { display: block; max-width: 100%; height: auto; }
@media screen and (max-width: 700px) {
    .logo-caja { max-width: 160px; }
    input[type="file"] { max-width: 100%; }
}
