/* ================================================================
   Tokeniza Console — Design System
   Paleta: sobria, financiera, modo claro
   Prefijo de clases propias: tz-
   ================================================================ */

/* ── Variables globales ─────────────────────────────────────── */
:root {
    /* Layout */
    --topbar-height:           64px;
    --sidebar-width:           220px;
    --sidebar-width-collapsed: 52px;

    /* Color primario: azul marino institucional */
    --color-primary:        #1B3A5C;
    --color-primary-hover:  #142d47;
    --color-primary-soft:   rgba(27, 58, 92, 0.08);
    --color-primary-border: rgba(27, 58, 92, 0.20);

    /* Acento: azul medio solo para CTAs secundarios */
    --color-accent:         #2E6DA4;
    --color-accent-hover:   #255a8a;

    /* Estados */
    --color-success:  #1a7f5a;
    --color-warning:  #92610a;
    --color-danger:   #b91c1c;
    --color-info:     #1d5fa3;

    /* Fondos */
    --bg-main:      #F4F6F9;
    --bg-topbar:    #FFFFFF;
    --bg-sidebar:   #1B3A5C;
    --bg-surface:   #FFFFFF;
    --bg-surface-2: #EEF1F5;
    --bg-tooltip:   #1F2937;

    /* Texto */
    --text-primary:        #111827;
    --text-secondary:      #4B5563;
    --text-muted:          #6B7280;
    --text-inverse:        #FFFFFF;
    --text-sidebar:        rgba(255, 255, 255, 0.75);
    --text-sidebar-active: #FFFFFF;

    /* Bordes */
    --border-subtle:  #E5E7EB;
    --border-default: #D1D5DB;

    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);

    /* Radios */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

/* ── Reset base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-main);
}

h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }

.label-sm {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.text-xs   { font-size: 11px; }
.text-sm   { font-size: 12px; }
.text-muted { color: var(--text-muted); }

/* ── Topbar ─────────────────────────────────────────────────── */
.tz-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    z-index: 1000;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.tz-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--color-primary);
    font-weight: 700;
    font-size: 15px;
    overflow: hidden;
    white-space: nowrap;
}

.tz-topbar-brand img {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.tz-topbar-brand span {
    transition: opacity 0.2s, width 0.22s;
}

body.sidebar-collapsed .tz-topbar-brand span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.tz-topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tz-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    transition: background 0.15s, color 0.15s;
}
.tz-toggle-btn:hover {
    background: var(--bg-surface-2);
    color: var(--color-primary);
}

/* ── Sidebar ────────────────────────────────────────────────── */
.tz-sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 900;
}

body.sidebar-collapsed .tz-sidebar {
    width: var(--sidebar-width-collapsed);
}

.tz-nav-list {
    list-style: none;
    padding: 8px 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.tz-nav-list::-webkit-scrollbar { width: 3px; }
.tz-nav-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* Cabecera de sección = botón de acordeón */
.tz-nav-group { list-style: none; }
.tz-nav-section {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 14px 16px 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    white-space: nowrap;
    overflow: hidden;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.15s, opacity 0.15s;
}
.tz-nav-section:hover { color: rgba(255,255,255,0.62); }
.tz-nav-section > span { flex: 1; text-align: left; }
.tz-nav-chev { font-size: 10px; opacity: 0.6; transition: transform 0.2s ease; }
.tz-nav-chev { transform: rotate(180deg); }                 /* abierto -> arriba */
.tz-nav-group.collapsed .tz-nav-chev { transform: rotate(0deg); }   /* cerrado -> abajo */

/* Items colapsables */
.tz-nav-group-items { list-style: none; margin: 0; padding: 0; overflow: hidden; max-height: 600px; transition: max-height 0.22s ease; }
.tz-nav-group.collapsed .tz-nav-group-items { max-height: 0; }

/* En modo icono (escritorio colapsado) se muestran todos los items, sin acordeón */
@media (min-width: 769px) {
    body.sidebar-collapsed .tz-nav-group-items { max-height: none !important; }
    body.sidebar-collapsed .tz-nav-chev { display: none; }
}

body.sidebar-collapsed .tz-nav-section {
    opacity: 0;
}

.tz-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    text-decoration: none;
    color: var(--text-sidebar);
    border-radius: 0;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    position: relative;
    margin: 1px 8px;
    border-radius: var(--radius-sm);
}

