/* =============================================================
   OFICYNA · Panel de Gestión — REDISEÑO (tema oscuro)
   Lenguaje visual: "Oficyna Command"
   - Fondo casi negro con aurora índigo
   - Jerarquía de página (page-head) + grillas bento
   - Tarjetas glass planas, sin borde superior de color
   - Acento de marca azul #0075f2 · tipografía Inter + JetBrains Mono
   Se conservan todos los selectores que usa el HTML/JS del panel.
   ============================================================= */

:root {
    /* ---- Marca Oficyna ---- */
    --brand: #0075f2;
    --brand-400: #3d9bff;
    --brand-300: #66b8ff;
    --brand-200: #99d0ff;
    --brand-100: #00294d;
    --brand-50: #001a33;
    --brand-glow: rgba(0, 117, 242, .55);
    --grad-brand: linear-gradient(180deg, var(--brand-400), var(--brand) 55%, #0059c9);

    /* ---- Superficies ---- */
    --bg: #00020E;
    --bg-card: linear-gradient(158deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .014));
    --bg-card-solid: #0d0f18;
    --surface: #0d0f18;
    --surface-2: #13151f;
    --surface-3: #191b27;
    --surface-hover: #161824;
    --surface-active: #1d2030;
    --bg-elev: #0d0f18;
    --overlay: rgba(2, 3, 6, .74);
    --text-brand: #66b8ff;

    /* ---- Auroras de ambiente (tonos de marca, suaves) ---- */
    --orb-a: rgba(0, 117, 242, .40);
    --orb-b: rgba(51, 160, 255, .30);
    --orb-c: rgba(102, 198, 255, .22);

    /* ---- Texto ---- */
    --text: #f5f6fa;
    --text-muted: #a5aac0;
    --text-dim: #6c7288;
    --text-2: #a5aac0;
    --text-3: #8a90a8;
    --text-4: #6c7288;

    /* ---- Bordes ---- */
    --border: rgba(255, 255, 255, .09);
    --border-2: rgba(255, 255, 255, .06);
    --border-3: rgba(255, 255, 255, .04);
    --border-light: rgba(255, 255, 255, .06);
    --border-strong: rgba(255, 255, 255, .17);

    /* ---- Acentos (nombres usados por JS/schemas) ---- */
    --green: #2bd49a;
    --green-dim: rgba(43, 212, 154, .13);
    --green-deep: #14352a;
    --green-dark: #0b1f14;
    --green-grad: linear-gradient(160deg, var(--brand-400), var(--brand));

    --gold: #66b8ff;
    --gold-light: #99d0ff;
    --gold-dark: #0075f2;
    --gold-glow: #99d0ff;
    --gold-dim: rgba(0, 117, 242, .22);

    --blue: #3d9bff;
    --blue-dim: rgba(0, 117, 242, .16);
    --cyan: #38bdf8;
    --cyan-dim: rgba(56, 189, 248, .13);
    --red: #ff6369;
    --red-dim: rgba(255, 99, 105, .13);
    --orange: #f5a524;
    --orange-dim: rgba(245, 165, 36, .13);
    --purple: #a78bfa;
    --purple-dim: rgba(167, 139, 250, .13);
    --magenta: #f472b6;
    --magenta-dim: rgba(244, 114, 182, .14);
    --indigo: #818cf8;
    --indigo-dim: rgba(129, 140, 248, .14);

    /* ---- Sombras ---- */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 10px 26px -12px rgba(0, 0, 0, .75), 0 3px 8px -3px rgba(0, 0, 0, .5);
    --shadow-lg: 0 22px 48px -16px rgba(0, 0, 0, .8), 0 6px 16px -6px rgba(0, 0, 0, .55);
    --shadow-brand: 0 12px 34px -14px var(--brand-glow);
    --shine: rgba(255, 255, 255, .06);
    --shine-strong: rgba(255, 255, 255, .14);
    --neu-da: rgba(0, 0, 0, .48);
    --neu-li: rgba(255, 255, 255, .09);
    --glass-strong: rgba(13, 15, 24, .82);

    /* ---- Sidebar (degradado vertical #00020E → aclarado sutil, sin morado) ---- */
    --sidebar-base: #00020E;
    --sidebar-mid: #02050f;
    --sidebar-soft: #060b1c;
    --sidebar-glow: #0a142e;

    /* ---- Layout ---- */
    --sidebar-w: 240px;
    --sidebar-collapsed: 64px;

    /* ---- Radios ---- */
    --r-xs: 5px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;

    /* ---- Tipografía ---- */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;

    /* ---- Movimiento ---- */
    --ease: cubic-bezier(.4, 0, .2, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background:
        radial-gradient(95% 62% at 50% 116%, color-mix(in srgb, #0075f2 20%, transparent), transparent 72%),
        radial-gradient(120% 80% at 88% -12%, color-mix(in srgb, #0075f2 14%, transparent), transparent 58%),
        linear-gradient(180deg, color-mix(in srgb, var(--sidebar-base) 88%, transparent) 0%, transparent 34%),
        linear-gradient(90deg, color-mix(in srgb, var(--sidebar-base) 72%, transparent) 0%, transparent 28%),
        linear-gradient(180deg, var(--sidebar-base) 0%, var(--sidebar-mid) 52%, var(--sidebar-soft) 100%);
    background-attachment: fixed;
    overflow-x: hidden;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -.022em; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }

.kpi-value, .stat-box-value, .cell-bright, .legend-pct, .num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1, "zero" 1;
}

::selection { background: var(--brand-glow); color: #fff; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--brand-300); outline-offset: 2px; border-radius: var(--r-xs); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-4); background-clip: content-box; }

/* ===== AMBIENT (aurora de marca) ===== */
.ambient {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
.ambient::before {
    content: '';
    position: absolute;
    inset: -30%;
    background: linear-gradient(115deg, transparent 36%, color-mix(in srgb, #0075f2 58%, transparent) 50%, transparent 64%);
    filter: blur(90px);
    opacity: .22;
    mix-blend-mode: screen;
    animation: auroraBeam 26s ease-in-out infinite alternate;
    pointer-events: none;
    will-change: transform;
}
.ambient-grid {
    display: none;
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(color-mix(in srgb, var(--sidebar-glow) 42%, transparent) 1px, transparent 1px),
        linear-gradient(90deg, color-mix(in srgb, var(--sidebar-glow) 42%, transparent) 1px, transparent 1px);
    background-size: 58px 58px;
    opacity: .10;
    -webkit-mask-image: radial-gradient(150% 130% at 50% 78%, #000 0%, transparent 92%);
    mask-image: radial-gradient(150% 130% at 50% 78%, #000 0%, transparent 92%);
    animation: gridPan 70s linear infinite;
    pointer-events: none;
}
.ambient::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: .025;
    pointer-events: none;
    background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(64px);
    opacity: .7;
    animation: drift 24s ease-in-out infinite alternate;
}
.orb-1 { width: 46vmax; height: 46vmax; top: -20vmax; left: -14vmax; background: radial-gradient(circle at 32% 32%, var(--orb-c), transparent 62%); }
.orb-2 { width: 40vmax; height: 40vmax; bottom: -18vmax; right: -12vmax; background: radial-gradient(circle at 68% 68%, var(--orb-a), transparent 60%); animation-delay: -8s; }
.orb-3 { width: 26vmax; height: 26vmax; top: 34%; left: 46%; background: radial-gradient(circle at 50% 50%, var(--orb-b), transparent 62%); animation-delay: -15s; }
.orb-4 { width: 24vmax; height: 24vmax; top: 8%; right: 12%; background: radial-gradient(circle at 50% 50%, var(--orb-c), transparent 62%); animation-delay: -4s; }
.orb-5 { width: 32vmax; height: 32vmax; top: 30vmax; left: -16vmax; background: radial-gradient(circle at 40% 40%, var(--orb-b), transparent 62%); animation-delay: -11s; }
.orb-6 { width: 34vmax; height: 34vmax; top: 42vmax; right: -18vmax; background: radial-gradient(circle at 60% 40%, var(--orb-b), transparent 62%); animation-delay: -6s; }
.orb-7 { width: 38vmax; height: 38vmax; bottom: -16vmax; left: 4vmax; background: radial-gradient(circle at 50% 50%, var(--orb-a), transparent 62%); animation-delay: -19s; }
.orb-8 { width: 30vmax; height: 30vmax; bottom: -14vmax; left: 38vmax; background: radial-gradient(circle at 50% 50%, var(--orb-a), transparent 62%); animation-delay: -14s; }

/* ===== SIDEBAR / RAIL ===== */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-right: 0;
    box-shadow: none;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: width .3s var(--ease), transform .3s var(--ease);
    overflow: hidden;
}
.sidebar::before {
    content: '';
    display: none;
    position: absolute;
    width: 520px; height: 520px;
    border-radius: 50%;
    filter: blur(110px);
    opacity: .5;
    background: radial-gradient(circle, var(--sidebar-glow), transparent 70%);
    bottom: -26%;
    left: -34%;
    animation: drift 34s ease-in-out infinite alternate;
    pointer-events: none;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
    padding: 0 14px;
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: 11px;
    flex-shrink: 0;
    position: relative;
    background: none;
    border-bottom: 0;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
}
.sidebar-logo img {
    max-height: 32px;
    width: auto;
    max-width: 32px;
    object-fit: contain;
}
.sidebar-brand {
    display: flex;
    flex-direction: column;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity .2s;
    min-height: 36px;
}
.sidebar.collapsed .sidebar-header { padding: 0 14px; gap: 0; }
.sidebar.collapsed .sidebar-brand { opacity: 0; width: 0; }
.sidebar-brand .name {
    font-weight: 750;
    font-size: .82rem;
    letter-spacing: .03em;
    color: var(--text);
    line-height: 1.2;
}
.sidebar-brand .sub {
    font-size: .54rem;
    color: var(--text-4);
    letter-spacing: .12em;
    text-transform: uppercase;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 9px 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.nav-section-label {
    padding: 12px 10px 6px;
    font-size: .56rem;
    font-weight: 700;
    color: var(--text-4);
    text-transform: uppercase;
    letter-spacing: .12em;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar.collapsed .nav-section-label { opacity: 0; height: 18px; padding: 0; }
.sidebar.collapsed .nav-badge { display: none; }

.nav-item-sidebar { position: relative; }

.nav-link-sidebar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 1px 2px;
    padding: 8px 10px;
    width: calc(100% - 4px);
    border-radius: var(--r-sm);
    color: var(--text-2);
    text-decoration: none;
    font-size: .82rem;
    font-weight: 540;
    transition: background .15s var(--ease), color .15s var(--ease), box-shadow .2s var(--ease), transform .15s var(--ease);
    cursor: pointer;
    border: none;
    background: none;
    text-align: left;
    white-space: nowrap;
}
.nav-link-sidebar:hover {
    color: var(--text);
    background: var(--surface-hover);
    transform: translateX(2px);
}
.nav-link-sidebar.active {
    color: var(--brand-200);
    font-weight: 640;
    background: linear-gradient(100deg, rgba(0, 117, 242, .30), transparent 130%);
    box-shadow: 0 10px 22px -14px var(--brand-glow), inset 0 1px 0 var(--shine);
}
.nav-link-sidebar.active::before {
    content: '';
    position: absolute;
    left: -11px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand);
}
.nav-link-sidebar.active:hover {
    background: linear-gradient(100deg, rgba(0, 117, 242, .38), transparent 130%);
    color: var(--text);
}
.nav-link-sidebar .nav-icon {
    width: 18px;
    text-align: center;
    font-size: .9rem;
    flex-shrink: 0;
    opacity: .85;
    transition: color .2s, transform .15s var(--ease), opacity .2s;
}
.nav-link-sidebar:hover .nav-icon,
.nav-link-sidebar.active .nav-icon { opacity: 1; transform: translateX(2px); }
.nav-link-sidebar.active .nav-icon { color: var(--brand-200); }
.nav-link-sidebar .nav-text { flex: 1; overflow: hidden; transition: opacity .2s; }
.sidebar.collapsed .nav-link-sidebar .nav-text { opacity: 0; width: 0; }
.nav-link-sidebar .nav-badge {
    background: var(--brand);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .16);
    font-size: .64rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
    flex-shrink: 0;
    box-shadow: 0 6px 14px -6px var(--brand-glow);
}
.nav-link-sidebar .nav-chevron {
    font-size: .68rem;
    opacity: .7;
    transition: transform .3s var(--ease);
    flex-shrink: 0;
}
.nav-link-sidebar.expanded .nav-chevron { transform: rotate(90deg); }

/* Submenú */
.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height .35s var(--ease);
    background: rgba(255, 255, 255, .02);
}
.nav-submenu.open { max-height: 3000px; overflow: visible; }
.sidebar.collapsed .nav-submenu { max-height: 0; }
.sidebar.collapsed .nav-submenu.open {
    max-height: 3000px;
    overflow: visible;
    width: 240px;
    background: var(--glass-strong);
    backdrop-filter: blur(22px) saturate(1.5);
    -webkit-backdrop-filter: blur(22px) saturate(1.5);
    border: 1px solid var(--border);
    border-radius: 0 var(--r-md) var(--r-md) 0;
    box-shadow: var(--shadow-lg);
    z-index: 1060;
    padding: 6px 0;
}
.sidebar.collapsed .nav-submenu.open .nav-link-sidebar { padding: 10px 18px 10px 30px; }
.sidebar.collapsed .nav-submenu.open .nav-link-sidebar::before { left: 16px; }
.sidebar.collapsed .nav-submenu.open .nav-text { opacity: 1; width: auto; color: var(--text-2); }
.sidebar.collapsed .nav-submenu.open .nav-link-sidebar:hover .nav-text,
.sidebar.collapsed .nav-submenu.open .nav-link-sidebar.active .nav-text { color: var(--brand-200); }

.nav-submenu .nav-link-sidebar {
    margin: 1px 8px;
    padding: 8px 12px 8px 40px;
    width: calc(100% - 16px);
    font-size: .8rem;
    position: relative;
}
.nav-submenu .nav-link-sidebar::before {
    content: '';
    position: absolute;
    left: 22px;
    top: 50%;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--text-4);
    transition: background .2s;
}
.nav-submenu .nav-link-sidebar:hover::before,
.nav-submenu .nav-link-sidebar.active::before { background: var(--brand-400); }
.nav-submenu .nav-link-sidebar.active { color: var(--brand-200); }

/* Sidebar footer */
.sidebar-footer { padding: 10px; border-top: 0; flex-shrink: 0; }
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background .15s var(--ease);
}
.sidebar-user:hover { background: var(--surface-hover); }
.sidebar-user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--brand), var(--brand-400));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .68rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 8px 18px -8px var(--brand-glow), inset 0 1px 0 rgba(255, 255, 255, .24);
}
.sidebar-user-info { overflow: hidden; transition: opacity .2s; }
.sidebar.collapsed .sidebar-user-info { opacity: 0; width: 0; }
.sidebar-user-info .name { font-size: .76rem; font-weight: 620; color: var(--text); }
.sidebar-user-info .role { font-size: .6rem; color: var(--text-4); }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    position: relative;
    z-index: 1;
    transition: margin-left .3s var(--ease);
}
body.sidebar-collapsed .main-content { margin-left: var(--sidebar-collapsed); }

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 58px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 0;
    box-shadow: none;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
    width: 34px; height: 34px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .05);
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .15s var(--ease);
    position: relative;
    flex-shrink: 0;
}
.icon-btn i { font-size: .95rem; line-height: 1; }
.icon-btn:hover {
    color: var(--brand-200);
    background: rgba(61, 155, 255, .16);
    border-color: rgba(61, 155, 255, .4);
    transform: translateY(-1px);
}
.search-trigger {
    width: auto;
    min-width: 220px;
    height: 34px;
    padding: 0 10px 0 11px;
    gap: 9px;
    justify-content: flex-start;
    color: var(--text-4);
    font-size: .8rem;
    background: color-mix(in srgb, var(--surface-2) 70%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.search-trigger i { font-size: .85rem; color: inherit; }
.search-trigger .search-label { font-size: .8rem; font-weight: 520; color: inherit; }
.search-trigger kbd {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 19px;
    padding: 0 5px;
    font-family: var(--font-mono);
    font-size: .62rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text-3);
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
}
.search-trigger:hover {
    color: var(--text-3);
    background: var(--surface);
    border-color: var(--border-strong);
    transform: none;
}
.notif-btn { color: #fcd34d; }
.notif-btn:hover { color: #fef3c7; background: rgba(245, 158, 11, .16); border-color: rgba(245, 158, 11, .4); }
.logout-btn { color: #fca5a5; }
.logout-btn:hover { color: #fee2e2; background: rgba(248, 113, 113, .16); border-color: rgba(248, 113, 113, .4); }
.notif-dot {
    position: absolute;
    top: 8px; right: 8px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 0 8px rgba(245, 158, 11, .7);
    border: 2px solid var(--bg);
}

.crumb { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.crumb-root { color: var(--text-4); font-weight: 600; }
.crumb-sep { font-size: .55rem; color: var(--text-4); opacity: .7; }
.crumb-current { color: var(--text); font-weight: 700; }

/* ===== CONTENT AREA ===== */
.content-area { padding: 20px 24px 40px; }
.content-area.is-inicio { padding: 0; }

/* ===== SHELL: entidades embebidas (iframe) ===== */
.content-area.is-view { padding: 0; }
.view-host { height: calc(100vh - 58px); height: calc(100dvh - 58px); }
.view-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
}
.view-host[hidden] { display: none !important; }

/* ===== INICIO: watermark gigante + hero tipográfico minimalista ===== */
.inicio-view {
    position: relative;
    min-height: calc(100vh - 58px);
    min-height: calc(100dvh - 58px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.inicio-view[hidden] { display: none !important; }

/* Fondo del login en todo #inicioView, entonado con los tonos del sidebar */
.inicio-watermark {
    position: absolute;
    z-index: 0;
    inset: 0;
    background:
        radial-gradient(120% 110% at 50% 50%, transparent 55%, color-mix(in srgb, var(--surface) 62%, transparent) 100%),
        linear-gradient(180deg, color-mix(in srgb, var(--brand) 6%, transparent) 0%, color-mix(in srgb, var(--brand) 12%, transparent) 100%),
        url("../../LOGIN/logo/realestate-bg.webp") center center / cover no-repeat;
    opacity: .3;
    filter: grayscale(.35) saturate(.8) brightness(1.05);
    pointer-events: none;
}
body.light-mode .inicio-watermark {
    opacity: .2;
    background:
        radial-gradient(120% 110% at 50% 50%, transparent 55%, color-mix(in srgb, var(--surface) 66%, transparent) 100%),
        linear-gradient(180deg, color-mix(in srgb, var(--brand) 5%, transparent) 0%, color-mix(in srgb, var(--brand) 9%, transparent) 100%),
        url("../../LOGIN/logo/realestate-bg.webp") center center / cover no-repeat;
}

/* Contenido central */
.inicio-center {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
    padding: 48px 56px;
    max-width: 880px;
    border-radius: 28px;
    background: radial-gradient(70% 80% at 50% 50%, color-mix(in srgb, var(--surface) 62%, transparent) 0%, transparent 74%);
}
.inicio-mark-wrap {
    display: block;
    animation: inicioRise .6s var(--ease-out) both;
}
.inicio-mark {
    display: block;
    width: clamp(120px, 15vw, 176px);
    height: auto;
    aspect-ratio: 466 / 397;
    filter: drop-shadow(0 14px 30px rgba(4, 5, 12, .45));
    user-select: none;
    -webkit-user-drag: none;
    animation: inicioLogoPulse 3.8s ease-in-out infinite;
}
body.light-mode .inicio-mark {
    content: url("../logo/Logo.webp");
    filter: drop-shadow(0 10px 22px rgba(0, 117, 242, .18));
    animation: inicioLogoPulse 3.8s ease-in-out infinite;
}
.inicio-title {
    margin: 0;
    font-size: clamp(2.1rem, 4.9vw, 3.3rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--text);
    text-shadow: 0 2px 26px rgba(4, 5, 12, .5);
    animation: inicioRise .6s var(--ease-out) .08s both;
}
.inicio-title-grad {
    background-image: linear-gradient(115deg, #4A7BC8 0%, #67E8F9 28%, #A5F3FC 46%, #C9A84C 70%, #4A7BC8 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 10px 40px rgba(34, 211, 238, .5));
    animation: inicioShimmer 7s linear infinite;
}
body.light-mode .inicio-title-grad {
    background-image: linear-gradient(115deg, #2E5090 0%, #0E7490 30%, #0369A1 52%, #B8860B 74%, #2E5090 100%);
}
.inicio-sub {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    font-size: clamp(1.02rem, 1.9vw, 1.24rem);
    font-weight: 500;
    line-height: 1.55;
    color: color-mix(in srgb, var(--text) 85%, var(--text-2));
    text-shadow: 0 2px 22px rgba(4, 5, 12, .5);
    animation: inicioRise .6s var(--ease-out) .16s both, inicioFade 4.5s ease-in-out .9s infinite;
}
.inicio-sub-accent {
    background: linear-gradient(92deg, var(--brand-300), #67E8F9 70%, var(--brand-200));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    font-weight: 800;
    letter-spacing: -.01em;
}
body.light-mode .inicio-sub-accent {
    background: linear-gradient(92deg, #0075f2, #0369A1 72%, #0075f2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
.inicio-sub-sep {
    color: color-mix(in srgb, var(--brand-300) 75%, var(--text-3));
    font-size: 1.1em;
    line-height: 1;
}
body.light-mode .inicio-sub { text-shadow: 0 1px 14px rgba(0, 117, 242, .12); }
.inicio-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--text) 88%, var(--text-2));
    text-shadow: 0 1px 16px rgba(4, 5, 12, .5);
    animation: inicioRise .6s var(--ease-out) .24s both;
}
.inicio-chip-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: .6rem;
    color: var(--brand-300);
    background: color-mix(in srgb, var(--brand-300) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--brand-300) 45%, transparent);
    box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--brand-300) 22%, transparent);
    animation: inicioNudge 2.6s ease-in-out infinite;
}
body.light-mode .inicio-chip-key { color: var(--brand); }
.inicio-chip-text {
    white-space: nowrap;
    background: linear-gradient(92deg, var(--text), color-mix(in srgb, var(--brand-300) 72%, var(--text)));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
body.light-mode .inicio-chip-text {
    background: linear-gradient(92deg, #12141d, #0075f2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
.inicio-chip::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -9px;
    height: 1px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--brand-300) 22%, #67E8F9 50%, var(--brand-300) 78%, transparent);
    opacity: 0;
    transform: scaleX(.2);
    animation: inicioChipLine 5s ease-in-out .75s infinite;
    pointer-events: none;
}

@keyframes inicioShimmer {
    from { background-position: 0% center; }
    to   { background-position: -200% center; }
}
@keyframes inicioFade {
    0%, 100% { opacity: 1; }
    50%      { opacity: .78; }
}
@keyframes inicioNudge {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(-4px); }
}
@keyframes inicioChipLine {
    0%, 20%  { opacity: 0; transform: scaleX(.2); }
    45%, 55% { opacity: .85; transform: scaleX(1); }
    90%, 100%{ opacity: 0; transform: scaleX(.2); }
}
@keyframes inicioRise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes inicioLogoPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .8; }
}
@media (prefers-reduced-motion: reduce) {
    .inicio-mark-wrap, .inicio-mark, .inicio-title, .inicio-title-grad,
    .inicio-sub, .inicio-chip, .inicio-chip-text, .inicio-chip-key,
    .inicio-chip::after { animation: none; }
}

/* Page head */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.page-eyebrow {
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--brand-300);
    margin-bottom: 5px;
}
.page-title {
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -.03em;
    background: linear-gradient(92deg, var(--text), color-mix(in srgb, var(--text-brand) 70%, var(--text)));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
.page-sub { font-size: .8rem; color: var(--text-3); margin-top: 4px; }
.page-head-side { display: flex; align-items: center; gap: 10px; }
.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 13px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 640;
    color: var(--green);
    background: var(--green-dim);
    border: 1px solid rgba(43, 212, 154, .3);
}
.live-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 0 rgba(43, 212, 154, .6);
    animation: pulse 2s infinite;
}

/* ===== BENTO GRID (sistema de la Guía de Formato) ===== */
.bento {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}
.bento:last-child { margin-bottom: 0; }
.bento > * { min-width: 0; }
.c3 { grid-column: span 3; }
.c4 { grid-column: span 4; }
.c5 { grid-column: span 5; }
.c6 { grid-column: span 6; }
.c7 { grid-column: span 7; }
.c8 { grid-column: span 8; }
.c12 { grid-column: span 12; }

/* Grillas KPI originales (conservan tamaño/diseño de las tarjetas) */
.kpi-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-bottom: 16px;
}
.kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ===== KPI CARDS ===== */
.kpi {
    --tone: var(--brand-400);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 138px;
    padding: 18px;
    background: linear-gradient(155deg, color-mix(in srgb, var(--surface) 78%, transparent), color-mix(in srgb, var(--brand-50) 46%, transparent));
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
    border-radius: var(--r-xl);
    transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
    box-shadow: var(--shadow-sm), inset 0 1px 0 var(--shine), inset 0 -8px 18px -14px var(--brand-glow);
}
.kpi::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, var(--tone), var(--brand) 45%, transparent 86%);
    box-shadow: 0 0 14px var(--tone);
    pointer-events: none;
}
.kpi::after {
    content: '';
    position: absolute;
    top: -40%; right: -20%;
    width: 190px; height: 190px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--tone), transparent 70%);
    opacity: .12;
    filter: blur(28px);
    pointer-events: none;
    transition: opacity .25s var(--ease);
}
.kpi:hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--tone) 42%, var(--border-strong));
    box-shadow: var(--shadow-md), inset 0 1px 0 var(--shine), 0 16px 32px -18px var(--tone);
}
.kpi:hover::after { opacity: .22; }

