:root {
    --azul-900: #0a2c4d;
    --azul-800: #0d3d6b;
    --azul-700: #12507f;
    --azul-600: #1a6fb0;
    --azul-500: #1a86c9;
    --azul-400: #3ba0dd;
    --verde: #7bc043;
    --rojo: #e05a4d;
    --amarillo: #f0a500;
    --gris-bg: #eef2f7;
    --gris-borde: #dbe3ec;
    --texto: #1f2d3d;
    --texto-tenue: #6b7c93;
    --grad-brand: linear-gradient(160deg, #0a4a7a 0%, #1789b8 100%);
    --grad-btn: linear-gradient(135deg, #0d5a9e 0%, #1a86c9 100%);
    --grad-side: linear-gradient(180deg, #0b2b4a 0%, #123e63 100%);
}

* { box-sizing: border-box; }

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

/* ===================== LOGIN (pantalla dividida) ===================== */
.login-split { display: flex; min-height: 100vh; }

.login-brand {
    flex: 1;
    background: var(--grad-brand);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem 3.5rem;
}
.login-brand .logo {
    width: 72px; height: 72px; border-radius: 18px;
    background: rgba(255,255,255,.12);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; margin-bottom: 1.5rem;
}
.login-brand h1 { font-size: 3rem; margin: 0 0 .5rem; font-weight: 800; }
.login-brand .tagline { font-size: 1.1rem; opacity: .92; margin-bottom: 2.5rem; line-height: 1.5; }
.login-brand ul { list-style: none; padding: 0; margin: 0; }
.login-brand li { display: flex; align-items: center; gap: .6rem; margin: .8rem 0; font-size: 1.05rem; }
.login-brand li .chk { color: var(--verde); font-weight: 700; }

.login-panel {
    width: 460px;
    background: #fff;
    display: flex; flex-direction: column; justify-content: center;
    padding: 3rem;
}
.login-panel h2 { font-size: 2rem; margin: 0 0 .3rem; }
.login-panel .sub { color: var(--texto-tenue); margin-bottom: 2rem; }
.field-icon { position: relative; margin-bottom: 1rem; }
.field-icon .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--texto-tenue); }
.field-icon input {
    width: 100%; padding: .85rem 1rem .85rem 2.6rem;
    border: 1px solid var(--gris-borde); border-radius: 10px;
    background: #eef3f9; font-size: .95rem;
}
.field-icon input:focus { outline: none; border-color: var(--azul-500); background: #fff; }
.recordar { display: flex; align-items: center; gap: .5rem; margin: .3rem 0 1.3rem; color: var(--texto-tenue); font-size: .9rem; }

.btn-brand {
    width: 100%; padding: .9rem; border: 0; border-radius: 10px;
    background: var(--grad-btn); color: #fff; font-weight: 700; font-size: 1rem;
    cursor: pointer;
}
.btn-brand:disabled { opacity: .6; cursor: not-allowed; }
.login-foot { margin-top: 2rem; text-align: center; color: var(--texto-tenue); font-size: .82rem; }
.login-foot a { color: var(--azul-500); text-decoration: none; }
.login-error { color: var(--rojo); font-size: .85rem; margin-bottom: .8rem; }

/* ===================== LAYOUT ===================== */
.page { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px; flex-shrink: 0;
    background: var(--grad-side); color: #cfe0f0;
    display: flex; flex-direction: column;
}
.sidebar .brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.2rem 1.25rem; color: #fff; font-size: 1.35rem; font-weight: 800;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand .mark {
    width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.14);
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.sidebar nav { padding: .75rem 0; }
.nav-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .75rem 1.25rem; color: #cfe0f0; text-decoration: none; font-size: .95rem;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(26,134,201,.28); border-left-color: var(--azul-400); color: #fff; }

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: .9rem 1.75rem; background: #fff; border-bottom: 1px solid var(--gris-borde);
}
.topbar .titulo { font-size: 1.1rem; font-weight: 600; }
.user-chip {
    display: flex; align-items: center; gap: .6rem;
    background: #f2f6fb; border: 1px solid var(--gris-borde); border-radius: 30px;
    padding: .35rem .8rem;
}
.user-chip .avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--grad-btn);
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-chip .nombre { font-size: .85rem; line-height: 1.1; }
.user-chip .rol { font-size: .72rem; color: var(--texto-tenue); }
.btn-link { background: none; border: 0; color: var(--azul-500); cursor: pointer; text-decoration: underline; font-size: .85rem; }
.content { padding: 1.5rem 1.75rem; }

h1 { font-size: 1.7rem; margin: 0 0 1rem; }