.tz-nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-sidebar-active);
}

.tz-nav-item.active .tz-nav-link {
    background: rgba(255,255,255,0.12);
    color: var(--text-sidebar-active);
    font-weight: 500;
}

.tz-nav-item.active .tz-nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #FFFFFF;
    border-radius: 0 2px 2px 0;
    margin-left: -8px;
}

.tz-nav-link i {
    font-size: 16px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

/* Badge de conteo en el menú lateral */
.tz-nav-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.14);
    color: var(--text-sidebar-active);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    border-radius: 10px;
    padding: 3px 7px;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.tz-nav-item.active .tz-nav-badge { background: rgba(255,255,255,0.26); }
body.sidebar-collapsed .tz-nav-badge { opacity: 0; width: 0; min-width: 0; padding: 0; margin: 0; overflow: hidden; }

.tz-nav-label {
    transition: opacity 0.15s, width 0.22s;
    overflow: hidden;
}

body.sidebar-collapsed .tz-nav-label {
    opacity: 0;
    width: 0;
}

/* Tooltip al colapsar */
body.sidebar-collapsed .tz-nav-link:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(var(--sidebar-width-collapsed) + 4px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-tooltip);
    color: var(--text-inverse);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
}

/* ── Footer fijo del sidebar: tipo de panel + rol ──────────── */
.tz-sidebar-footer {
    background: #071f3a;
    flex: 0 0 auto;
    padding: 9px 5px;
    border-top: 1px solid rgba(255, 255, 255, 0.10);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tipo de panel (badge OPERADOR; auth.js -> inline-flex). Secundario. */
.tz-sidebar-role {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2px 10px;
    background: rgba(255,255,255,0.10);
    color: rgba(255,255,255,0.6);
    border-radius: 20px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Tipo de panel. Principal (blanco, prominente). */
.tz-sidebar-paneltype {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: rgba(255,255,255,0.97);
    white-space: nowrap;
}
.tz-sidebar-paneltype i { font-size: 15px; opacity: 0.75; }

/* Rol del usuario. Secundario. */

.tz-sidebar-userrole {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.55);
    white-space: nowrap;
}
.tz-sidebar-userrole i { font-size: 12px; opacity: 0.5; }

/* Modo icono (escritorio colapsado): se oculta todo el footer */
@media (min-width: 769px) {
    body.sidebar-collapsed .tz-sidebar-footer { display: none !important; }
}

/* ── Zona central ───────────────────────────────────────────── */
.tz-main {
    margin-top: var(--topbar-height);
    margin-left: var(--sidebar-width);
    min-height: calc(100vh - var(--topbar-height));
    padding: 28px;
    transition: margin-left 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-main);
}

body.sidebar-collapsed .tz-main {
    margin-left: var(--sidebar-width-collapsed);
}

#tz-view {
    max-width: 1400px;
}

/* ── Componentes ────────────────────────────────────────────── */

/* Tarjeta */
.tz-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
}

/* Botones */
.tz-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.tz-btn-primary {
    background: var(--color-primary);
    color: var(--text-inverse);
    border-color: var(--color-primary);
}
.tz-btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: var(--text-inverse);
}

.tz-btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-default);
}
.tz-btn-secondary:hover {
    background: var(--bg-surface-2);
}

.tz-btn-danger {
    background: var(--color-danger);
    color: var(--text-inverse);
    border-color: var(--color-danger);
}

/* Badge / Pill de estado */
.tz-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    white-space: nowrap;
}
.tz-badge-success { background: rgba(26,127,90,0.10); color: var(--color-success); }
.tz-badge-warning { background: rgba(146,97,10,0.10); color: var(--color-warning); }
.tz-badge-danger  { background: rgba(185,28,28,0.10); color: var(--color-danger); }
.tz-badge-info    { background: var(--color-primary-soft); color: var(--color-primary); }
.tz-badge-muted   { background: var(--bg-surface-2); color: var(--text-muted); }

/* Tabla */
.tz-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.tz-table th {
    text-align: left;
    padding: 11px 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-surface-2);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}
