:root {
    --bg-main: #0E1117;
    --bg-panel: #161B22;
    --bg-elevated: #1C2128;
    --bg-soft: #111827;

    --border-color: #2A2F36;
    --border-soft: rgba(255, 255, 255, 0.06);

    --text-primary: #E6EDF3;
    --text-secondary: #8B949E;
    --text-muted: #94A3B8;

    --color-primary: #3FA36B;
    --color-primary-hover: #2E7D57;
    --color-success: #3FA36B;
    --color-warning: #D29922;
    --color-danger: #F85149;
    --color-info: #60A5FA;

    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.24);
    --shadow-strong: 0 14px 34px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
}

.hidden {
    display: none !important;
}

/* ============================= */
/* ELEMENTOS BASE */
/* ============================= */

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    margin-top: 0;
}

p {
    color: var(--text-primary);
}

a {
    color: inherit;
}

input,
select,
textarea,
button {
    font: inherit;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="email"],
select,
textarea {
    height: 40px;
    width: 100%;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-soft);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

textarea {
    min-height: 100px;
    padding: 10px 12px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-secondary);
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(63, 163, 107, 0.9);
    box-shadow: 0 0 0 3px rgba(63, 163, 107, 0.16);
}

input[type="checkbox"] {
    accent-color: var(--color-primary);
}

button {
    border: 1px solid transparent;
    border-radius: 8px;
    min-height: 38px;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

/* ============================= */
/* LAYOUT PRINCIPAL */
/* ============================= */

.app-layout {
    display: flex;
    height: 100vh;
    min-height: 100vh;
}

.main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.content {
    flex: 1;
    width: 100%;
    min-width: 0;
    max-width: none;
    padding: var(--spacing-xl);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ============================= */
/* SIDEBAR */
/* ============================= */

.sidebar {
    width: 228px;
    flex: 0 0 228px;
    background: linear-gradient(180deg, var(--bg-panel) 0%, #131A23 100%);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: var(--spacing-lg) var(--spacing-md);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.28);
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-logo {
    width: 100%;
    max-width: 170px;
    height: auto;
    display: block;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 12px;
    margin-bottom: var(--spacing-sm);
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: 0.2s ease;
    min-height: 44px;
}

.sidebar nav a:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    transform: translateX(3px);
}

.sidebar nav a.active {
    background: rgba(63, 163, 107, 0.18);
    color: #ffffff;
    border: 1px solid rgba(63, 163, 107, 0.34);
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.10);
    margin: 16px 0;
}

.sidebar nav a span {
    width: 22px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    margin-right: 6px;
}

.logout-btn {
    margin-top: auto;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 8px;
}

.logout-btn:hover {
    background: rgba(248, 81, 73, 0.18);
    border-color: rgba(248, 81, 73, 0.5);
    color: white;
}

/* ============================= */
/* TOPBAR */
/* ============================= */

.topbar {
    height: 72px;
    background: linear-gradient(90deg, var(--bg-panel) 0%, rgba(22, 27, 34, 0.94) 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-xl);
    gap: 16px;
}

.topbar-left {
    min-width: 0;
}

.topbar-left h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(63, 163, 107, 0.12);
    color: var(--color-success);
    border: 1px solid rgba(63, 163, 107, 0.28);
    font-size: 0.95rem;
    font-weight: 600;
}

/* ============================= */
/* SECCIONES */
/* ============================= */

.section {
    display: none;
}

.section.active {
    display: block;
}

.section h2 {
    margin-bottom: 18px;
    font-size: 1.2rem;
}

/* ============================= */
/* DASHBOARD */
/* ============================= */

.dashboard-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) 320px 320px;
    grid-template-rows: auto auto;
    gap: var(--spacing-xl);
    margin-top: var(--spacing-lg);
    width: 100%;
}

.dashboard-layout h2,
.dashboard-layout h3 {
    margin-top: 0;
}

.dashboard-metrics {
    grid-column: 1;
    grid-row: 1 / 3;
    min-width: 0;
}

.dashboard-alerts {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
}

.dashboard-activity {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
}

