/* ============================================================
   NexDocs — Theme unificado (8.1 UI redesign, 2026-08-17)
   Tokens oscuros suavizados (slate) + TT Hoves.
   Los componentes del shell vivían inline en _Layout.cshtml;
   se movieron aquí sin cambiar nombres de clase ni tokens.
   ============================================================ */

/* Breakpoints de referencia (fase rediseño B — documentación, sin reestructurar):
   ≤1024px → drawer off-canvas del sidebar + bloque touch (pointer:coarse también)
   641-1024px → tablet
   ≤640px → mini-cards de .table-admin
   Kanban (CSS local en Tareas/Index): 3 cols ≥1200px / 2 cols 700-1199 / 1 col <700 */

/* ─── TT Hoves (TypeType) — pesos locales ─────────────── */
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_ExtraLight.otf') format('opentype');
    font-weight: 200;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_ExtraLight_Italic.otf') format('opentype');
    font-weight: 200;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_Light.otf') format('opentype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_Light_Italic.otf') format('opentype');
    font-weight: 300;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_Italic.otf') format('opentype');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_Medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_DemiBold.otf') format('opentype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_DemiBold_Italic.otf') format('opentype');
    font-weight: 600;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_Bold_Italic.otf') format('opentype');
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_ExtraBold.otf') format('opentype');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_ExtraBold_Italic.otf') format('opentype');
    font-weight: 800;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_Black.otf') format('opentype');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_Black_Italic.otf') format('opentype');
    font-weight: 900;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_Thin.otf') format('opentype');
    font-weight: 100;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_Thin_Italic.otf') format('opentype');
    font-weight: 100;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'TT Hoves';
    src: url('/fonts/tt-hoves/TT_Hoves_Hairline.otf') format('opentype');
    font-weight: 100;
    font-style: normal;
    font-display: swap;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    /* Aliases --rc-*: tokens legacy de las vistas, unificados al tema oscuro neutro (UI 8.1) */
    --rc-bg: #101114;
    --rc-panel: #1b1c21;
    --rc-surface: #1b1c21;
    --rc-raised: #232429;
    --rc-border: #26272d;
    --rc-border2: #303139;
    --rc-orange: #FF4C26;
    --rc-orange-d: #e03d1a;
    --rc-orange-g: rgba(255, 76, 38, 0.12);
    --rc-text: #ECECEE;
    --rc-muted: #9A9CA3;
    --rc-faint: #C6C8CE;
    --rc-green: #5dca8a;
    --rc-green-bg: #1a3a28;
    --rc-red: #f87171;
    --rc-red-bg: #3a1a1a;

    --accent: #FF4C26;
    --accent-dim: rgba(255, 76, 38, 0.12);
    --accent-hover: rgba(255, 76, 38, 0.08);
    --bg-body: #101114;
    --bg-sidebar: #16171b;
    --bg-topbar: #17181c;
    --bg-card: #1b1c21;
    --border: #26272d;
    --border-mid: #303139;
    --text-primary: #ECECEE;
    --text-muted: #9A9CA3;
    --text-soft: #C6C8CE;
    --sidebar-w: 240px;
    --sidebar-c: 68px;
    --topbar-h: 62px;
    --font: 'TT Hoves', 'Segoe UI', system-ui, sans-serif;
    --font-cond: 'TT Hoves', 'Segoe UI', system-ui, sans-serif;

    /* Estado unificado (fase UX): verde=ok, ámbar=en curso, morado=revisión, rojo=error */
    --status-ok: #5dca8a;
    --status-warn: #FBBF24;
    --status-review: #A78BFA;
    --status-error: #f87171;
    --status-ok-bg: #1a3a28;
    --status-warn-bg: #3a3210;
    --status-review-bg: #2a2140;
    --status-error-bg: #3a1a1a;

    /* Escala tipográfica fija — código nuevo usa --fs-*; literales legacy se conservan */
    --fs-xs: 12px;
    --fs-sm: 14px;
    --fs-md: 16px;
    --fs-lg: 20px;
    --fs-xl: 24px;
    --fs-2xl: 32px;
    --fs-3xl: 40px;
    /* Contraste verificado: --text-muted #9A9CA3 sobre #101114 = 6.8:1, sobre #1b1c21 = 6.1:1 (AA ok) */
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
    /* [UI] Fase rediseño B — pull-to-refresh inerte en táctil */
    overscroll-behavior-y: contain;
}