/* Columna numérica/derecha en el header estándar */
.tz-table th.tz-th-right { text-align: right; }
.tz-table td.tz-td-right { text-align: right; }
.tz-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}
.tz-table tr:last-child td { border-bottom: none; }
.tz-table tbody tr:hover td { background: var(--bg-surface-2); }

/* Spinner */
.tz-spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--color-primary-soft);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: tz-spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes tz-spin { to { transform: rotate(360deg); } }

/* Toast */
#tz-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tz-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-tooltip);
    color: var(--text-inverse);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    min-width: 260px;
    max-width: 380px;
    animation: tz-toast-in 0.25s ease;
}
.tz-toast.success { border-left: 3px solid #34d399; }
.tz-toast.error   { border-left: 3px solid #f87171; }
.tz-toast.warning { border-left: 3px solid #fbbf24; }
.tz-toast.info    { border-left: 3px solid #60a5fa; }

@keyframes tz-toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Modal */
.tz-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.tz-modal {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    padding: 28px;
}
.tz-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.tz-modal-title { font-size: 16px; font-weight: 600; }

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .tz-sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: var(--sidebar-width) !important;
    }
    body.sidebar-open .tz-sidebar {
        transform: translateX(0);
    }
    /* En móvil el sidebar es overlay y SIEMPRE expandido (icono+texto+badge),
       aunque el escritorio lo hubiera dejado colapsado. */
    body.sidebar-collapsed .tz-sidebar { width: var(--sidebar-width) !important; }
    body.sidebar-collapsed .tz-nav-label { opacity: 1 !important; width: auto !important; }
    body.sidebar-collapsed .tz-nav-badge { opacity: 1 !important; width: auto !important; min-width: 18px !important; padding: 1px 7px !important; margin: 0 !important; overflow: visible !important; }
    body.sidebar-collapsed .tz-nav-section { opacity: 1 !important; height: auto !important; overflow: visible !important; }
    body.sidebar-collapsed .tz-topbar-brand span { opacity: 1 !important; }
    .tz-main {
        margin-left: 0 !important;
        padding: 16px;
    }
    .tz-backdrop {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 850;
    }
    body.sidebar-open .tz-backdrop {
        display: block;
    }
}

/* ── Avatar usuario ─────────────────────────────────────────── */
.tz-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    cursor: pointer;
}

/* ── Page header ────────────────────────────────────────────── */
.tz-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.tz-page-title { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.tz-page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Tenant badge (topbar) ──────────────────────────────── */
.tz-tenant-badge {
    margin-left: 8px;
    padding: 3px 10px;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    display: none;
}

/* ── Spinner pequeño (botones) ──────────────────────────── */
.tz-spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
    border-top-color: #fff;
    border-color: rgba(255,255,255,0.3);
    border-top-color: #fff;
}

/* ── Favicon fallback ───────────────────────────────────── */
.tz-logo-fallback {
    width: 28px;
    height: 28px;
    background: var(--color-primary);
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Iconos de estado ───────────────────────────────────── */
.tz-icon-success { color: var(--color-success); margin-right: 6px; }
.tz-icon-warning { color: var(--color-warning); margin-right: 6px; }
.tz-icon-danger  { color: var(--color-danger);  margin-right: 6px; }
.tz-icon-info    { color: var(--color-accent);  margin-right: 6px; }

/* ── Utilidades de iconos ───────────────────────────────── */
.tz-icon-lg { font-size: 20px; }
.tz-icon-md { font-size: 17px; }

/* ── Estado de carga ────────────────────────────────────── */
.tz-loading-state {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
}

/* ── Logo en topbar ─────────────────────────────────────── */
.tz-topbar-brand img { display: none; }

.tz-logo-bg {
    width: 140px;
    height: 44px;
    background-image: url('/assets/img/logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: left center;
    flex-shrink: 0;
}

/* ── User menu / dropdown ───────────────────────────────────── */
.tz-user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tz-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    display: none;
    overflow: hidden;
}
.tz-user-dropdown.open { display: block; }

.tz-user-dropdown-info {
    padding: 12px 14px;
    background: var(--bg-surface-2);
    border-bottom: 1px solid var(--border-subtle);
}

.tz-user-dropdown-divider {
    height: 1px;
    background: var(--border-subtle);
}

.tz-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.tz-user-dropdown-item:hover {
    background: var(--bg-surface-2);
    color: var(--color-danger);
}
.tz-user-dropdown-item i { font-size: 14px; }

/* ── Tabs de estado ─────────────────────────────────────────── */
.tz-tabs-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 6px 8px 0;
    margin-bottom: 0;
    border-bottom: none;
}

.tz-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.tz-tab:hover { color: var(--text-primary); background: var(--bg-surface-2); }
.tz-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 700;
    background: var(--bg-surface);
}