.dashboard-working {
    grid-column: 3;
    grid-row: 1 / 3;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    max-height: 420px;
    overflow-y: auto;
    min-width: 0;
}

#dashboardStats {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
}

.stat-card {
    background: linear-gradient(145deg, var(--bg-panel), var(--bg-elevated));
    border: 1px solid var(--border-color);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    transition: 0.25s ease;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.stat-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--color-primary);
    opacity: 0.7;
}

.stat-card.success::after {
    background: var(--color-success);
}

.stat-card.warning::after {
    background: var(--color-warning);
}

.stat-card.danger::after {
    background: var(--color-danger);
}

.stat-card:hover {
    border-color: rgba(63, 163, 107, 0.55);
    box-shadow: var(--shadow-strong);
}

.stat-card h3 {
    margin: 0 0 var(--spacing-sm);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.stat-card p {
    margin: 0;
    font-size: 40px;
    font-weight: 700;
    letter-spacing: 1px;
}

.stat-card.clickable {
    cursor: pointer;
}

/* ============================= */
/* CONTENEDORES COMUNES */
/* ============================= */

.card,
.auditoria-card,
#moduloInformes .card {
    background: linear-gradient(180deg, rgba(28, 33, 40, 0.98) 0%, rgba(22, 27, 34, 0.98) 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
}

.card {
    padding: 20px;
}

.page-card {
    background: linear-gradient(180deg, rgba(28, 33, 40, 0.98) 0%, rgba(22, 27, 34, 0.98) 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-soft);
}

/* ============================= */
/* TABLAS */
/* ============================= */

.table-wrapper {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

table,
.tabla {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    margin-top: var(--spacing-md);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

th,
td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
}

th {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

tbody tr:hover td {
    background: rgba(255, 255, 255, 0.025);
}

td .acciones-tabla,
td .table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================= */
/* FORMULARIOS Y FILTROS */
/* ============================= */

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    font-size: 13px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
}

.form-inline,
.form-row,
.logs-filtros,
.logs-search,
.row,
.row-botones {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.logs-search {
    margin-bottom: 10px;
}

.logs-filtros {
    margin-bottom: 12px;
}

.form-inline input[type="text"],
.form-inline input[type="number"],
.form-inline input[type="date"],
.form-inline select,
.logs-search input,
.logs-filtros input,
.logs-filtros select,
.row input,
.row select {
    width: auto;
    min-width: 140px;
}

.form-inline label,
.checkbox-group label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 14px;
    min-height: 40px;
}

.form-error,
.mensaje-error {
    color: var(--color-danger);
    font-size: 13px;
}

.mensaje-info {
    color: var(--color-info);
    font-size: 13px;
}

/* ============================= */
/* BOTONES */
/* ============================= */

.btn-primary,
#btnNuevoEmpleado,
#btnNuevoTipoAusencia,
#moduloInformes button,
.login-btn,
.password-card button {
    background: var(--color-primary);
    border: 1px solid transparent;
    color: white;
}

.btn-primary:hover,
#btnNuevoEmpleado:hover,
#btnNuevoTipoAusencia:hover,
#moduloInformes button:hover,
.login-btn:hover,
.password-card button:hover {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
}

.btn-sm {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 0.88rem;
}

.btn-incidencia {
    background: rgba(210, 153, 34, 0.18);
    border: 1px solid rgba(210, 153, 34, 0.4);
    color: #f8d778;
    padding: 8px 12px;
    border-radius: 8px;
}

.btn-incidencia:hover {
    background: rgba(210, 153, 34, 0.28);
}

/* Botones usados por tabla */
.btn-ver,
.btn-editar,
.btn-toggle,
.btn-reset {
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 8px;
}

.btn-ver,
.btn-editar {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-ver:hover,
.btn-editar:hover {
    background: var(--bg-elevated);
}

.btn-toggle {
    background: rgba(63, 163, 107, 0.18);
    border: 1px solid rgba(63, 163, 107, 0.36);
    color: #D7F5E2;
}

.btn-toggle:hover {
    background: rgba(63, 163, 107, 0.28);
}

.btn-reset {
    background: rgba(210, 153, 34, 0.16);
    border: 1px solid rgba(210, 153, 34, 0.35);
    color: #F0D58B;
}

.btn-reset:hover {
    background: rgba(210, 153, 34, 0.26);
}

/* ============================= */
/* EMPLEADOS */
/* ============================= */

.empleados-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
}

.empleados-contador {
    font-weight: 600;
    font-size: 14px;
}

.limite-alcanzado {
    color: var(--color-danger);
}

/* ============================= */
/* SWITCH */
/* ============================= */

.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
}

.switch input {
    display: none;
}

.slider {
    position: absolute;
    cursor: pointer;
    background-color: #374151;
    border-radius: 20px;
    inset: 0;
    transition: 0.3s;
}

.slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .slider {
    background-color: var(--color-success);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* ============================= */
/* MODALES */
/* ============================= */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-panel) 100%);
    width: 420px;
    max-width: 100%;
    border-radius: 14px;
    padding: 22px;
    color: white;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.42);
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    min-height: auto;
    padding: 0;
}