/* ─── SIDEBAR ──────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-w);
    height: 100%;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease;
    z-index: 999;
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, rgba(255, 76, 38, 0.25) 65%, transparent 100%);
    z-index: 2;
    pointer-events: none;
}

/* Estado colapsado / oculto — body classes persistidas en localStorage */
body.sb-collapsed .sidebar {
    width: var(--sidebar-c);
}

body.sb-collapsed .sidebar .nav-text,
body.sb-collapsed .sidebar .nav-badge,
body.sb-collapsed .sidebar .section-title {
    display: none;
}

body.sb-collapsed .sidebar .sb-logo-full {
    display: none;
}

body.sb-collapsed .sidebar .sb-logo-icon {
    display: block;
}

body.sb-collapsed .sidebar .sb-brand {
    justify-content: center;
    padding: 16px 0;
}

body.sb-collapsed .topbar {
    left: var(--sidebar-c);
}

body.sb-collapsed .page-content {
    margin-left: var(--sidebar-c);
}

body.sb-hidden .sidebar {
    display: none;
}

body.sb-hidden .topbar {
    left: 0;
}

body.sb-hidden .page-content {
    margin-left: 0;
}

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

.sb-logo-full {
    height: 28px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
    display: block;
}

.sb-logo-icon {
    display: none;
    width: 28px;
    height: 28px;
    object-fit: contain;
}

/* Toggle expandir/colapsar (dentro del sidebar, bajo el logo) */
.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: none;
    border: none;
    color: var(--text-soft);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 14px;
    margin: 2px 8px;
    border-radius: 7px;
    transition: color 0.15s, background 0.15s;
    font-family: var(--font);
}
.toggle-btn:hover {
    background: var(--accent-hover);
    color: var(--text-primary);
}

/* Colapsado: chevron centrado justo bajo el sb-logo-icon */
body.sb-collapsed .toggle-btn {
    justify-content: center;
    width: 100%;
    padding: 4px 0;
    margin: 6px 0 0;
}

/* El menu-2 del topbar solo aplica en <=1024px (abre el drawer);
   en desktop el control de ocultar/mostrar son hideSidebarBtn/showSidebarBtn */
.menu-toggle {
    display: none;
}

/* Nav items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    margin: 2px 8px;
    text-decoration: none;
    color: var(--text-soft);
    border-radius: 7px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    letter-spacing: -0.01em;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(255, 76, 38, 0.14) 0%, rgba(255, 76, 38, 0.04) 100%);
    color: #fff;
    border-left: 2px solid var(--accent);
    padding-left: 12px;
    font-weight: 600;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    flex-shrink: 0;
    color: inherit;
}

.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

.section-title {
    font-size: 10px;
    letter-spacing: 2.5px;
    color: var(--text-muted);
    padding: 18px 22px 5px;
    text-transform: uppercase;
    font-weight: 700;
    font-family: var(--font);
}

/* Tree child items injected by views */
.nav-item.tree-child {
    padding-left: 28px;
    font-size: 13px;
}

body.sb-collapsed .sidebar .nav-item.tree-child .nav-text,
body.sb-collapsed .sidebar .tree-section-sep {
    display: none;
}

.tree-section-sep {
    height: 0.5px;
    background: var(--border);
    margin: 6px 14px;
}

/* ─── TOPBAR ──────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--topbar-h);
    background: var(--bg-topbar);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 24px rgba(0, 0, 0, 0.45);
    z-index: 1000;
    transition: left 0.25s ease;
    backdrop-filter: blur(8px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-center {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-self: center;
}

.topbar-brand-logo {
    height: 30px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    display: block;
    image-rendering: -webkit-optimize-contrast;
}

.topbar-toggle {
    background: none;
    border: none;
    color: var(--text-soft);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.topbar-toggle:hover {
    background: var(--accent-hover);
    color: var(--text-primary);
}

.topbar-page-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-self: end;
}

.topbar-date {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-soft);
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

/* User chip en el topbar (la identidad y el logout viven en este dropdown) */
.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 12px 5px 6px;
}

