/* =====================================================================
   Transporte Emanuel — tema oscuro profesional
   Colores de marca tomados del emblema: amarillo #FDB92E, azul #0057C0
   ===================================================================== */
:root {
    --bg: #0a0e17;
    --bg-2: #0d1220;
    --surface: #121a2b;
    --surface-2: #172136;
    --surface-3: #1d2942;
    --border: #23304a;
    --border-2: #2e3d5c;
    --text: #e6ebf5;
    --text-2: #a4b0c7;
    --muted: #7483a0;

    --brand: #fdb92e;
    --brand-2: #ffcb57;
    --brand-ink: #1a1203;
    --blue: #2f7cf6;
    --blue-2: #0057c0;
    --green: #22c55e;
    --red: #ef4444;
    --orange: #f59e0b;
    --purple: #a78bfa;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, .55);
    --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .7);
    --ease: cubic-bezier(.22, .61, .36, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);

    --sb-w: 264px;
    --sb-w-min: 78px;
    --tb-h: 68px;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.right { text-align: right; }
::selection { background: rgba(253, 185, 46, .35); }

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }

/* Resplandor de fondo */
.bg-glow {
    position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background:
        radial-gradient(600px 400px at 85% -10%, rgba(47, 124, 246, .10), transparent 70%),
        radial-gradient(500px 360px at 10% 110%, rgba(253, 185, 46, .06), transparent 70%);
}

/* =====================================================================
   Sidebar
   ===================================================================== */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: var(--sb-w);
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, #0e1424 0%, #0b101c 100%);
    border-right: 1px solid var(--border);
    transition: width .35s var(--ease-out), transform .35s var(--ease-out);
    overflow: hidden;
}
.sb-brand {
    display: flex; align-items: center; gap: 12px;
    height: var(--tb-h); padding: 0 18px; flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.sb-logo { width: 40px; height: 40px; flex-shrink: 0; filter: drop-shadow(0 4px 10px rgba(253, 185, 46, .25)); transition: transform .5s var(--ease-out); }
.sb-brand:hover .sb-logo { transform: rotate(-12deg) scale(1.05); }
.sb-brand-text { display: flex; flex-direction: column; line-height: 1.1; white-space: nowrap; transition: opacity .2s; }
.sb-brand-text strong { font-size: 15px; letter-spacing: .02em; }
.sb-brand-text span { font-size: 11px; font-weight: 700; color: var(--brand); letter-spacing: .14em; }

.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 12px 16px; }
.sb-group {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
    color: var(--muted); padding: 16px 12px 6px; white-space: nowrap; transition: opacity .2s;
}
.sb-link {
    position: relative; display: flex; align-items: center; gap: 13px;
    height: 44px; padding: 0 14px; margin: 2px 0; border-radius: 11px;
    color: var(--text-2); font-weight: 500; white-space: nowrap;
    transition: background .2s, color .2s, transform .2s var(--ease);
}
.sb-link i { width: 20px; font-size: 16px; text-align: center; flex-shrink: 0; transition: transform .25s var(--ease), color .2s; }
.sb-link:hover { background: var(--surface-2); color: var(--text); }
.sb-link:hover i { transform: translateX(2px); color: var(--brand); }
.sb-link.active {
    color: #fff; font-weight: 600;
    background: linear-gradient(90deg, rgba(253, 185, 46, .16), rgba(253, 185, 46, .03));
    box-shadow: inset 0 0 0 1px rgba(253, 185, 46, .18);
}
.sb-link.active i { color: var(--brand); }
.sb-link.active::before {
    content: ''; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 4px;
    border-radius: 0 4px 4px 0; background: var(--brand);
    box-shadow: 0 0 12px rgba(253, 185, 46, .6);
}
.sb-text { flex: 1; transition: opacity .2s; }
.sb-soon {
    font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .03em;
    padding: 2px 7px; border-radius: 20px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
    transition: opacity .2s;
}
.sb-footer {
    display: flex; align-items: center; gap: 10px; padding: 14px 16px;
    border-top: 1px solid var(--border); flex-shrink: 0; white-space: nowrap;
}
.sb-user { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; transition: opacity .2s; }
.sb-user strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.sb-user span { font-size: 11.5px; color: var(--muted); }
.sb-overlay {
    position: fixed; inset: 0; z-index: 45; background: rgba(3, 6, 12, .6);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s;
}

