:root {
    --rojo: #c0392b;
    --negro: #111111;
    --gris: #f4f4f5;
    --borde: #ddd;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: var(--gris);
    margin: 0;
    color: #222;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--negro);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 22px 16px;
    border-bottom: 1px solid rgba(255,255,255,.12);
    text-align: center;
}
.sidebar-brand img { height: 90px; }
.sidebar-brand span { font-weight: bold; letter-spacing: 1px; font-size: 12px; color: #ccc; }

.sidebar nav {
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    flex: 1;
}
.sidebar nav a {
    color: #ddd;
    text-decoration: none;
    padding: 12px 20px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .4px;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.activa {
    background: rgba(192,57,43,.18);
    border-left-color: var(--rojo);
    color: #fff;
    font-weight: 600;
}
.sidebar nav a.salir {
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,.12);
    color: #f1948a;
}

.content {
    flex: 1;
    min-width: 0;
    background:
        repeating-linear-gradient(45deg, rgba(17,17,17,.05) 0px, rgba(17,17,17,.05) 1px, transparent 1px, transparent 26px),
        repeating-linear-gradient(135deg, rgba(192,57,43,.05) 0px, rgba(192,57,43,.05) 1px, transparent 1px, transparent 26px),
        radial-gradient(ellipse at top left, rgba(192,57,43,.06) 0%, transparent 55%),
        var(--gris);
}

.container {
    max-width: 1200px;
    margin: 20px auto;
    background: #fff;
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

h1 { font-size: 20px; margin-top: 0; color: var(--negro); text-transform: uppercase; letter-spacing: .3px; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border: 1px solid var(--borde); padding: 6px 8px; text-align: left; }
th { background: var(--negro); color: #fff; text-transform: uppercase; letter-spacing: .3px; }

.btn {
    display: inline-block;
    background: var(--rojo);
    color: #fff;
    border: none;
    padding: 7px 14px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
}
.btn:hover { background: #a93226; }
.btn.secundario { background: #555; }
.btn.pequeno { padding: 3px 8px; font-size: 12px; }

.form-row { margin-bottom: 12px; }
.form-row label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 13px; }
.form-row input, .form-row select {
    width: 100%;
    padding: 7px;
    border: 1px solid var(--borde);
    border-radius: 4px;
    font-size: 14px;
}

.alerta { padding: 10px 14px; border-radius: 4px; margin-bottom: 14px; font-size: 14px; }
.alerta.error { background: #fdecea; color: #a93226; border: 1px solid #f5c6cb; }
.alerta.ok { background: #eafaf1; color: #1e824c; border: 1px solid #b7e4c7; }

.acciones { display: flex; gap: 8px; margin-bottom: 16px; }

.selector-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 3px solid #eee;
}
.selector-tabs a {
    padding: 10px 24px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .6px;
    font-size: 13px;
    text-decoration: none;
    color: #999;
    border-bottom: 3px solid transparent;
    margin-bottom: -3px;
}
.selector-tabs a:hover { color: var(--negro); }
.selector-tabs a.activo {
    color: var(--rojo);
    border-bottom-color: var(--rojo);
}

.login-split {
    min-height: 100vh;
    display: flex;
}

.login-izquierda {
    flex: 2.2;
    position: relative;
    overflow: hidden;
    background: url('../img/login-fondo.jpg') center center / cover no-repeat, #0a0a0a;
    border-right: 3px solid var(--rojo);
}
.login-izquierda::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(192,57,43,.3) 50%, transparent 100%);
    height: 220px;
    animation: escaneo 5s linear infinite;
    pointer-events: none;
}
@keyframes escaneo {
    0%   { transform: translateY(-220px); }
    100% { transform: translateY(100vh); }
}

.login-derecha {
    flex: 1;
    background: #111214;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.login-form-wrap { width: 100%; max-width: 360px; }
.login-form-wrap h1 {
    color: #fff;
    font-size: 28px;
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 4px;
}
.login-subtitulo { color: #9a9a9a; font-size: 14px; margin: 0 0 28px; }

.campo-icono { margin-bottom: 18px; }
.campo-icono label { display: block; margin-bottom: 6px; font-size: 13px; color: #ccc; font-weight: 600; }
.input-icono {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #1c1d20;
    border: 1px solid #34363a;
    border-radius: 6px;
    padding: 0 12px;
}
.input-icono:focus-within { border-color: var(--rojo); }
.input-icono svg { flex-shrink: 0; color: #888; }
.input-icono input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    padding: 12px 0;
    font-size: 14px;
}
.input-icono input::placeholder { color: #666; }
.toggle-password { background: none; border: none; cursor: pointer; color: #888; display: flex; padding: 4px; }
.toggle-password:hover { color: #ccc; }

.login-opciones { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; font-size: 13px; }
.recordarme { display: flex; align-items: center; gap: 6px; color: #ccc; cursor: pointer; }
.recordarme input { accent-color: var(--rojo); }
.olvido { color: var(--rojo); text-decoration: none; }
.olvido:hover { text-decoration: underline; }

.btn-login {
    width: 100%;
    background: var(--rojo);
    color: #fff;
    border: none;
    padding: 13px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}
.btn-login:hover { background: #a93226; }

.login-divisor { display: flex; align-items: center; gap: 10px; margin: 26px 0 16px; color: #555; }
.login-divisor::before, .login-divisor::after { content: ""; flex: 1; height: 1px; background: #34363a; }

.login-pie { text-align: center; }
.login-pie strong { display: block; color: #fff; font-size: 14px; letter-spacing: .5px; }
.login-pie span { display: block; color: #888; font-size: 12px; margin-top: 2px; }

.login-credito { text-align: center; margin-top: 20px; color: #666; font-size: 11px; }
.login-credito a { color: #888; }

@media (max-width: 800px) {
    .login-split { flex-direction: column; }
    .login-izquierda { clip-path: none; flex: 0 0 160px; }
    .login-derecha { flex: 1; }
}

.calendario-wrap { overflow-x: hidden; }
.calendario-wrap table { width: 100%; table-layout: fixed; font-size: 13px; }
.calendario-wrap th, .calendario-wrap td {
    padding: 7px 2px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.calendario-wrap th:first-child, .calendario-wrap td:first-child {
    width: 170px;
    text-align: left;
    white-space: normal;
}
.celda-turno {
    cursor: pointer;
    font-weight: bold;
    color: #fff;
    font-size: 14px;
}
th.celda-fin-semana { background: #34495e; color: #fff; }
th.celda-domingo { background: var(--rojo); color: #fff; }
td.celda-fin-semana { background: #fde2e2; color: #922b21; }
th.celda-feriado { background: #eb6834; color: #fff; cursor: help; }

.fila-jefe-turno > td:first-child {
    background: var(--negro);
    color: #fff;
    font-weight: 700;
    border-left: 4px solid var(--rojo);
}
.badge-jefe {
    display: inline-block;
    margin-left: 6px;
    background: var(--rojo);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .5px;
    padding: 2px 6px;
    border-radius: 3px;
    vertical-align: middle;
}

.filtros { display: flex; gap: 10px; align-items: end; margin-bottom: 16px; flex-wrap: wrap; }
.filtros .form-row { margin-bottom: 0; min-width: 160px; }

.subtitulo { font-size: 15px; text-transform: uppercase; letter-spacing: .3px; color: var(--negro); margin: 24px 0 12px; }

.leyenda-grafico { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; font-size: 12px; color: #555; }
.leyenda-grafico .leyenda-item { display: flex; align-items: center; gap: 6px; }
.leyenda-grafico i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }

.grid-empresas-chart {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}
.tarjeta-empresa-chart {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 14px 16px;
    background: #fff;
}
.tarjeta-empresa-chart h3 {
    font-size: 13px;
    margin: 0 0 12px;
    color: var(--negro);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.barra-fila { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.barra-fila:last-child { margin-bottom: 0; }
.barra-etiqueta { width: 58px; font-size: 11px; color: #666; flex-shrink: 0; }
.barra-pista { flex: 1; height: 14px; background: #f1f1ef; border-radius: 4px; overflow: hidden; }
.barra-relleno { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.barra-valor { width: 22px; text-align: right; font-size: 12px; font-weight: 700; color: var(--negro); flex-shrink: 0; }

.indicadores-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 12px 16px;
    margin: 0 0 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.indicador-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border-radius: 8px;
    background: #f8f9fa;
    border-left: 3px solid var(--ind-color, #0d6efd);
    flex: 1 1 140px;
    min-width: 130px;
}
.ind-icono {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--ind-color, #0d6efd);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    flex-shrink: 0;
}
.ind-datos { display: flex; flex-direction: column; line-height: 1.2; }
.ind-label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: #888; }
.ind-valor { font-size: 15px; font-weight: 800; color: #1a1a2e; }
.ind-fecha { font-size: 9.5px; color: #adb5bd; }

/* ===== Responsive ===== */

/* Tablas genéricas (empresas, personal, asignaciones, usuarios): scroll propio
   en vez de romper el ancho de la página en pantallas chicas. */
@media (max-width: 700px) {
    .container > table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Sidebar: de riel vertical fijo a barra superior horizontal en móvil/tablet. */
@media (max-width: 860px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    .sidebar-brand {
        flex-direction: row;
        padding: 10px 14px;
        border-bottom: none;
        border-right: 1px solid rgba(255,255,255,.12);
    }
    .sidebar-brand img { height: 36px; }
    .sidebar-brand span { font-size: 10px; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; padding: 4px; flex: 1; }
    .sidebar nav a { padding: 8px 10px; font-size: 10.5px; border-left: none; border-bottom: 3px solid transparent; }
    .sidebar nav a.activa { border-left: none; border-bottom-color: var(--rojo); }
    .sidebar nav a.salir { margin-top: 0; margin-left: auto; border-top: none; }

    .container { margin: 12px; padding: 14px; }
}

/* Calendario: en pantallas chicas, mejor scroll horizontal con columnas
   legibles que forzar 31 columnas ilegibles en el ancho de un celular. */
@media (max-width: 700px) {
    .calendario-wrap { overflow-x: auto; }
    .calendario-wrap table { table-layout: auto; width: auto; min-width: 900px; }
    .calendario-wrap th:first-child, .calendario-wrap td:first-child { width: auto; min-width: 140px; }
}

@media (max-width: 480px) {
    .login-derecha { padding: 24px 18px; }
    .login-form-wrap h1 { font-size: 22px; }
    .filtros { flex-direction: column; align-items: stretch; }
    .filtros .form-row { min-width: 0; }
}