.modal-body {
    margin-bottom: 20px;
}

.modal-footer,
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* ============================= */
/* BADGES */
/* ============================= */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    font-size: 11px;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.3px;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset;
}

.badge-danger {
    background: rgba(248, 81, 73, 0.15);
    color: var(--color-danger);
    border: 1px solid rgba(248, 81, 73, 0.4);
}

.badge-warning {
    background: rgba(210, 153, 34, 0.15);
    color: var(--color-warning);
    border: 1px solid rgba(210, 153, 34, 0.4);
}

.badge-primary {
    background: rgba(63, 163, 107, 0.15);
    color: var(--color-primary);
    border: 1px solid rgba(63, 163, 107, 0.4);
}

.badge-success {
    background: rgba(63, 163, 107, 0.2);
    color: #dff7e8;
    border: 1px solid rgba(63, 163, 107, 0.4);
}

.badge-secondary {
    background: #374151;
    color: #fff;
}

.badge-activa {
    background: rgba(63, 163, 107, 0.18);
    color: #dff7e8;
    border: 1px solid rgba(63, 163, 107, 0.38);
}

.badge-inactiva {
    background: rgba(148, 163, 184, 0.14);
    color: #c7d2de;
    border: 1px solid rgba(148, 163, 184, 0.28);
}

.badge-jornada {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    background: rgba(248, 81, 73, 0.15);
    color: var(--color-danger);
    border: 1px solid rgba(248, 81, 73, 0.4);
}

/* ============================= */
/* LOGIN */
/* ============================= */

.login-wrapper {
    display: flex;
    min-height: 100vh;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at top, #0f172a, #020617);
    padding: 24px;
}

.login-card {
    width: 380px;
    max-width: 100%;
    background: #1e293b;
    padding: 40px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: 0 0 40px rgba(63, 163, 107, 0.12);
    animation: fadeIn 0.6s ease;
}

.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 28px;
    text-align: center;
}

.login-brand-logo {
    width: 100%;
    max-width: 300px;
    height: auto;
    display: block;
    margin-bottom: 16px;
}

.login-subtitle {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: #94a3b8;
}

.login-btn {
    width: 100%;
    padding: 12px;
    min-height: 44px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.6s linear infinite;
    margin-left: 8px;
}

/* ============================= */
/* INCIDENCIAS */
/* ============================= */

#incidenciasSection h2 {
    margin-bottom: var(--spacing-lg);
}

#modalCerrarJornada .modal-content {
    border-left: 4px solid var(--color-warning);
}

#modalCerrarJornada p {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 4px 0;
}

#horaSalidaManual {
    width: 100%;
}

/* ============================= */
/* FICHAJES / TIMELINE */
/* ============================= */

td.evento {
    font-weight: 500;
}

td.hora {
    font-family: monospace;
    font-size: 14px;
}

.timeline-row td {
    padding: 8px 12px 16px 12px;
    overflow-x: auto;
}

.timeline-jornada {
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0.95;
    min-width: 720px;
}