.kpi.green { --tone: var(--green); }
.kpi.cyan { --tone: var(--cyan); }
.kpi.blue { --tone: var(--brand-400); }
.kpi.orange { --tone: var(--orange); }
.kpi.purple { --tone: var(--purple); }
.kpi.gold { --tone: var(--gold); }
.kpi.magenta-tone { --tone: var(--magenta); }
.kpi.indigo-tone { --tone: var(--indigo); }

.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.kpi-label {
    font-size: .7rem;
    font-weight: 650;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-4);
    line-height: 1.35;
}
.kpi-unit { color: var(--text-4); font-weight: 600; letter-spacing: .02em; }
.kpi-ic {
    width: 34px; height: 34px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .92rem;
    color: #fff;
    background: linear-gradient(160deg, color-mix(in srgb, var(--tone) 78%, #fff), var(--tone));
    box-shadow: 0 8px 16px -8px var(--tone), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.kpi-value {
    margin-top: 14px;
    font-family: var(--font);
    font-weight: 730;
    font-size: 1.8rem;
    color: var(--text);
    line-height: 1.08;
    letter-spacing: -.032em;
    font-variant-numeric: tabular-nums;
}
.kpi-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; gap: 8px; font-size: .72rem; color: var(--text-3); }
.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .72rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
}
.kpi-trend i { font-size: .6rem; }
.kpi-trend.up { background: var(--green-dim); color: var(--green); }
.kpi-trend.down { background: var(--red-dim); color: var(--red); }

.kpi-bar {
    margin-top: auto;
    height: 5px;
    background: var(--border-light);
    border-radius: 999px;
    overflow: hidden;
}
.kpi-bar > div {
    width: 0%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand-400), var(--brand));
    transition: width 1s var(--ease-out);
}