.topbar-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-cond);
}

.topbar-username {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── PAGE CONTENT ──────────────────────────────────── */
.page-content {
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    transition: margin-left 0.25s ease;
    padding: 32px 36px;
    min-height: calc(100vh - var(--topbar-h));
}

/* ─── Estados de carga y error (uiLoading/uiError de site.js) ─────── */
.ui-loading {
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ui-shimmer {
    height: 14px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--border) 25%, var(--border-mid) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: ui-shimmer 1.2s ease-in-out infinite;
}
.ui-loading-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
@keyframes ui-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.ui-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--rc-red);
    border-radius: 8px;
    background: var(--rc-red-bg);
    color: var(--rc-red);
    font-size: 13px;
}
.ui-retry {
    background: none;
    border: 1px solid var(--rc-red);
    color: var(--rc-red);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: background 0.15s;
}
.ui-retry:hover { background: rgba(248, 113, 113, 0.1); }

/* ─── Accesibilidad: foco visible para navegación por teclado ─────── */
.nav-item:focus-visible,
.topbar-toggle:focus-visible,
.toggle-btn:focus-visible,
.pd-close:focus-visible,
.pd-proj:focus-visible,
.pd-badge:focus-visible,
.client-card:focus-visible,
.btn-login:focus-visible,
.ui-retry:focus-visible,
.modal-box button:focus-visible,
.modal-box .btn-close-modal:focus-visible,
/* [UI] Fase UX — componentes nuevos */
.row-menu-item:focus-visible,
.user-menu-btn:focus-visible,
.btn-secondary:focus-visible,
.btn-danger:focus-visible,
.toast button:focus-visible,
.tab-search:focus-visible,
.tab-btn:focus-visible,
.card-estado-select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ─── prefers-reduced-motion: sin transiciones ni animaciones ─────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
    .sidebar, .topbar, .page-content, .pendientes-rail {
        transition: none !important;
    }
    .client-card:hover { transform: none !important; }
}

/* ─── Modales unificados (UI 8.1 — antes 13 definiciones duplicadas) ─── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 1200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open {
    display: flex;
}

.modal-box,
.modal-box-sp {
    background: var(--rc-panel);
    border-radius: 14px;
    padding: 26px;
    width: 460px;
    max-width: 94vw;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--rc-border2);
    border-top: 3px solid var(--accent);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.modal-box-sp {
    width: 480px;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}
.modal-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: -10px;
    margin-bottom: 16px;
}
.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* ─── Responsive: topbar (UI 8.1) ─── */
@media (max-width: 900px) {
    .topbar { padding: 0 16px; }
    .topbar-date { display: none; }
}
@media (max-width: 640px) {
    .topbar-username { display: none; }
    .topbar-page-title {
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ─── Puntos de estado (reemplazan emojis 🔴🟡🟢🟣 — UI 8.1) ─── */
.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
/* [UI] Fase UX: unificados a los tokens --status-* (.dot-green cambia #34D399 -> #5dca8a) */
.dot-green  { background: var(--status-ok); }
.dot-amber  { background: var(--status-warn); }
.dot-red    { background: var(--status-error); }
.dot-purple { background: var(--status-review); }

/* ─── Botón primario unificado (tintado — UI 8.1) ─── */
.btn-primary {
    display: inline-block;
    background: var(--rc-orange-g);
    color: var(--rc-orange);
    border: 1px solid var(--rc-orange-d);
    padding: 7px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    line-height: 1.4;
}
.btn-primary:hover {
    background: var(--rc-orange);
    border-color: var(--rc-orange);
    color: #ffffff;
    text-decoration: none;
}

/* Grupo de acciones en headers de sección */
.section-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ─── Fase UX: componentes compartidos ─────────────────────────── */

/* Botones secundario y destructivo (base para jerarquía de un primario por pantalla) */
.btn-secondary {
    display: inline-block;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-mid);
    padding: 7px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.4;
    transition: border-color 0.2s, color 0.2s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.btn-danger {
    display: inline-block;
    background: rgba(248, 113, 113, 0.12);
    color: var(--status-error);
    border: 1px solid var(--status-error);
    padding: 7px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.4;
    transition: background 0.2s, color 0.2s;
}
.btn-danger:hover { background: var(--status-error); color: #ffffff; text-decoration: none; }

/* Chips de estado (Activo/Inactivo y similares) */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: var(--fs-xs);
    font-weight: 600;
    white-space: nowrap;
}
.chip-ok { color: var(--status-ok); background: var(--status-ok-bg); }
.chip-warn { color: var(--status-warn); background: var(--status-warn-bg); }
.chip-review { color: var(--status-review); background: var(--status-review-bg); }
.chip-error { color: var(--status-error); background: var(--status-error-bg); }

/* Avatar con iniciales */
.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    flex-shrink: 0;
}

/* Mono para IDs/códigos/celdas Excel */
.mono {
    font-family: 'Cascadia Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
}

/* Estado vacío compartido (server: _EmptyState.cshtml; cliente: emptyStateHTML) */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
    padding: 32px 16px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 30px; color: var(--border-mid); margin-bottom: 4px; }