.timeline-bar {
    position: relative;
    flex: 1;
    min-width: 420px;
    height: 4px;
    background: #2b3a55;
    margin: 0 10px;
    border-radius: 999px;
}

.timeline-line {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: #60A5FA;
    border-radius: 999px;
    box-shadow: 0 0 8px rgba(96, 165, 250, 0.45);
}

.timeline-start,
.timeline-end {
    position: absolute;
    top: -3px;
    width: 10px;
    height: 10px;
    background: #60A5FA;
    border-radius: 50%;
}

.timeline-start {
    left: -1px;
}

.timeline-end {
    right: -1px;
}

.timeline-hora {
    font-size: 12px;
    color: #9aa4b2;
    font-family: monospace;
    white-space: nowrap;
}

.timeline-total {
    font-size: 12px;
    color: #9aa4b2;
    margin-top: 4px;
}

.timeline-pausa {
    position: absolute;
    top: -6px;
    transform: translateX(-50%);
    font-size: 14px;
    color: #f59e0b;
}

/* ============================= */
/* TRABAJANDO AHORA */
/* ============================= */

.trabajador-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 14px;
}

.trabajador-nombre {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trabajador-dot {
    width: 8px;
    height: 8px;
    background: var(--color-success);
    border-radius: 50%;
}

.trabajando-ahora-vacio {
    opacity: 0.6;
}

/* ============================= */
/* AUDITORÍA */
/* ============================= */

.auditoria-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px,1fr));
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.auditoria-card {
    padding: 20px;
}

.ok {
    color: #2ea043;
    font-weight: bold;
}

.error {
    color: #f85149;
    font-weight: bold;
}

/* ============================= */
/* LOGS */
/* ============================= */

.logs-integridad {
    margin: 10px 0 16px;
    font-weight: 600;
}

#tabla-logs {
    width: 100%;
    min-width: 1250px;
    border-collapse: collapse;
    table-layout: fixed;
}

#tabla-logs th,
#tabla-logs td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    word-break: break-word;
}

#tabla-logs th {
    background: rgba(255, 255, 255, 0.04);
    color: #e5e7eb;
    font-weight: 600;
}

#tabla-logs tbody tr {
    transition: background 0.15s ease;
    cursor: pointer;
    background: #111827;
    color: #e5e7eb;
}

#tabla-logs tbody tr:nth-child(even) {
    background: #0f172a;
}

#tabla-logs tbody tr:hover {
    background: #1f2937;
}

#tabla-logs tr td {
    border-left: none !important;
    box-shadow: none !important;
    outline: none !important;
}

#tabla-logs th:nth-child(1),
#tabla-logs td:nth-child(1) {
    width: 180px;
}

#tabla-logs th:nth-child(2),
#tabla-logs td:nth-child(2) {
    width: 110px;
}

#tabla-logs th:nth-child(3),
#tabla-logs td:nth-child(3) {
    width: 205px;
}

#tabla-logs th:nth-child(4),
#tabla-logs td:nth-child(4) {
    width: 190px;
}

#tabla-logs th:nth-child(5),
#tabla-logs td:nth-child(5) {
    width: 60px;
    text-align: center;
}

#tabla-logs th:nth-child(6),
#tabla-logs td:nth-child(6) {
    width: 320px;
}

#tabla-logs th:nth-child(7),
#tabla-logs td:nth-child(7) {
    width: 110px;
}

#tabla-logs th:nth-child(8),
#tabla-logs td:nth-child(8) {
    width: 110px;
}

#tabla-logs tr.log-login {
    background: rgba(59, 130, 246, 0.06);
}

#tabla-logs tr.log-login_fallido {
    background: rgba(239, 68, 68, 0.08);
}

#tabla-logs tr.log-logout {
    background: rgba(148, 163, 184, 0.06);
}

#tabla-logs tr.log-refresh_token {
    background: rgba(125, 211, 252, 0.06);
}

#tabla-logs tr.log-fichaje_entrada,
#tabla-logs tr.log-fichaje_salida,
#tabla-logs tr.log-fichaje_pausa,
#tabla-logs tr.log-fichaje_ausencia_inicio,
#tabla-logs tr.log-fichaje_ausencia_fin {
    background: rgba(16, 185, 129, 0.05);
}