.tz-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 700;
    background: var(--bg-surface-2);
    color: var(--text-muted);
    border-radius: 10px;
    transition: background 0.15s, color 0.15s;
}
.tz-tab.active .tz-tab-count {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

/* Tabla conectada a los tabs */
.tz-card.tz-card-tabbed {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: 1px solid var(--border-subtle);
}

/* ── Badge de fase (transición interna) ─────────────────────── */
.tz-fase-badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid transparent;
}
.tz-fase-success { background: rgba(26,127,90,0.08); color: var(--color-success); border-color: rgba(26,127,90,0.2); }
.tz-fase-danger  { background: rgba(185,28,28,0.08); color: var(--color-danger);  border-color: rgba(185,28,28,0.2); }
.tz-fase-warning { background: rgba(146,97,10,0.08); color: var(--color-warning); border-color: rgba(146,97,10,0.2); }
.tz-fase-info    { background: rgba(14,116,144,0.08); color: var(--color-info);   border-color: rgba(14,116,144,0.2); }
.tz-fase-muted   { background: var(--bg-surface-2); color: var(--text-muted);     border-color: var(--border-subtle); }

/* ── KPIs por fase ──────────────────────────────────────────── */
.tz-kpis-fase-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 10px 16px;
    flex-wrap: wrap;
}
.tz-kpis-fase-total {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-right: 20px;
    border-right: 1px solid var(--border-subtle);
    min-width: 100px;
}
.tz-kpis-fase-items {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.tz-kpi-fase-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.tz-kpi-fase-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── KPIs por fase — cards con ícono ────────────────────────── */
.tz-fase-kpis {
    display: flex;
    gap: 10px;
    padding: 14px 0 10px;
    flex-wrap: wrap;
}

.tz-fase-kpi-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    min-width: 160px;
    flex: 1;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s;
}
.tz-fase-kpi-card:hover { box-shadow: var(--shadow-md); }

.tz-fase-kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.tz-fase-kpi-body { min-width: 0; }

.tz-fase-kpi-value {
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 2px;
}

.tz-fase-kpi-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.tz-fase-kpi-monto {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Columnas ordenables ────────────────────────────────────── */
/* Cabeceras ordenables (con icono asc/desc) — estándar de listado */
.tz-th-sort { white-space: nowrap; cursor: pointer; user-select: none; }
.tz-th-sort:hover { color: var(--text-secondary); }
.tz-th-sort:hover { background: var(--bg-surface-2); }
.tz-th-sort-active { color: var(--color-primary) !important; }
.tz-sort-ic { font-size: 10px; margin-left: 5px; opacity: .40; vertical-align: middle; transition: opacity .12s; }
.tz-th-sort:hover .tz-sort-ic { opacity: .75; }
.tz-th-sort-active .tz-sort-ic { opacity: 1; }

/* ── Expediente documental ──────────────────────────────────── */
.tz-expediente { display: flex; flex-direction: column; gap: 10px; }

.tz-doc-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.tz-doc-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-surface-2);
    border-bottom: 1px solid var(--border-subtle);
}

.tz-doc-icon {
    width: 34px; height: 34px;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}

.tz-doc-info { flex: 1; min-width: 0; }
.tz-doc-type { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.tz-doc-filename { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

.tz-doc-view-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 12px; font-size: 12px; font-weight: 600;
    background: var(--color-primary); color: white;
    border-radius: var(--radius-sm); text-decoration: none;
    white-space: nowrap; flex-shrink: 0;
    transition: opacity 0.15s;
}
.tz-doc-view-btn:hover { opacity: 0.85; }

.tz-doc-meta { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }

.tz-doc-meta-row {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 4px 12px;
    align-items: center;
    font-size: 12px;
}
.tz-doc-hash-row { grid-template-columns: auto 1fr; }

.tz-doc-meta-label {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted); white-space: nowrap;
}