.empty-state .empty-title { font-size: var(--fs-sm); font-weight: 600; color: var(--text-soft); }
.empty-state .empty-hint { font-size: var(--fs-xs); }

/* Toasts globales (window.toast) */
.toast-container {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text-primary);
    font-size: var(--fs-sm);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    animation: toast-in 0.2s ease;
}
.toast-success { border-left-color: var(--status-ok); }
.toast-error { border-left-color: var(--status-error); }
.toast button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: auto;
    font-size: 15px;
    line-height: 1;
    padding: 2px;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Botón en estado de carga (window.uiButtonLoading) */
.btn-loading { position: relative; pointer-events: none; opacity: 0.7; }
.btn-loading::after {
    content: "";
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    display: inline-block;
    vertical-align: -2px;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Filtro con valor activo (Limpiar resalta qué hay aplicado) */
select.filter-active, input.filter-active {
    border-color: var(--accent);
    color: var(--accent);
}

/* Badge de conteo en pestañas */
.tab-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
}

/* Validación unobtrusive (Clientes y formularios) */
.field-validation-error {
    display: block;
    color: var(--status-error);
    font-size: var(--fs-xs);
    margin-top: 4px;
}
.input-validation-error { border-color: var(--status-error) !important; }

/* Link inactivo (fallback "Sin vínculo" en Formatos) */
.link-muted { color: var(--text-muted); font-size: 12px; }

/* Error inline en modales (mapeo Excel) */
.field-error { color: var(--status-error); font-size: var(--fs-xs); margin-top: 4px; }

/* ─── Fase UX: shell (menú de usuario, breadcrumbs, footer, drawer, modal de sesión) ─── */

/* Dropdown del usuario en el topbar */
.user-menu { position: relative; }
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.15s;
}
.user-menu-btn:hover { background: var(--accent-hover); }

.user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    min-width: 230px;
    /* [UI] Fase rediseño B — nunca desbordar el viewport en móvil */
    max-width: calc(100vw - 24px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    padding: 12px;
    display: none;
    z-index: 1001;
}
.user-dropdown.open { display: block; animation: toast-in 0.15s ease; }
.ud-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}
.ud-name { font-size: var(--fs-sm); font-weight: 700; color: var(--text-primary); }
.ud-meta { font-size: var(--fs-xs); color: var(--text-muted); }
.ud-logout { display: flex; justify-content: flex-end; }

