/* ============================================
   NinhoMail - Outlook Local Inbox Viewer
   Rediseño 2026-09-01 — estética terminal:
   verde-negros profundos, acento verde terminal
   solo en activo/primario, texto mint-white.
   ============================================ */

:root {
    /* ── Surfaces (verde-negro profundo) ── */
    --bg: hsl(160, 22%, 2.6%);
    --bg-sidebar: hsl(156, 14%, 7.2%);
    --bg-card: hsl(154, 14%, 9.4%);
    --bg-hover: hsl(152, 16%, 12.8%);
    --bg-active: hsl(152, 18%, 15.8%);
    --bg-input: hsl(164, 26%, 2.2%);
    /* ── Acento (verde terminal — solo activo/primario) ── */
    --accent: hsl(152, 72%, 48%);
    --accent-hover: hsl(153, 74%, 42%);
    --accent-light: hsl(150, 76%, 64%);
    --accent-soft: hsl(152, 72%, 48%, 0.13);
    --accent-softer: hsl(152, 72%, 48%, 0.06);
    --accent-ring: hsl(152, 72%, 48%, 0.32);
    --avatar-bg: hsl(152, 62%, 50%);
    /* ── Texto (mint-white) ── */
    --text: hsl(140, 18%, 96%);
    --text-secondary: hsl(148, 12%, 84%);
    --text-muted: hsl(156, 8%, 54%);
    --text-disabled: hsl(158, 8%, 38%);
    /* ── Bordes (hairline mint) ── */
    --border: hsl(150, 28%, 88%, 0.09);
    --border-strong: hsl(150, 26%, 90%, 0.14);
    --divider: hsl(150, 28%, 88%, 0.05);
    /* ── Semánticos ── */
    --success: hsl(152, 62%, 50%);
    --error: hsl(4, 74%, 60%);
    --error-soft: hsl(4, 74%, 60%, 0.11);
    --amber: hsl(38, 92%, 60%);
    --amber-soft: hsl(38, 92%, 60%, 0.11);
    --info: hsl(196, 80%, 54%);
    --white: #ffffff;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.30);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.40);
    --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app {
    display: flex;
    height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    /* FIX AUDIT r3 (NEW-7): la status-bar ya no existe — el sidebar mantenía
       los 24px de reserva y dejaba el hueco viejo. */
    height: 100vh;
    overflow: hidden;
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    flex-shrink: 0;
}

.brand-logo svg { stroke: var(--white); }

.brand-text h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.3px;
}

.brand-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.badge-secure {
    font-size: 9px;
    font-weight: 700;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.status-indicator {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-indicator.online { color: var(--success); }
.status-indicator.expired { color: var(--error); }

.status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
}

.status-indicator.online .status-dot { background: var(--success); }
.status-indicator.expired .status-dot { background: var(--error); }

/* Token Panel - oculto por defecto */
.token-panel {
    display: none;
    border-bottom: 1px solid var(--border);
}

.token-panel.visible {
    display: block;
}

.token-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 0.15s;
}

.token-toggle:hover { background: var(--bg-hover); }

.token-toggle svg { transition: transform 0.2s; }

.token-panel.open .token-toggle svg { transform: rotate(180deg); }

.token-content {
    padding: 0 20px 16px;
    display: none;
}

.token-panel.open .token-content { display: block; }

.token-content input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 8px 10px;
    font-size: 12px;
    font-family: 'Consolas', monospace;
    margin-bottom: 6px;
    outline: none;
}

.token-content input:focus { border-color: var(--accent); }

.token-content input::placeholder { color: var(--text-muted); }

.token-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.btn-connect {
    flex: 1;
    padding: 8px 12px;
    background: var(--accent);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-connect:hover { background: var(--accent-hover); }

.btn-disconnect {
    padding: 8px 12px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
}

.token-status {
    margin-top: 8px;
    font-size: 11px;
    min-height: 16px;
}

.token-status.success { color: var(--success); }
.token-status.error { color: var(--error); }

/* Navigation */
.nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section { margin-bottom: 4px; }

.nav-section h3 {
    padding: 12px 20px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.nav-section ul { list-style: none; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    margin: 0 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.12s;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-item.active {
    background: hsl(152, 72%, 48%, 0.13);
    color: var(--accent-light);
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.nav-item .icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
}

.nav-item .name { flex: 1; }

.nav-item .count {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
    margin-left: auto;
}

/* Sidebar Stats */
.sidebar-stats {
    padding: 12px 20px 4px;
    display: none;
    align-items: baseline;
    gap: 12px;
    flex-shrink: 0;
}

.sidebar-stats.visible {
    display: flex;
}

.sidebar-stats .stat-total {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.sidebar-stats .stat-new {
    font-size: 12px;
    color: #22c55e;
    font-weight: 600;
}

/* User Bar - siempre visible abajo */
.user-bar {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.user-bar.hidden {
    display: none;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--avatar-bg), hsl(150, 76%, 64%));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--white);
    flex-shrink: 0;
}

.user-info { min-width: 0; }

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.welcome-content {
    text-align: center;
    max-width: 420px;
    padding: 40px;
}

.welcome-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    color: var(--white);
}

.welcome-content h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 8px;
}

.welcome-content > p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.welcome-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
}

.step-num {
    width: 24px;
    height: 24px;
    background: var(--accent);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Email View */
.email-view {
    display: flex;
    height: 100%;
}

/* List Panel */
.list-panel {
    width: 420px;
    min-width: 360px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--bg);
    position: relative;
}

.list-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--border);
}

.list-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.list-title-row h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--white);
}

.btn-refresh {
    width: 34px;
    height: 34px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-refresh:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--accent);
}

.btn-refresh:active { transform: scale(0.95); }

