:root {
    --azul-oscuro: #0b2545;
    --azul: #13315c;
    --celeste: #3d9be9;
    --verde: #1fae6b;
    --rojo: #e0483e;
    --naranja: #d97a19;
    --gris-fondo: #f4f7fb;
    --gris-borde: #e3e8f0;
    --gris-texto: #5a6578;
    --blanco: #fff;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    background: var(--gris-fondo);
    color: var(--azul-oscuro);
}
a { color: var(--celeste); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: 240px; flex-shrink: 0;
    background: var(--azul-oscuro); color: #cfe0f5;
    display: flex; flex-direction: column;
    padding: 22px 0;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 22px 20px; }
.sidebar-logo {
    font-weight: 800; font-size: 1.2rem; color: #fff;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
    color: #cfe0f5; padding: 12px 22px; font-size: .92rem; font-weight: 500;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar-nav a.active { background: rgba(61,155,233,.15); border-left-color: var(--celeste); color: #fff; }

.user-menu { position: relative; }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--celeste); color: #04121a;
    border: none; cursor: pointer;
    font-weight: 800; font-size: .95rem;
    display: flex; align-items: center; justify-content: center;
}
.user-avatar:hover { filter: brightness(1.1); }
.user-dropdown {
    display: none;
    position: absolute; top: calc(100% + 10px); right: 0; z-index: 50;
    background: var(--blanco); color: var(--azul-oscuro);
    border-radius: 10px; box-shadow: 0 14px 34px rgba(0,0,0,.28);
    min-width: 180px; padding: 14px 0; text-align: left;
}
.user-dropdown.open { display: block; }
.user-dropdown-role { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gris-texto); padding: 0 16px; }
.user-dropdown-name { font-weight: 700; font-size: .92rem; padding: 2px 16px 10px; border-bottom: 1px solid var(--gris-borde); margin-bottom: 6px; }
.user-dropdown a { display: block; padding: 9px 16px; font-size: .88rem; color: var(--azul-oscuro); }
.user-dropdown a:hover { background: var(--gris-fondo); text-decoration: none; }
.user-dropdown a:last-child { color: var(--rojo); }

.content { flex: 1; padding: 32px 40px; max-width: 1100px; min-width: 0; }
.content-header h1 { font-size: 1.5rem; margin: 0 0 20px; }

.card-header-row {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 12px; margin-bottom: 18px;
}

.alerta { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: .9rem; }
.alerta-ok { background: #e4f8ee; color: var(--verde); border: 1px solid #bdeed4; }
.alerta-error { background: #fdeceb; color: var(--rojo); border: 1px solid #f8c9c4; }
.alerta-info { background: #e9f3fd; color: var(--azul); border: 1px solid #c9e2f8; }

.card {
    background: var(--blanco); border: 1px solid var(--gris-borde); border-radius: 12px;
    padding: 24px; margin-bottom: 24px;
}
.card h2 { font-size: 1.05rem; margin: 0 0 16px; }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-box { background: var(--blanco); border: 1px solid var(--gris-borde); border-radius: 12px; padding: 18px 20px; }
.stat-box .num { font-size: 1.7rem; font-weight: 800; color: var(--azul-oscuro); }
.stat-box .lbl { font-size: .8rem; color: var(--gris-texto); }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--gris-borde); }
th { color: var(--gris-texto); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fafbfe; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge-ok { background: #e4f8ee; color: var(--verde); }
.badge-pendiente { background: #fdf1e2; color: var(--naranja); }
.badge-off { background: #f1f2f5; color: var(--gris-texto); }
.badge-rol { background: #e9f3fd; color: var(--azul); }

form.form-inline { display: inline; }

.form-box { max-width: 420px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.field label:has(input[type="checkbox"]), .field label:has(input[type="radio"]) {
    display: flex; align-items: flex-start; gap: 8px; font-weight: 500;
}
.field input:not([type="checkbox"]):not([type="radio"]), .field select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--gris-borde); border-radius: 8px;
    font-size: .92rem; font-family: inherit;
}
.field input[type="checkbox"], .field input[type="radio"] { width: auto; flex-shrink: 0; margin-top: 3px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--celeste); }
.field-hint { font-size: .78rem; color: var(--gris-texto); margin-top: 4px; }

.campo-password { position: relative; }
.campo-password input { padding-right: 40px !important; }
.toggle-password {
    position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
    background: none; border: none; padding: 8px; cursor: pointer;
    color: var(--gris-texto); display: flex; align-items: center; border-radius: 6px;
}
.toggle-password:hover { color: var(--celeste); }
.toggle-password.activo { color: var(--celeste); }

.filtros-form {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px;
    margin: 16px 0; padding: 14px; background: #f8f9fb; border-radius: 8px;
}
.filtros-form .field { margin-bottom: 0; min-width: 160px; }
.filtros-form .filtros-acciones { display: flex; gap: 8px; min-width: 0; }

.paginador {
    display: flex; align-items: center; justify-content: center; gap: 16px;
    margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--gris-borde);
}
.paginador-info { font-size: .85rem; color: var(--gris-texto); }
.btn-disabled { opacity: .4; cursor: default; pointer-events: none; }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--celeste); color: #fff; border: none;
    padding: 10px 20px; border-radius: 8px; font-weight: 600; font-size: .88rem;
    cursor: pointer;
}
.btn:hover { background: #2a86d1; text-decoration: none; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: .78rem; }
.btn-ok { background: var(--verde); }
.btn-ok:hover { background: #17945a; }
.btn-danger { background: var(--rojo); }
.btn-danger:hover { background: #c53b32; }
.btn-secondary { background: #eef2f7; color: var(--azul-oscuro); }
.btn-secondary:hover { background: #e2e8f1; }

.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--azul-oscuro); padding: 20px;
}
.auth-box {
    background: var(--blanco); border-radius: 16px; padding: 36px 34px; width: 100%; max-width: 420px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.auth-box h1 { font-size: 1.3rem; text-align: center; margin: 0 0 4px; }
.auth-box .auth-sub { text-align: center; color: var(--gris-texto); font-size: .85rem; margin-bottom: 24px; }
.auth-box .auth-links { text-align: center; margin-top: 18px; font-size: .85rem; }
.token-box {
    font-family: 'Courier New', monospace; background: #0b2545; color: #7ee0ff;
    padding: 8px 12px; border-radius: 6px; font-size: .82rem; word-break: break-all; display: inline-block;
}
.empty-state { color: var(--gris-texto); font-size: .9rem; padding: 20px 0; text-align: center; }

@media (max-width: 820px) {
    .app-shell { flex-direction: column; min-height: auto; }
    .sidebar { width: 100%; flex-direction: column; padding: 0; }
    .sidebar-top { width: 100%; padding: 14px 16px; }
    .sidebar-nav {
        flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
        -webkit-overflow-scrolling: touch; border-top: 1px solid rgba(255,255,255,.1);
    }
    .sidebar-nav a { padding: 12px 16px; white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
    .sidebar-nav a.active { border-left-color: transparent; border-bottom-color: var(--celeste); }
    .content { padding: 18px; }
    .card { padding: 18px; }
    .auth-box { padding: 26px 20px; }
    table { font-size: .82rem; }
    th, td { padding: 8px 10px; }
}

@media (max-width: 480px) {
    .content { padding: 14px; }
    .auth-page { padding: 10px; }
}