/* Breadcrumbs (partial _Breadcrumbs; ViewBag.Breadcrumbs = null no renderiza) */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-bottom: 14px;
}
.breadcrumbs a { color: var(--text-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .bc-sep { color: var(--border-mid); }
.breadcrumbs .bc-current { color: var(--text-soft); font-weight: 600; }

/* Footer con versión (verificación de deploys manuales) */
.app-footer {
    text-align: center;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    padding: 18px 16px 22px;
    border-top: 1px solid var(--border);
    margin-top: 28px;
}

/* Modal de sesión unificado a .modal-box */
.session-box { width: 380px; text-align: center; }
.session-icon { font-size: 32px; margin-bottom: 12px; }
.session-box .modal-title { font-size: 17px; }
.session-box .modal-sub { margin-top: 0; }
.session-box .modal-footer { justify-content: center; }
#session-countdown { color: var(--accent); font-weight: 700; }

/* ─── Fase UX: tablas admin y menú de acciones por fila ─── */

/* Búsqueda client-side de pestañas admin */
.tab-search {
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: 8px;
    padding: 7px 12px;
    color: var(--text-primary);
    font-size: var(--fs-sm);
    font-family: var(--font);
    width: 220px;
    max-width: 100%;
    margin-bottom: 0;
}
.tab-search::placeholder { color: var(--text-muted); }
.tab-search:focus { outline: none; border-color: var(--accent); }

/* Zebra + hover naranja en tablas admin (mayor especificidad que .data-table local) */
.table-admin tbody tr:nth-child(even) td { background: var(--rc-raised); }
.table-admin tbody tr:hover td { background: var(--accent-hover); }

/* Menú ⋯ de acciones por fila (se posiciona fijo vía JS para no quedar recortado) */
.row-menu-wrap { position: relative; display: inline-block; }
.row-menu {
    display: none;
    min-width: 170px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    z-index: 1500;
}
.row-menu.open { display: block; animation: toast-in 0.12s ease; }
.row-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: var(--fs-sm);
    font-family: var(--font);
    cursor: pointer;
    text-align: left;
}
.row-menu-item:hover { background: var(--accent-hover); color: var(--accent); }
.row-menu-item.danger { color: var(--status-error); }
.row-menu-item.danger:hover { background: var(--status-error-bg); color: var(--status-error); }

/* Select de estado compacto en tarjetas del kanban (fase UX) */
.card-estado-select {
    width: 100%;
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: 6px;
    color: var(--text-soft);
    font-size: 12px;
    padding: 4px 8px;
    font-family: var(--font);
    cursor: pointer;
}
.card-estado-select:focus { outline: none; border-color: var(--accent); }

/* Wizard (fase UX — CrearProyecto en 4 pasos) */
.stepper {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.step-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 600;
}
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
}
.step-item.step-active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.step-item.step-active .step-num { background: var(--accent); color: #ffffff; }
.step-item.step-done { border-color: var(--status-ok); color: var(--status-ok); }
.step-item.step-done .step-num { background: var(--status-ok); color: #101114; }
.wizard-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* Leyenda de colores por proyecto (calendario) */
.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 14px;
    font-size: var(--fs-xs);
    color: var(--text-muted);
}
.cal-legend:empty { display: none; }
.cal-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend-dot { width: 9px; height: 9px; border-radius: 3px; }

/* Píldora de prioridad en tarjetas */
.card-prioridad {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

/* Tablas admin en móvil: filas -> mini-tarjetas apiladas (labels vía data-label) */
@media (max-width: 640px) {
    .table-admin, .table-admin tbody, .table-admin tr, .table-admin td { display: block; }
    .table-admin thead { display: none; }
    .table-admin tr { border-bottom: 1px solid var(--border); padding: 10px 0; }
    .table-admin td {
        border-bottom: none !important;
        padding: 4px 8px;
        display: flex;
        justify-content: space-between;
        gap: 12px;
        text-align: right;
    }
    .table-admin td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        text-align: left;
        flex-shrink: 0;
    }
    .table-admin td:not([data-label]) { display: block; text-align: left; }
    .table-admin td:not([data-label])::before { content: none; }
}

/* Drawer móvil: <=1024px el sidebar pasa a off-canvas con scrim */
.drawer-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 998;
    display: none;
}
@media (max-width: 1024px) {
    .topbar { left: 0 !important; }
    .page-content { margin-left: 0 !important; }

    .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
    body.drawer-open .sidebar { transform: translateX(0); }
    body.drawer-open .drawer-scrim { display: block; }

    /* El drawer siempre muestra la navegación completa (sin estados colapsado/oculto) */
    body.sb-collapsed .sidebar { width: var(--sidebar-w); }
    body.sb-collapsed .sidebar .nav-text,
    body.sb-collapsed .sidebar .nav-badge,
    body.sb-collapsed .sidebar .section-title { display: initial; }
    body.sb-collapsed .sidebar .sb-logo-full { display: block; }
    body.sb-collapsed .sidebar .sb-logo-icon { display: none; }
    body.sb-collapsed .sidebar .sb-brand { justify-content: flex-start; padding: 20px 16px 16px; }
    body.sb-hidden .sidebar { display: flex; }

    /* [UI] Ronda 2 — topbar: menu-2 abre el drawer; hide/show no aplican en móvil.
       syncHideButtons solo escribe style.display="" o "none", esta regla gana sin !important */
    .menu-toggle { display: inline-flex; }
    #hideSidebarBtn,
    #showSidebarBtn { display: none; }

    /* Paridad con los resets de sb-collapsed: el chevron vuelve a su posición expandida */
    body.sb-collapsed .toggle-btn {
        justify-content: flex-start;
        width: auto;
        padding: 4px 14px;
        margin: 2px 8px;
    }
}