.btn-refresh.spinning svg {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* SaaS micro-animations */
@keyframes rise-in-sm {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes msg-body-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-body-enter {
    animation: msg-body-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes pop-in {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .detail-header,
    .detail-body,
    .msg-body-enter,
    .sk-line,
    .spin-dot,
    .loading {
        animation: none !important;
    }
}

.list-tabs {
    display: flex;
    gap: 4px;
}

.tab-btn {
    padding: 6px 14px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.12s;
    font-weight: 500;
}

.tab-btn:hover { color: var(--text); background: var(--bg-hover); }

.tab-btn.active {
    color: var(--white);
    background: var(--bg-card);
}

/* Search */
.list-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 10px;
    color: var(--text-muted);
}

.list-search .search-field {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    height: 36px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.list-search .search-field:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px hsl(152, 72%, 48%, 0.10);
}

.list-search .search-field input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 13px;
    outline: none;
    min-width: 0;
}

.list-search .search-field input::placeholder { color: var(--text-muted); }

.list-search .search-clear {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    font-size: 14px;
    line-height: 1;
}

.list-search .search-clear.visible { display: block; }

/* Email List */
.email-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.email-list::-webkit-scrollbar { width: 6px; }
.email-list::-webkit-scrollbar-track { background: transparent; }
.email-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.email-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid rgba(39, 39, 58, 0.5);
    position: relative;
}

.email-item:hover { background: var(--bg-hover); }

.email-item.active { background: hsl(152, 72%, 48%, 0.06); }

.email-item.unread::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

.email-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
.av-fallback {
    width: 100%; height: 100%; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: var(--white);
    text-transform: uppercase;
}
.av-logo {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    border-radius: 50%; object-fit: cover;
    opacity: 0; transition: opacity .2s ease;
}
.av-logo.loaded { opacity: 1; }

.email-content {
    flex: 1;
    min-width: 0;
}

.email-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3px;
}

.email-sender {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-item.unread .email-sender { color: var(--white); }

.email-date {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 8px;
}

.email-subject {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.email-item.unread .email-subject { color: var(--accent-light); }

.email-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   DETAIL PANEL
   ============================================ */

.detail-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg);
}

.detail-panel::-webkit-scrollbar { width: 8px; }
.detail-panel::-webkit-scrollbar-track { background: transparent; }
.detail-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.detail-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.detail-empty-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    max-width: 380px;
    animation: rise-in-sm 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.detail-empty-icon-wrap {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    position: relative;
}

.detail-empty-icon-wrap::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: radial-gradient(circle, var(--accent-soft), transparent 65%);
    z-index: -1;
    opacity: 0.5;
    filter: blur(12px);
}

.detail-empty-icon-wrap svg {
    stroke: var(--accent);
    opacity: 0.8;
}

.detail-empty h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 4px;
}

.detail-empty p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 320px;
}

.detail-empty-shortcuts {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: 11.5px;
    color: var(--text-disabled);
}

.detail-empty-shortcuts kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    margin-right: 4px;
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 1px 0 var(--border);
}

/* Detail Actions — flat SaaS toolbar */
.detail-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    min-height: 52px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}
.detail-actions::-webkit-scrollbar { display: none; }

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 0 0 auto;
    height: 34px;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    border: 0;
    background: transparent;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    touch-action: manipulation;
}

.action-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.92;
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.action-btn:active {
    background: var(--bg-active);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Danger button (Delete) */
.action-btn--danger {
    color: rgba(239, 68, 68, 0.85) !important;
}
.action-btn--danger:hover {
    background: var(--error-soft) !important;
    color: #f87171 !important;
}

/* Block button active state */
.action-btn.active {
    color: var(--accent-light);
    background: var(--accent-soft);
}

/* Flag button active */
.action-btn.flagged {
    color: var(--amber);
    background: var(--amber-soft);
    animation: pop-in 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Toolbar divider */
.toolbar-divider {
    display: inline-block;
    width: 1px;
    height: 18px;
    margin: 0 8px;
    background: var(--border-strong);
    flex-shrink: 0;
    align-self: center;
    opacity: 0.9;
}

/* Detail Header — SaaS reading pane */
.detail-header {
    padding: 20px 24px 0;
    animation: rise-in-sm 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.detail-header h2 {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 16px;
    font-size: clamp(1.125rem, 1.05rem + 0.35vw, 1.375rem);
    font-weight: 700;
    color: var(--white);
    line-height: 1.3;
    letter-spacing: -0.025em;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.detail-sender-row {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding-bottom: 16px;
}

.detail-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--avatar-bg), hsl(150, 76%, 64%));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--white);
    flex-shrink: 0;
    user-select: none;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.1),
        0 1px 2px rgba(0, 0, 0, 0.25);
}

.detail-sender-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 1px;
}

.detail-from-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px 16px;
    min-width: 0;
}

.detail-from-text {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    min-width: 0;
    flex: 1;
}

.detail-recip-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    min-width: 0;
}

.detail-to {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
    padding: 0;
}

.detail-to-label {
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-disabled);
}

.detail-to-addr {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    color: var(--text-secondary);
}

.detail-attach-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-hover);
    border: 1px solid var(--border);
    letter-spacing: -0.01em;
    transition: border-color 0.12s, background 0.12s;
}

.detail-attach-badge:hover {
    border-color: var(--border-strong);
    background: var(--bg-active);
}

.detail-attach-badge svg {
    color: var(--accent-light);
}