/* ===== CARDS (sistema de la Guía de Formato) ===== */
.card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 15px;
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border: 1px solid color-mix(in srgb, var(--border-strong) 68%, transparent);
    border-radius: var(--r-lg);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
    box-shadow: var(--shadow-sm), inset 0 1px 0 var(--shine), inset 0 0 0 1px color-mix(in srgb, var(--surface) 26%, transparent);
}
.card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, var(--brand-400), var(--brand) 42%, transparent 88%);
    box-shadow: 0 0 14px var(--brand-glow);
    opacity: .9;
    pointer-events: none;
}
.card:has(.card-head) { padding: 0; }
.card:not(.kpi):hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--brand-300) 40%, var(--border-strong));
    box-shadow: var(--shadow-md), inset 0 1px 0 var(--shine), 0 18px 34px -20px var(--brand-glow);
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 15px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand-50) 34%, transparent), transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
    box-shadow: inset 2px 0 0 var(--brand), inset 0 1px 0 var(--shine);
}
.ch-txt { display: flex; flex-direction: column; min-width: 0; }
.card-head h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .88rem;
    font-weight: 640;
    letter-spacing: -.015em;
    color: var(--text);
}
.card-head h3::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 2px;
    background: linear-gradient(140deg, var(--brand-300), var(--brand));
    box-shadow: 0 0 8px var(--brand-glow);
    flex-shrink: 0;
}
.card-head .ch-sub { font-size: .7rem; color: var(--text-4); margin-top: 2px; padding-left: 14px; }
.card-body { padding: 15px; flex: 1; min-height: 0; }