/* ===================== KPI CARDS ===================== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi-card {
    background: #fff; border-radius: 14px; padding: 1.25rem 1.4rem;
    box-shadow: 0 1px 6px rgba(15,40,70,.07); display: flex; align-items: center; gap: 1rem;
}
.kpi-card .ico { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.kpi-card .ico.azul { background: #e3f0fb; color: var(--azul-600); }
.kpi-card .ico.verde { background: #e8f6dc; color: #5a9a2a; }
.kpi-card .ico.rojo { background: #fbe3e0; color: var(--rojo); }
.kpi-card .num { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.kpi-card .lbl { color: var(--texto-tenue); font-size: .85rem; }

/* ===================== PANELES / CHART ===================== */
.panel { background: #fff; border-radius: 14px; padding: 1.25rem 1.4rem; box-shadow: 0 1px 6px rgba(15,40,70,.07); margin-bottom: 1.25rem; }
.panel h3 { margin: 0 0 1rem; font-size: 1.05rem; }
.barchart { display: flex; align-items: flex-end; gap: 1.2rem; height: 180px; padding-top: .5rem; }
.barchart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .4rem; height: 100%; justify-content: flex-end; }
.barchart .bar { width: 60%; max-width: 70px; background: var(--grad-btn); border-radius: 6px 6px 0 0; min-height: 3px; }
.barchart .bar-lbl { font-size: .78rem; color: var(--texto-tenue); text-align: center; }
.barchart .bar-val { font-size: .8rem; font-weight: 700; }

/* ===================== TABLAS ===================== */
.tabla { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 6px rgba(15,40,70,.07); }
.tabla th, .tabla td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid #eef2f7; font-size: .9rem; }
.tabla th { background: #f4f8fc; font-weight: 600; color: var(--texto); }
.tabla .titulo { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vacio { text-align: center; color: var(--texto-tenue); padding: 1.5rem; }
.badge { padding: .2rem .6rem; border-radius: 20px; font-size: .8rem; font-weight: 600; }
.badge.on { background: #e0f5e2; color: #1f7a45; }
.badge.off { background: #fbe0dd; color: #a4342a; }

/* ===================== FORM / BOTONES ===================== */
.form-inline { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.filtro-label { color: var(--texto-tenue); font-size: .85rem; }
.dia-chk { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; padding: .2rem .5rem; border: 1px solid var(--gris-borde); border-radius: 8px; background: #fff; }

/* Explorador (treeview) */
.explorador { display: flex; gap: 1rem; align-items: flex-start; }
.tree { width: 300px; flex-shrink: 0; max-height: 78vh; overflow: auto; }
.tree-empresa { padding: .5rem .4rem; cursor: pointer; font-weight: 600; border-radius: 7px; display: flex; align-items: center; gap: .4rem; }
.tree-empresa:hover { background: #eef6fd; }
.tree-equipo { padding: .4rem .4rem .4rem 1.7rem; cursor: pointer; border-radius: 7px; display: flex; align-items: center; gap: .45rem; font-size: .9rem; }
.tree-equipo:hover { background: #eef6fd; }
.tree-equipo.selected { background: #dcecfb; font-weight: 600; }
.detail { flex: 1; min-width: 0; }
.dot-on { color: #2ecc71; }
.dot-off { color: var(--rojo); }

/* Barra de productividad */
.prod-bar { display: flex; height: 24px; border-radius: 7px; overflow: hidden; margin: .4rem 0 1rem; background: #eef2f7; }
.prod-seg { height: 100%; }
.prod-prod { background: #2ecc71; }
.prod-no { background: #e74c3c; }
.prod-neu { background: #4a4a4a; }
.prod-sin { background: #c9d2e3; }
.input { padding: .55rem .75rem; border: 1px solid var(--gris-borde); border-radius: 8px; font-size: .9rem; background: #fff; }
.input:focus { outline: none; border-color: var(--azul-500); }
.campo { margin-bottom: .8rem; display: flex; flex-direction: column; gap: .3rem; }
.btn-primary { background: var(--grad-btn); color: #fff; border: 0; padding: .55rem 1.1rem; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-danger { background: transparent; color: var(--rojo); border: 1px solid var(--rojo); padding: .35rem .7rem; border-radius: 8px; cursor: pointer; font-size: .8rem; }
.btn-outline { background: #fff; color: var(--azul-600); border: 1px solid var(--azul-500); padding: .5rem .9rem; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .85rem; }
.btn-outline:hover { background: #eef6fd; }

.clave-box { background: #fff9e6; border: 1px solid #f0d98a; padding: 1rem; border-radius: 10px; margin-bottom: 1rem; }
.clave { font-family: monospace; font-size: 1rem; background: var(--azul-900); color: #7ee787; padding: .5rem .8rem; border-radius: 8px; margin-top: .5rem; word-break: break-all; }

.paginador { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; justify-content: center; flex-wrap: wrap; }
.pag-info { color: var(--texto-tenue); font-size: .85rem; margin: 0 .5rem; }
.btn-pag { background: #fff; border: 1px solid var(--gris-borde); color: var(--texto); padding: .4rem .7rem; border-radius: 8px; cursor: pointer; font-size: .85rem; }
.btn-pag:hover:not(:disabled) { background: #eef6fd; border-color: var(--azul-500); }
.btn-pag:disabled { opacity: .45; cursor: not-allowed; }