.detail-sender-name {
    font-size: 14px;
    font-weight: 650;
    color: var(--text);
    letter-spacing: -0.015em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-sender-email {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: -0.005em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-date {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

/* Detail divider */
.detail-header::after {
    content: '';
    display: block;
    height: 1px;
    margin: 0 24px;
    background: var(--divider);
}

/* Detail Body Card */
.detail-body-card {
    flex: 1;
    overflow-y: auto;
    padding: 12px 24px 40px;
    background: var(--bg);
}

.detail-body-card::-webkit-scrollbar { width: 8px; }
.detail-body-card::-webkit-scrollbar-track { background: transparent; }
.detail-body-card::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.detail-body {
    background: var(--white);
    color: #1a1a1a;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.7;
    min-height: 200px;
    box-shadow: var(--shadow-md);
    overflow-wrap: break-word;
    word-break: break-word;
    overflow: hidden;
    animation: rise-in-sm 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.detail-body a { color: #2563eb; }
.detail-body img { max-width: 100%; height: auto; }
.detail-body pre {
    background: #f4f4f5;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
}

/* Show Original bar — pill button style */
.restore-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 8px 16px;
    min-height: 44px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.restore-bar .restore-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    border-radius: 999px;
    border: 1px solid var(--accent);
    background: var(--accent-softer);
    color: var(--accent-light);
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
    font-family: var(--font);
}

.restore-bar .restore-btn:hover {
    background: var(--accent-soft);
    color: var(--white);
    border-color: var(--accent-light);
}

.restore-bar .restore-btn:active {
    transform: scale(0.97);
}

.restore-bar .restore-btn.active {
    border-color: var(--success);
    color: var(--success);
    background: rgba(34, 197, 94, 0.08);
}

.restore-bar .restore-btn.active:hover {
    background: rgba(34, 197, 94, 0.14);
}

/* FIX auditoría 2026-08-13: portado del bloque viejo eliminado */
.restore-bar .restore-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.restore-bar .restore-info {
    font-size: 11px;
    color: var(--text-muted);
}

/* Spin dot for loading state */
.spin-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: loading-pulse 1.2s ease-in-out infinite;
}

@keyframes loading-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 hsl(152, 72%, 48%, 0.4); opacity: 1; }
    50% { transform: scale(1.15); box-shadow: 0 0 0 6px hsl(152, 72%, 48%, 0); opacity: 0.85; }
}

/* Contenido del email renderizado directamente (sin iframe) */
.msg-body-html {
    padding: 24px 28px;
}

.msg-body-html img { max-width: 100% !important; height: auto !important; }
.msg-body-html table { max-width: 100% !important; border-collapse: collapse; }
.msg-body-html pre, .msg-body-html code { white-space: pre-wrap; word-wrap: break-word; font-size: 13px; }
.msg-body-html blockquote { border-left: 3px solid #e2e8f0; margin: 10px 0; padding: 6px 16px; color: #64748b; }

/* IFRAME para renderizar emails */
.msg-iframe {
    width: 100%;
    border: 0;
    min-height: 200px;
    height: auto;
    opacity: 0;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
    background: var(--white);
}

/* ============================================
   LOADING / ERROR
   ============================================ */

.loading {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 16px;
    padding: 8px 4px 28px;
    margin: 8px 20px 0;
    animation: rise-in-sm 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
    color: var(--text-muted);
    font-size: 13px;
}

.loading p {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-muted);
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* Skeleton loading lines */
.msg-skeleton {
    display: flex;
    flex-direction: column;
    gap: 11px;
    padding: 18px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-sidebar);
}

.sk-line {
    height: 11px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-active) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.35s ease-in-out infinite;
}

.sk-line:nth-child(1) { width: 70%; }
.sk-line:nth-child(2) { width: 95%; animation-delay: 0.05s; }
.sk-line:nth-child(3) { width: 88%; animation-delay: 0.1s; }
.sk-line:nth-child(4) { width: 60%; animation-delay: 0.15s; }
.sk-line:nth-child(5) { width: 92%; animation-delay: 0.2s; }
.sk-line:nth-child(6) { width: 80%; animation-delay: 0.25s; }

.sk-gap { height: 8px; }

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.error-display {
    margin: 16px;
    padding: 14px 18px;
    background: var(--error-soft);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius);
    color: var(--error);
    font-size: 13px;
    line-height: 1.5;
    animation: rise-in-sm 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.error-display .error-retry {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--error);
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.error-display .error-retry:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.5);
}

/* ============================================
   UTILITIES
   ============================================ */

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 900px) {
    .list-panel { width: 320px; min-width: 280px; }
    .sidebar { width: 220px; }
}

/* ============================================
   NUEVO v3.0: TOAST NOTIFICATIONS
   ============================================ */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.4);
    color: #22c55e;
}

.toast.error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.toast.info {
    background: hsl(152, 72%, 48%, 0.13);
    border-color: hsl(152, 72%, 48%, 0.32);
    color: hsl(150, 76%, 64%);
}

/* ============================================
   NUEVO v3.0: ATTACHMENTS
   ============================================ */

.attach-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 24px;
    animation: rise-in-sm 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.att-item {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    max-width: min(280px, 100%);
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    font-size: 12px;
    user-select: none;
    color: var(--text-secondary);
    text-decoration: none;
    text-align: left;
    touch-action: manipulation;
}

.att-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text);
}

.att-item:active {
    transform: none;
}

.att-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    border: 1px solid transparent;
    transition: transform 0.12s;
}

.att-item:hover .att-icon {
    transform: scale(1.05);
}

.att-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.att-size {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.att-dl {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    transition: color 0.12s, background 0.12s;
}

.att-item:hover .att-dl {
    color: var(--accent-light);
    background: var(--accent-softer);
}

/* ============================================
   NUEVO v3.0: EMAIL ITEM EXTRAS
   ============================================ */

.att-indicator {
    font-size: 12px;
    margin-left: 4px;
    opacity: 0.6;
}

.email-item.unread .att-indicator {
    opacity: 1;
}

/* ============================================
   NUEVO v3.0: BLOCK BUTTON
   ============================================ */

#blockBtn.active {
    color: #e5484d !important;
    border-color: rgba(229, 72, 77, 0.4) !important;
    background: rgba(229, 72, 77, 0.08) !important;
}

#blockBtn.active:hover {
    background: rgba(229, 72, 77, 0.15) !important;
}

/* ============================================
   KEYBOARD NAVIGATION HELPERS
   ============================================ */

.email-item {
    transition: background 0.1s;
}

.email-item:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Responsive v3.0 */
@media (max-width: 900px) {
    .att-name { max-width: 120px; }
    .toast { font-size: 12px; padding: 10px 16px; }
}

@media (max-width: 640px) {
    .attach-list { padding: 8px 12px; }
    .att-name { max-width: 100px; }
    .att-dl { display: none; }
}

/* ============================================
   NUEVO v3.1: PAGINATION
   ============================================ */

.pagination {
    /* FIX 2026-09-01: estructura SkyMail v22 — columna: fila de botones
       (pg-row, wrap) + info en línea propia. La fila única se cortaba. */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
    font-size: 12px;
    min-height: 44px;
}

.pg-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
    row-gap: 6px;
    max-width: 100%;
}

.pg-btn {
    /* FIX 2026-09-01: pill transparente estilo SkyMail v22 (era botón
       bordeado 28px). */
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 9px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    font-variant-numeric: tabular-nums;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    flex-shrink: 0;
}

.pg-btn:hover:not(:disabled) {
    /* FIX AUDIT r2: --hover no existe en :root — era declaración inválida */
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--accent);
}

.pg-btn.active {
    background: var(--accent);
    border-color: transparent;
    color: #04120b;
    font-weight: 700;
    box-shadow: 0 1px 0 rgba(255,255,255,.14) inset,
                0 6px 14px hsla(152, 50%, 18%, .28);
}