.chart-canvas { position: relative; flex: 1; }
.chart-canvas canvas { width: 100% !important; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 11px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: var(--surface-3);
    color: var(--text-2);
    font-size: .7rem;
    font-weight: 540;
    cursor: pointer;
    transition: all .12s var(--ease);
    box-shadow: 0 3px 8px -4px rgba(0, 0, 0, .16), inset 0 1px 0 var(--shine);
    flex-shrink: 0;
}
.chip:hover { background: var(--surface-hover); color: var(--text); transform: translateY(-1px); }
.chip.is-on,
.chip.active {
    background: linear-gradient(180deg, var(--brand-400), var(--brand));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 18px -8px var(--brand-glow), inset 0 1px 0 rgba(255, 255, 255, .28);
}

.doughnut-legend { display: flex; flex-direction: column; gap: 6px; }
.legend-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 9px;
    border-radius: var(--r-sm);
    transition: background .15s var(--ease);
}
.legend-item:hover { background: var(--surface-hover); }
.legend-dot {
    width: 10px; height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
    box-shadow: 0 0 9px -1px currentColor;
}
.legend-name {
    font-size: .78rem;
    color: var(--text-3);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.legend-pct {
    font-size: .8rem;
    font-weight: 700;
    color: var(--brand-300);
    font-variant-numeric: tabular-nums;
}
.doughnut-legend > div span:last-child { color: var(--brand-300); }

/* ===== STAT BOXES (diferenciadas por tono) ===== */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.stat-box {
    --tone: var(--brand-400);
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 11px;
    background:
        linear-gradient(150deg, color-mix(in srgb, var(--tone) 12%, transparent), transparent 62%),
        color-mix(in srgb, var(--surface-3) 76%, transparent);
    border: 1px solid color-mix(in srgb, var(--tone) 22%, var(--border-2));
    border-radius: var(--r-md);
    padding: 12px 12px 12px 15px;
    transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
    box-shadow: inset 0 1px 0 var(--shine);
}
.stat-box::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--tone) 72%, #fff), var(--tone));
    box-shadow: 0 0 12px -2px var(--tone);
}
.stat-box:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--tone) 48%, var(--border));
    box-shadow: var(--shadow-md), 0 12px 24px -16px var(--tone), inset 0 1px 0 var(--shine);
}
.stat-box:hover .stat-box-icon { transform: scale(1.06) rotate(-3deg); }
.stat-box-icon {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 36px; height: 36px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    color: #fff;
    background: linear-gradient(160deg, color-mix(in srgb, var(--tone) 76%, #fff), var(--tone));
    box-shadow: 0 8px 16px -8px var(--tone), inset 0 1px 0 rgba(255, 255, 255, .3);
    transition: transform .22s var(--ease);
}
.stat-box-value {
    grid-column: 2;
    grid-row: 1;
    font-family: var(--font);
    font-weight: 720;
    font-size: 1.3rem;
    line-height: 1.1;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}
.stat-box-label {
    grid-column: 2;
    grid-row: 2;
    font-size: .63rem;
    font-weight: 560;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-4);
}

.stat-box.blue { --tone: var(--blue); }
.stat-box.green { --tone: var(--green); }
.stat-box.orange { --tone: var(--orange); }
.stat-box.purple { --tone: var(--purple); }

/* ===== ACTIVITY TABLE ===== */
.activity-scroll { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--brand) transparent; }
.activity-scroll::-webkit-scrollbar { height: 6px; }
.activity-scroll::-webkit-scrollbar-track { background: transparent; }
.activity-scroll::-webkit-scrollbar-thumb { background: linear-gradient(90deg, var(--brand-100), var(--brand)); border-radius: 999px; }
.activity-scroll::-webkit-scrollbar-thumb:hover { background: var(--brand); }