.tz-doc-hash {
    font-family: monospace; font-size: 11px;
    background: var(--bg-surface-2); padding: 2px 7px;
    border-radius: 3px; color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.tz-doc-expiry {
    font-size: 11px; display: inline-flex; align-items: center; gap: 3px;
    color: var(--color-success);
}
.tz-doc-expiry-warn { color: var(--color-danger); }

.tz-doc-blockchain {
    display: flex; flex-direction: column; gap: 5px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}
.tz-blockchain-item {
    display: flex; align-items: center; gap: 7px;
    font-size: 12px;
}
.tz-blockchain-link {
    display: inline-flex; align-items: center; gap: 4px;
    color: var(--color-primary); text-decoration: none; font-size: 11px;
}
.tz-blockchain-link:hover { text-decoration: underline; }
.tz-blockchain-link code {
    font-family: monospace; font-size: 11px;
    background: var(--bg-surface-2); padding: 1px 5px;
    border-radius: 3px; border: 1px solid var(--border-subtle);
}

/* ── Modal ──────────────────────────────────────────────────── */
.tz-modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.tz-modal {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    width: 100%; max-width: 540px;
    max-height: 90vh; display: flex; flex-direction: column;
    overflow: hidden;
}
.tz-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px; border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.tz-modal-title {
    font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px;
    color: var(--text-primary);
}
.tz-modal-title i { color: var(--color-primary); }
.tz-modal-close {
    background: none; border: none; cursor: pointer; font-size: 16px;
    color: var(--text-muted); padding: 4px; border-radius: 4px;
}
.tz-modal-close:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.tz-modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.tz-modal-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 14px 20px; border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

/* ── Lista de contratos en modal ────────────────────────────── */
.tz-contratos-list { display: flex; flex-direction: column; gap: 8px; }
.tz-contrato-option {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer; transition: all 0.15s;
    background: var(--bg-surface);
}
.tz-contrato-option:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}
.tz-contrato-option-left { flex: 1; min-width: 0; }
.tz-contrato-option-name { font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.tz-contrato-option-right {
    display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.tz-contrato-option-linea { text-align: right; display: flex; flex-direction: column; gap: 1px; }

/* ── Condiciones del contrato en drawer ─────────────────────── */
.tz-cesion-contrato-info {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}
.tz-cesion-contrato-nombre {
    font-size: 13px; font-weight: 700;
    display: flex; align-items: center; gap: 7px;
    margin-bottom: 10px;
}
.tz-cesion-condiciones {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.tz-cond-pill {
    display: flex; flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 5px 10px; min-width: 80px;
}
.tz-cond-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.tz-cond-pill strong { font-size: 12px; }

/* ── Selector de pagarés ────────────────────────────────────── */
.tz-cesion-selector-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 6px;
}
.tz-pagares-selector {
    display: flex; flex-direction: column; gap: 4px;
    max-height: 300px; overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 6px;
    background: var(--bg-surface-2);
}
.tz-pagare-check-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer; transition: background 0.1s;
    background: var(--bg-surface);
    border: 1px solid transparent;
}
.tz-pagare-check-row:hover { background: var(--color-primary-soft); border-color: var(--color-primary-border); }
.tz-pagare-check-row input[type="checkbox"] { flex-shrink: 0; accent-color: var(--color-primary); width: 15px; height: 15px; }
.tz-pagare-check-info { flex: 1; min-width: 0; }

/* ── Resumen cesión ─────────────────────────────────────────── */
.tz-resumen-cesion { display: flex; flex-direction: column; gap: 16px; }
.tz-resumen-row { display: flex; align-items: center; gap: 10px; }
.tz-resumen-kpis {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.tz-resumen-kpi {
    text-align: center;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 8px;
}
.tz-resumen-kpi-val { font-size: 18px; font-weight: 800; color: var(--color-primary); }
.tz-resumen-kpi-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); margin-top: 3px; }
.tz-resumen-pagares {
    max-height: 200px; overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}
.tz-resumen-pagare-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-subtle);
}
.tz-resumen-pagare-row:last-child { border-bottom: none; }

