/* =========================================
   JournalByTTS — layout.css
   Sidebar, topbar, main content, grid layout
   ========================================= */

/* ─── SIDEBAR ─── */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    height: 100vh;
    width: 240px;
    background-color: var(--bg-elev);
    color: var(--ink-2);
    border-right: 1px solid var(--border);
    transition: width var(--t-base) var(--ease-out);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar::after { display: none; }

@media (min-width: 1024px) {
    .sidebar.collapsed { width: 60px; }
}

.sidebar-header {
    padding: 14px 16px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.sidebar-header::after { display: none; }

.sidebar-brand {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: var(--text-lg);
    font-weight: 400;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    letter-spacing: -0.01em;
}

.sidebar-brand::after { display: none; }

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--ink-3);
    cursor: pointer;
    padding: 6px;
    transition: color var(--t-fast);
}
.sidebar-toggle:hover { color: var(--ink); }
.sidebar.collapsed .sidebar-toggle i { transform: rotate(180deg); }

.sidebar-nav { padding: 8px 0; flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav-bottom { list-style: none; margin: 0; border-top: 1px solid rgba(120,144,176,0.1); padding: 4px 0 8px; }

.sidebar-nav .nav-link,
.sidebar-nav-bottom .nav-link {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    color: var(--ink-2);
    text-decoration: none;
    transition: background var(--t-fast), color var(--t-fast);
    white-space: nowrap;
    font-size: var(--text-xs);
    font-weight: 400;
    border-left: none;
    border-radius: var(--r-sm);
    margin: 0 6px;
}

.sidebar-nav .nav-link i,
.sidebar-nav-bottom .nav-link i {
    width: 15px;
    margin-right: 8px;
    text-align: center;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav-bottom .nav-link:hover {
    color: var(--ink);
    background: var(--bg-hover);
}

.sidebar-nav .nav-link.active,
.sidebar-nav-bottom .nav-link.active {
    color: var(--accent-soft-fg);
    background: var(--accent-soft);
    font-weight: 500;
}

@media (min-width: 1024px) {
    .sidebar.collapsed .nav-link span { display: none; }
    .sidebar.collapsed .nav-link i { margin-right: 0; }
}

/* Separador de sección en nav */
.nav-separator {
    height: 1px;
    background: rgba(206, 191, 159, 0.1);
    margin: 5px 12px;
}

/* Separador de categoría en nav (con etiqueta) */
.nav-group-separator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 2px;
    list-style: none;
}
.nav-group-separator::before,
.nav-group-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(206, 191, 159, 0.1);
}
.nav-group-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(206, 191, 159, 0.45);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Selector de cuentas en sidebar ── */
.sidebar-accsec {
    padding: 8px 8px 6px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(206,191,159,0.12);
    margin-bottom: 2px;
    position: relative;
}
.sidebar-accsec-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    padding: 0 2px;
}
.sidebar-accsec-icon {
    font-size: 0.62rem;
    color: var(--accent);
    width: 12px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-accsec-title {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(192,208,232,0.45);
    white-space: nowrap;
    overflow: hidden;
}

/* Botón de cuenta seleccionada (trigger del dropdown) */
.sidebar-acc-selected {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    background: rgba(232,92,74,0.1);
    border: 1px solid rgba(232,92,74,0.25);
    border-radius: 6px;
    padding: 5px 7px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
    color: #f0f4fa;
}
.sidebar-acc-selected:hover {
    background: rgba(232,92,74,0.16);
    border-color: rgba(232,92,74,0.4);
}
.sidebar-acc-selected .acc-item-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.sidebar-acc-selected-name {
    font-size: 0.73rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.sidebar-acc-selected-chevron {
    font-size: 0.6rem;
    color: rgba(192,208,232,0.5);
    flex-shrink: 0;
    transition: transform 0.2s;
}
.sidebar-acc-selected.open .sidebar-acc-selected-chevron {
    transform: rotate(180deg);
}

/* Panel dropdown de cuentas — Modern premium */
.sidebar-acc-dropdown {
    position: absolute;
    left: 8px;
    right: 8px;
    top: calc(100% + 2px);
    background: var(--bg-elev);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(232, 85, 43, 0.08);
    z-index: 2000;
    overflow: hidden;
    display: none;
}
.sidebar-acc-dropdown.open {
    display: block;
    animation: popoverIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sidebar-acc-dropdown-list {
    display: flex;
    flex-direction: column;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(120,144,176,0.2) transparent;
}

.sidebar-acc-item {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    background: none;
    border: 1px solid transparent;
    border-radius: 5px;
    padding: 5px 7px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
    color: rgba(192,208,232,0.75);
}
.sidebar-acc-item:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(120,144,176,0.2);
    color: #c8d8ee;
}
.sidebar-acc-item.active {
    background: rgba(232,92,74,0.12);
    border-color: rgba(232,92,74,0.3);
    color: #f0f4fa;
}
.sidebar-acc-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.sidebar-acc-info {
    overflow: hidden;
    min-width: 0;
}
.sidebar-acc-name {
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.sidebar-acc-sub {
    font-size: 0.65rem;
    color: rgba(192,208,232,0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.sidebar-acc-loading,
.sidebar-acc-empty {
    font-size: 0.7rem;
    color: rgba(192,208,232,0.4);
    padding: 6px 8px;
    text-align: center;
    line-height: 1.5;
}
.sidebar-acc-empty a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.68rem;
}

/* Sidebar colapsado: ocultar sección de cuentas completamente SOLO en escritorio */
@media (min-width: 1024px) {
    .sidebar.collapsed .sidebar-accsec { display: none; }
}

/* Sidebar — ítem de Perfil personalizado */
.nav-link-profile,
.nav-link-academy {
    display: flex;
    align-items: center;
    gap: 0;
}
.sidebar-user-avatar,
.sidebar-academy-logo {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 12px;
    flex-shrink: 0;
    border: 1px solid rgba(192, 208, 232, 0.3);
}
.sidebar-user-initial,
.sidebar-academy-initial {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 700;
    margin-right: 12px;
    flex-shrink: 0;
    letter-spacing: 0;
}
.sidebar-user-initial {
    background: var(--accent);
}
.sidebar-academy-initial {
    background: var(--ink-3);
    font-size: 0.72rem;
}
.sidebar-academy-initial i {
    font-size: 0.65rem;
    opacity: 0.9;
}
.sidebar.collapsed .sidebar-user-avatar,
.sidebar.collapsed .sidebar-academy-logo,
.sidebar.collapsed .sidebar-user-initial,
.sidebar.collapsed .sidebar-academy-initial {
    margin-right: 0;
}

/* Sidebar collapsed: solo iconos (solo escritorio) */
@media (min-width: 1024px) {
    .sidebar.collapsed .nav-link span,
    .sidebar.collapsed .sidebar-brand,
    .sidebar.collapsed .nav-separator {
        opacity: 0;
        width: 0;
        overflow: hidden;
        transition: opacity 0.2s, width 0.3s;
    }
    .sidebar.collapsed .sidebar-brand {
        display: none;
    }
    .sidebar.collapsed .nav-link {
        justify-content: center;
        padding: 12px 0;
    }
    .sidebar.collapsed .sidebar-header {
        justify-content: center;
        padding: 22px 12px 18px;
    }
    .sidebar.collapsed .nav-group-separator {
        justify-content: center;
        padding: 8px 0;
        gap: 0;
    }
    .sidebar.collapsed .nav-group-separator::before {
        display: none;
    }
    .sidebar.collapsed .nav-group-separator::after {
        flex: none;
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: rgba(206, 191, 159, 0.35);
    }
    .sidebar.collapsed .nav-group-label {
        display: none;
    }
}

/* Sidebar expandido: mostrar texto */
.sidebar:not(.collapsed) .nav-link span {
    opacity: 1;
    width: auto;
    transition: opacity 0.2s 0.1s;
}

/* ─── CONTENIDO PRINCIPAL ─── */
.content {
    margin-left: 60px;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.content-inner {
    padding: 32px 36px;
    flex: 1;
}

.content.expanded {
    margin-left: 240px;
}

@media (max-width: 1023px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .content,
    .content.expanded {
        margin-left: 0 !important;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .content-inner {
        padding: 14px 12px;
        max-width: 100%;
        overflow-x: hidden;
    }
}

/* ─── BARRA SUPERIOR ─── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 500;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    justify-content: space-between;
    gap: 12px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-xs);
    color: var(--ink-3);
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
}
.topbar-left .topbar-sep { color: var(--ink-4); }
.topbar-left .topbar-page {
    font-weight: 500;
    color: var(--ink-3);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar { background: var(--bg-elev); border-bottom-color: var(--border); }

/* ─── BREADCRUMB ─── */
.topbar-sep { color: var(--ink-3); margin: 0 4px; opacity: 0.7; }
.topbar-page { color: var(--ink-3); font-size: 0.82rem; font-weight: 500; }

/* ─── PAGE HEADER ─── */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 28px;
    padding: 32px 32px 0;
    position: relative;
    flex-wrap: wrap;
    gap: 16px;
}
.page-header::after { display: none; }
.page-header h1 {
    margin: 0;
    color: var(--ink);
    font-family: var(--font-serif);
    font-style: italic;
    font-size: var(--text-4xl);
    font-weight: 400;
    letter-spacing: -0.02em;
}
.page-subtitle { margin: 6px 0 0; color: var(--ink-3); font-size: var(--text-sm); }

/* ─── TWO COLUMN LAYOUT ─── */
.two-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 0;
}
@media (max-width: 900px) {
    .two-column-layout { grid-template-columns: 1fr; }
}
.two-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 900px) {
    .two-column-layout { grid-template-columns: 1fr; }
}

/* ─── HAMBURGER BUTTON ─── */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 10px;
    transition: background 0.15s;
}
.hamburger-btn:hover { background: var(--washi); }
.hamburger-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--ink-2);
    border-radius: 6px;
    transition: all 0.2s;
}
@media (max-width: 1023px) {
    .hamburger-btn { display: flex; }
}