.activity-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .82rem; }
.activity-table thead th {
    position: sticky;
    top: 0;
    padding: 10px 14px;
    font-size: .6rem;
    font-weight: 700;
    color: var(--text-4);
    text-transform: uppercase;
    letter-spacing: .09em;
    background: color-mix(in srgb, var(--surface-2) 88%, transparent);
    backdrop-filter: blur(8px) saturate(1.2);
    -webkit-backdrop-filter: blur(8px) saturate(1.2);
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}
.activity-table thead th:first-child { padding-left: 18px; }
.activity-table tbody tr { transition: background .15s var(--ease), box-shadow .15s var(--ease); }
.activity-table tbody tr:hover {
    background: color-mix(in srgb, var(--brand) 9%, transparent);
    box-shadow: inset 3px 0 0 var(--brand);
}
.activity-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-3);
    color: var(--text-2);
    vertical-align: middle;
}
.activity-table tbody td:first-child { padding-left: 18px; }
.activity-table thead th:nth-child(4),
.activity-table thead th:nth-child(5),
.activity-table thead th:nth-child(6),
.activity-table tbody td:nth-child(4),
.activity-table tbody td:nth-child(5),
.activity-table tbody td:nth-child(6) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.activity-table tbody tr:last-child td { border-bottom: 0; }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .01em;
    text-transform: capitalize;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14);
}
.status-badge.paid { background: var(--green-dim); color: #7ee7c0; border-color: rgba(43, 212, 154, .35); }
.status-badge.pending { background: var(--orange-dim); color: #fbd38d; border-color: rgba(245, 165, 36, .38); }
.status-badge.cancelled { background: var(--red-dim); color: #fca5a5; border-color: rgba(255, 99, 105, .38); }
.status-badge .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
}

.cell-bright { color: var(--text); font-weight: 650; }
.legend-pct { color: var(--brand-200); }

/* ===== USER MENU / DROPDOWN ===== */
.avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    background: linear-gradient(140deg, var(--brand), var(--brand-400));
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .02em;
    box-shadow: var(--shadow-sm);
}
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    height: 36px;
    padding: 0 8px 0 5px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: none;
    color: var(--text-2);
    cursor: pointer;
    transition: background .15s var(--ease), border-color .15s var(--ease);
    flex-shrink: 0;
}
.user-menu-btn:hover { background: var(--surface-hover); border-color: var(--border); }
.user-menu-btn .u-meta { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.user-menu-btn .u-name { font-size: .75rem; font-weight: 620; color: var(--text); }
.user-menu-btn .u-role { font-size: .62rem; color: var(--text-4); }
.user-menu-btn .u-caret { font-size: .6rem; color: var(--text-4); margin-left: 2px; transition: transform .18s var(--ease); }
.user-menu-btn.open .u-caret { transform: rotate(180deg); }

.menu {
    position: fixed;
    z-index: 1200;
    min-width: 210px;
    padding: 5px;
    background: var(--glass-strong);
    backdrop-filter: blur(22px) saturate(1.5);
    -webkit-backdrop-filter: blur(22px) saturate(1.5);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    animation: menuIn .14s var(--ease-out) both;
    transform-origin: top right;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 32px;
    padding: 0 10px;
    border-radius: var(--r-xs);
    border: none;
    background: none;
    font-size: .8rem;
    font-family: var(--font);
    color: var(--text-2);
    text-align: left;
    cursor: pointer;
    transition: background .12s var(--ease), color .12s var(--ease);
}
.menu-item:hover { background: var(--surface-hover); color: var(--text); }
.menu-item i { width: 15px; text-align: center; font-size: .82rem; opacity: .75; }
.menu-item.danger { color: var(--red); }
.menu-item.danger:hover { background: var(--red-dim); }
.menu-item.danger i { opacity: 1; }
.menu-sep { height: 1px; background: var(--border-2); margin: 5px 0; }
.menu-label {
    padding: 7px 10px 4px;
    font-size: .6rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-4);
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }

/* ===== FADE-UP ===== */
/* Se anima con `translate` (no `transform`) para no bloquear el hover de las tarjetas. */
.fade-up { opacity: 0; translate: 0 14px; animation: fadeUp .55s var(--ease-out) forwards; }
.delay-1 { animation-delay: .04s; }
.delay-2 { animation-delay: .08s; }
.delay-3 { animation-delay: .12s; }
.delay-4 { animation-delay: .16s; }
.delay-5 { animation-delay: .20s; }
.delay-6 { animation-delay: .24s; }
.delay-7 { animation-delay: .28s; }
.delay-8 { animation-delay: .32s; }

@keyframes fadeUp { to { opacity: 1; translate: 0 0; } }
@keyframes drift {
    0%   { transform: translate(0, 0) scale(1); }
    33%  { transform: translate(40px, -30px) scale(1.05); }
    66%  { transform: translate(-24px, 22px) scale(.95); }
    100% { transform: translate(30px, -10px) scale(1.02); }
}
@keyframes auroraBeam {
    0%   { transform: translate3d(-6%, -4%, 0) rotate(0deg) scale(1); }
    50%  { transform: translate3d(5%, 3%, 0) rotate(7deg) scale(1.06); }
    100% { transform: translate3d(-4%, 5%, 0) rotate(-6deg) scale(1.02); }
}
@keyframes gridPan {
    from { background-position: 0 0, 0 0; }
    to   { background-position: 58px 58px, 58px 58px; }
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(43, 212, 154, .55); }
    70%  { box-shadow: 0 0 0 8px rgba(43, 212, 154, 0); }
    100% { box-shadow: 0 0 0 0 rgba(43, 212, 154, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .fade-up { animation: none; opacity: 1; translate: none; transform: none; }
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== TOOLTIP SIDEBAR ===== */
.sidebar-tooltip {
    display: none;
    position: fixed;
    transform: translateY(-50%);
    z-index: 1070;
    background: var(--glass-strong);
    backdrop-filter: blur(18px) saturate(1.5);
    -webkit-backdrop-filter: blur(18px) saturate(1.5);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--r-sm);
    white-space: nowrap;
    font-size: .78rem;
    color: var(--text);
    font-weight: 540;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
}

/* ===== THEME TOGGLE (estilo icon-btn + efectos según modo) ===== */
.theme-toggle {
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle input { display: none; }
.theme-toggle-track {
    position: relative;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    color: var(--text-2);
    background: radial-gradient(circle at 50% 50%, rgba(120, 130, 255, .16), transparent 72%);
    transition: background .3s var(--ease), border-color .3s var(--ease), color .3s var(--ease), transform .3s var(--ease);
}
.theme-toggle:hover .theme-toggle-track {
    color: var(--text);
    background: var(--surface-hover);
    border-color: var(--border-2);
    transform: translateY(-1px);
}
.theme-toggle input:checked ~ .theme-toggle-track {
    color: var(--text);
    background: radial-gradient(circle at 50% 50%, rgba(245, 158, 11, .20), transparent 72%);
    border-color: rgba(245, 158, 11, .28);
}
.theme-toggle-track::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 0 0 rgba(120, 130, 255, .42);
    animation: ringIndigo 3.2s ease-out infinite;
    pointer-events: none;
}
.theme-toggle input:checked ~ .theme-toggle-track::after { animation: ringAmber 3.2s ease-out infinite; }
.theme-toggle-thumb {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: none;
    border-radius: 0;
    box-shadow: none;
    transform: none;
}
.theme-icon-moon,
.theme-icon-sun {
    position: absolute;
    inset: 0;
    /* Font Awesome fija width:1.25em en .fa/.fas; sin esto el <i> no se estira
       con inset:0 y el icono queda pegado a la izquierda en lugar de centrado */
    width: auto;
    height: auto;
    display: grid;
    place-items: center;
    line-height: 1;
    font-size: .92rem;
    transition: opacity .3s var(--ease), transform .45s var(--ease);
}
.theme-icon-moon { color: #9aa6ff; text-shadow: 0 0 8px rgba(120, 130, 255, .55); }
.theme-icon-sun { color: #f59e0b; text-shadow: 0 0 8px rgba(245, 158, 11, .6); }

/* Estado según el modo activo: oscuro → luna, claro → sol */
.theme-icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }
.theme-icon-sun { opacity: 0; transform: rotate(90deg) scale(.4); }
.theme-toggle input:checked ~ .theme-toggle-track .theme-icon-moon { opacity: 0; transform: rotate(-90deg) scale(.4); }
.theme-toggle input:checked ~ .theme-toggle-track .theme-icon-sun { opacity: 1; transform: rotate(0deg) scale(1); }

/* Animaciones/efectos por modo */
.theme-icon-moon { animation: moonGlow 3.6s ease-in-out infinite; }
.theme-icon-sun { animation: none; }
.theme-toggle input:checked ~ .theme-toggle-track .theme-icon-moon { animation: none; }
.theme-toggle input:checked ~ .theme-toggle-track .theme-icon-sun { animation: sunSpin 10s linear infinite; }

@keyframes moonGlow {
    0%, 100% { opacity: .85; transform: rotate(0deg) scale(1); }
    50% { opacity: 1; transform: rotate(-6deg) scale(1.1); }
}
@keyframes sunSpin {
    from { transform: rotate(0deg) scale(1); }
    to { transform: rotate(360deg) scale(1); }
}
@keyframes ringIndigo {
    0% { box-shadow: 0 0 0 0 rgba(120, 130, 255, .42); }
    70%, 100% { box-shadow: 0 0 0 9px rgba(120, 130, 255, 0); }
}
@keyframes ringAmber {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, .45); }
    70%, 100% { box-shadow: 0 0 0 9px rgba(245, 158, 11, 0); }
}