/* ── Spinner pequeño ────────────────────────────────────────── */
.tz-spinner-sm {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ── Steps bar ──────────────────────────────────────────────── */
.tz-steps-bar {
    display: flex; align-items: center; gap: 0;
    margin-bottom: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.tz-step {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; color: var(--text-muted);
    white-space: nowrap;
}
.tz-step span {
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--bg-surface-2); border: 2px solid var(--border-default);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 800;
}
.tz-step-active { color: var(--color-primary); }
.tz-step-active span { background: var(--color-primary); border-color: var(--color-primary); color: white; }
.tz-step-done { color: var(--color-success); }
.tz-step-done span { background: var(--color-success); border-color: var(--color-success); color: white; }
.tz-step-line {
    flex: 1; height: 2px; background: var(--border-subtle); margin: 0 8px;
}
.tz-step-line-done { background: var(--color-success); }
.tz-action-btn-danger { color: var(--color-danger) !important; }
.tz-action-btn-danger:hover { background: rgba(185,28,28,0.08) !important; }

/* ================================================================
   Sidebar — Redimensionado por drag & drop
   ================================================================ */

/* Handle de arrastre, anclado al borde derecho del sidebar */
.tz-sidebar-resizer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    z-index: 950;
    background: transparent;
    transition: background 0.15s ease;
    touch-action: none;          /* drag fluido en táctil */
}

.tz-sidebar-resizer::after {
    /* Línea-guía visual fina */
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 2px;
    background: transparent;
    transition: background 0.15s ease;
}

.tz-sidebar-resizer:hover::after,
body.sidebar-resizing .tz-sidebar-resizer::after {
    background: rgba(255, 255, 255, 0.25);
}

/* Mientras se arrastra: sin transiciones para que siga al cursor */
body.sidebar-resizing .tz-sidebar,
body.sidebar-resizing .tz-main {
    transition: none !important;
}

/* Evitar selección de texto y forzar cursor durante el arrastre */
body.sidebar-resizing {
    cursor: col-resize;
    user-select: none;
    -webkit-user-select: none;
}

/* No tiene sentido redimensionar cuando está colapsado o en móvil */
body.sidebar-collapsed .tz-sidebar-resizer {
    display: none;
}

@media (max-width: 768px) {
    .tz-sidebar-resizer {
        display: none;
    }
}