/* ─── MARCA MOBILE EN TOPBAR ─── */
.topbar-brand-mobile {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 1rem;
    color: var(--ink);
    letter-spacing: -0.01em;
    text-decoration: none;
    white-space: nowrap;
    display: none;
}
@media (max-width: 1023px) {
    /* Topbar UNA fila: ☰ marca … [foto] [account-switcher ▾] */
    .topbar {
        padding: 0 10px;
        gap: 8px;
        height: 56px;
        flex-wrap: nowrap;
    }
    .topbar-left {
        gap: 8px;
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }
    .topbar-right {
        gap: 8px;
        flex: 0 0 auto;
        min-width: 0;
    }
    .topbar-brand-mobile { display: inline; }
    .topbar-sep { display: none; }
    .topbar-page { display: none; }

    /* Ocultar elementos no críticos en móvil — viven ahora en el sidebar */
    .topbar-right > .seg,
    .topbar-right > .mode-toggle-pill,
    .topbar-right > .lang-toggle-pill,
    .topbar-right > .theme-toggle-btn {
        display: none;
    }

    /* Orden visual en topbar-right: foto a la izquierda, account-switcher a la derecha */
    .topbar-right .user-pill-wrap { order: 1; }
    .topbar-right .account-switcher { order: 2; }

    /* Account-switcher compacto en línea */
    .topbar .account-switcher-btn {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 4px 8px 4px 4px;
        max-width: 180px;
    }
    .topbar .acc-btn-icon { width: 22px; height: 22px; flex-shrink: 0; }
    .topbar .acc-btn-content {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        min-width: 0;
        line-height: 1.1;
        gap: 1px;
    }
    .topbar .acc-btn-label {
        display: block;
        font-size: 9px;
        line-height: 1;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--ink-3);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .topbar .acc-btn-name {
        display: block;
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.72rem;
        font-weight: 600;
        line-height: 1.2;
    }
    .topbar .acc-btn-chevron { flex-shrink: 0; font-size: 0.6rem; }

    /* User-pill compacto: solo avatar */
    .user-pill {
        padding: 0;
        background: transparent;
        border: 0;
    }
    .user-pill > span { display: none; }

    /* Dropdown del account-switcher: fixed full-width bajo el topbar */
    .account-dropdown {
        position: fixed;
        top: 60px;
        left: 8px;
        right: 8px;
        width: auto;
        max-height: 70vh;
    }
}
@media (max-width: 380px) {
    .topbar .acc-btn-label { display: none; }
    .topbar .acc-btn-name { max-width: 80px; }
    .topbar-brand-mobile { font-size: 0.85rem; }
}
@media (max-width: 340px) {
    .topbar-brand-mobile { display: none; }
}