/* ===== OVERLAY MOBILE ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1040;
}
body:has(.sidebar.mobile-open) .sidebar-overlay { display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1400px) {
    .c3 { grid-column: span 6; }
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1200px) {
    .c3, .c4, .c5, .c6, .c7, .c8 { grid-column: span 12; }
}
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w) !important;
        background: color-mix(in srgb, var(--sidebar-base) 88%, transparent);
        backdrop-filter: blur(20px) saturate(1.2);
        -webkit-backdrop-filter: blur(20px) saturate(1.2);
        border-right: 1px solid var(--border);
        box-shadow: 12px 0 40px rgba(0, 0, 0, .45);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .content-area { padding: 16px 14px; }
    .topbar { padding: 0 14px; }
    .search-trigger .search-label, .search-trigger kbd { display: none; }
    .search-trigger { width: 34px; min-width: 34px; padding: 0; justify-content: center; }
    .user-menu-btn .u-meta { display: none; }
}
@media (max-width: 768px) {
    .bento { gap: 12px; }
    .kpi-grid, .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page-title { font-size: 1.4rem; }
    .stats-grid, .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    /* Inicio: menos padding, logo y tipografía a escala de teléfono */
    .inicio-center { gap: 16px; padding: 32px 22px; }
    .inicio-mark { width: clamp(104px, 34vw, 150px); }
    .inicio-title { font-size: clamp(1.9rem, 8.4vw, 2.6rem); }
    .inicio-chip { gap: 10px; font-size: .64rem; letter-spacing: .1em; }
    .inicio-chip-text { white-space: normal; }
}
@media (max-width: 520px) {
    .c3, .c4, .c5, .c6, .c7, .c8 { grid-column: span 12; }
    .kpi-grid, .kpi-grid-4 { grid-template-columns: 1fr; }
    .kpi-value { font-size: 1.4rem; }
    .card, .kpi { padding: 13px; }
    .card:has(.card-head) { padding: 0; }

    .content-area { padding: 14px 12px; }
    .inicio-center { gap: 14px; padding: 26px 16px; }
    .inicio-title { font-size: clamp(1.7rem, 9.4vw, 2.2rem); }
    .inicio-sub { flex-wrap: wrap; justify-content: center; gap: 8px; font-size: .98rem; }
    .inicio-chip-text { letter-spacing: .08em; }
}