/* ── Barra de cobertura compartida (cesión / reemplazo) con sobre-cobertura ── */
.tz-cov { margin: 4px 0 14px; }
.tz-cov-top { display:flex; align-items:baseline; justify-content:space-between; gap:10px; margin-bottom:6px; }
.tz-cov-label { font-size:12.5px; color:var(--text-secondary); }
.tz-cov-pct { font-size:12.5px; font-weight:700; color:var(--text-muted); white-space:nowrap; }
.tz-cov-pct.ok { color:var(--color-success,#16a34a); }
.tz-cov-track { position:relative; height:10px; border-radius:6px; background:#eceff3; overflow:hidden; }
.tz-cov-zone-over { position:absolute; top:0; bottom:0; right:0;
    background:repeating-linear-gradient(45deg, rgba(22,163,74,0.07) 0, rgba(22,163,74,0.07) 5px, rgba(22,163,74,0.14) 5px, rgba(22,163,74,0.14) 10px); }
.tz-cov-fill { position:absolute; top:0; bottom:0; left:0; background:var(--color-warning,#ca8a04);
    transition:width .28s ease, background .28s ease; z-index:1; }
.tz-cov-fill.ok { background:var(--color-success,#16a34a); }
.tz-cov-fill-over { position:absolute; top:0; bottom:0; background:#7bdba0; transition:width .28s ease; z-index:1; }
.tz-cov-mark { position:absolute; top:-1px; bottom:-1px; width:2px; background:#fff;
    box-shadow:0 0 0 1px rgba(0,0,0,0.14); z-index:2; }
.tz-cov-foot { margin-top:5px; text-align:right; min-height:15px; }
.tz-cov-falta { font-size:11px; color:#b4341f; font-weight:600; }
.tz-cov-extra { font-size:11px; color:var(--text-muted); display:inline-flex; align-items:center; gap:4px; }
.tz-cov-extra.ok { color:var(--color-success,#15803d); }
.tz-cov-extra i { font-size:10px; }


/* Rol del usuario como chip pequeño junto al avatar (header) */
.tz-user-rolechip {
    display: none;
    align-items: center;
    max-width: 160px;
    padding: 3px 10px;
    margin-right: 2px;
    background: var(--color-primary-soft, rgba(31,159,146,0.12));
    color: var(--color-primary, #1f9f92);
    border: 1px solid var(--color-primary-border, rgba(31,159,146,0.25));
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 640px) { .tz-user-rolechip { display: none !important; } }

/* ── Centro de notificaciones (campana) ─────────────────────── */
.tz-notif { position: relative; }
.tz-notif-btn { position: relative; }
.tz-notif-btn.has-alerts i { color: var(--color-accent); }
.tz-notif-badge {
    position: absolute; top: -3px; right: -3px;
    min-width: 17px; height: 17px; padding: 0 4px;
    background: var(--color-danger, #c0392b); color: #fff;
    border-radius: 999px; font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg-surface, #fff); line-height: 1;
}
.tz-notif-pop {
    position: absolute; top: calc(100% + 10px); right: 0;
    width: 360px; max-width: 90vw;
    background: var(--bg-surface); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md, 12px); box-shadow: var(--shadow-lg, 0 12px 40px rgba(0,0,0,.18));
    z-index: 2000; display: none; overflow: hidden;
}
.tz-notif-pop.open { display: block; }
.tz-notif-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid var(--border-subtle);
    font-size: 14px; font-weight: 700; color: var(--text-primary);
}
.tz-notif-count { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.tz-notif-list { max-height: 420px; overflow-y: auto; }
.tz-notif-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 14px; border-bottom: 1px solid var(--border-subtle);
}
.tz-notif-item:last-child { border-bottom: none; }
.tz-notif-ic {
    width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
    background: var(--bg-surface-2); color: var(--text-secondary);
}
.tz-notif-ic.sev-danger  { background: rgba(192,57,43,.12);  color: var(--color-danger, #c0392b); }
.tz-notif-ic.sev-warning { background: rgba(146,97,10,.12);  color: var(--color-warning, #92610a); }
.tz-notif-ic.sev-info    { background: var(--color-primary-soft); color: var(--color-accent); }
.tz-notif-body { flex: 1 1 auto; min-width: 0; }
.tz-notif-row1 { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.tz-notif-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.tz-notif-desc { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.tz-notif-go { flex: 0 0 auto; white-space: nowrap; align-self: center; }
.tz-btn-sm { padding: 4px 10px; font-size: 12px; }
.tz-notif-empty { padding: 28px 14px; text-align: center; color: var(--text-muted); font-size: 13px; }
.tz-notif-empty i { color: var(--color-success, #1a7f5a); margin-right: 6px; }
@media (max-width: 480px) { .tz-notif-pop { position: fixed; top: 56px; right: 8px; left: 8px; width: auto; } }

/* ── Panel de credenciales del gestor ───────────────────────── */
.tz-cred-panel { display:flex; flex-direction:column; gap:6px; }
.tz-cred-row { display:flex; align-items:center; gap:10px; padding:7px 0; border-bottom:1px solid var(--border-subtle); }
.tz-cred-lbl { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--text-muted); min-width:90px; }
.tz-cred-val { font-family:'JetBrains Mono',monospace; font-size:12px; color:var(--text-primary); background:var(--bg-surface-2); padding:3px 8px; border-radius:6px; word-break:break-all; }
.tz-cred-note { font-size:13px; color:var(--text-muted); padding:8px 0; }
.tz-cred-otp { background:var(--bg-surface-2); border:1px solid var(--border-subtle); border-radius:10px; padding:12px 14px; margin-top:4px; }
.tz-cred-otp-label { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--color-accent); margin-bottom:8px; }
.tz-cred-otp-val { font-family:'JetBrains Mono',monospace; font-size:22px; font-weight:700; letter-spacing:3px; color:var(--text-primary); text-align:center; background:#071f3a; border-radius:8px; padding:10px; margin-bottom:6px; }
.tz-cred-otp-note { font-size:11.5px; color:var(--text-muted); text-align:center; }