/* ── Sidebar móvil-extras: mode/theme/lang dentro del drawer ── */
.sidebar-mobile-extras { display: none; }
@media (max-width: 1023px) {
    .sidebar-mobile-extras {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 12px 14px 18px;
        border-top: 1px solid var(--border);
        margin-top: 4px;
    }
    .sidebar-mobile-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }
    .sidebar-mobile-label {
        font-size: 0.72rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--ink-3);
    }
}

/* ─── SIDEBAR MÓVIL ─── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28,18,8,0.55);
    z-index: 999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; animation: fadeIn 0.2s ease; }

@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
    }
    .sidebar.mobile-open {
        transform: translateX(0) !important;
        box-shadow: 4px 0 24px rgba(28,18,8,0.35);
    }
    /* collapsed no tiene efecto en móvil — se controla solo con mobile-open */
    .sidebar.collapsed { width: 240px; }
}

.topbar-avatar-link {
    display: flex; align-items: center; gap: 8px;
    text-decoration: none; color: var(--ink-3);
    font-size: 0.8rem; font-weight: 500;
    transition: color 0.15s;
}
.topbar-avatar-link:hover { color: var(--text); }
.topbar-avatar-img {
    width: 28px; height: 28px; border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(232,92,74,0.25);
}
.topbar-avatar-initial {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    display: flex; align-items: center; justify-content: center;
    font-size: 0.72rem; font-weight: 700; color: #fff;
    border: 2px solid rgba(232,92,74,0.25);
}
.topbar-avatar-name { font-size: 0.78rem; }
@media (max-width: 560px) {
    .topbar-avatar-name { display: none; }
    .account-switcher-btn span { display: none; }
}