#tabla-logs tr.log-tipo_ausencia_creado,
#tabla-logs tr.log-tipo_ausencia_editado,
#tabla-logs tr.log-tipo_ausencia_activado,
#tabla-logs tr.log-tipo_ausencia_desactivado {
    background: rgba(168, 85, 247, 0.06);
}

#detalleLog {
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 60vh;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 8px;
}

/* ============================= */
/* INFORMES */
/* ============================= */

#moduloInformes .card {
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 0 20px rgba(63, 163, 107, 0.08);
}

#moduloInformes h3 {
    margin-bottom: 15px;
    color: #fff;
}

#moduloInformes .row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#moduloInformes select,
#moduloInformes input {
    padding: 0 12px;
    background: #0f172a;
    border: 1px solid #334155;
    color: #fff;
    border-radius: 8px;
    min-height: 40px;
}

#moduloInformes button {
    min-height: 40px;
    padding: 10px 18px;
    border-radius: 8px;
}

.informe-resumen {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(160px,1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.resumen-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px 12px;
}

.resumen-card h4 {
    margin: 0;
    font-size: 12px;
    color: #9aa4b2;
    font-weight: 500;
}

.resumen-card p {
    margin: 3px 0 0 0;
    font-size: 18px;
    font-weight: 600;
    color: #e6edf3;
}

#moduloInformes .row-botones {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    align-items: center;
    flex-wrap: wrap;
}

#moduloInformes .row-botones button {
    width: auto;
    min-width: 150px;
    height: 40px;
}

#previewInforme {
    margin-top: 0;
    min-width: 0;
}

.informe-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.informe-filtros {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.informe-preview {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 15px;
    min-width: 0;
    max-height: 70vh;
    overflow: auto;
}

.informe-preview table,
#previewInforme table {
    width: 100%;
    min-width: 720px;
    margin-top: 0;
}

/* ============================= */
/* CAMBIO DE CONTRASEÑA */
/* ============================= */

.password-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    padding: 24px;
}

.password-card {
    background: #1e293b;
    padding: 40px;
    border-radius: 12px;
    width: 420px;
    max-width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    text-align: center;
    border: 1px solid var(--border-color);
}

.password-card h2 {
    color: #fff;
    margin-bottom: 10px;
}

.password-info {
    color: #94a3b8;
    font-size: 14px;
    margin-bottom: 25px;
}

.password-card input {
    width: 100%;
    margin-bottom: 12px;
}

.password-card button {
    width: 100%;
    padding: 12px;
}

.error {
    margin-top: 10px;
    color: #ef4444;
    font-size: 13px;
}

/* ============================= */
/* TIPOS DE AUSENCIA / TABLAS */
/* ============================= */

.acciones-tabla {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ============================= */
/* ANIMACIONES */
/* ============================= */

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-6px); }
    100% { transform: translateX(0); }
}

/* ============================= */
/* RESPONSIVE */
/* ============================= */

@media (max-width: 1280px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .dashboard-metrics,
    .dashboard-alerts,
    .dashboard-activity,
    .dashboard-working {
        grid-column: auto;
        grid-row: auto;
    }

    .dashboard-working {
        max-height: none;
    }
}

@media (max-width: 1024px) {
    .informe-layout {
        grid-template-columns: 1fr;
    }

    .informe-preview {
        max-height: none;
    }
}