.pg-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pg-dots {
    color: var(--text-muted);
    padding: 0 4px;
    font-size: 12px;
}

.pg-info {
    /* FIX 2026-09-01: línea propia 100% con ellipsis (estilo SkyMail). */
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-ellipsis {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 0 4px;
    min-width: 24px;
    text-align: center;
}

/* compat: elipsis viejo */
.pg-dots {
    color: var(--text-muted);
    padding: 0 4px;
    font-size: 13px;
}

/* ============================================
   NUEVO v3.1: NAV BADGE
   ============================================ */

.nav-badge {
    font-size: 10.5px;
    font-weight: 600;
    color: hsl(156, 8%, 54%);
    background: hsl(156, 14%, 7.2%);
    padding: 3px 9px;
    border-radius: 999px;
    min-width: 24px;
    text-align: center;
    border: 1px solid hsl(150, 26%, 90%, 0.10);
    line-height: 1.4;
    transition: all 0.2s ease;
    margin-left: auto;
    flex-shrink: 0;
}

.nav-item:hover .nav-badge {
    color: hsl(156, 8%, 62%);
    border-color: hsl(152, 16%, 18%);
    background: hsl(152, 16%, 13%);
}

.nav-item.active .nav-badge {
    color: hsl(150, 76%, 64%);
    background: linear-gradient(135deg, hsl(152, 72%, 48%, 0.15), hsl(152, 72%, 48%, 0.10));
    border-color: hsl(152, 72%, 48%, 0.25);
}

/* ============================================
   LIST-HEADER: folder title with count
   ============================================ */

.list-title-row h2 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.folder-count-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

/* ============================================
   TELEGRAM FLOAT BUTTON
   ============================================ */

.telegram-float {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    background: #0088cc;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 136, 204, 0.4);
    z-index: 1000;
    transition: all 0.2s ease;
    text-decoration: none;
}

.telegram-float:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 24px rgba(0, 136, 204, 0.5);
}

.telegram-float:active {
    transform: scale(0.95);
}

/* ============================================
   NEW BADGE
   ============================================ */

.new-badge {
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    padding: 3px 8px;
    border-radius: 6px;
    letter-spacing: 0.5px;
    margin-left: 10px;
    display: inline-flex;
    align-items: center;
    animation: pulse-new 2s ease-in-out infinite;
}

@keyframes pulse-new {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.folder-title-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================
   NAV SECTIONS (FAVORITES / FOLDERS / SETTINGS)
   ============================================ */

.nav-section {
    margin-bottom: 8px;
}

.nav-section h3 {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 12px 20px 6px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

/* ============================================
   INBOX RULES PANEL
   ============================================ */

.rules-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100vh;
    background: var(--bg);
    border-left: 1px solid var(--border);
    z-index: 200;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rules-panel.open {
    right: 0;
}

.rules-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.rules-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.rules-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    line-height: 1;
}

.rules-close:hover {
    color: var(--text);
}

.rules-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.rules-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 199;
    display: none;
}

.rules-overlay.open {
    display: block;
}

.blocked-sender-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.blocked-sender-item span {
    font-size: 13px;
    color: var(--text);
}

.btn-unblock {
    padding: 4px 10px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
}

.btn-unblock:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 900px) {
    .telegram-float {
        width: 44px;
        height: 44px;
        bottom: 16px;
        right: 16px;
    }
}

/* ============================================
   TABS CON CONTADORES
   ============================================ */

.tab-btn {
    position: relative;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.12s;
    font-family: var(--font);
}

.tab-btn:hover { color: var(--text); background: var(--bg-hover); }

.tab-btn.active {
    background: var(--accent);
    color: var(--white);
}

.tab-count {
    font-size: 10px;
    font-weight: 600;
    margin-left: 4px;
    opacity: 0.7;
}

/* ============================================
   INBOX RULES MODAL CENTRADO
   ============================================ */

.rules-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 199;
    display: none;
    align-items: center;
    justify-content: center;
}

.rules-overlay.open {
    display: flex;
}

.rules-panel {
    width: 600px;
    max-width: 90vw;
    max-height: 80vh;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.2s ease;
}

.rules-overlay.open .rules-panel {
    transform: scale(1);
    opacity: 1;
}

.rules-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.rules-header h3 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rules-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
    line-height: 1;
    border-radius: 6px;
    transition: all 0.15s;
}

.rules-close:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.rules-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

/* Rule card */
.rule-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.15s;
}

.rule-card:hover {
    border-color: var(--accent);
}