/* ─── TABLA RESPONSIVE ─── */
@media (max-width: 1023px) {
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .content-inner { padding: 16px; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .two-column-layout { grid-template-columns: 1fr !important; }
    .topbar { padding: 0 16px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-card { padding: 16px 14px; }
}

/* ─── ICON SPACING GLOBAL ─── */
.sidebar-nav .nav-link,
.sidebar-nav-bottom .nav-link {
    padding: 11px 20px 11px 22px;
    gap: 0;
}
.sidebar-nav .nav-link i,
.sidebar-nav-bottom .nav-link i {
    width: 22px;
    margin-right: 14px;
    font-size: 0.9rem;
    flex-shrink: 0;
    text-align: center;
}
.btn i, .btn-sm i, .btn-xs i {
    margin-right: 6px;
}
.account-switcher-btn > i {
    margin-right: 8px;
}

/* ─── NAV LINKS SIDEBAR ─── */
.nav-link {
    border-radius: var(--r-sm) !important;
    margin: 1px 8px !important;
    transition: background var(--t-fast), color var(--t-fast) !important;
}
.nav-link:hover { background: var(--bg-hover) !important; color: var(--ink) !important; }
.nav-link.active {
    background: var(--accent-soft) !important;
    color: var(--accent-soft-fg) !important;
    border-radius: var(--r-sm) !important;
}
.nav-link-admin.active,
.nav-link-admin:hover {
    background: var(--accent-soft) !important;
    color: var(--accent-soft-fg) !important;
}

/* ─── MODE PILL TOGGLE ─── */
.mode-toggle-pill {
    display: flex;
    align-items: center;
    background: rgba(120,144,176,0.07);
    border: 1px solid rgba(120,144,176,0.14);
    border-radius: 20px;
    padding: 3px 4px;
    gap: 2px;
}
.mode-pill-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: var(--ink-3);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
    white-space: nowrap;
}
.mode-pill-btn i { font-size: 0.7rem; }
.mode-pill-btn:hover { background: rgba(120,144,176,0.12); color: var(--text); }
.mode-pill-btn.active {
    background: rgba(232,92,74,0.15);
    color: var(--accent);
}
@media (max-width: 640px) {
    .mode-pill-btn span { display: none; }
    .mode-pill-btn { padding: 4px 7px; }
    .seg button span { display: none; }
    .seg button { padding: 4px 8px; }
}

/* ─── Segmented mode toggle (.seg) ─── */
.seg {
    display: flex;
    align-items: center;
    background: rgba(120,144,176,0.07);
    border: 1px solid rgba(120,144,176,0.14);
    border-radius: 20px;
    padding: 3px 4px;
    gap: 2px;
    flex-shrink: 0;
}
.seg button {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: var(--ink-3);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
    white-space: nowrap;
    font-family: var(--font-sans);
}
.seg button i { font-size: 0.7rem; }
.seg button:hover {
    background: rgba(120,144,176,0.12);
    color: var(--text);
}
.seg button.on {
    background: rgba(232,92,74,0.15);
    color: var(--accent);
}
@media (max-width: 640px) {
    .seg button span { display: none; }
    .seg button { padding: 4px 8px; }
}

/* account-pill (topbar components canvas) */
.account-pill {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: 500;
}
.account-pill .label { color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-size: 10px; }
.account-pill .value { color: var(--ink); }
.account-pill .firm { color: var(--accent); font-weight: 600; }

.user-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--bg-sunk);
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: 500;
}
/* Avatar placeholder (div con inicial) */
.user-pill div.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFB39C, #E8552B);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 600;
  font-size: 11px;
  flex-shrink: 0;
}
/* Avatar foto real (img) — reglas estrictas para evitar deformaciones */
.user-pill img,
.user-pill img.avatar {
  display: block;
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  max-width: 26px;
  max-height: 26px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  flex-shrink: 0;
  background: var(--bg-sunk);
  border: 0;
  padding: 0;
}
.user-pill-wrap {
  position: relative;
  display: inline-flex;
}
.user-pill-wrap .user-pill { cursor: pointer; }
.user-pill-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(232, 85, 43, 0.08);
  padding: 6px;
  margin-top: 8px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.96);
  transition:
    opacity 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.user-pill-dropdown::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  height: 6px;
}
.user-pill-wrap:hover .user-pill-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.user-pill-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.2px;
  color: var(--ink);
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  position: relative;
}
.user-pill-dropdown-item i { width: 14px; text-align: center; color: var(--ink-3); font-size: 12px; transition: color 0.2s; }
.user-pill-dropdown-item:hover {
  background: linear-gradient(90deg, rgba(232,85,43,0.08), rgba(232,85,43,0.02));
  color: var(--accent);
  padding-left: 16px;
}
.user-pill-dropdown-item:hover i { color: var(--accent); }
.user-pill-dropdown-item--danger { color: var(--danger, #e55); }
.user-pill-dropdown-item--danger i { color: var(--danger, #e55); }
.user-pill-dropdown-item--danger:hover { background: color-mix(in srgb, var(--danger, #e55) 10%, transparent); }
.user-pill-dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* app shell (canvas) */
.app {
  display: grid;
  grid-template-columns: 56px 1fr;
  min-height: 100%;
  background: var(--bg);
}
.main { display: flex; flex-direction: column; min-width: 0; }

/* canvas crumbs */
.crumbs {
  font-size: var(--text-xs);
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}
.crumbs .sep { margin: 0 6px; opacity: .5; }
.crumbs .current { color: var(--ink); }
.topbar-spacer { flex: 1; }

/* ─── LIGHT THEME topbar ─── */
html[data-theme="light"] .topbar {
    background: var(--bg-elev);
    border-bottom-color: var(--border);
}
html[data-theme="light"] .topbar-page { color: var(--ink-3); }
html[data-theme="light"] .topbar-sep  { color: var(--ink-4); }
html[data-theme="light"] .lang-toggle-pill {
    background: rgba(30,60,100,0.06);
    border-color: rgba(30,60,100,0.12);
}
html[data-theme="light"] .lang-pill-btn { color: var(--ink-3); }
html[data-theme="light"] .lang-pill-btn:hover { color: var(--text); background: rgba(30,60,100,0.08); }
html[data-theme="light"] .theme-toggle-btn {
    border-color: rgba(30,60,100,0.18);
    color: var(--ink-3);
}
html[data-theme="light"] .theme-toggle-btn:hover {
    background: rgba(30,60,100,0.07);
    border-color: rgba(30,60,100,0.3);
    color: var(--text);
}

/* ══════════════════════════════════════════
   ACCOUNT SWITCHER (topbar)
   ══════════════════════════════════════════ */

.account-switcher { position: relative; }

.account-switcher-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 6px 12px 6px 8px;
    border-radius: var(--r-pill);
    font-size: var(--text-xs);
    color: var(--ink-2);
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast);
    white-space: nowrap;
}
.account-switcher-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}
.account-switcher-btn.open {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

.acc-btn-icon {
    width: 22px; height: 22px; border-radius: var(--r-xs);
    background: var(--bg-sunk);
    color: var(--ink-3);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem; flex-shrink: 0;
}
.acc-btn-icon i { margin: 0; line-height: 1; }
.acc-btn-label {
    font-size: 10px; color: var(--ink-3); font-weight: 500;
    line-height: 1; text-transform: uppercase; letter-spacing: 0.06em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acc-btn-name {
    font-size: var(--text-xs); font-weight: 600; color: var(--ink);
    line-height: 1.2; white-space: nowrap; max-width: 200px;
}
.acc-btn-name .firm { color: var(--accent); font-weight: 600; }
.acc-btn-name .phase { color: var(--ink-3); font-weight: 500; }
.acc-btn-chevron {
    font-size: 0.62rem; color: var(--ink-3); flex-shrink: 0;
    transition: transform var(--t-fast); margin-left: 2px;
}
.account-switcher-btn.open .acc-btn-chevron { transform: rotate(180deg); }

.account-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 300px;
    background: rgba(20, 26, 38, 0.6);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    z-index: 600;
    display: none;
    overflow: hidden;
    transform-origin: top right;
}
html[data-theme="light"] .account-dropdown {
    background: rgba(255, 255, 255, 0.6);
}
.account-dropdown.open {
    display: block;
    animation: accDropIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes accDropIn {
    from { opacity: 0; transform: scale(0.96) translateY(-4px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.acc-drop-header {
    padding: 12px 14px 10px;
    background: var(--bg-sunk);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.acc-drop-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-3); }
.acc-drop-count { font-size: 10px; color: var(--ink-3); font-weight: 500; }

.acc-search-wrap {
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.acc-search-wrap i {
    position: absolute; left: 22px; top: 50%;
    transform: translateY(-50%); font-size: 0.72rem;
    color: var(--ink-3); pointer-events: none;
}
.acc-search-input {
    width: 100%; padding: 6px 10px 6px 30px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: var(--text-xs); color: var(--ink);
    font-family: var(--font-sans); outline: none;
    transition: border-color var(--t-fast);
}
.acc-search-input::placeholder { color: var(--ink-4); }
.acc-search-input:focus { border-color: var(--accent); }

.acc-drop-list {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    padding: 6px 0;
}

.acc-firm-group { margin-bottom: 2px; }
.acc-firm-label {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px 4px;
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.1em; color: var(--ink-3);
}
.acc-firm-label-line { flex: 1; height: 1px; background: var(--divider); }

.acc-drop-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; cursor: pointer;
    transition: background var(--t-fast);
    border-left: 2px solid transparent;
}
.acc-drop-item:hover { background: var(--bg-hover); }
.acc-drop-item.active { background: var(--accent-soft); border-left-color: var(--accent); }

.acc-item-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.acc-item-body { flex: 1; min-width: 0; }
.acc-item-top  { display: flex; align-items: baseline; gap: 6px; }
.acc-item-bottom { margin-top: 2px; }
.acc-item-size  {
    font-family: var(--font-mono); font-size: var(--text-sm);
    font-weight: 600; color: var(--ink); letter-spacing: -0.01em; line-height: 1;
}
.acc-item-login { font-size: 10px; color: var(--ink-3); font-weight: 400; }
.acc-item-check { font-size: 0.72rem; color: var(--accent); flex-shrink: 0; opacity: 0; transition: opacity var(--t-fast); }
.acc-drop-item.active .acc-item-check { opacity: 1; }

.acc-drop-empty { padding: 20px 14px; text-align: center; font-size: var(--text-sm); color: var(--ink-3); line-height: 1.6; }
.acc-drop-empty a { color: var(--accent); font-weight: 500; font-size: var(--text-xs); }

.acc-drop-footer {
    padding: 9px 14px; border-top: 1px solid var(--border);
    background: var(--bg-sunk);
    display: flex; align-items: center; justify-content: space-between;
}
.acc-drop-footer a { font-size: var(--text-xs); color: var(--accent); font-weight: 500; text-decoration: none; display: flex; align-items: center; gap: 5px; transition: color var(--t-fast); }
.acc-drop-footer a:hover { color: var(--accent-hover); }
.acc-drop-footer-stats { font-size: 10px; color: var(--ink-3); }

.acc-no-results { padding: 16px 14px; text-align: center; font-size: var(--text-sm); color: var(--ink-3); display: none; }

.account-dropdown-item { display: flex; align-items: center; gap: 10px; padding: 9px 14px; font-size: 0.82rem; color: var(--ink); cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.12s; border-radius: 8px; margin: 2px 6px; }
.account-dropdown-item:last-child { border-bottom: none; }
.account-dropdown-item:hover { background: var(--bg-hover); }
.account-dropdown-item .acc-firm { font-weight: 600; font-size: 0.82rem; }
.account-dropdown-item .acc-meta { font-size: 0.75rem; color: var(--ink-3); }
.account-dropdown-item .acc-phase-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.account-dropdown-empty { padding: 14px; font-size: 0.8rem; color: var(--ink-3); text-align: center; }

@media (max-width: 1023px) {
    .acc-drop-list {
        max-height: calc(70vh - 130px);
    }
}

/* ─── SIDEBAR TEXT COLOR PER THEME ─── */
/* Light theme: black text in sidebar */
html[data-theme="light"] .sidebar,
html[data-theme="light"] .sidebar-brand,
html[data-theme="light"] .sidebar-nav .nav-link,
html[data-theme="light"] .sidebar-nav-bottom .nav-link,
html[data-theme="light"] .sidebar-accsec-title,
html[data-theme="light"] .sidebar-acc-name,
html[data-theme="light"] .sidebar-acc-sub,
html[data-theme="light"] .sidebar-toggle {
    color: #000;
}
html[data-theme="light"] .sidebar-acc-selected,
html[data-theme="light"] .sidebar-acc-selected-name,
html[data-theme="light"] .sidebar-acc-item {
    color: #1a1a1a;
}
html[data-theme="light"] .sidebar-acc-selected-chevron {
    color: rgba(0,0,0,0.4);
}
html[data-theme="light"] .sidebar-acc-dropdown {
    background: #fff;
    border-color: rgba(0,0,0,0.12);
}
html[data-theme="light"] .sidebar-acc-item:hover {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.1);
    color: #000;
}
html[data-theme="light"] .sidebar-nav .nav-link:hover,
html[data-theme="light"] .sidebar-nav-bottom .nav-link:hover {
    color: #000 !important;
}

/* Dark theme: white text in sidebar */
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .sidebar-brand,
html[data-theme="dark"] .sidebar-nav .nav-link,
html[data-theme="dark"] .sidebar-nav-bottom .nav-link,
html[data-theme="dark"] .sidebar-accsec-title,
html[data-theme="dark"] .sidebar-acc-name,
html[data-theme="dark"] .sidebar-acc-sub,
html[data-theme="dark"] .sidebar-toggle {
    color: #fff;
}
html[data-theme="dark"] .sidebar-nav .nav-link:hover,
html[data-theme="dark"] .sidebar-nav-bottom .nav-link:hover {
    color: #fff !important;
}

/* Keep active link using accent in both themes */
html[data-theme="light"] .sidebar-nav .nav-link.active,
html[data-theme="light"] .sidebar-nav-bottom .nav-link.active,
html[data-theme="dark"] .sidebar-nav .nav-link.active,
html[data-theme="dark"] .sidebar-nav-bottom .nav-link.active {
    color: var(--accent-soft-fg) !important;
}

/* ─── ACCOUNT DROPDOWN — legibilidad por tema ─── */
html[data-theme="dark"] .acc-drop-title,
html[data-theme="dark"] .acc-drop-count,
html[data-theme="dark"] .acc-firm-label,
html[data-theme="dark"] .acc-item-size,
html[data-theme="dark"] .acc-item-login,
html[data-theme="dark"] .acc-drop-empty,
html[data-theme="dark"] .acc-drop-footer-stats,
html[data-theme="dark"] .account-dropdown-item,
html[data-theme="dark"] .account-dropdown-item .acc-meta,
html[data-theme="dark"] .account-dropdown-empty {
    color: #f0f3f8 !important;
}
html[data-theme="dark"] .acc-search-input {
    color: #f0f3f8;
    background: rgba(255, 255, 255, 0.06);
}
html[data-theme="dark"] .acc-search-input::placeholder { color: rgba(240, 243, 248, 0.55); }

html[data-theme="light"] .acc-drop-title,
html[data-theme="light"] .acc-drop-count,
html[data-theme="light"] .acc-firm-label,
html[data-theme="light"] .acc-item-size,
html[data-theme="light"] .acc-item-login,
html[data-theme="light"] .acc-drop-empty,
html[data-theme="light"] .acc-drop-footer-stats,
html[data-theme="light"] .account-dropdown-item,
html[data-theme="light"] .account-dropdown-item .acc-meta,
html[data-theme="light"] .account-dropdown-empty {
    color: #1a2a3a !important;
}

/* ─── KPI TOOLTIP — texto legible por tema ─── */
html[data-theme="light"] .info-tooltip .tooltip-text {
    background: #ffffff;
    color: #1a2a3a;
    border: 1px solid rgba(30, 60, 100, 0.12);
}
html[data-theme="light"] .info-tooltip .tooltip-text::after {
    border-top-color: #ffffff;
}
html[data-theme="dark"] .info-tooltip .tooltip-text {
    background: #1c2433;
    color: #f0f3f8;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
html[data-theme="dark"] .info-tooltip .tooltip-text::after {
    border-top-color: #1c2433;
}