/* ─── Touch targets (fase rediseño B): ≥44px en táctil y ≤1024px ─────── */
@media (pointer: coarse), (max-width: 1024px) {
    .nav-item,
    .topbar-toggle,
    .toggle-btn,
    .user-menu-btn,
    .btn-primary,
    .btn-secondary,
    .btn-danger,
    .btn-nueva-compra,
    .tab-search,
    .row-menu-item,
    .card-estado-select {
        min-height: 44px;
    }
    .row-menu {
        padding: 8px;
    }
}

/* Tablet (641-1024px): filas de tablas admin más cómodas al tacto */
@media (min-width: 641px) and (max-width: 1024px) {
    .table-admin tbody tr td { padding: 13px 16px; }
}

/* ─── Dashboards (fase rediseño D): KPI unificado, leyenda de donas y gantt ─────── */
.dd-stats { display:flex; gap:10px; margin-bottom:22px; }
.dd-stat  { flex:1; background:#141414; border:1px solid #1f1f1f; border-radius:9px; padding:12px 16px; }
.dd-stat-lbl { font-size:10px; letter-spacing:1.6px; text-transform:uppercase; color:#444; font-weight:700; margin-bottom:4px; }
.dd-stat-val { font-size:24px; font-weight:700; color:#f0f0f0; line-height:1; }
.dd-stat-sub { font-size:11px; color:#555; margin-top:3px; }
.donut-wrap { display:flex; align-items:center; gap:18px; padding:16px; }
.d-legend   { display:flex; flex-direction:column; gap:7px; }
.d-item     { display:flex; align-items:center; gap:7px; font-size:12px; color:#ccc; }
.d-dot      { width:8px; height:8px; border-radius:50%; flex-shrink:0; }
.d-pct      { font-weight:700; margin-left:auto; padding-left:12px; font-size:12px; }
.g-hoy { position:absolute; top:-3px; bottom:-3px; width:2px; background:rgba(255,255,255,.55); border-radius:2px; pointer-events:none; }

/* ─── Consistencia global (fase rediseño E) ─────── */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-subtitle { font-size: 14px; color: var(--text-muted); }
.btn-nueva-compra { display:flex; align-items:center; gap:6px; background:var(--rc-orange-g); color:var(--rc-orange); border:1px solid var(--rc-orange-d); border:none; border-radius:7px; padding:7px 14px; font-size:13px; font-weight:600; cursor:pointer; font-family:inherit; transition:opacity .15s; }
.btn-nueva-compra:hover { opacity:.85; }