.rule-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.rule-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.rule-card-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-enabled {
    font-size: 10px;
    font-weight: 700;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.btn-delete-rule {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s;
}

.btn-delete-rule:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.rule-card-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.rule-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.rule-tag {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* Empty state */
.rules-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.rules-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* ============================================
   TOKEN TOGGLE BUTTON (small gear icon)
   ============================================ */

.token-toggle-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    z-index: 10;
    opacity: 0.5;
    transition: all 0.15s;
}

.token-toggle-btn:hover {
    opacity: 1;
    color: var(--text);
    background: var(--bg-hover);
}


/* ============================================
   INBOX RULES MODAL CENTRADO
   ============================================ */

.rules-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 199;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.rules-overlay.open {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.rules-modal {
    width: 580px;
    max-width: 92vw;
    max-height: 80vh;
    background: hsl(164, 26%, 2.2%);
    border: 1px solid hsl(150, 26%, 90%, 0.12);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
    animation: scaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.rules-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    flex-shrink: 0;
}

.rules-modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.rules-close-btn {
    background: none;
    border: none;
    color: hsl(156, 8%, 54%);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 6px;
    transition: all 0.15s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rules-close-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.rules-add-new {
    padding: 0 24px 16px;
    flex-shrink: 0;
}

.btn-add-rule {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: hsl(151, 70%, 51%);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    border-radius: 8px;
    transition: all 0.15s;
}

.btn-add-rule:hover {
    background: hsl(152, 72%, 48%, 0.06);
}

.rules-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px 24px;
}

/* Rule card */
.rule-card {
    background: hsl(154, 14%, 9.4%);
    border: 1px solid hsl(150, 26%, 90%, 0.12);
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.rule-card:hover {
    border-color: #2a2a4a;
    background: #1a1a30;
}

.rule-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.rule-card-name {
    font-size: 14px;
    font-weight: 600;
    color: #e2e2f0;
}

.rule-card-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-enabled {
    font-size: 9px;
    font-weight: 700;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.btn-delete-rule {
    background: none;
    border: none;
    color: hsl(156, 8%, 54%);
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s;
    line-height: 1;
}

.btn-delete-rule:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.rule-card-description {
    font-size: 12px;
    color: #7a7a8a;
    line-height: 1.6;
    margin-bottom: 12px;
}

.rule-card-actions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.rule-action-tag {
    font-size: 11px;
    padding: 5px 12px;
    border-radius: 6px;
    background: hsl(152, 72%, 48%, 0.06);
    color: hsl(150, 76%, 64%);
    border: 1px solid hsl(152, 72%, 48%, 0.16);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Empty state */
.rules-empty {
    text-align: center;
    padding: 60px 20px;
    color: hsl(156, 8%, 54%);
}

.rules-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.2;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    .rules-modal {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        border-radius: 12px 12px 0 0;
    }
}

/* ============================================
   NEW MESSAGE BANNER
   ============================================ */

.new-msg-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    background: linear-gradient(90deg, hsl(152,72%,48%,0.14), hsl(152,72%,48%,0.08));
    border-bottom: 1px solid hsl(152,72%,48%,0.22);
    font-size: 13px;
    color: hsl(150, 76%, 64%);
    animation: slideDown 0.3s ease;
    flex-shrink: 0;
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.nmb-text {
    font-weight: 500;
}

.nmb-btn {
    padding: 4px 12px;
    background: var(--accent);
    border: none;
    color: #fff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s;
}

.nmb-btn:hover {
    background: hsl(150, 76%, 64%);
    transform: translateY(-1px);
}

.nmb-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    margin-left: 4px;
}

.nmb-close:hover {
    color: #fff;
}

/* ============================================
   HOVER ACTIONS en email list
   ============================================ */

.email-item {
    position: relative;
}

.email-actions-hover {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    gap: 4px;
    background: linear-gradient(90deg, transparent, var(--bg-card) 20%);
    padding-left: 30px;
}

.email-item:hover .email-actions-hover {
    display: flex;
}

.email-item.active:hover .email-actions-hover {
    display: flex;
    background: linear-gradient(90deg, transparent, #1e1e32 20%);
}

.email-btn-delete,
.email-btn-block,
.email-btn-flag {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    line-height: 1;
}

.email-btn-flag:hover {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}
.email-btn-flag.flagged {
    color: #eab308;
}
.email-item.flagged .email-sender::before {
    content: '\2605';
    color: #eab308;
    margin-right: 4px;
    font-size: 12px;
}

.email-btn-delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.email-btn-block:hover {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

/* Mobile elements hidden by default on desktop */
.menu-btn,
.sidebar-close,
.sidebar-overlay,
.back-btn {
    display: none;
}

/* Base mobile element styles */
.menu-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
}
.menu-btn:hover { background: var(--bg-hover); }

.sidebar-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-hover);
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.sidebar-close:hover { background: var(--accent); color: #fff; }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
}
.sidebar-overlay.open { opacity: 1; visibility: visible; }

.back-btn {
    height: 34px;
    padding: 0 10px;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    font-family: var(--font);
    align-items: center;
    gap: 6px;
    transition: background 0.12s ease, color 0.12s ease;
    margin-right: 4px;
    padding-right: 8px;
    border-right: 1px solid var(--border);
}
.back-btn:hover { background: var(--bg-hover); color: var(--text); }
.back-btn:active { background: var(--bg-active); }

/* ======== max-width: 768px (Tablet/Mobile) ======== */
@media (max-width: 768px) {
    .app { overflow: hidden; max-width: 100vw; }

    .sidebar {
        position: fixed;
        top: 0; bottom: 0; left: 0;
        width: min(280px, 84vw);
        transform: translateX(-100%);
        box-shadow: 16px 0 48px hsl(160, 22%, 1%, 0.75);
        z-index: 55;
        transition: transform 0.25s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: flex; }
    .menu-btn { display: flex; }
    .sidebar-overlay.open { display: block; }

    .main-content {
        width: 100vw;
        max-width: 100vw;
        min-width: 0;
        overflow: hidden;
    }

    .email-view {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        height: 100dvh; /* dynamic viewport height for mobile */
        display: flex;
    }

    .list-panel {
        flex: 1;
        border-right: none;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100vw;
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }

    .list-header {
        padding: 0 14px;
    }
    .list-search {
        padding: 0 12px 8px;
    }
    .list-search .search-field {
        height: 34px;
        padding: 0 10px;
    }

    .email-list {
        overflow-x: hidden;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    /* Detail panel becomes full-screen overlay on mobile */
    .detail-panel {
        position: fixed;
        inset: 0;
        z-index: 40;
        max-width: 100vw;
        overflow-x: hidden;
        background: var(--bg);
        transform: translateX(100%);
        transition: transform 0.25s ease;
        visibility: hidden;
    }
    .detail-panel.open {
        transform: translateX(0);
        visibility: visible;
    }

    .back-btn { display: flex; }

    .detail-actions {
        padding: 8px 14px;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .detail-actions::-webkit-scrollbar { display: none; }

    .detail-header {
        padding: 16px 14px 14px;
    }

    .detail-body-card {
        margin: 12px;
        border-radius: var(--radius-sm);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: calc(100vw - 24px);
    }

    .detail-body {
        margin: 0;
    }

    .msg-body-html {
        margin: 12px;
        border-radius: var(--radius-sm);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: calc(100vw - 24px);
        word-break: break-word;
    }

    .tool-label { display: none; }

    /* Pagination at bottom on mobile (no sticky) */
    .pagination {
        padding: 6px 10px 4px;
        gap: 6px;
        background: var(--bg);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
        flex-shrink: 0;
    }
    .pg-btn {
        height: 32px;
        min-width: 32px;
        padding: 0 6px;
        font-size: 12px;
        border-radius: 6px;
    }
    .pg-info {
        font-size: 10.5px;
        width: 100%;
        text-align: center;
        margin-top: 2px;
        padding-bottom: 2px;
    }

    .toast {
        bottom: 16px;
        font-size: 12.5px;
        padding: 10px 16px;
        max-width: calc(100vw - 32px);
        white-space: normal;
    }

    .rules-overlay { align-items: flex-end; }
    .rules-modal {
        width: 100%;
        max-width: 100vw;
        max-height: 85vh;
        border-radius: var(--radius) var(--radius) 0 0;
    }
}

/* ======== max-width: 420px (Small phones) ======== */
@media (max-width: 420px) {
    .list-header { height: 48px; padding: 0 12px; }
    #currentFolderTitle { font-size: 14px; }
    .icon-btn { width: 34px; height: 34px; }
    .search-box { height: 34px; padding: 0 12px; }
    .tab-btn { padding: 4px 11px; font-size: 11px; }
    .email-item { padding: 10px 12px 10px 10px; gap: 10px; }
    .email-avatar { width: 34px; height: 34px; font-size: 11px; }
    .action-btn { height: 32px; padding: 0 9px; font-size: 11px; }
    .detail-header { padding: 14px 12px 12px; }
    #detailSubject { font-size: 17px; }
    .detail-sender-row { gap: 10px; flex-wrap: wrap; }
    .detail-date { width: 100%; text-align: left; margin-top: 6px; padding-left: 48px; }
    .msg-body-html { margin: 10px; max-width: calc(100vw - 20px); }
    .pagination { padding: 4px 8px 2px; }
}

/* ======== Landscape small height ======== */
@media (max-height: 500px) and (orientation: landscape) {
    .list-header { height: 44px; }
    .search-box { height: 30px; }
    .tab-btn { padding: 3px 11px; }
    .email-item { padding: 8px 14px 8px 12px; }
    .detail-actions { min-height: 38px; padding: 4px 10px; flex-wrap: nowrap; }
    .detail-header { padding: 12px 18px 10px; }
    #detailSubject { font-size: 17px; margin-bottom: 10px; }
    .nav-item { height: 34px; }
}

/* ============================================
   USER ACTIONS (Switch / Sign out)
   ============================================ */

.user-actions {
    display: flex;
    gap: 0;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.user-actions.hidden { display: none; }

.btn-user-action {
    flex: 1;
    padding: 10px 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s;
}

.btn-user-action:first-child { border-right: 1px solid var(--border); }

.btn-user-action:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.btn-user-action.btn-signout:hover { color: var(--error); }

/* ============================================
   WELCOME SCREEN - SIGN IN BUTTON
   ============================================ */

.btn-welcome-signin {
    margin-top: 24px;
    padding: 12px 40px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border: none;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}

.btn-welcome-signin:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px hsl(152, 72%, 48%, 0.3);
}

/* ============================================
   LOGIN MODAL
   ============================================ */

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
}

.login-overlay.open { display: flex; }

.login-modal {
    width: 460px;
    max-width: 92vw;
    background: hsl(164, 26%, 2.2%);
    border: 1px solid hsl(150, 26%, 90%, 0.12);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
    animation: scaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 24px 24px 16px;
}

.login-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.login-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.login-close-btn {
    background: none;
    border: none;
    color: hsl(156, 8%, 54%);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 6px;
    transition: all 0.15s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-close-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.login-tabs {
    display: flex;
    gap: 0;
    padding: 0 24px;
    margin-bottom: 20px;
}

.login-tab {
    flex: 1;
    padding: 10px 0;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s;
}

.login-tab:first-child { border-radius: 8px 0 0 8px; }
.login-tab:last-child { border-radius: 0 8px 8px 0; border-left: none; }

.login-tab.active {
    background: hsl(152, 72%, 48%, 0.10);
    border-color: var(--accent);
    color: var(--text);
}

.login-tab:hover:not(.active) {
    background: var(--bg-hover);
    color: var(--text);
}

.login-form {
    padding: 0 24px 24px;
}

.login-field {
    margin-bottom: 16px;
}

.login-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    transition: border-color 0.15s;
}

.login-input-wrap:focus-within {
    border-color: var(--accent);
}

.login-input-icon {
    font-size: 14px;
    color: var(--text-muted);
    margin-right: 8px;
    flex-shrink: 0;
}

.login-input-wrap input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    padding: 10px 0;
    width: 100%;
}

.login-input-wrap input::placeholder {
    color: var(--text-muted);
}

.login-eye-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}

.login-eye-btn:hover { color: var(--text); }

.btn-login-submit {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, hsl(154, 74%, 44%), hsl(151, 70%, 51%));
    border: none;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s;
    margin-top: 4px;
}

.btn-login-submit:hover {
    background: linear-gradient(135deg, hsl(155, 76%, 38%), hsl(154, 74%, 44%));
    box-shadow: 0 4px 16px hsl(152, 72%, 48%, 0.25);
}

.btn-login-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-login-submit.loading {
    position: relative;
    color: transparent;
}

.btn-login-submit.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.login-error {
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: #ef4444;
    font-size: 12px;
}

.login-error.hidden { display: none; }

.login-note {
    margin-top: 16px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ============================================
   STATUS BAR (bottom)
   ============================================ */

/* ============================================
   TOKEN EXPIRED BANNER
   ============================================ */

.expired-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    background: linear-gradient(90deg, rgba(239,68,68,0.15), rgba(239,68,68,0.08));
    border-bottom: 1px solid rgba(239,68,68,0.3);
    font-size: 13px;
    color: #ef4444;
    animation: slideDown 0.3s ease;
    flex-shrink: 0;
}

.expired-banner .eb-text { font-weight: 500; }

.expired-banner .eb-btn {
    padding: 4px 12px;
    background: rgba(239,68,68,0.2);
    border: 1px solid rgba(239,68,68,0.4);
    color: #ef4444;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s;
}

.expired-banner .eb-btn:hover {
    background: rgba(239,68,68,0.3);
}


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

/* ======== Login modal mobile ======== */
@media (max-width: 640px) {
    .login-modal {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        border-radius: 12px 12px 0 0;
    }
    .login-overlay { align-items: flex-end; }
}

/* ============================================
   FEATURES: Skeleton Loading
   ============================================ */
.sk-list { padding: 0; }
.sk-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    animation: sk-fade .8s ease-in-out calc(var(--i) * .06s) infinite alternate;
}
.sk-bone { background: var(--bg-hover); border-radius: 6px; }
.sk-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sk-line { height: 10px; }
.sk-w60 { width: 60%; }
.sk-w80 { width: 80%; }
.sk-w40 { width: 40%; }
@keyframes sk-fade { from { opacity: .3; } to { opacity: .7; } }