/* ===== TOPBAR QUICK LINKS / DROPDOWN ===== */
.topbar-dd {
    position: relative;
    display: flex;
    align-items: center;
}

.topbar-dd-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 190px;
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1200;
}

.topbar-dd.open .topbar-dd-menu {
    display: flex;
}

.topbar-dd-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 9px;
    color: var(--text-2);
    text-decoration: none;
    font-size: .86rem;
    font-weight: 500;
    transition: all .15s var(--ease);
}

.topbar-dd-menu a i {
    width: 18px;
    text-align: center;
    color: var(--text-4);
}

.topbar-dd-menu a:hover {
    background: rgba(61, 155, 255, .14);
    color: var(--brand-200);
}

.topbar-dd-menu a:hover i {
    color: var(--brand-200);
}

/* ===== TOPBAR QUICK LINKS COLOREADOS POR ENTIDAD ===== */
.topbar-right .quick-link {
    transition: all .16s var(--ease);
}

.topbar-right .quick-facturacion:hover {
    color: #22c55e;
    background: rgba(34, 197, 94, .14);
    border-color: rgba(34, 197, 94, .48);
}

.topbar-right .quick-carteras:hover {
    color: #38bdf8;
    background: rgba(56, 189, 248, .14);
    border-color: rgba(56, 189, 248, .48);
}

.topbar-right .quick-personas:hover,
.topbar-dd.open .quick-personas {
    color: #f472b6;
    background: rgba(244, 114, 182, .14);
    border-color: rgba(244, 114, 182, .48);
}

/* Dropdown items con color por entidad */
.topbar-dd-menu .dd-terceros:hover {
    color: #38bdf8;
    background: rgba(56, 189, 248, .12);
}

.topbar-dd-menu .dd-terceros:hover i {
    color: #38bdf8;
}

.topbar-dd-menu .dd-clientes:hover {
    color: #22c55e;
    background: rgba(34, 197, 94, .12);
}

.topbar-dd-menu .dd-clientes:hover i {
    color: #22c55e;
}

.topbar-dd-menu .dd-usuarios:hover {
    color: #f59e0b;
    background: rgba(245, 158, 11, .12);
}

.topbar-dd-menu .dd-usuarios:hover i {
    color: #f59e0b;
}


/* ===== TOPBAR QUICK: contenedor desktop ===== */
.topbar-quick {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== MOBILE APP STYLE ===== */
@media (max-width: 992px) {
    .topbar {
        gap: 8px;
        padding: 0 12px;
    }
    .topbar-left { gap: 8px; min-width: 0; }
    /* Marca compacta en lugar de la ruta completa */
    .crumb { display: flex; }
    .crumb .crumb-sep,
    .crumb .crumb-current { display: none; }
    .crumb-root {
        color: var(--text);
        font-size: .95rem;
        font-weight: 800;
        letter-spacing: -.02em;
    }

    /* La fila de atajos pasa a ser un dock inferior tipo app */
    .topbar-quick {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1035;
        justify-content: space-around;
        gap: 2px;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
        background: color-mix(in srgb, var(--surface-1) 86%, transparent);
        -webkit-backdrop-filter: blur(20px) saturate(1.4);
        backdrop-filter: blur(20px) saturate(1.4);
        border-top: 1px solid var(--border);
        box-shadow: 0 -10px 30px -18px rgba(0, 0, 0, .8);
    }
    .topbar-quick .quick-link {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        height: auto;
        min-height: 50px;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        padding: 5px 2px 4px;
        border: none;
        background: none;
        border-radius: 12px;
        color: var(--text-3);
    }
    /* Icono en "chip" con el color de cada entidad */
    .topbar-quick .quick-link i {
        display: grid;
        place-items: center;
        width: 34px;
        height: 28px;
        border-radius: 9px;
        font-size: 1rem;
        background: color-mix(in srgb, currentColor 14%, transparent);
        transition: transform .15s var(--ease), background .15s var(--ease);
    }
    .topbar-quick .quick-carteras i   { color: #38bdf8; }
    .topbar-quick .quick-facturacion i{ color: #22c55e; }
    .topbar-quick .quick-personas i   { color: #f472b6; }
    .topbar-quick .quick-personas.open i {
        background: color-mix(in srgb, currentColor 26%, transparent);
        transform: translateY(-1px);
    }
    .topbar-quick .quick-link:active i { transform: scale(.9); }
    .topbar-quick .quick-link::after {
        content: attr(title);
        font-size: .56rem;
        font-weight: 600;
        letter-spacing: .02em;
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .topbar-quick .quick-link:active {
        transform: scale(.94);
        background: var(--surface-hover);
    }

    /* Aire inferior para que el dock no tape el contenido */
    .content-area { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
    .inicio-view { padding-bottom: 84px; }
    /* Las entidades embebidas (iframe) también deben dejar libre el dock */
    .view-host {
        height: calc(100vh - 58px - 78px);
        height: calc(100dvh - 58px - 78px);
    }

}

@media (max-width: 420px) {
    .topbar-quick .quick-link::after { font-size: .5rem; }
    .topbar { padding: 0 10px; }
}