/* Colapsado en escritorio */
.sb-collapsed .sidebar { width: var(--sb-w-min); }
.sb-collapsed .sb-brand-text, .sb-collapsed .sb-group, .sb-collapsed .sb-text,
.sb-collapsed .sb-soon, .sb-collapsed .sb-user, .sb-collapsed .sb-footer .icon-btn { opacity: 0; pointer-events: none; }
.sb-collapsed .sb-group { height: 14px; padding: 0; }
.sb-collapsed .sb-brand { padding: 0 19px; }
.sb-collapsed .sb-footer { padding: 14px 20px; }
.sb-collapsed .sb-link { padding: 0 17px; }
.sb-collapsed .sb-link:hover::after {
    content: attr(data-tip); position: fixed; left: calc(var(--sb-w-min) + 6px);
    padding: 6px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
    background: var(--surface-3); color: var(--text); border: 1px solid var(--border-2); box-shadow: var(--shadow);
    animation: fadeIn .15s;
}
.sb-collapsed .sidebar { overflow: visible; }
.sb-collapsed .sb-nav { overflow: visible; }

/* =====================================================================
   Contenedor principal + topbar
   ===================================================================== */
.app-main {
    position: relative; z-index: 1;
    margin-left: var(--sb-w); min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column; min-width: 0;
    transition: margin-left .35s var(--ease-out);
}
.sb-collapsed .app-main { margin-left: var(--sb-w-min); }

.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--tb-h); display: flex; align-items: center; gap: 16px; padding: 0 26px;
    background: rgba(10, 14, 23, .78);
    backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
    border-bottom: 1px solid var(--border);
}
.tb-title { flex: 1; min-width: 0; }
.tb-title h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { display: flex; align-items: center; gap: 14px; }
.tb-clock { color: var(--text-2); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; text-transform: capitalize; }
.tb-clock i { color: var(--brand); margin-right: 3px; }

/* Botón hamburguesa animado */
.hamburger {
    width: 42px; height: 42px; flex-shrink: 0; position: relative;
    border: 1px solid var(--border); border-radius: 11px; background: var(--surface);
    cursor: pointer; transition: background .2s, border-color .2s, transform .15s;
}
.hamburger:hover { background: var(--surface-2); border-color: var(--border-2); }
.hamburger:active { transform: scale(.94); }
.hamburger span {
    position: absolute; left: 11px; right: 11px; height: 2px; border-radius: 2px; background: var(--text);
    transition: transform .35s var(--ease-out), opacity .2s, top .35s var(--ease-out), width .35s var(--ease-out);
}
.hamburger span:nth-child(1) { top: 14px; }
.hamburger span:nth-child(2) { top: 20px; right: 16px; }
.hamburger span:nth-child(3) { top: 26px; }
.hamburger:hover span:nth-child(2) { right: 11px; }
.sb-open .hamburger span:nth-child(1) { top: 20px; transform: rotate(45deg); }
.sb-open .hamburger span:nth-child(2) { opacity: 0; transform: translateX(-8px); }
.sb-open .hamburger span:nth-child(3) { top: 20px; transform: rotate(-45deg); }