/* ============================================
   FEATURES: Top Progress Bar
   ============================================ */
.top-progress {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 2px;
    background: transparent; overflow: hidden; pointer-events: none;
}
.top-progress.active::after {
    content: ''; position: absolute; left: -40%; width: 40%; height: 100%;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: tp-slide 1.2s ease-in-out infinite;
}
@keyframes tp-slide { to { left: 100%; } }

/* ============================================
   FEATURES: Micro-interactions
   ============================================ */
.qm-flash-success { animation: qm-flash-s .5s ease; }
.qm-flash-danger { animation: qm-flash-d .5s ease; }
.qm-flash-accent { animation: qm-flash-a .5s ease; }
.qm-shake { animation: qm-shake .4s ease; }
.qm-wobble { animation: qm-wobble .5s ease; }
.qm-tick-in { animation: qm-tick .3s ease; }
.qm-glow { animation: qm-glow .6s ease; }
.qm-badge-flip { animation: qm-bflip .38s ease; }

@keyframes qm-flash-s { 0%,100% { background: inherit; } 50% { background: rgba(34,197,94,.15); } }
@keyframes qm-flash-d { 0%,100% { background: inherit; } 50% { background: rgba(239,68,68,.15); } }
@keyframes qm-flash-a { 0%,100% { background: inherit; } 50% { background: hsl(152,72%,48%,0.16); } }
@keyframes qm-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes qm-wobble { 0% { transform: rotate(0); } 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } 100% { transform: rotate(0); } }
@keyframes qm-tick { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes qm-glow { 0%,100% { box-shadow: none; } 50% { box-shadow: 0 0 8px var(--accent); } }
@keyframes qm-bflip { 0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* Ripple */
.btn-ripple { position: relative; overflow: hidden; }
.qm-ripple {
    position: absolute; border-radius: 50%; background: rgba(255,255,255,.15);
    width: var(--rs); height: var(--rs);
    left: calc(var(--rx) - var(--rs) / 2);
    top: calc(var(--ry) - var(--rs) / 2);
    animation: qm-rip .5s ease-out forwards; pointer-events: none;
}
@keyframes qm-rip { from { transform: scale(0); opacity: 1; } to { transform: scale(1); opacity: 0; } }

.copy-ok svg { color: var(--success); }

/* ============================================
   FEATURES: Empty States
   ============================================ */
.state-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 60px 20px; text-align: center; color: var(--text-muted);
}
.state-icon-wrap { margin-bottom: 16px; opacity: .5; }
.state-icon-wrap svg { stroke: var(--text-muted); }
.state-empty h3 { font-size: 16px; color: var(--text-secondary); margin: 0 0 6px; font-weight: 600; }
.state-empty p { font-size: 13px; margin: 0; color: var(--text-muted); }

/* ============================================
   FEATURES: Context Menu
   ============================================ */
.ctx-menu {
    display: none; position: fixed; z-index: 9999;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; padding: 4px 0; min-width: 160px;
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.ctx-item {
    padding: 8px 16px; font-size: 13px; color: var(--text);
    cursor: pointer; transition: background .15s;
}
.ctx-item:hover, .ctx-item:focus-visible { background: var(--bg-hover); outline: 2px solid var(--accent); outline-offset: -2px; }

/* ============================================
   FEATURES: Drag & Drop
   ============================================ */
.email-item.dragging { opacity: .4; }
.nav-item.drop-target { background: hsl(152,72%,48%,0.16) !important; border-color: var(--accent) !important; }

/* ============================================
   MAIL MODE UI (IMAP = teal accent)
   ============================================ */
body.imap-mode {
    --accent: hsl(190, 84%, 52%);
    --accent-hover: hsl(190, 84%, 46%);
    --accent-light: hsl(190, 92%, 68%);
}

/* ============================================
   EMAIL ITEM SELECTED (Ctrl+A / Space)
   ============================================ */
.email-item.selected {
    background: hsl(152, 72%, 48%, 0.13);
    border-left: 3px solid var(--accent);
}
body.imap-mode .email-item.selected {
    background: rgba(56, 189, 248, .12);
}

/* ============================================
   SELECTION ACTION BAR (BULKSEL 2026-09-18)
   Barra sticky bajo el list-header cuando hay
   ≥1 email seleccionado (Espacio/X, Ctrl+A).
   ============================================ */
.selection-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-strong);
    position: sticky;
    top: 0;
    z-index: 20;
    animation: selbar-in .15s ease-out;
}
.selection-bar.hidden {
    display: none;
}
@keyframes selbar-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.selection-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-light);
    white-space: nowrap;
    min-width: 68px;
}
.selection-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.selection-actions::-webkit-scrollbar { display: none; }
.sel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 9px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, color .12s, opacity .12s;
}
.sel-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.sel-btn:active { background: var(--bg-active); }
.sel-btn:disabled {
    opacity: .45;
    cursor: default;
    pointer-events: none;
}
.sel-btn--danger {
    color: var(--error);
}
.sel-btn--danger:hover {
    background: var(--error-soft);
    color: var(--error);
}
.sel-btn--clear {
    margin-left: auto;
    padding: 6px 8px;
    color: var(--text-muted);
}

