:root {
  --app-sidebar-width: 260px;
  --app-sidebar-bg: #0f1b2d;
  --app-sidebar-fg: #c9d4e3;
  --app-sidebar-active: #1f6feb;
}

body { background: #f4f6f9; }
.min-w-0 { min-width: 0; }

.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-content { flex: 1 1 auto; }

.app-sidebar {
  --bs-offcanvas-width: var(--app-sidebar-width);
  --bs-offcanvas-bg: var(--app-sidebar-bg);
  --bs-offcanvas-color: var(--app-sidebar-fg);
  background: var(--app-sidebar-bg);
  color: var(--app-sidebar-fg);
}
@media (min-width: 992px) {
  .app-sidebar { width: var(--app-sidebar-width); flex: 0 0 var(--app-sidebar-width); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .app-sidebar .offcanvas-body { display: flex; }
}
.sidebar-link, .sidebar-sublink { color: var(--app-sidebar-fg); border-radius: .375rem; padding: .45rem .75rem; font-size: .925rem; background: transparent; border: 0; }
.sidebar-sublink { padding-left: 2.35rem; font-size: .875rem; }
.sidebar-link:hover, .sidebar-sublink:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-link.active, .sidebar-sublink.active { background: var(--app-sidebar-active); color: #fff; }
.sidebar-toggle .chevron { transition: transform .15s ease-out; margin-top: .25rem; }
.sidebar-toggle.collapsed .chevron { transform: rotate(-90deg); }
@media (prefers-reduced-motion: reduce) { .sidebar-toggle .chevron { transition: none; } }

.app-header { min-height: 56px; }
.notif-menu { width: min(380px, 92vw); }
.notif-menu .list-group-item.unread { background: var(--bs-primary-bg-subtle); }

.card { border: 0; box-shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1); }
.kpi .kpi-value { font-size: 1.6rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .kpi-label { font-size: .8rem; color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: .02em; }
.kpi .kpi-icon { font-size: 1.5rem; opacity: .8; }

.table-admin { font-size: .9rem; }
.table-admin th { white-space: nowrap; font-weight: 600; color: var(--bs-secondary-color); font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }
.table-admin th a { color: inherit; text-decoration: none; }
.table-admin td { vertical-align: middle; }
.table-admin tr.row-deleted td { opacity: .6; text-decoration: line-through; }
.tabular { font-variant-numeric: tabular-nums; }

.mobile-card { border-left: 4px solid var(--bs-primary); }
.mobile-card dl { display: grid; grid-template-columns: max-content 1fr; gap: .15rem .75rem; margin: 0; font-size: .875rem; }
.mobile-card dt { color: var(--bs-secondary-color); font-weight: 500; }
.mobile-card dd { margin: 0; overflow-wrap: anywhere; }

.detail-grid { display: grid; grid-template-columns: minmax(140px, 30%) 1fr; gap: .4rem 1rem; }
.detail-grid dt { color: var(--bs-secondary-color); font-weight: 500; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 575.98px) { .detail-grid { grid-template-columns: 1fr; } .detail-grid dd { margin-bottom: .5rem; } }

.json-block { max-height: 260px; overflow: auto; background: var(--bs-tertiary-bg); padding: .5rem; border-radius: .25rem; white-space: pre-wrap; }
.checkbox-grid { max-height: 320px; overflow-y: auto; columns: 2 280px; }
.checkbox-grid > div { break-inside: avoid; }
.wizard-steps { counter-reset: step; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; list-style: none; }
.wizard-steps li { font-size: .8rem; padding: .25rem .6rem; border-radius: 1rem; background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); }
.wizard-steps li.done { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.wizard-steps li.current { background: var(--bs-primary); color: #fff; }
.filters-card .form-label { font-size: .8rem; margin-bottom: .15rem; }
.btn:focus-visible, .nav-link:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; }

/* ===================================================================== */
/* Diseño v2: profundidad, gradientes y movimiento                        */
/* ===================================================================== */
:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --brand-1: #4f46e5;
  --brand-2: #7c3aed;
  --brand-grad: linear-gradient(135deg, var(--brand-1), var(--brand-2) 55%, #c026d3);
  --app-sidebar-bg: #0b1020;
  --app-sidebar-active: var(--brand-1);
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 6px rgba(15, 23, 42, .06);
  --shadow-2: 0 2px 4px rgba(15, 23, 42, .06), 0 12px 28px -8px rgba(30, 27, 75, .22);
  --bs-primary: #4f46e5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: #4f46e5;
  --bs-link-color-rgb: 79, 70, 229;
  --bs-link-hover-color: #4338ca;
  --bs-link-hover-color-rgb: 67, 56, 202;
}
body { background: radial-gradient(1200px 600px at 100% -10%, rgba(124, 58, 237, .06), transparent 60%), #f5f6fb; }
.btn-primary { --bs-btn-bg: #4f46e5; --bs-btn-border-color: #4f46e5; --bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca; --bs-btn-active-bg: #3730a3; --bs-btn-active-border-color: #3730a3; --bs-btn-disabled-bg: #4f46e5; --bs-btn-disabled-border-color: #4f46e5; }
.btn-outline-primary { --bs-btn-color: #4f46e5; --bs-btn-border-color: #4f46e5; --bs-btn-hover-bg: #4f46e5; --bs-btn-hover-border-color: #4f46e5; --bs-btn-active-bg: #4338ca; --bs-btn-active-border-color: #4338ca; }
.form-control:focus, .form-select:focus { border-color: #a5b4fc; box-shadow: 0 0 0 .25rem rgba(79, 70, 229, .18); }
.text-gradient { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Feedback al presionar: inmediato y corto (transición, se puede interrumpir). */
.btn { transition: transform 120ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn-glow { background-image: var(--brand-grad); border: 0; box-shadow: 0 8px 20px -6px rgba(79, 70, 229, .55); }
@media (hover: hover) and (pointer: fine) {
  .btn-glow:hover { box-shadow: 0 10px 26px -6px rgba(124, 58, 237, .65); }
}

/* Barra lateral */
.app-sidebar { background: linear-gradient(180deg, #0b1020 0%, #121735 60%, #1a1446 100%); box-shadow: inset -1px 0 0 rgba(255, 255, 255, .06); }
.app-sidebar .offcanvas-header { color: #fff; }
.app-sidebar .offcanvas-header .bi-fingerprint { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 1.25rem; }
.sidebar-link, .sidebar-sublink { transition: background-color 150ms ease, color 150ms ease; }
.sidebar-link.active, .sidebar-sublink.active { background: var(--brand-grad); box-shadow: 0 6px 16px -6px rgba(124, 58, 237, .7); }

/* Encabezado translúcido */
.app-header { background: rgba(255, 255, 255, .78) !important; backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px); }

/* Tarjetas con profundidad */
.card { box-shadow: var(--shadow-1); border-radius: .85rem; }
.table-admin tbody tr { transition: background-color 120ms ease; }

/* KPI: franja de color según el indicador y elevación al pasar el puntero. */
.kpi { position: relative; overflow: hidden; transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out); }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: #c7d2fe; }
.kpi:has(.text-success)::before { background: linear-gradient(#10b981, #059669); }
.kpi:has(.text-danger)::before { background: linear-gradient(#f43f5e, #e11d48); }
.kpi:has(.text-warning-emphasis)::before { background: linear-gradient(#f59e0b, #d97706); }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, rgba(124, 58, 237, .08), transparent 70%); pointer-events: none; }
.kpi .kpi-value { font-size: 1.75rem; color: #1e1b4b; }
.kpi .kpi-value.text-success { color: #059669 !important; }
.kpi .kpi-value.text-danger { color: #e11d48 !important; }
@media (hover: hover) and (pointer: fine) {
  a.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
}

/* Entrada escalonada (una vez por carga de página; 40 ms entre elementos). */
@keyframes rise-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.kpi-grid > * { animation: rise-in 360ms var(--ease-out) both; }
.kpi-grid > *:nth-child(2) { animation-delay: 40ms; }
.kpi-grid > *:nth-child(3) { animation-delay: 80ms; }
.kpi-grid > *:nth-child(4) { animation-delay: 120ms; }
.kpi-grid > *:nth-child(5) { animation-delay: 160ms; }
.kpi-grid > *:nth-child(6) { animation-delay: 200ms; }

/* Menús desplegables: crecen desde su botón. */
.dropdown-menu { border: 0; border-radius: .75rem; box-shadow: 0 10px 38px -10px rgba(22, 23, 24, .35), 0 10px 20px -15px rgba(22, 23, 24, .2); }
.dropdown-menu.show { animation: pop-in 180ms var(--ease-out); transform-origin: top right; }
.dropdown-menu:not(.dropdown-menu-end).show { transform-origin: top left; }
@keyframes pop-in { from { opacity: 0; scale: 0.96; translate: 0 -4px; } }
.modal.fade .modal-dialog { transition: transform 240ms var(--ease-out); transform: scale(0.96) translateY(8px); }
.modal.show .modal-dialog { transform: none; }
.modal-content { border: 0; border-radius: 1rem; box-shadow: 0 24px 60px -12px rgba(15, 23, 42, .35); }

/* Encabezado del dashboard con globo 3D */
.dash-hero { position: relative; overflow: hidden; border-radius: 1.1rem; padding: 1.6rem 1.75rem; color: #fff; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; min-height: 170px;
  background: radial-gradient(600px 300px at 85% 30%, rgba(124, 58, 237, .55), transparent 70%), linear-gradient(135deg, #0b1020 0%, #1e1b4b 55%, #312e81 100%);
  box-shadow: 0 18px 40px -18px rgba(30, 27, 75, .7); animation: rise-in 420ms var(--ease-out) both; }
.dash-globe { position: absolute; right: -40px; top: 50%; width: 360px; height: 360px; transform: translateY(-50%); pointer-events: none; opacity: .9; }
.dash-hero-body, .dash-hero-filters { position: relative; z-index: 1; }
.dash-hero-filters { padding: .5rem; border-radius: .8rem; background: rgba(11, 16, 32, .55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, .12); }
.dash-hero-filters .form-select, .dash-hero-filters .form-control { background-color: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .25); color: #fff; color-scheme: dark; }
.dash-hero-filters option { color: #111; }
@media (max-width: 767.98px) { .dash-globe { opacity: .35; right: -120px; } }

/* Chip con punto vivo */
.login-chip { display: inline-flex; align-items: center; gap: .45rem; font-size: .75rem; font-weight: 500; padding: .3rem .7rem; border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18); color: #e0e7ff; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; animation: pulse 2.2s linear infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); } 70%, 100% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); } }

/* Inicio de sesión */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; }
.login-hero { position: relative; overflow: hidden; color: #fff; display: flex; align-items: flex-end; padding: 3rem;
  background: radial-gradient(800px 500px at 30% 40%, rgba(124, 58, 237, .45), transparent 70%), linear-gradient(160deg, #070b18 0%, #141a3d 55%, #2a1b5e 100%); }
.login-globe { position: absolute; inset: 0; width: 100%; height: 100%; }
.login-hero-copy { position: relative; max-width: 30rem; animation: rise-in 600ms var(--ease-out) 200ms both; }
.login-hero-copy h2 { font-size: clamp(1.6rem, 2.6vw, 2.3rem); font-weight: 700; line-height: 1.15; margin: 1rem 0 .6rem; letter-spacing: -.02em; }
.login-hero-copy p { color: #c7d2fe; margin: 0; }
.login-hero .text-gradient { background-image: linear-gradient(135deg, #a5b4fc, #c4b5fd 50%, #f0abfc); }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; perspective: 1200px; }
.login-stage { width: min(400px, 100%); transform-style: preserve-3d; transition: transform 400ms var(--ease-out); }
.login-brand { text-align: center; margin-bottom: 1.5rem; transform-style: preserve-3d; }
.brand-mark { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; margin-bottom: .9rem; font-size: 2rem; color: #fff; background: var(--brand-grad);
  box-shadow: 0 14px 30px -10px rgba(124, 58, 237, .7), inset 0 1px 0 rgba(255, 255, 255, .35); transform: translateZ(40px); }
.login-card { border-radius: 1.1rem; box-shadow: 0 30px 60px -25px rgba(30, 27, 75, .35), 0 0 0 1px rgba(79, 70, 229, .06); }
.enter { animation: rise-in 520ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 60ms + 120ms); }
@media (max-width: 991.98px) {
  .login-shell { grid-template-columns: 1fr; grid-template-rows: 240px 1fr; }
  .login-hero { padding: 1.5rem; }
  .login-hero-copy h2 { font-size: 1.35rem; }
  .login-hero-copy p { display: none; }
}

/* Movimiento reducido: se conservan los cambios de opacidad, se elimina el desplazamiento. */
@media (prefers-reduced-motion: reduce) {
  @keyframes rise-in { from { opacity: 0; } }
  @keyframes pop-in { from { opacity: 0; } }
  .btn:active:not(:disabled) { transform: none; }
  .kpi, .login-stage, .modal.fade .modal-dialog { transition: none; }
  .modal.fade .modal-dialog { transform: none; }
  .pulse-dot { animation: none; }
}