/* Menú de usuario */
.dropdown { position: relative; }
.user-chip {
    display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px;
    border: 1px solid var(--border); border-radius: 40px; background: var(--surface); cursor: pointer;
    transition: background .2s, border-color .2s;
}
.user-chip:hover { background: var(--surface-2); border-color: var(--border-2); }
.uc-name { font-weight: 600; font-size: 13px; }
.uc-caret { font-size: 10px; color: var(--muted); transition: transform .25s var(--ease); }
.dropdown.open .uc-caret { transform: rotate(180deg); }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; z-index: 60;
    background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 13px; padding: 6px;
    box-shadow: var(--shadow-lg);
    opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98); transform-origin: top right;
    transition: opacity .2s var(--ease), transform .25s var(--ease-out), visibility .2s;
}
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: none; }
.dm-head { padding: 10px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: flex; flex-direction: column; }
.dm-head span { font-size: 12px; color: var(--muted); }
.dm-item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 9px;
    border: 0; background: none; color: var(--text-2); font-size: 13.5px; text-align: left; cursor: pointer;
    transition: background .15s, color .15s;
}
.dm-item i { width: 16px; text-align: center; }
.dm-item:hover { background: var(--surface-3); color: var(--text); }
.dm-item.danger:hover { color: #ff8585; background: rgba(239, 68, 68, .12); }

.content { flex: 1; padding: 26px; width: 100%; max-width: 1440px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.app-footer { padding: 16px 26px 22px; color: var(--muted); font-size: 12px; text-align: center; }

/* Transiciones de página */
.page-enter > * { animation: riseIn .55s var(--ease-out) both; }
.page-enter > *:nth-child(2) { animation-delay: .06s; }
.page-enter > *:nth-child(3) { animation-delay: .12s; }
.page-enter > *:nth-child(4) { animation-delay: .18s; }
.page-enter > *:nth-child(n+5) { animation-delay: .24s; }
body.page-leave .content { opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s; }

@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }
@keyframes shimmer { from { background-position: -400px 0; } to { background-position: 400px 0; } }

/* =====================================================================
   Componentes
   ===================================================================== */
.card {
    background: linear-gradient(180deg, var(--surface) 0%, #101727 100%);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h3 { font-size: 15px; display: flex; align-items: center; gap: 9px; }
.card-head h3 i { color: var(--brand); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }

/* Botones */
.btn {
    position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 18px; border-radius: 11px; border: 1px solid transparent;
    font-weight: 600; font-size: 14px; white-space: nowrap; cursor: pointer; user-select: none;
    transition: background .2s, border-color .2s, box-shadow .25s, transform .15s var(--ease), color .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { cursor: not-allowed; opacity: .75; }
.btn-primary {
    color: var(--brand-ink);
    background: linear-gradient(180deg, var(--brand-2), var(--brand));
    box-shadow: 0 6px 18px -6px rgba(253, 185, 46, .55), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn-primary:hover { box-shadow: 0 10px 26px -6px rgba(253, 185, 46, .7), inset 0 1px 0 rgba(255, 255, 255, .35); }
.btn-ghost { background: var(--surface-2); border-color: var(--border-2); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--red); color: #fff; box-shadow: 0 6px 18px -6px rgba(239, 68, 68, .6); }
.btn-danger:hover { background: #f05454; }
.btn-block { width: 100%; }
.btn-lg { height: 50px; font-size: 15px; border-radius: 13px; }
.btn .spinner {
    display: none; width: 18px; height: 18px; border-radius: 50%;
    border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-label { display: none; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent;
    color: var(--text-2); cursor: pointer; transition: background .2s, color .2s, border-color .2s, transform .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-2); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.danger:hover { color: #ff8a8a; background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .3); }
.icon-btn.success:hover { color: #5ee08f; background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .3); }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.input {
    width: 100%; height: 44px; padding: 0 14px; border-radius: 11px;
    background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text);
    font: inherit; font-size: 14.5px; outline: none;
    transition: border-color .2s, box-shadow .25s, background .2s;
}
select.input {
    appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237483a0' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 13px center;
}
.input::placeholder { color: #5a6886; }
.input:hover { border-color: #3a4a6b; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(253, 185, 46, .14); background: #0f1525; }
.hint { color: var(--muted); font-size: 12px; }
.field.has-error .input { border-color: var(--red); box-shadow: 0 0 0 4px rgba(239, 68, 68, .12); }
.field-error { color: #ff8a8a; font-size: 12px; animation: riseIn .25s var(--ease-out); }
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > i { position: absolute; left: 14px; color: var(--muted); font-size: 14px; pointer-events: none; transition: color .2s; }
.input-icon .input { padding-left: 40px; }
.input-icon:focus-within > i { color: var(--brand); }
.input-icon .input:has(+ .pass-toggle) { padding-right: 44px; }
.pass-toggle {
    position: absolute; right: 6px; width: 34px; height: 34px; border: 0; border-radius: 8px;
    background: transparent; color: var(--muted); cursor: pointer; transition: color .2s, background .2s;
}
.pass-toggle:hover { color: var(--text); background: var(--surface-3); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }

/* Interruptores */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; color: var(--text-2); user-select: none; }
.toggle input, .perm-item input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
    position: relative; width: 38px; height: 22px; flex-shrink: 0; border-radius: 22px;
    background: var(--surface-3); border: 1px solid var(--border-2); transition: background .25s, border-color .25s;
}
.switch::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
    background: #8a97b1; transition: transform .3s var(--ease-out), background .25s;
}
input:checked + .switch, input:checked + .perm-card .switch { background: rgba(253, 185, 46, .25); border-color: var(--brand); }
input:checked + .switch::after, input:checked + .perm-card .switch::after { transform: translateX(16px); background: var(--brand); }
input:focus-visible + .switch, input:focus-visible + .perm-card { box-shadow: 0 0 0 3px rgba(253, 185, 46, .3); }
input:disabled + .switch { opacity: .5; }
.check-row { display: flex; flex-wrap: wrap; gap: 14px 28px; margin-top: 18px; }

/* Permisos */
.perm-box { border: 1px solid var(--border); border-radius: 13px; padding: 16px; background: rgba(13, 18, 32, .6); }
.perm-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.perm-head strong i { color: var(--brand); margin-right: 4px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.perm-item { position: relative; cursor: pointer; }
.perm-card {
    display: flex; align-items: center; gap: 11px; padding: 12px 13px; border-radius: 11px;
    border: 1px solid var(--border-2); background: var(--bg-2); transition: border-color .2s, background .2s, transform .15s;
}
.perm-card > i { width: 18px; text-align: center; color: var(--muted); transition: color .2s; }
.perm-card > span:not(.switch) { flex: 1; font-size: 13.5px; font-weight: 500; }
.perm-item:hover .perm-card { border-color: #3a4a6b; }
.perm-item input:checked + .perm-card { border-color: rgba(253, 185, 46, .5); background: rgba(253, 185, 46, .06); }
.perm-item input:checked + .perm-card > i { color: var(--brand); }

/* Badges / estados */
.badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px;
    font-size: 11.5px; font-weight: 600; font-style: normal; white-space: nowrap;
    background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border-2);
}
.badge-soon { font-size: 10px; padding: 1px 7px; color: var(--muted); }
.badge-rol-admin { background: rgba(253, 185, 46, .12); color: var(--brand-2); border-color: rgba(253, 185, 46, .3); }
.badge-rol-supervisor { background: rgba(167, 139, 250, .12); color: #c4b5fd; border-color: rgba(167, 139, 250, .3); }
.badge-rol-vendedor { background: rgba(47, 124, 246, .12); color: #8db8ff; border-color: rgba(47, 124, 246, .3); }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; }
.status.on { color: #6ee7a0; }
.status.on::before { background: var(--green); box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.status.off { color: var(--muted); }
.status.off::before { background: #56627c; }

/* Avatares */
.avatar {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 40px; height: 40px; border-radius: 50%; font-weight: 700; font-size: 14px; letter-spacing: .02em;
    color: var(--brand-ink); background: linear-gradient(135deg, var(--brand-2), #e79a12);
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }

/* Alertas */
.alert {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 11px;
    font-size: 13.5px; border: 1px solid; margin-bottom: 16px; animation: riseIn .3s var(--ease-out);
}
.alert i { margin-top: 2px; }
.alert-danger { background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .35); color: #ffb0b0; }
.alert-warn { background: rgba(245, 158, 11, .1); border-color: rgba(245, 158, 11, .35); color: #fcd28a; }
.alert-info { background: rgba(253, 185, 46, .08); border-color: rgba(253, 185, 46, .3); color: #fde3a6; margin: 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stats-sm { grid-template-columns: repeat(3, 1fr); }
.stat { display: flex; align-items: center; gap: 15px; padding: 18px; transition: transform .25s var(--ease), border-color .25s; }
.stat:hover { transform: translateY(-3px); border-color: var(--border-2); }
.stat-icon {
    width: 48px; height: 48px; border-radius: 13px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.stat > div:last-child { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; }
.c-yellow { background: rgba(253, 185, 46, .13); color: var(--brand); }
.c-green { background: rgba(34, 197, 94, .13); color: #4ade80; }
.c-blue { background: rgba(47, 124, 246, .14); color: #6aa5ff; }
.c-purple { background: rgba(167, 139, 250, .14); color: #b9a6ff; }

/* Bienvenida */
.welcome {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    background:
        radial-gradient(420px 160px at 100% 0%, rgba(253, 185, 46, .14), transparent 70%),
        radial-gradient(380px 200px at 0% 100%, rgba(47, 124, 246, .12), transparent 70%),
        linear-gradient(180deg, var(--surface) 0%, #101727 100%);
}
.welcome h2 { font-size: 22px; margin-bottom: 3px; }
.wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.4s ease-in-out 1s 2; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } 40% { transform: rotate(-4deg); } 50% { transform: rotate(10deg); } }

/* Gráfico de barras */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 210px; padding: 6px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; }
.bar-val { font-size: 12px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.bar { flex: 1; width: 100%; max-width: 46px; display: flex; align-items: flex-end; border-radius: 9px; background: rgba(35, 48, 74, .45); overflow: hidden; }
.bar i {
    display: block; width: 100%; height: max(var(--h), 3%); border-radius: 9px;
    background: linear-gradient(180deg, var(--brand-2), #d98c0a);
    transform-origin: bottom; animation: grow .9s var(--ease-out) both .3s;
}
.bar-col:nth-child(2) i { animation-delay: .36s; } .bar-col:nth-child(3) i { animation-delay: .42s; }
.bar-col:nth-child(4) i { animation-delay: .48s; } .bar-col:nth-child(5) i { animation-delay: .54s; }
.bar-col:nth-child(6) i { animation-delay: .6s; } .bar-col:nth-child(7) i { animation-delay: .66s; }
.bar-label { font-size: 12px; color: var(--muted); }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* Accesos rápidos */
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.quick-item {
    position: relative; display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 12px;
    background: var(--bg-2); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: 13.5px;
    transition: transform .25s var(--ease), border-color .25s, background .25s;
}
.quick-item i { font-size: 20px; color: var(--brand); transition: transform .3s var(--ease-out); }
.quick-item:hover { transform: translateY(-3px); border-color: rgba(253, 185, 46, .4); background: rgba(253, 185, 46, .05); }
.quick-item:hover i { transform: scale(1.12); }
.quick-item .badge { position: absolute; top: 12px; right: 12px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 0 10px 22px; border-bottom: 1px dashed var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline li > div { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-dot { position: absolute; left: 3px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px rgba(253, 185, 46, .15); }

/* Toolbar + tabla */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.toolbar .grow { flex: 1 1 260px; }
.toolbar select.input { width: auto; min-width: 160px; }
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
    text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid rgba(35, 48, 74, .6); vertical-align: middle; }
.table tbody tr { transition: background .2s; }
.table tbody tr:hover { background: rgba(23, 33, 54, .6); }
.table tr.is-off td { opacity: .6; }
.table tr.is-off td.actions { opacity: 1; }
.table th.right, .table td.right { text-align: right; }
.actions { white-space: nowrap; }
.row-in { animation: riseIn .4s var(--ease-out) both; }
.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell > div { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.user-cell .badge { font-size: 10px; padding: 1px 7px; vertical-align: 1px; }
.skeleton { display: block; height: 38px; border-radius: 9px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 800px 100%; animation: shimmer 1.3s infinite linear; }

/* Estado vacío */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 50px 24px; }
.empty-state.small { padding: 28px 16px; }
.empty-state h2 { font-size: 21px; }
.empty-state p { color: var(--text-2); max-width: 440px; }
.empty-icon {
    width: 76px; height: 76px; border-radius: 22px; display: flex; align-items: center; justify-content: center;
    font-size: 30px; color: var(--brand); background: rgba(253, 185, 46, .1); border: 1px solid rgba(253, 185, 46, .25);
    animation: float 4s ease-in-out infinite;
}
.empty-icon.danger { color: #ff8a8a; background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .3); }
.empty-state.small .empty-icon { width: 56px; height: 56px; font-size: 22px; border-radius: 16px; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* Modales */
.modal {
    position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: rgba(3, 6, 12, .66); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    opacity: 0; visibility: hidden; transition: opacity .25s var(--ease), visibility .25s;
}
.modal.show { opacity: 1; visibility: visible; }
.modal-dialog {
    width: 100%; max-width: 560px; max-height: calc(100dvh - 40px); display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border-2); border-radius: 18px; box-shadow: var(--shadow-lg);
    transform: translateY(18px) scale(.97); transition: transform .35s var(--ease-out);
}
.modal-dialog > form { display: flex; flex-direction: column; min-height: 0; }
.modal.show .modal-dialog { transform: none; }
.modal-dialog.sm { max-width: 420px; }
.modal-dialog.lg { max-width: 780px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16.5px; display: flex; align-items: center; gap: 10px; }
.modal-header h3 i { color: var(--brand); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }
body.modal-open { overflow: hidden; }
.confirm-body { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 28px; }
.confirm-body h3 { font-size: 17px; }
.confirm-icon {
    width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px;
    color: var(--brand); background: rgba(253, 185, 46, .12); margin-bottom: 6px;
}
.confirm-icon.danger { color: #ff8a8a; background: rgba(239, 68, 68, .12); }
.modal-dialog[role=alertdialog] .modal-footer { border-top: 0; justify-content: center; padding-bottom: 24px; }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
    display: flex; align-items: center; gap: 11px; min-width: 260px; max-width: 380px; padding: 13px 16px;
    border-radius: 12px; background: var(--surface-3); border: 1px solid var(--border-2); box-shadow: var(--shadow-lg);
    font-size: 13.5px; font-weight: 500; pointer-events: auto;
    opacity: 0; transform: translateX(30px); transition: opacity .3s var(--ease), transform .4s var(--ease-out);
}
.toast.in { opacity: 1; transform: none; }
.toast i { font-size: 17px; }
.toast-ok i { color: var(--green); }
.toast-error i { color: var(--red); }
.toast-warn i { color: var(--orange); }
.toast-info i { color: var(--blue); }
.toast-ok { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }

/* =====================================================================
   Login
   ===================================================================== */
.login-page { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; background: #070a12; }
.login-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; animation: drift 18s ease-in-out infinite alternate; }
.b1 { width: 520px; height: 520px; background: #0057c0; top: -160px; left: -120px; }
.b2 { width: 440px; height: 440px; background: #fdb92e; bottom: -200px; right: -120px; opacity: .28; animation-duration: 22s; }
.b3 { width: 300px; height: 300px; background: #1d4ed8; bottom: 10%; left: 40%; opacity: .25; animation-duration: 26s; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(60px, 40px) scale(1.12); } }
.road { position: absolute; left: 0; right: 0; bottom: 70px; height: 4px; display: flex; gap: 60px; opacity: .14; animation: road 3s linear infinite; }
.road i { flex: 0 0 90px; height: 4px; border-radius: 4px; background: #fdb92e; }
@keyframes road { from { transform: translateX(0); } to { transform: translateX(-150px); } }

.login-wrap {
    position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh;
    display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: 40px;
    max-width: 1180px; margin: 0 auto; padding: 40px 32px;
}
.login-hero { animation: riseIn .8s var(--ease-out) both; }
.login-logo { width: 100%; max-width: 520px; margin-bottom: 34px; filter: drop-shadow(0 12px 30px rgba(0, 0, 0, .5)); }
.login-hero h2 { font-size: 30px; line-height: 1.2; margin-bottom: 10px; }
.login-hero p { color: var(--text-2); font-size: 15.5px; max-width: 460px; }
.login-feats { list-style: none; padding: 0; margin: 26px 0 0; display: flex; flex-direction: column; gap: 12px; }
.login-feats li { display: flex; align-items: center; gap: 12px; color: var(--text-2); animation: riseIn .6s var(--ease-out) both; }
.login-feats li:nth-child(1) { animation-delay: .3s; } .login-feats li:nth-child(2) { animation-delay: .4s; } .login-feats li:nth-child(3) { animation-delay: .5s; }
.login-feats i {
    width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    color: var(--brand); background: rgba(253, 185, 46, .1); border: 1px solid rgba(253, 185, 46, .22);
}
.login-card {
    width: 100%; max-width: 420px; justify-self: end; padding: 36px 34px 26px;
    background: rgba(18, 26, 43, .72); border: 1px solid rgba(46, 61, 92, .8); border-radius: 22px;
    backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .05);
    animation: riseIn .7s var(--ease-out) .1s both;
}
.login-card.shake { animation: shake .5s var(--ease); }
.login-emblem { width: 64px; height: 64px; display: block; margin-bottom: 18px; filter: drop-shadow(0 8px 20px rgba(253, 185, 46, .3)); }
.login-card h1 { font-size: 26px; }
.login-card > .muted { margin: 4px 0 24px; }
.login-card .btn { margin-top: 6px; }
.login-foot { margin-top: 22px; text-align: center; color: var(--muted); font-size: 12px; }
body.login-out .login-card, body.login-out .login-hero { opacity: 0; transform: translateY(-10px) scale(.98); transition: opacity .4s, transform .45s var(--ease-out); }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 1200px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .stats-sm { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); width: min(var(--sb-w), 84vw); }
    .sb-open .sidebar { transform: none; }
    .sb-open .sb-overlay { opacity: 1; visibility: visible; }
    .app-main, .sb-collapsed .app-main { margin-left: 0; }
    .grid-2 { grid-template-columns: 1fr; }
    .login-wrap { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 32px 18px; gap: 26px; align-content: center; }
    .login-hero p { margin: 0 auto; }
    .login-hero h2, .login-feats { display: none; }
    .login-logo { max-width: 360px; margin-bottom: 4px; }
    .login-card { justify-self: center; text-align: left; }
    .login-emblem { display: none; }
}
@media (max-width: 720px) {
    body { font-size: 14px; }
    .topbar { padding: 0 14px; gap: 12px; }
    .tb-clock, .uc-name, .uc-caret { display: none; }
    .user-chip { padding: 4px; }
    .tb-title h1 { font-size: 16px; }
    .content { padding: 16px; gap: 16px; }
    .card { padding: 16px; }
    .stats, .stats-sm { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stats-sm .stat:first-child { grid-column: 1 / -1; }
    .stat { padding: 14px; gap: 12px; }
    .stat-icon { width: 40px; height: 40px; font-size: 16px; border-radius: 11px; }
    .stat-value { font-size: 19px; }
    .welcome .btn { width: 100%; }
    .form-grid { grid-template-columns: 1fr; }
    .toolbar select.input { flex: 1 1 140px; min-width: 0; }
    .toolbar .btn { flex: 1 1 100%; }
    .bars { gap: 7px; height: 180px; }
    .quick { grid-template-columns: 1fr 1fr; }

    /* Tabla como tarjetas en celulares */
    .table-wrap { margin: 0; padding: 0; overflow: visible; }
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody { display: block; }
    .table-cards tr {
        display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 14px;
        margin-bottom: 10px; border: 1px solid var(--border); border-radius: 13px; background: var(--bg-2);
    }
    .table-cards td { display: block; padding: 0; border: 0; }
    .table-cards td[data-label="Usuario"] { grid-column: 1; }
    .table-cards td.actions { grid-column: 2; grid-row: 1; align-self: start; }
    .table-cards td[data-label="Rol"], .table-cards td[data-label="Estado"] { display: inline-block; }
    .table-cards td[data-label="Contacto"], .table-cards td[data-label="Último acceso"] { grid-column: 1 / -1; color: var(--text-2); }
    .table-cards td[data-label="Último acceso"]::before { content: 'Último acceso: '; color: var(--muted); }
    .table-cards td[data-label="Rol"] { grid-column: 1; }
    .table-cards td[data-label="Estado"] { grid-column: 2; justify-self: end; }
    .table-cards tr.skeleton-row { display: block; padding: 0; border: 0; background: none; }

    .modal { padding: 0; align-items: flex-end; }
    .modal-dialog, .modal-dialog.sm, .modal-dialog.lg { max-width: 100%; max-height: 92dvh; border-radius: 20px 20px 0 0; transform: translateY(100%); }
    .modal-dialog[role=alertdialog] { border-radius: 20px 20px 0 0; }
    .modal-footer .btn { flex: 1; }
    .toasts { left: 12px; right: 12px; bottom: 12px; }
    .toast { min-width: 0; max-width: none; }
    .login-card { padding: 28px 22px 20px; border-radius: 18px; }
    .login-logo { max-width: 290px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