/* ============================================
   RULES PANEL: Sealed + Add Rule Form
   ============================================ */
.rule-card.rule-sealed {
    border-left: 3px solid #eab308;
}
.badge-sealed {
    background: #eab308; color: #000; padding: 2px 8px;
    border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase;
}
.badge-copies {
    background: var(--bg-hover); color: var(--text-secondary); padding: 2px 8px;
    border-radius: 4px; font-size: 10px; font-weight: 600;
}
.rule-action-tag.sealed {
    background: rgba(234, 179, 8, .15); color: #eab308;
}

.add-rule-form {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 10px;
}
.add-rule-form.hidden { display: none; }
.rule-input, .rule-select {
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text); padding: 10px 14px; border-radius: 8px;
    font-size: 13px; width: 100%; outline: none;
    transition: border-color .2s;
}
.rule-input:focus, .rule-select:focus { border-color: var(--accent); }
.rule-target.hidden { display: none; }
.rule-form-actions {
    display: flex; gap: 10px; justify-content: flex-end;
}
.btn-create-rule {
    background: var(--accent); color: #fff; border: none;
    padding: 8px 20px; border-radius: 8px; font-size: 13px;
    font-weight: 600; cursor: pointer; transition: background .2s;
}
.btn-create-rule:hover { background: var(--accent-hover); }
.btn-cancel-rule {
    background: var(--bg-hover); color: var(--text-secondary); border: none;
    padding: 8px 16px; border-radius: 8px; font-size: 13px;
    cursor: pointer; transition: background .2s;
}
.btn-cancel-rule:hover { background: var(--border); }

