/* ─── Reset y base ─── */
*, *::before, *::after { box-sizing: border-box; }

/* ─── Botón flotante de ayuda contextual (MainLayout) ───
   Discreto: por defecto es un círculo con "?"; al pasar el mouse se expande a una
   píldora y revela "¿Cómo funciona esta sección?". En táctil queda como círculo. */
.help-fab {
    position: fixed; right: 20px; bottom: 20px; z-index: 900;
    display: flex; align-items: center;
    background: #0f766e; color: #fff; text-decoration: none;
    height: 48px; border-radius: 999px; overflow: hidden;
    box-shadow: 0 6px 18px rgba(15,118,110,.30);
    font-size: 13px; font-weight: 600;
    transition: background .15s, transform .15s, box-shadow .15s;
}
.help-fab:hover {
    background: #0b5e57; transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(15,118,110,.40); text-decoration: none; color: #fff;
}
.help-fab-icon {
    flex-shrink: 0; width: 48px; height: 48px;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 20px;
}
.help-fab-label {
    max-width: 0; opacity: 0; white-space: nowrap; overflow: hidden;
    transition: max-width .25s ease, opacity .2s ease, padding .25s ease;
}
.help-fab:hover .help-fab-label { max-width: 280px; opacity: 1; padding-right: 20px; }
@media (max-width: 640px) {
    .help-fab { right: 14px; bottom: 14px; }
}
html, body { height: 100%; margin: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1f2937;
    background: #f3f4f6;
    -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
a { color: #00BB94; text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: #6b7280; }

/* ─── Login ─── */
.empty-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    /* Fondo navy de marca (igual que el login del portal del trabajador), en vez del
       gris del body. La tarjeta blanca resalta encima. */
    background: linear-gradient(135deg, #0D1B3D, #103A5F);
}
.login-shell { width: 100%; max-width: 400px; }
.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 32px;
}
.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}
.login-logo img {
    border-radius: 21px;
    filter: drop-shadow(0 6px 18px rgba(13, 27, 61, 0.18));
}
.login-brand {
    margin: 4px 0 0;
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #0D1B3D;
    text-align: center;
}
.login-wordmark {
    display: block;
    height: 24px;
    width: auto;
    margin: 8px auto 0;
}
.login-accent {
    width: 48px;
    height: 3px;
    background: #00BB94;
    border-radius: 2px;
    margin: 8px auto 0;
}
.login-sub {
    text-align: center;
    color: #64748b;
    margin: 12px 0 24px;
    font-size: 13px;
    line-height: 1.4;
}
.login-foot {
    text-align: center;
    margin: 16px 0 0;
    font-size: 13px;
    color: #64748b;
}
.login-foot a { color: #0d9488; text-decoration: none; font-weight: 600; }
.login-foot a:hover { text-decoration: underline; }

/* ─── Forms ─── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: #00BB94; }

/*
 * .form-select: dropdown con el mismo look que .form-input + chevron SVG inline.
 * Resetea el chrome nativo del navegador (appearance: none) y pinta la flecha como
 * background-image para que sea consistente cross-platform (Chrome/Firefox/Edge
 * estilizan los <select> nativos muy distinto entre sí).
 */
.form-select {
    padding: 10px 38px 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background-color: #fff;
    color: #374151;
    line-height: 1.4;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px 6px;
    transition: border-color 0.15s, box-shadow 0.15s;
    cursor: pointer;
}
.form-select:hover:not(:disabled) { border-color: #9ca3af; }
.form-select:focus {
    outline: none;
    border-color: #00BB94;
    box-shadow: 0 0 0 3px rgba(0,187,148,0.12);
}
.form-select:disabled { opacity: 0.6; cursor: not-allowed; background-color: #f9fafb; }

/*
 * .report-controls: usa la MISMA estética que .report-filters (white card con
 * border) para que se vea como una continuación visual de la barra de filtros
 * estándar. Internamente reutiliza .filter-group con label uppercase arriba +
 * control abajo, de modo que el ojo lea "Agrupar por" igual que "Sucursal" o
 * "Área". Sin esta unificación, mezclar dos estilos de "contenedor de control"
 * en la misma página se ve incoherente.
 */
.report-controls {
    background: #fff;
    border: 1px solid #E5EAF0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}
.form-error {
    background: #fee2e2;
    color: #b91c1c;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
}

/* ─── Botones ─── */
.btn-primary {
    width: 100%;
    background: #00BB94;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-top: 8px;
}
.btn-primary:hover:not([disabled]) { background: #009B7A; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.btn-secondary:hover:not(:disabled) { background: #f9fafb; }
.btn-secondary:disabled { opacity: .5; cursor: not-allowed; }

.btn-success, .btn-danger {
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 4px;
}
.btn-success { background: #10b981; }
.btn-success:hover { background: #059669; }
.btn-danger { background: #ef4444; }
.btn-danger:hover { background: #dc2626; }

.btn-link {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 13px;
    text-align: left;
    width: 100%;
    padding: 8px 0;
}
.btn-link:hover { color: #00BB94; }

/* Variante para acciones destructivas inline (tablas, formularios).
   Resetea el width/align/padding de .btn-link (pensado para sidebar) y
   aplica color de peligro. Combinar con .btn-link: class="btn-link btn-link-danger". */
.btn-link-danger {
    width: auto;
    text-align: inherit;
    padding: 6px 10px;
    border-radius: 6px;
    color: #b91c1c;
    cursor: pointer;
}
.btn-link-danger:hover { color: #7f1d1d; background: #fef2f2; }
.btn-link-danger:disabled { color: #9ca3af; background: transparent; cursor: not-allowed; }

/* ─── Layout ─── */
.layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: #1f2937;
    color: white;
    display: flex;
    flex-direction: column;
    padding: 24px 0;
}
.brand {
    padding: 0 20px 24px;
    border-bottom: 1px solid #374151;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
/* El :hover debe repetir el text-decoration: la regla global `a:hover { underline }`
   es mas especifica que `.brand` y le ganaba, subrayando el wordmark y "Portal admin".
   La marca es un enlace, pero no debe leerse como texto enlazado. */
.brand:hover { opacity: .9; text-decoration: none; }
.brand-logo {
    flex: 0 0 auto;
    display: inline-flex;
    line-height: 0;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
}
.brand-logo img {
    display: block;
    border-radius: 9px;
}
.brand-text {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.1;
}
.brand-name {
    display: block;
    height: 18px;
    width: auto;
}
.brand-sub {
    display: block;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

/* Chip persistente de la empresa activa en el sidebar. Clases prefijadas
   `tenant-chip-*` para no colisionar con `.tenant-name` que usa SelectTenant
   (lista de empresas en login multi-tenant, fondo claro). */
.tenant-chip {
    display: flex; align-items: center; gap: 10px;
    margin: 0 12px 16px;
    padding: 12px 14px;
    background: #374151;
    border-left: 3px solid #22D3C5;
    border-radius: 8px;
    overflow: hidden;
}
.tenant-chip-icon { font-size: 18px; flex-shrink: 0; }
/* Logo de la empresa en el lugar del ícono. Caja fija y chica: el sidebar mide 240px
   (~188px utiles dentro del chip), asi que el logo cede el ancho para que la razon
   social quede A SU LADO y no debajo. El tamaño que configura el operador se respeta
   donde hay espacio real (topbar del portal del trabajador y cabecera de la app). */
.tenant-chip-logo {
    flex-shrink: 0;
    max-width: 88px; max-height: 34px;
    width: auto; height: auto; object-fit: contain;
}
/* Con logo el espacio es escaso: se recorta el padding lateral y el gap para que la
   razon social conserve ancho legible en vez de truncarse a dos palabras. */
.tenant-chip:has(.tenant-chip-logo) { gap: 8px; padding: 10px 10px; }
.tenant-chip-text {
    display: flex; flex-direction: column; gap: 2px;
    min-width: 0; flex: 1;
}
.tenant-chip-name {
    font-size: 13px; font-weight: 700;
    color: #ffffff;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tenant-chip-rut {
    font-size: 11px;
    color: #cbd5e1;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav { flex: 1; padding: 0 12px; }
.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    color: #d1d5db;
    font-size: 14px;
    margin-bottom: 4px;
    transition: background 0.15s;
}
.nav-link:hover { background: #374151; text-decoration: none; }
.nav-link.active { background: #00BB94; color: white; }
.nav-icon { margin-right: 10px; opacity: 0.7; }

/* Grupo colapsable del nav: header con la misma forma que un .nav-link normal
   (mismo padding, color, hover) pero como <button> nativo. Los items hijos
   van indentados con padding-left, sin bordes verticales que ensucien el
   sidebar oscuro. El chevron es discreto y rota suavemente al expandir. */
.nav-group-header {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: #d1d5db;
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 4px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}
.nav-group-header:hover { background: #374151; color: #fff; }
.nav-group-header.expanded { color: #fff; }
.nav-group-label { flex: 1; }
.nav-group-chevron {
    margin-left: 8px;
    font-size: 10px;
    opacity: 0.55;
    transition: transform 0.18s ease;
    display: inline-block;
}
.nav-group-header.expanded .nav-group-chevron { transform: rotate(90deg); opacity: 0.9; }

/* Items del grupo: mismos estilos base que un .nav-link pero indentados.
   Sin border-left ni divisores — el padding sostiene la jerarquía visual. */
.nav-group-items {
    margin: 2px 0 6px 0;
}
.nav-link-sub {
    padding-left: 34px;        /* alinea ícono del hijo con el label del padre */
}
.nav-link-sub .nav-icon {
    opacity: 0.6;
}
.nav-link-sub.active .nav-icon { opacity: 1; }
.nav-badge {
    margin-left: auto;
    padding: 2px 8px;
    background: #EF4444;
    color: white;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.nav-link.active .nav-badge { background: #FFFFFF; color: #00BB94; }

.sidebar-foot { padding: 0 20px; border-top: 1px solid #374151; padding-top: 16px; }

.content { padding: 32px 40px; overflow-y: auto; }

/* ─── Pages ─── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}
.page-header h1 { margin: 0 0 6px; font-size: 24px; }
.page-sub { margin: 0; color: #6b7280; font-size: 13px; max-width: 600px; }

/* ── Responsivo: drawer móvil + ajustes de contenido ──────────────────────
   En desktop el sidebar es columna fija (grid). En pantallas chicas se vuelve
   un drawer off-canvas controlado por la hamburguesa del topbar móvil. */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }
.hamburger {
    background: transparent; border: none; color: #fff;
    font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px;
}
.mobile-brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.mobile-brand:hover { text-decoration: none; }  /* mismo motivo que .brand:hover */
.mobile-brand img { border-radius: 6px; }
.mobile-wordmark { height: 16px; width: auto; border-radius: 0 !important; }

/* Contenedor de tablas anchas: scroll horizontal en vez de romper el layout. */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 900px) {
    /* minmax(0,1fr) (no "1fr"): permite que la columna se encoja al ancho del viewport.
       Con "1fr" el min-width auto de los items deja que un hijo ancho (tabla, texto largo)
       estire la columna y con ella el topbar → se veía "muy ancho". min-width:0 en los
       items refuerza el mismo objetivo. Cualquier contenido ancho ahora hace scroll
       dentro de .content en vez de estirar el layout. */
    /* auto 1fr: la fila del topbar mide su alto natural y el CONTENIDO absorbe el resto del
       viewport. Sin esto, el grid (min-height:100vh) estira las filas automáticas por igual
       y el topbar oscuro se agranda enorme mientras la página carga (poco contenido). */
    .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
    /* Alto natural (padding + contenido). El salto de alto al cargar lo evita el width/height
       del wordmark en el markup (el navegador reserva el espacio antes de aplicar el CSS);
       max-height acota cualquier imagen. NO forzar height fijo: dejaba la barra más alta que
       su contenido y se veía un espacio de más bajo la barra. */
    .mobile-topbar {
        display: flex; align-items: center; gap: 12px;
        background: #1f2937; color: #fff; padding: 10px 14px;
        position: sticky; top: 0; z-index: 30;
        min-width: 0;
    }
    .mobile-topbar img { max-height: 24px; width: auto; }
    .content { min-width: 0; overflow-x: auto; }
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; width: 264px;
        transform: translateX(-100%); transition: transform .22s ease;
        z-index: 50; overflow-y: auto;
    }
    .layout.sidebar-open .sidebar {
        transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.5);
    }
    .layout.sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0;
        background: rgba(0,0,0,.45); z-index: 40;
    }
    .content { padding: 16px; }
    /* Encabezado compacto en móvil: en columna, el subtítulo largo (p. ej.
       Privacidad, Importaciones) estiraba el header y se veía "muy alto"
       comparado con el dashboard. Reducimos tipografías/espaciado y limitamos
       el subtítulo a 2 líneas para que la altura sea uniforme en todas las
       páginas. El texto completo sigue disponible en desktop. */
    .page-header { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 16px; }
    .page-header h1 { font-size: 20px; margin-bottom: 2px; }
    .page-sub {
        font-size: 12px; line-height: 1.4;
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Tablas normales (sin .data-cards): scroll horizontal dentro del contenedor. */
    .table-scroll .data-table:not(.data-cards) { min-width: 760px; }
}

/* Modo tarjeta para tablas densas (.data-cards). Se activa ANTES que el drawer
   (1200px vs 900px) porque el sidebar de 240px le quita ancho a la tabla: a
   <=1200px ya no cabe una tabla de 6 columnas + acciones. Cada fila se vuelve
   una tarjeta apilada → la columna Acciones nunca se va fuera de vista ni aparece
   scroll horizontal. El label de cada dato viene de data-label. */
@media (max-width: 1200px) {
    /* Prefijo .data-table.data-cards (especificidad 0,2,x) para GANARLE a las
       reglas base .data-table (0,1,x) que están más abajo en el archivo; si no,
       la tabla conserva su fondo blanco/sombra y los huecos entre tarjetas se ven
       blancos con los bordes flotando. */
    .data-table.data-cards,
    .data-table.data-cards tbody,
    .data-table.data-cards tr { display: block; width: auto; }
    /* Tabla transparente: el fondo gris de la página separa las tarjetas. */
    .data-table.data-cards { min-width: 0; background: transparent; box-shadow: none; border-radius: 0; overflow: visible; }
    .data-table.data-cards thead { display: none; }
    .data-table.data-cards tr {
        background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
        padding: 12px 14px; margin-bottom: 12px;
        box-shadow: 0 1px 2px rgba(0,0,0,.04);
    }
    .data-table.data-cards td { display: block; border: none; padding: 3px 0; text-align: left; }
    .data-table.data-cards td::before {
        content: attr(data-label); display: block;
        font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
        color: #94a3b8; font-weight: 600; margin-bottom: 2px;
    }
    .data-table.data-cards td.actions-cell {
        display: flex; flex-wrap: wrap; gap: .35rem;
        padding-top: 10px; border-top: 1px solid #f1f5f9; margin-top: 6px;
    }
    .data-table.data-cards td.actions-cell::before { display: none; }
    /* Sin acciones en la fila (ej. historial no-aprobado): no dejar el separador vacío. */
    .data-table.data-cards td.actions-cell:empty { display: none; }
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}
.auto-refresh-hint {
    color: #9ca3af;
    font-size: 11px;
    user-select: none;
}

.loading, .empty {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}
/* Spinner animado antes del texto del .loading. Las páginas usan
   <div class="loading">Cargando...</div>; el ::before agrega el spinner
   sin tocar el markup de cada página. */
.loading::before {
    content: "";
    display: block;
    width: 36px;
    height: 36px;
    margin: 0 auto 16px;
    border: 3px solid #e5e7eb;
    border-top-color: #00BB94;   /* primario de la marca */
    border-radius: 50%;
    animation: rhp-spin 0.7s linear infinite;
}
@keyframes rhp-spin {
    to { transform: rotate(360deg); }
}
/* Respeta usuarios con "reducir movimiento" activado: en vez de girar,
   atenuamos el spinner para no marear (accesibilidad). */
@media (prefers-reduced-motion: reduce) {
    .loading::before { animation: none; opacity: .5; }
}
.empty-icon {
    display: inline-block;
    width: 48px;
    height: 48px;
    line-height: 48px;
    border-radius: 50%;
    background: #d1fae5;
    color: #10b981;
    font-size: 24px;
    margin-bottom: 12px;
}

/* ─── Tables ─── */
.data-table {
    width: 100%;
    background: white;
    border-radius: 12px;
    border-collapse: collapse;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    overflow: hidden;
}
.data-table th {
    text-align: left;
    padding: 12px 16px;
    background: #f9fafb;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e5e7eb;
}
/* El encabezado debe alinearse igual que su dato: sin esto, "text-align: left" de
   .data-table th gana por especificidad sobre .text-right/.text-center y el titulo
   numerico queda corrido respecto de la columna (dato a la derecha, titulo a la izquierda). */
.data-table th.text-right { text-align: right; }
.data-table th.text-center { text-align: center; }
.data-table td {
    padding: 14px 16px;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: top;
}
.data-table tr:last-child td { border-bottom: none; }
.actions-col, .actions-cell { white-space: nowrap; text-align: right; }
.reason-cell { color: #b91c1c; font-style: italic; max-width: 300px; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.tag-success { background: #d1fae5; color: #065f46; }
.tag-danger { background: #fee2e2; color: #991b1b; }
.tag-info { background: #dbeafe; color: #1e40af; }
.tag-warning { background: #fef3c7; color: #92400e; }

.message {
    margin-top: 16px;
    padding: 12px 16px;
    background: #eff6ff;
    color: #1e40af;
    border-radius: 8px;
    font-size: 13px;
}

/* ─── Tenant list ─── */
.tenant-list { display: flex; flex-direction: column; gap: 8px; }
.tenant-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px 16px;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
}
.tenant-card:hover:not([disabled]) {
    border-color: #00BB94;
    background: #f0f9ff;
}
.tenant-card:disabled { opacity: 0.6; cursor: not-allowed; }
.tenant-name { font-weight: 600; font-size: 15px; color: #1f2937; }
.tenant-rut { font-size: 12px; color: #6b7280; margin-top: 2px; }

/* ─── Modal ─── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}
.modal-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    padding: 24px;
    width: 100%;
    max-width: 500px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}
.modal-title { margin: 0 0 4px; font-size: 18px; }
.modal-sub { margin: 0 0 16px; color: #6b7280; font-size: 13px; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
.modal-actions .btn-danger { padding: 8px 16px; font-size: 13px; }
.modal-actions .btn-secondary { padding: 8px 16px; }

/* ─── Botones de acción de tabla (btn-action variants) ─────────────────
   Pills outlined sobre fondo tinted; cada intent (neutral/info/success/
   create/danger) tiene su tono coherente con el resto del portal. Usados
   en tablas como /equipo, /encuestas, /trabajador/{id}/documentos. Vivían
   en el <style> de TeamSetup.razor pero ese sólo carga cuando esa página
   se monta — al promoverlos acá quedan disponibles globalmente. */
.btn-action {
    padding: 5px 11px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    background: transparent;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease;
    line-height: 1.2;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-action:disabled { opacity: .5; cursor: not-allowed; }
/* Íconos SVG dentro de botones: heredan el color del texto (stroke=currentColor). */
.btn-action svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-secondary svg, .btn-primary svg, .btn-danger svg, .btn-success svg {
    width: 14px; height: 14px; vertical-align: -2px; margin-right: 5px;
}
/* Los botones-enlace (<a class="btn-*">) no deben heredar el subrayado de a:hover. */
a.btn-secondary:hover, a.btn-primary:hover { text-decoration: none; }
/* Los .btn-action que son <a> (ej. "Ver") heredarían el subrayado del
   a:hover global (línea 12). Esta regla lo neutraliza: .btn-action:hover
   (0,2,0) gana sobre a:hover (0,1,1) por especificidad, sin !important. */
.btn-action:hover { text-decoration: none; }

.btn-action-neutral { color: #475569; border-color: #cbd5e1; background: #f8fafc; }
.btn-action-neutral:hover:not(:disabled) { background: #f1f5f9; border-color: #94a3b8; }

.btn-action-info { color: #1e40af; border-color: #bfdbfe; background: #eff6ff; }
.btn-action-info:hover:not(:disabled) { background: #dbeafe; border-color: #93c5fd; }

.btn-action-success { color: #0f766e; border-color: #99f6e4; background: #f0fdfa; }
.btn-action-success:hover:not(:disabled) { background: #ccfbf1; border-color: #5eead4; }

.btn-action-create { color: #b45309; border-color: #fde68a; background: #fffbeb; }
.btn-action-create:hover:not(:disabled) { background: #fef3c7; border-color: #fcd34d; }

.btn-action-danger { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.btn-action-danger:hover:not(:disabled) { background: #fee2e2; border-color: #fca5a5; }

/* Grid de acciones en la celda — usado en /equipo y /encuestas. */
.actions-cell { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.form-group small { display: block; color: #6b7280; font-size: 11px; margin-top: 4px; }
textarea.form-input { resize: vertical; font-family: inherit; }

/* ─── Dashboard ─── */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.metric-card {
    display: block;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    border-left: 4px solid #00BB94;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
}
a.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    text-decoration: none;
}
.metric-card.metric-warn { border-left-color: #f59e0b; }
.metric-card.metric-danger { border-left-color: #ef4444; }
.metric-card.metric-primary { border-left-color: #00BB94; }
.metric-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.metric-value {
    font-size: 36px;
    font-weight: 700;
    margin: 8px 0 4px;
    color: #1f2937;
}
.metric-foot { font-size: 12px; color: #6b7280; }

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 32px 0 12px;
}
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}
.action-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: white;
    border-radius: 10px;
    padding: 16px 20px;
    border: 1px solid #e5e7eb;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
}
.action-card:hover {
    border-color: #00BB94;
    background: #f0f9ff;
    text-decoration: none;
}
.action-icon {
    font-size: 22px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #dbeafe;
    color: #00BB94;
}
.action-title { font-size: 14px; font-weight: 600; }
.action-sub { font-size: 12px; color: #6b7280; margin-top: 2px; }

/* ─── Forms extra ─── */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.modal-large { max-width: 640px; }
.modal-confirm { width: auto; padding: 10px 20px; margin-top: 0; }

.filters-bar {
    margin-bottom: 16px;
    font-size: 13px;
    color: #6b7280;
    display: flex;
    gap: 16px;
    align-items: center;
}
.filters-bar label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* Header con botones inline.
   Solo aplica cuando el page-header tiene 2+ divs hijos (típicamente título + acciones
   a la derecha). El :not(:first-child) evita que la regla afecte a páginas con un solo
   div hijo (título + subtítulo sin botones) — sin esto, el flex ponía el h1 y el
   page-sub uno al lado del otro. */
.page-header > div:last-child:not(:first-child) { display: flex; align-items: center; }

/* ─── Info cards (declaración) ─── */
.card-stack { display: flex; flex-direction: column; gap: 14px; }
.info-card {
    background: white;
    border-radius: 12px;
    padding: 18px 22px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.info-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.info-value {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}
.info-sub { font-size: 13px; color: #6b7280; margin-top: 4px; }
.info-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-top: 6px;
    color: #374151;
}
.text-success { color: #10b981; }
.text-warn { color: #f59e0b; }

/* ─── Integraciones (config de conector) ─── */
.int-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 4px;
}
.int-input:focus { outline: none; border-color: #00BB94; box-shadow: 0 0 0 2px rgba(0,187,148,0.15); }
.int-mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; resize: vertical; }
.int-example { background: #0d1117; color: #c9d1d9; padding: 12px; border-radius: 6px; overflow-x: auto; margin-top: 6px; white-space: pre-wrap; }
.int-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: #374151; margin-top: 8px; }

/* ─── Filter grid (fallas) ─── */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
    padding: 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.filter-grid .form-group { margin-bottom: 0; }

.table-meta {
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 8px;
}
.tag-warn { background: #fef3c7; color: #92400e; }
.tag-default { background: #e5e7eb; color: #374151; }

/* ─── Tabs (TeamRequests: Pendientes / Historial) ─── */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    margin: 16px 0 16px;
}
.tab {
    background: transparent;
    border: none;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: #0D1B3D; }
.tab-active { color: #00BB94; border-bottom-color: #00BB94; }
.tab-count {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    background: #E6F7F5;
    color: #00BB94;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}
.tab-filter {
    margin-left: auto;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    color: #374151;
}

/* ─── Importaciones ─── */
.page-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.back-link {
    display: inline-block;
    color: #64748b;
    font-size: 13px;
    text-decoration: none;
    margin-bottom: 4px;
}
.back-link:hover { color: #00BB94; text-decoration: underline; }
.text-danger { color: #b91c1c; font-weight: 600; }
.empty-icon {
    display: block;
    font-size: 32px;
    color: #cbd5e1;
    text-align: center;
    margin-bottom: 8px;
}
.warn-text {
    display: block;
    color: #92400e;
    background: #fef3c7;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    margin-top: 6px;
    line-height: 1.4;
}
.code-pill {
    display: inline-block;
    background: #f1f5f9;
    color: #0f172a;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 600;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}

/* ─── Reportes (Fase 0b) ─── */

.report-section {
    margin-bottom: 36px;
}
.report-section h2 {
    margin: 0 0 4px;
    font-size: 18px;
    color: #0D1B3D;
}
.report-section .section-sub {
    margin: 0 0 16px;
    font-size: 13px;
    color: #64748B;
    max-width: 700px;
}
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.report-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #E5EAF0;
    overflow: hidden;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.report-card.card-available:hover {
    border-color: #00BB94;
    box-shadow: 0 4px 14px rgba(0, 187, 148, 0.12);
}
.report-card.card-pending {
    opacity: 0.65;
    background: #F8FAFC;
}
.report-card-link, .report-card-disabled {
    display: block;
    padding: 16px;
    color: inherit;
}
/* El portal tiene a:hover { text-decoration: underline } global que se cuela
   en el hover del card y subraya el título "encima del box". Forzamos none
   en todos los estados del link y en cualquier descendiente (h3/p). Mismo
   patrón que se usó en .kpi-card del dashboard. */
.report-card-link,
.report-card-link:link,
.report-card-link:visited,
.report-card-link:hover,
.report-card-link:focus,
.report-card-link:active,
.report-card-link *,
.report-card-link *:hover { text-decoration: none !important; }
.report-card h3 {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 600;
    color: #0D1B3D;
    display: flex;
    align-items: center;
    gap: 8px;
}
.report-card p {
    margin: 0;
    font-size: 12px;
    color: #64748B;
    line-height: 1.45;
}
.badge-pending {
    font-size: 10px;
    background: #FEF3C7;
    color: #92400E;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 500;
}

/* Filtros de reporte */
.report-filters {
    background: #fff;
    border: 1px solid #E5EAF0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}
.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.filter-group label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #64748B;
    font-weight: 600;
}
.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}
/* Los botones de la toolbar NO deben estirarse a todo el ancho: .btn-primary
   trae width:100% (pensado para formularios/modales), lo que en la barra los
   pone uno por línea. Acá van inline, de ancho automático. */
.filter-actions .btn-primary,
.filter-actions .btn-secondary { width: auto; margin-top: 0; }
/* Al envolver en pantallas medianas/chicas, alinear a la izquierda: el
   flex-end escalonado de botones envueltos se ve desparejo. */
@media (max-width: 1200px) {
    .filter-actions { justify-content: flex-start; }
}

/* Toolbar de export */
.report-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #F8FAFC;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
}
.toolbar-info {
    font-size: 12px;
    color: #64748B;
}
.row-count {
    font-weight: 500;
}
.toolbar-actions {
    display: flex;
    gap: 8px;
}
.toolbar-actions .btn-secondary {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.toolbar-actions .icon {
    font-size: 14px;
}
.toolbar-actions button.btn-secondary {
    cursor: pointer;
    border: 1px solid #CBD5E1;
    background: #FFFFFF;
    color: #334155;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    transition: background-color 0.15s ease;
}
.toolbar-actions button.btn-secondary:hover:not(:disabled) {
    background: #F1F5F9;
}
.toolbar-actions button.btn-secondary:disabled {
    cursor: progress;
    opacity: 0.65;
}
.toolbar-error {
    display: inline-block;
    margin-left: 12px;
    color: #B91C1C;
    font-weight: 500;
}
.spinner-inline {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 6px;
    border: 2px solid #CBD5E1;
    border-top-color: #475569;
    border-radius: 50%;
    animation: spin-inline 0.8s linear infinite;
    vertical-align: -2px;
}
@keyframes spin-inline {
    to { transform: rotate(360deg); }
}

/* KPI cards (dashboard de asistencia) */
.kpi-card {
    background: #fff;
    border-radius: 12px;
    padding: 18px;
    border: 1px solid #E5EAF0;
    border-top: 3px solid #00BB94;
}
.kpi-card.kpi-warning { border-top-color: #F59E0B; }
.kpi-card.kpi-danger  { border-top-color: #EF4444; }
.kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748B;
    margin-bottom: 8px;
}
.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: #0D1B3D;
    line-height: 1.1;
}
.kpi-unit {
    font-size: 14px;
    font-weight: 500;
    color: #64748B;
    margin-left: 4px;
}
.kpi-trend {
    font-size: 12px;
    margin-top: 6px;
}
.kpi-trend.trend-up { color: #10B981; }
.kpi-trend.trend-down { color: #EF4444; }
.kpi-trend.trend-neutral { color: #64748B; }
.kpi-caption {
    font-size: 11px;
    color: #94A3B8;
    margin-top: 4px;
}

/* Resumen pills arriba de tablas de reportes */
.summary-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.status-pill {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}
.text-right {
    text-align: right;
}
.text-center { text-align: center; }
.text-danger { color: #b91c1c; font-weight: 600; }
.text-warning { color: #92400e; font-weight: 600; }
.text-success { color: #047857; font-weight: 600; }
.muted { color: #94A3B8; }

/* Dashboard de KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.kpi-meta {
    background: #F8FAFC;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    color: #64748B;
    margin-bottom: 16px;
}

/* ─── Reconexión del circuito Blazor ─── */
.reconnect-modal { display: none; }
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex; align-items: center; justify-content: center;
    position: fixed; inset: 0; z-index: 1000; background: rgba(13, 27, 61, 0.55);
}
.reconnect-box { background:#fff; color:#103A5F; border-radius:12px; padding:16px 22px;
    font-size:14px; font-weight:600; box-shadow:0 16px 40px rgba(0,0,0,.35); }