@media (max-width: 900px) {
    .app-layout {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        flex: 0 0 auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .topbar {
        height: auto;
        min-height: 72px;
        padding: 14px 18px;
    }

    .content {
        padding: 20px;
    }

    .sidebar nav a:hover {
        transform: none;
    }
}

@media (max-width: 640px) {
    .content {
        padding: 16px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .empleados-header,
    .form-inline,
    .form-row,
    .logs-filtros,
    .row,
    .row-botones {
        flex-direction: column;
        align-items: stretch;
    }

    .form-inline input[type="text"],
    .form-inline input[type="number"],
    .form-inline input[type="date"],
    .form-inline select,
    .logs-search input,
    .logs-filtros input,
    .logs-filtros select,
    .row input,
    .row select {
        width: 100%;
        min-width: 0;
    }

    .modal-content {
        padding: 18px;
    }

    .login-card,
    .password-card {
        padding: 28px 22px;
    }
}

.toolbar-filtros {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    color: var(--text-primary);
}

.checkbox-inline input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.paginacion {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 14px;
    flex-wrap: wrap;
}

/* ============================= */
/* TOASTS */
/* ============================= */

.toast-container {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    min-width: 280px;
    max-width: 420px;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-panel) 100%);
    color: var(--text-primary);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.34);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    pointer-events: auto;
    animation: toastIn 0.22s ease;
}

.toast-success {
    border-color: rgba(63, 163, 107, 0.45);
}

.toast-error {
    border-color: rgba(248, 81, 73, 0.45);
}

.toast-info {
    border-color: rgba(96, 165, 250, 0.40);
}

.toast-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.toast-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: break-word;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    min-height: auto;
    padding: 0;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-primary);
    transform: none;
}

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-8px) translateX(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0) translateX(0);
    }
}

/* ============================= */
/* INFORMES PRO */
/* ============================= */

.informe-card-principal {
    padding: 22px;
}

.informe-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.informe-card-header h3 {
    margin: 0 0 6px 0;
}

.informe-card-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.informe-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.informe-filtros {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
}

.informe-botones {
    margin-top: 4px;
}

.informe-msg {
    min-height: 18px;
    margin-top: 4px;
}

.informe-preview-wrapper {
    min-width: 0;
}

.informe-preview-placeholder {
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    background: #0f172a;
    border: 1px dashed #334155;
    border-radius: 12px;
    padding: 24px;
}

.informe-preview-placeholder h4 {
    margin: 0;
    font-size: 1rem;
}

.informe-preview-placeholder p {
    margin: 0;
    max-width: 420px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.informe-preview-icon {
    font-size: 2rem;
    opacity: 0.9;
}

.informe-preview {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 18px;
    min-width: 0;
    max-height: 72vh;
    overflow: auto;
}

.informe-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.informe-preview-title h3 {
    margin: 0 0 6px 0;
    font-size: 1.1rem;
}

.informe-preview-title p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.informe-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.informe-meta-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 12px 14px;
}

.informe-meta-item .label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.informe-meta-item .value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.informe-resumen {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(160px,1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.resumen-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 12px 14px;
}

.resumen-card h4 {
    margin: 0;
    font-size: 12px;
    color: #9aa4b2;
    font-weight: 500;
}

.resumen-card p {
    margin: 5px 0 0 0;
    font-size: 20px;
    font-weight: 700;
    color: #e6edf3;
}

.informe-tabla-wrapper {
    overflow-x: auto;
}

.informe-tabla-wrapper table {
    margin-top: 0;
    min-width: 720px;
}

.informe-empresa-filtros {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: end;
}

.informe-empresa-filtros .form-group {
    min-width: 180px;
    margin-bottom: 0;
}

.informe-empresa-accion {
    min-width: 240px;
}

.dashboard-alert {
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-soft);
    font-weight: 600;
    line-height: 1.4;
}

.dashboard-alert.success {
    background: rgba(63, 163, 107, 0.12);
    border-color: rgba(63, 163, 107, 0.22);
    color: #dff7e8;
}

.dashboard-alert.danger {
    background: rgba(248, 81, 73, 0.12);
    border-color: rgba(248, 81, 73, 0.22);
    color: #ffd5d2;
}

@media (max-width: 1024px) {
    .informe-layout {
        grid-template-columns: 1fr;
    }

    .informe-preview {
        max-height: none;
    }
}

@media (max-width: 640px) {
    .informe-empresa-filtros {
        flex-direction: column;
        align-items: stretch;
    }

    .informe-empresa-filtros .form-group,
    .informe-empresa-accion {
        min-width: 0;
        width: 100%;
    }

    .informe-preview-header {
        flex-direction: column;
    }
}