/* ============================================
   REDISEÑO 2026-09-01 — Componentes nuevos
   (estética terminal, alineada al viewer v22)
   ============================================ */

/* ── Iconos Phosphor (sprite #i-*) ── */
.i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    flex-shrink: 0;
}
.i use { width: 100%; height: 100%; }
.i { display: inline-flex; }
.i svg { display: block; }
.i-sm { width: 14px; height: 14px; }
.i-md { width: 18px; height: 18px; }
.i-lg { width: 22px; height: 22px; }

/* ── Command Bar (barra de comando global) ── */
.command-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 9px 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--accent-ring);
    flex-shrink: 0;
}
.command-bar-left { display: flex; align-items: center; gap: 8px; }
.command-bar-search { flex: 1 1 auto; min-width: 0; max-width: 560px; margin: 0 auto; }
.command-bar .search-field {
    display: flex;
    align-items: center;
    gap: 9px;
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    transition: border-color .15s, background .15s;
}
.command-bar .search-field:focus-within {
    border-color: var(--accent);
    background: var(--bg-hover);
}
.command-bar .search-field input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 13.5px;
    font-family: var(--font);
    min-width: 0;
}
.command-bar .search-field input::placeholder { color: var(--text-muted); }
.command-bar .icon-btn {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.command-bar .icon-btn:hover {
    border-color: var(--accent-ring);
    color: var(--text);
    background: var(--bg-hover);
}
.command-folder {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: .02em;
    white-space: nowrap;
}

/* ── Tooltips data-tip ── */
[data-tip] { position: relative; }
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%) translateY(4px);
    padding: 5px 8px;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--accent-ring);
    color: var(--text);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: -.01em;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    z-index: 9999;
    box-shadow: var(--shadow-md);
    transition: opacity .15s, transform .15s;
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.command-bar [data-tip]::after {
    bottom: auto;
    top: calc(100% + 8px);
    transform: translateX(-50%) translateY(-4px);
}
.command-bar [data-tip]:hover::after {
    transform: translateX(-50%) translateY(0);
}

/* ── Skeleton loaders ── */
.rules-skel, .source-skel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-bottom: 12px;
}
.rules-skel span, .source-skel span {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg,
        var(--bg-hover) 25%, var(--bg-active) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
    animation: nm-skel 1.3s ease-in-out infinite;
}
.rules-skel span:nth-child(1) { width: 82%; }
.rules-skel span:nth-child(2) { width: 95%; }
.rules-skel span:nth-child(3) { width: 68%; }
.source-skel span:nth-child(1) { width: 80%; }
.source-skel span:nth-child(2) { width: 92%; }
.source-skel span:nth-child(3) { width: 70%; }
.source-skel span { height: 14px; }
@keyframes nm-skel {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.rules-loading-state, .source-state--loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 28px 16px;
    width: 100%;
}
.rules-loading-label, .source-state-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}
.mini-spinner {
    width: 13px; height: 13px;
    border-radius: 50%;
    border: 2px solid var(--accent-soft);
    border-top-color: var(--accent);
    animation: nm-spin .7s linear infinite;
    display: inline-block;
}
@keyframes nm-spin { to { transform: rotate(360deg); } }

/* ── Source states unificados (Show Original) ── */
.source-state {
    min-height: min(42vh, 340px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    padding: 36px 20px;
}
.source-state-icon {
    width: 52px; height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    margin-bottom: 4px;
    background: var(--accent-soft);
    color: var(--accent-light);
    border: 1px solid var(--accent-ring);
}
.source-state-icon .i { font-size: 22px; width: 22px; height: 22px; }
.source-state h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -.018em;
    color: var(--text);
}
.source-state p {
    margin: 0;
    max-width: 36ch;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text-muted);
}
.source-state--error .source-state-icon {
    background: var(--error-soft);
    color: var(--error);
    border-color: hsl(4, 74%, 60%, 0.30);
}
.source-state--expired .source-state-icon,
.source-state--warn .source-state-icon {
    background: var(--amber-soft);
    color: var(--amber);
    border-color: hsl(38, 92%, 60%, 0.30);
}
.source-state-btn {
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--white);
    border: none;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.source-state-btn:hover { background: var(--accent-hover); }
.source-kicker {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 4px 2px 0;
}

/* ── Blocked Senders (overlay estilo reglas) ── */
.blocked-list { display: flex; flex-direction: column; gap: 8px; }
.blocked-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: border-color .15s, background .15s;
}
.blocked-row:hover { border-color: var(--accent-ring); background: var(--bg-hover); }
.blocked-av {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--white);
    background: var(--avatar-bg);
    flex-shrink: 0;
}
.blocked-copy { flex: 1; min-width: 0; }
.blocked-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.blocked-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.blocked-email {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.blocked-dot { color: var(--text-disabled); }
.blocked-when { white-space: nowrap; }
.blocked-unblock {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent-light);
    border: 1px solid var(--accent-ring);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.blocked-unblock:hover { background: var(--accent); color: var(--white); }

/* ── Reglas: contador y CTAs (rediseño panel) ── */
.rules-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0 4px;
}
.rules-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: .02em;
}
.rules-cta {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--white);
    border: none;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.rules-cta:hover { background: var(--accent-hover); }
.rules-cta--danger {
    background: transparent;
    color: var(--error);
    border: 1px solid hsl(4, 74%, 60%, 0.30);
}
.rules-cta--danger:hover { background: var(--error-soft); }
.rules-header-lead {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Sprite oculto (iconos Phosphor) */
.hidden-sprite {
    position: absolute;
    width: 0; height: 0;
    overflow: hidden;
}

/* search-clear en command-bar (mismo mecanismo .visible del listener) */
.command-bar .search-clear {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
}
.command-bar .search-clear:hover { color: var(--text); background: var(--bg-hover); }
.command-bar .search-clear.visible { display: flex; }
