/* ==========================================================================
   CSS GLOBAL - MP MANAGER GLASSMORPHISM DARK DESIGN
   ========================================================================== */

   :root {
    --font-primary: 'Outfit', sans-serif;
    --font-mono: 'Fira Code', 'JetBrains Mono', monospace;

    /* Harmonious HSL Color System */
    --bg-app: hsl(222, 40%, 7%);
    --bg-glass: rgba(15, 23, 42, 0.65);
    --bg-glass-hover: rgba(30, 41, 59, 0.7);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-glow: rgba(124, 58, 237, 0.25);
    
    --color-primary: hsl(263, 90%, 62%);
    --color-primary-glow: rgba(124, 58, 237, 0.5);
    --color-primary-grad: linear-gradient(135deg, hsl(263, 90%, 62%), hsl(244, 79%, 60%));
    
    --color-success: hsl(162, 76%, 45%);
    --color-success-glow: rgba(16, 185, 129, 0.2);
    
    --color-warning: hsl(38, 92%, 50%);
    --color-warning-glow: rgba(245, 158, 11, 0.2);
    
    --color-danger: hsl(343, 85%, 55%);
    --color-danger-glow: rgba(239, 68, 68, 0.2);

    --text-primary: hsl(210, 40%, 96%);
    --text-secondary: hsl(215, 25%, 68%);
    --text-muted: hsl(215, 16%, 47%);
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-glow: 0 0 15px 0 rgba(124, 58, 237, 0.2);
}

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

body {
    font-family: var(--font-primary);
    background-color: var(--bg-app);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(124, 58, 237, 0.05) 0%, transparent 45%);
}

input, button, select, textarea {
    font-family: inherit;
    color: inherit;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary-glow);
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 10;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-glass);
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    font-size: 24px;
    background: var(--color-primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(124, 58, 237, 0.4));
}

.brand-logo h2 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand-subtitle {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--color-primary);
    margin-top: 4px;
    font-weight: 600;
}

.search-box {
    margin: 16px 24px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

.search-box input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 12px 12px 12px 40px;
    font-size: 14px;
    outline: none;
    transition: var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--color-primary-glow);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 10px 0 rgba(124, 58, 237, 0.1);
}

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

.branch-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin: 16px 8px 8px 8px;
    font-weight: 700;
}

.branch-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Elemento de lista Sucursal */
.branch-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.branch-item:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-glass);
}

.branch-item.active {
    background: var(--color-primary-grad);
    box-shadow: var(--shadow-glow);
}

.branch-item-name {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.branch-item.active .branch-item-name {
    color: #fff;
}

.branch-item-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.branch-item.active .branch-item-meta {
    color: rgba(255, 255, 255, 0.7);
}

/* Contenido Principal Layout */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: rgba(10, 15, 28, 0.2);
}

/* Header Global */
.global-header {
    padding: 24px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
}

.active-info {
    display: flex;
    align-items: center;
    gap: 16px;
    transition: background var(--transition-fast) ease;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
}

.active-info:hover {
    background: rgba(255, 255, 255, 0.05);
}

.active-info-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.active-branch-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
}

.active-branch-link:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.active-info-details {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.active-info-details span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid var(--border-glass);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.035);
}

.active-info-details i {
    color: var(--color-primary);
}

.active-badge {
    height: 48px;
    width: 48px;
    border-radius: var(--radius-md);
    background: var(--color-primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-primary);
    border: 1px solid var(--border-glass-glow);
    box-shadow: var(--shadow-glow);
}

.global-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.text-secondary {
    color: var(--text-secondary);
    font-size: 13px;
}

.text-danger {
    color: var(--color-danger);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
    outline: none;
}

.btn-primary {
    background: var(--color-primary-grad);
    border: 1px solid transparent;
    box-shadow: 0 4px 15px 0 rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 rgba(124, 58, 237, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.28);
    color: var(--color-danger);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.44);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.sync-dropdown {
    position: relative;
    display: inline-flex;
    align-items: stretch;
}

.sync-main-btn {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.sync-menu-btn {
    width: 42px;
    padding: 10px 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.16);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.sync-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 230px;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-premium);
    z-index: 50;
    overflow: hidden;
}

.sync-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: transparent;
    border: 0;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.sync-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Barra de Sincronización */
.sync-status-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
}

.sync-progress-bar-wrapper {
    width: 100px;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
}

.sync-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--color-primary-grad);
    border-radius: 10px;
    transition: width 0.3s ease;
}

.sync-progress-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-primary);
}

.hidden {
    display: none !important;
}

/* Navigation Tabs */
.navigation-tabs {
    display: flex;
    background: var(--bg-glass);
    padding: 0 40px;
    border-bottom: 1px solid var(--border-glass);
}

.tab-link {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 16px 24px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-link:hover {
    color: var(--text-primary);
}

.tab-link.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

/* Tab Content Wrappers */
.tab-content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 30px 40px;
    min-height: 0;
}

.tab-content-wrapper.scripts-mode {
    overflow: hidden;
}

.tab-section {
    display: none;
    animation: fadeIn var(--transition-normal);
}

.tab-section.active {
    display: block;
}

#tab-scripts.active {
    height: 100%;
    min-height: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   CARDS & GRIDS
   ========================================================================== */

.card {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-premium);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 24px;
}

/* Metrics Dashboard Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-premium);
    transition: var(--transition-normal);
}

.metric-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-glass-glow);
}

.metric-icon {
    height: 56px;
    width: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.metric-icon.primary { background: rgba(124, 58, 237, 0.1); color: var(--color-primary); }
.metric-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--color-success); }
.metric-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--color-warning); }
.metric-icon.danger { background: rgba(239, 68, 68, 0.1); color: var(--color-danger); }

.metric-details h3 {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.2;
}

.metric-details p {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.sub-metric {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

/* Details Dashboard Grid */
.dashboard-details-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 30px;
}

.panel-card {
    height: 420px;
    display: flex;
    flex-direction: column;
}

.panel-card .card-body {
    flex: 1;
    overflow-y: auto;
}

/* Distribución de Estado UI */
.status-distribution-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dist-bar-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dist-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.dist-bar-bg {
    height: 8px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    overflow: hidden;
}

.dist-bar-fill {
    height: 100%;
    border-radius: 10px;
}

.dist-bar-fill.won { background: var(--color-success); }
.dist-bar-fill.open { background: hsl(217, 91%, 60%); }
.dist-bar-fill.lost { background: var(--color-danger); }
.dist-bar-fill.abandoned { background: var(--text-muted); }

.pipeline-overview-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pipeline-overview-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.pipeline-overview-summary div {
    padding: 14px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.035);
}

.pipeline-overview-summary strong {
    display: block;
    font-size: 24px;
    line-height: 1;
    color: var(--text-primary);
}

.pipeline-overview-summary span {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 12px;
}

.pipeline-overview-item {
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    padding: 14px;
}

.pipeline-overview-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.pipeline-overview-item-header strong {
    display: block;
    color: var(--text-primary);
    font-size: 15px;
}

.pipeline-id {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    margin-left: 6px;
    vertical-align: middle;
    user-select: all;
}

.pipeline-overview-item-header > span {
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.pipeline-label,
.pipeline-stages-title {
    display: block;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.pipeline-stages-title {
    margin: 4px 0 8px;
}

.pipeline-stages-list {
    display: grid;
    gap: 6px;
}

.pipeline-stage-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border: 1px solid rgba(124, 58, 237, 0.18);
    border-radius: var(--radius-sm);
    background: rgba(124, 58, 237, 0.08);
}

.stage-order {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: rgba(124, 58, 237, 0.16);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex: 0 0 auto;
}

.stage-name {
    color: var(--text-primary);
    font-size: 13px;
    flex: 1;
}

.stage-opp-count {
    margin-left: auto;
    min-width: 28px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-primary);
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: 999px;
    padding: 2px 8px;
}

/* ==========================================================================
   TABLAS Y PAGINACIÓN
   ========================================================================== */

.table-card {
    display: flex;
    flex-direction: column;
    max-height: 600px;
}

.table-wrapper {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-glass);
}

.data-table th {
    background: rgba(255, 255, 255, 0.02);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
}

.data-table tbody tr {
    transition: var(--transition-fast);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--color-success); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--color-danger); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--color-warning); }
.badge-primary { background: rgba(124, 58, 237, 0.1); color: var(--color-primary); }

.badge-status-active { background: rgba(16, 185, 129, 0.1); color: var(--color-success); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-status-inactive { background: rgba(245, 158, 11, 0.1); color: var(--color-warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-status-draft { background: rgba(255, 255, 255, 0.05); color: var(--text-secondary); border: 1px solid var(--border-glass); }

.tag-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    margin-right: 4px;
}

.pagination-bar {
    padding: 16px 24px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.pagination-buttons {
    display: flex;
    gap: 8px;
}

/* Toolbar global */
.toolbar {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pipeline-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
}

.form-control {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    outline: none;
    color: var(--text-primary);
    cursor: pointer;
}

.form-control:focus {
    border-color: var(--color-primary-glow);
}

/* ==========================================================================
   BOARD KANBAN
   ========================================================================== */

.kanban-board {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 15px;
    min-height: 500px;
}

.kanban-column {
    flex: 0 0 300px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 280px);
}

.kanban-column-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.01);
}

.kanban-column-header h4 {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.kanban-card-count {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.kanban-cards-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Tarjeta Kanban Individual */
.kanban-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 16px;
    transition: var(--transition-normal);
    cursor: grab;
}

.kanban-card:hover {
    border-color: var(--color-primary-glow);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: var(--shadow-premium);
    transform: translateY(-2px);
}

.kanban-card-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.4;
}

.kanban-card-contact {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.kanban-card-vehicle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.kanban-card-value {
    font-weight: 700;
    font-size: 13px;
    color: var(--color-success);
}

/* Vacío / Error del Board */
.board-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 24px;
}

.board-empty-state i {
    font-size: 60px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.board-empty-state p {
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 8px;
}

/* ==========================================================================
   TAB TERMINAL Y SCRIPTS
   ========================================================================== */

.scripts-layout-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 30px;
    height: 100%;
    min-height: 0;
}

.scripts-catalog-column, .scripts-terminal-column {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.scripts-card {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.scripts-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px 24px;
}

/* Categoría de Scripts */
.script-search-box {
    position: relative;
    margin-bottom: 14px;
}

.script-search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}

.script-search-box input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 11px 12px 11px 40px;
    outline: none;
    font-size: 13px;
    transition: var(--transition-fast);
}

.script-search-box input:focus {
    border-color: var(--color-primary-glow);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.12);
}

.script-category-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.btn-category {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--text-secondary);
}

.btn-category:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-category.active {
    background: var(--color-primary);
    color: #fff;
    border-color: transparent;
}

.scripts-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
}

/* Tarjeta de Script Individual */
.script-item-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: var(--transition-normal);
}

.script-item-card:hover {
    border-color: var(--border-glass-glow);
    background: rgba(255, 255, 255, 0.04);
}

.script-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.script-item-header h4 {
    font-size: 14px;
    font-weight: 700;
}

.script-item-header p {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.script-item-card p.desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.script-scope-panel {
    background: rgba(124, 58, 237, 0.06);
    border: 1px solid rgba(124, 58, 237, 0.16);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.script-options-panel {
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.14);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.script-panel-label {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.script-scope-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.script-scope-choice,
.script-mode-choice,
.script-option-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.script-scope-choice,
.script-mode-choice {
    padding: 8px 12px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.script-scope-choice:hover,
.script-mode-choice:hover,
.script-option-toggle:hover {
    border-color: var(--border-glass-glow);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.script-scope-choice input,
.script-mode-choice input,
.script-option-toggle input {
    accent-color: var(--color-primary);
}

.script-scope-choice:has(input:checked),
.script-mode-choice:has(input:checked) {
    background: rgba(124, 58, 237, 0.22);
    border-color: var(--color-primary);
    color: #fff;
}

.script-scope-choice.danger:has(input:checked) {
    background: rgba(245, 158, 11, 0.18);
    border-color: var(--color-warning);
}

.script-scope-select,
.script-location-search,
.script-location-id-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid var(--border-glass);
    border-radius: 4px;
    padding: 8px 10px;
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
}

.script-location-picker {
    margin-top: 8px;
}

.script-location-id-row {
    margin-top: 8px;
}

.script-location-actions {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}

.script-location-list {
    max-height: 170px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: 4px;
}

.script-location-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
}

.script-location-option:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.script-location-option input {
    accent-color: var(--color-primary);
}

.script-scope-help {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 11px;
}

.script-mode-label {
    margin-top: 12px;
}

.script-mode-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.script-mode-choice:has(input[value="parallel"]:checked) {
    background: rgba(245, 158, 11, 0.18);
    border-color: var(--color-warning);
}

.script-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px;
}

.script-option-toggle {
    border-radius: var(--radius-sm);
    padding: 9px 10px;
}

.script-option-toggle:has(input:checked) {
    background: rgba(16, 185, 129, 0.16);
    border-color: var(--color-success);
}

.script-option-toggle span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.script-option-toggle strong {
    color: var(--text-primary);
    font-size: 12px;
}

.script-option-toggle small {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
}

.script-advanced-args {
    flex: 1;
}

.script-advanced-args summary {
    width: fit-content;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    margin-bottom: 8px;
}

.script-advanced-args[open] {
    min-width: 260px;
}

.script-item-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.script-item-args-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 12px;
    outline: none;
}

.script-item-args-input:focus {
    border-color: var(--color-primary-glow);
}

.script-item-card {
    transition: border-color 0.4s ease, background 0.4s ease, box-shadow 0.4s ease;
}
.script-item-card.is-running {
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.03);
}
.script-item-card.is-success {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.03);
}
.script-item-card.is-failed {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.03);
}

.terminal-status-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 12px;
    letter-spacing: 0.5px;
    margin-left: 10px;
    display: inline-flex;
    align-items: center;
}
.terminal-status-badge.idle {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
}
.terminal-status-badge.running {
    background: rgba(59, 130, 246, 0.15);
    color: #3B82F6;
    border: 1px solid rgba(59, 130, 246, 0.3);
    animation: pulseRun 1.5s infinite ease-in-out;
}
.terminal-status-badge.success {
    background: rgba(16, 185, 129, 0.15);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.terminal-status-badge.failed {
    background: rgba(239, 110, 110, 0.15);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.terminal-status-badge.disconnected {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

@keyframes pulseRun {
    0% { opacity: 0.7; }
    50% { opacity: 1; filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.4)); }
    100% { opacity: 0.7; }
}

.terminal-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.universal-dryrun-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
    transition: all 0.3s ease;
}

.universal-dryrun-toggle.is-active {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.05);
}

.universal-dryrun-toggle.is-danger {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.3);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.05);
}

.universal-dryrun-toggle.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.toggle-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    user-select: none;
    white-space: nowrap;
}

.universal-dryrun-toggle.is-active .toggle-label {
    color: #3B82F6;
}

.universal-dryrun-toggle.is-danger .toggle-label {
    color: var(--color-warning);
}

/* Base Switch Styles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .3s;
    border-radius: 20px;
    border: 1px solid var(--border-glass);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: rgba(59, 130, 246, 0.2);
    border-color: #3B82F6;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(14px);
    background-color: #3B82F6;
}

/* Naranja para el modo de peligro/escritura real */
.universal-dryrun-toggle.is-danger .toggle-switch input:not(:checked) + .toggle-slider {
    border-color: var(--color-warning);
}

.universal-dryrun-toggle.is-danger .toggle-slider:before {
    background-color: var(--color-warning);
}


/* Columna de Consola Terminal */
.terminal-card {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-color: rgba(124, 58, 237, 0.15);
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
    /* Necesario para que el badge "Volver al final" se ancle al card. */
    position: relative;
}
.terminal-card.is-running {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.1);
}
.terminal-card.is-success {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.1);
}
.terminal-card.is-failed {
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.1);
}
.terminal-card.is-disconnected {
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.1);
}

.terminal-header {
    background: rgba(0, 0, 0, 0.4);
    gap: 32px; /* Espacio de separación garantizado entre el título/badge y las acciones */
}

.terminal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.terminal-dot {
    height: 12px;
    width: 12px;
    border-radius: 50%;
}
.terminal-dot.red { background: #FF5F56; }
.terminal-dot.yellow { background: #FFBD2E; }
.terminal-dot.green { background: #27C93F; }

.terminal-card .card-header h3 {
    font-family: var(--font-mono);
    font-size: 14px;
    white-space: nowrap;
}

.terminal-body {
    flex: 1;
    min-height: 0;
    background: #05070F;
    padding: 20px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    color: #00FF66; /* Verde Matrix */
    line-height: 1.5;
    border-top: 1px solid rgba(0, 0, 0, 0.3);
}

.terminal-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
}

.terminal-placeholder i {
    font-size: 40px;
    margin-bottom: 16px;
    color: var(--text-muted);
}

.terminal-placeholder p {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.terminal-placeholder span {
    font-size: 12px;
}

.terminal-line {
    white-space: pre-wrap;
    word-break: break-all;
    margin-bottom: 4px;
}

.terminal-line.info { color: #3B82F6; }
.terminal-line.error { color: #EF4444; }
.terminal-line.success { color: #10B981; }
.terminal-line.download { margin: 8px 0; }

/* Pestañas internas de la terminal (Salida / Errores) */
.terminal-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 12px 0 12px;
    background: rgba(0, 0, 0, 0.45);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.terminal-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 14px;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
    border-bottom: 2px solid transparent;
}

.terminal-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.terminal-tab.active {
    color: #00FF66;
    border-bottom-color: #00FF66;
    background: rgba(0, 255, 102, 0.04);
}

.terminal-tab.has-errors {
    color: #EF4444;
}

.terminal-tab.has-errors.active {
    color: #EF4444;
    border-bottom-color: #EF4444;
    background: rgba(239, 68, 68, 0.05);
}

.terminal-error-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
}

.terminal-tab.has-errors .terminal-error-count {
    background: rgba(239, 68, 68, 0.18);
    color: #EF4444;
    border-color: rgba(239, 68, 68, 0.4);
}

/* Panel de Errores */
.terminal-errors-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
}

.terminal-errors-summary {
    padding: 14px 20px;
    background: rgba(239, 68, 68, 0.06);
    border-bottom: 1px solid rgba(239, 68, 68, 0.18);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.terminal-errors-summary-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: #EF4444;
    font-size: 13px;
}

.terminal-errors-summary-main strong {
    font-size: 22px;
    font-weight: 800;
    color: #EF4444;
    line-height: 1;
}

.terminal-errors-summary-meta {
    color: var(--text-muted);
    font-size: 11px;
}

.terminal-errors-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.terminal-error-item {
    border: 1px solid rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.04);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: #FCA5A5;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.terminal-error-item-header {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.terminal-error-item-header .err-script {
    color: #00FF66;
    font-weight: 700;
}

.terminal-error-item-header .err-task {
    color: #3B82F6;
}

.terminal-error-item-header .err-time {
    margin-left: auto;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
}

.terminal-error-item-body {
    white-space: pre-wrap;
    word-break: break-word;
    color: #EF4444;
    line-height: 1.45;
}

.terminal-download-link {
    display: inline-block;
    padding: 6px 14px;
    background: #10B981;
    color: #ffffff !important;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
}
.terminal-download-link:hover { background: #059669; }

.script-run-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    /* En el nuevo header sticky el padding/margen los maneja el .terminal-run-bar */
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
}

/* Barra sticky sobre #terminal-screen: contador, controles de run, descargar log. */
.terminal-run-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.55);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.terminal-run-bar.hidden {
    display: none;
}

.terminal-run-bar-stats {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}

.terminal-run-bar-stats i {
    font-size: 11px;
}

.terminal-run-bar-stats .truncated {
    color: #F59E0B;
    font-weight: 600;
}

.terminal-run-bar-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
}

.terminal-run-bar-controls:empty {
    display: none;
}

.terminal-run-bar-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

/* Badge flotante "Volver al final del log" — visible solo cuando el usuario
   se aleja del fondo durante un run activo. */
.terminal-resume-scroll {
    position: absolute;
    right: 24px;
    bottom: 24px;
    z-index: 5;
    padding: 8px 14px;
    border-radius: 999px;
    border: none;
    background: rgba(59, 130, 246, 0.92);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s ease, transform 0.15s ease;
}

.terminal-resume-scroll:hover {
    background: rgba(37, 99, 235, 1);
    transform: translateY(-1px);
}

.terminal-resume-scroll.hidden {
    display: none;
}

@media (max-width: 1180px) {
    .global-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
    }

    .header-actions {
        flex-wrap: wrap;
    }

    .tab-content-wrapper.scripts-mode {
        overflow-y: auto;
    }

    #tab-scripts.active {
        height: auto;
    }

    .scripts-layout-grid {
        grid-template-columns: 1fr;
        height: auto;
    }

    .scripts-catalog-column,
    .scripts-terminal-column {
        min-height: 520px;
    }
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-premium);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn var(--transition-fast) forwards;
    min-width: 280px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left: 4px solid var(--color-success); }
.toast.error { border-left: 4px solid var(--color-danger); }
.toast.info { border-left: 4px solid var(--color-primary); }

/* ==========================================================================
   MODAL WINDOWS (GLASSMORPHISM STYLE)
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    transition: opacity var(--transition-fast) ease;
}

.modal-backdrop.hidden {
    display: none !important;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    width: 480px;
    max-width: 90%;
    box-shadow: var(--shadow-premium);
    overflow: hidden;
    animation: modalScaleUp var(--transition-fast) forwards;
}

@keyframes modalScaleUp {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.btn-close-modal:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ============== Modales custom (appConfirm / appPrompt) ============== */
.modal-card.severity-warning { border-left: 4px solid #FBBF24; }
.modal-card.severity-danger  { border-left: 4px solid var(--color-danger); }
.modal-card.severity-info    { border-left: 4px solid var(--color-primary); }

.app-modal-message {
    color: var(--text-secondary);
    font-size: 14px;
    white-space: pre-wrap;
    line-height: 1.5;
    margin: 0;
}

.app-modal-prompt-input {
    width: 100%;
    margin-top: 14px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono, monospace);
    letter-spacing: 1px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s ease;
}
.app-modal-prompt-input:focus {
    border-color: var(--color-primary);
}

/* Modal de progreso (long-running tasks como renovar sesión) */
.app-progress-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding: 8px 4px;
}

.app-progress-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* Spinner girando (estado: corriendo) */
.app-progress-icon.spinning {
    border: 4px solid rgba(124, 58, 237, 0.2);
    border-top-color: var(--color-primary);
    animation: appProgressSpin 0.9s linear infinite;
}
@keyframes appProgressSpin {
    to { transform: rotate(360deg); }
}

/* Éxito: check verde con animación */
.app-progress-icon.success {
    background: rgba(52, 211, 153, 0.12);
    color: #34D399;
    font-size: 36px;
    animation: appProgressPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Error: X roja */
.app-progress-icon.failure {
    background: rgba(248, 113, 113, 0.12);
    color: #F87171;
    font-size: 36px;
    animation: appProgressShake 0.5s ease;
}
@keyframes appProgressPop {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}
@keyframes appProgressShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.app-progress-title {
    font-weight: bold;
    font-size: 15px;
    color: var(--text-primary);
    text-align: center;
}
.app-progress-detail {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    line-height: 1.5;
    min-height: 18px;
    white-space: pre-wrap;
}
.app-progress-log {
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font-mono, monospace);
    text-align: center;
    opacity: 0.7;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-height: 14px;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
    border: 1px solid var(--color-danger);
}
.btn-danger:hover:not(:disabled) {
    filter: brightness(1.1);
}
.btn-danger:disabled,
.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: none;
}

.script-editor-modal {
    width: 760px;
    max-width: 94vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.script-editor-body {
    overflow-y: auto;
    flex: 1;
}

.script-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.script-form-grid label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.script-form-full {
    grid-column: 1 / -1;
}

.script-check-row {
    flex-direction: row !important;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

@media (max-width: 760px) {
    .script-form-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   COMPARATIVA MARCA vs SUCURSALES
   ========================================================================== */

.comparativa-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.comparativa-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.comparativa-subtitle {
    margin: 0;
    max-width: 720px;
    font-size: 13px;
}

.comparativa-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.comparativa-status-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 10px;
    background: rgba(124, 92, 252, 0.10);
    border: 1px solid rgba(124, 92, 252, 0.35);
    margin-bottom: 18px;
}
.comparativa-status-banner.is-error {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.55);
}
.comparativa-status-banner.is-error .comparativa-status-icon {
    color: #ef4444;
}
.comparativa-status-icon {
    font-size: 22px;
    color: #a78bfa;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}
.comparativa-status-body {
    flex: 1;
    min-width: 0;
}
.comparativa-status-title {
    font-weight: 600;
    color: var(--text-primary, #f3f4f6);
    margin-bottom: 2px;
}
.comparativa-status-msg {
    font-size: 13px;
    color: var(--text-secondary, #94a3b8);
    word-break: break-word;
}

.comparativa-totals-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 1100px) {
    .comparativa-totals-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
    .comparativa-totals-grid { grid-template-columns: 1fr; }
}

.comparativa-total-card {
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    transition: var(--transition-normal);
}

.comparativa-total-card:hover {
    border-color: var(--border-glass-glow);
}

.comparativa-total-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.comparativa-total-value {
    font-size: 32px;
    font-weight: 800;
    line-height: 1.1;
}

.comparativa-total-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.comparativa-diff-card.is-ok {
    border-color: rgba(16, 185, 129, 0.45);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0.02));
}
.comparativa-diff-card.is-ok .comparativa-total-value { color: var(--color-success); }

.comparativa-diff-card.is-mismatch {
    border-color: rgba(239, 68, 68, 0.45);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.10), rgba(239, 68, 68, 0.02));
}
.comparativa-diff-card.is-mismatch .comparativa-total-value { color: var(--color-danger); }

.comparativa-info-card {
    margin-bottom: 24px;
}

.comparativa-demos-list {
    margin: 0;
    padding: 0 0 0 18px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.8;
}

.comparativa-buckets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 900px) {
    .comparativa-buckets-grid { grid-template-columns: 1fr; }
}

.comparativa-bucket-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.comparativa-bucket-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}

.comparativa-bucket-header h4 {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.comparativa-bucket-header p {
    font-size: 12px;
    margin: 0;
    line-height: 1.5;
}

.comparativa-bucket-badge {
    font-size: 22px;
    font-weight: 800;
    color: var(--color-primary);
    background: rgba(124, 58, 237, 0.10);
    border: 1px solid rgba(124, 58, 237, 0.3);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    min-width: 60px;
    text-align: center;
}

.comparativa-bucket-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.comparativa-bucket-body {
    border-top: 1px solid var(--border-glass);
    padding-top: 14px;
    max-height: 480px;
    overflow-y: auto;
}

.comparativa-bucket-filter {
    position: relative;
    margin-bottom: 10px;
}

.comparativa-bucket-filter i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}

.comparativa-bucket-filter input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 8px 12px 8px 36px;
    font-size: 13px;
    outline: none;
    color: var(--text-primary);
}

.comparativa-bucket-table th,
.comparativa-bucket-table td {
    font-size: 12px;
    padding: 8px 10px;
}

/* Master checkbox dentro del <th> de la tabla del bucket */
.comp-bulk-master-checkbox,
.comp-bulk-row-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    vertical-align: middle;
}

.comp-bulk-master-checkbox {
    accent-color: var(--color-primary, #8b5cf6);
}

.comp-bulk-row-checkbox:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

/* Posibles coincidencias (fuzzy matches) en bucket missing_in_assigned_branch */
.fuzzy-matches-cell {
    font-size: 12px;
}

.fuzzy-matches-summary {
    cursor: pointer;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fbbf24;
    font-weight: 600;
    user-select: none;
}

.fuzzy-matches-summary::-webkit-details-marker {
    display: none;
}

.fuzzy-matches-summary:hover {
    background: rgba(245, 158, 11, 0.18);
}

.fuzzy-matches-cell[open] .fuzzy-matches-summary {
    margin-bottom: 6px;
}

.fuzzy-matches-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fuzzy-match-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 8px;
    align-items: start;
    padding: 6px 8px;
    border-left: 3px solid rgba(245, 158, 11, 0.45);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

.fuzzy-match-item .contact-link {
    font-size: 12px;
    font-weight: 500;
}

.fuzzy-match-meta {
    grid-column: 2 / -1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
}

.fuzzy-match-branch {
    color: var(--text-secondary);
}

.fuzzy-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 18px;
    padding: 0 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    font-family: monospace;
}

.fuzzy-badge-phone {
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.fuzzy-badge-email-strong {
    background: rgba(168, 85, 247, 0.18);
    color: #d8b4fe;
    border: 1px solid rgba(168, 85, 247, 0.4);
}

.fuzzy-badge-email {
    background: rgba(168, 85, 247, 0.10);
    color: #c4b5fd;
    border: 1px solid rgba(168, 85, 247, 0.28);
}

.fuzzy-badge-name {
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.comparativa-per-branch-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==========================================================================
   MODAL DE SYNC + PILLS
   ========================================================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay[hidden] { display: none; }

/* Forzar [hidden] sobre cualquier display explicito (botones .btn con flex, etc.) */
[hidden] { display: none !important; }

.modal-dialog {
    background: var(--bg-glass);
    background-color: rgb(15, 23, 42);
    border: 1px solid var(--border-glass-glow);
    border-radius: var(--radius-md);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 1100px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-glass);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

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

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 24px;
    border-top: 1px solid var(--border-glass);
}

.sync-summary-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

@media (max-width: 800px) {
    .sync-summary-grid { grid-template-columns: repeat(2, 1fr); }
}

.sync-summary-cell {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sync-summary-cell span {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.sync-summary-cell strong {
    font-size: 22px;
    font-weight: 800;
}

.sync-summary-cell.is-danger {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.06);
}

.sync-summary-cell.is-danger strong { color: var(--color-danger); }

.sync-detail-wrapper {
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    overflow-y: auto;
    max-height: 50vh;
}

.sync-detail-table th,
.sync-detail-table td {
    font-size: 12px;
    vertical-align: top;
}

.sync-detail-table tr.is-create td {
    background: rgba(16, 185, 129, 0.04);
}

.sync-detail-table tr.is-update td {
    background: rgba(124, 58, 237, 0.04);
}

.sync-detail-table tr.is-danger td {
    background: rgba(239, 68, 68, 0.06);
}

.sync-status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-glass);
}

.sync-status-pill.is-create {
    background: rgba(16, 185, 129, 0.10);
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--color-success);
}

.sync-status-pill.is-update {
    background: rgba(124, 58, 237, 0.10);
    border-color: rgba(124, 58, 237, 0.4);
    color: var(--color-primary);
}

.sync-status-pill.is-danger {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--color-danger);
}

.sync-status-pill.is-skip {
    background: rgba(148, 163, 184, 0.10);
    border-color: rgba(148, 163, 184, 0.4);
    color: var(--text-secondary);
}

.sync-detail-table tr.is-skip td {
    background: rgba(148, 163, 184, 0.04);
    opacity: 0.85;
}

.sync-action-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    margin-right: 4px;
    margin-bottom: 3px;
}

.sync-action-pill.is-create {
    background: rgba(16, 185, 129, 0.10);
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--color-success);
}

.sync-action-pill.is-update {
    background: rgba(124, 58, 237, 0.10);
    border-color: rgba(124, 58, 237, 0.4);
    color: var(--color-primary);
}

.sync-row-error {
    margin-top: 6px;
    font-size: 11px;
    color: var(--color-danger);
    background: rgba(239, 68, 68, 0.06);
    border-left: 2px solid var(--color-danger);
    padding: 4px 8px;
    border-radius: 4px;
}

.text-danger { color: var(--color-danger); }

.btn-micro-delete {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--color-danger);
    border-radius: var(--radius-sm);
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 12px;
    padding: 0;
}

.btn-micro-delete:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.55);
}

.btn-micro-delete:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-micro-delete.is-locked {
    opacity: 0.35;
    border-color: rgba(148, 163, 184, 0.3);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn-micro-delete.is-locked:hover {
    background: transparent;
}

.btn-micro-sync-from-branch {
    background: transparent;
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: var(--color-success);
    border-radius: var(--radius-sm);
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 12px;
    padding: 0;
    margin-right: 4px;
}

.btn-micro-sync-from-branch[hidden] { display: none !important; }

.btn-micro-sync-from-branch:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.65);
}

.btn-micro-sync-from-branch:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-micro-sync-from-branch.is-disabled {
    opacity: 0.3;
    border-color: rgba(148, 163, 184, 0.3);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn-micro-sync-from-branch.is-disabled:hover {
    background: transparent;
}

.resolution-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    margin-left: 4px;
    vertical-align: middle;
    cursor: help;
}

.resolution-badge.resolution-tienda {
    background: rgba(124, 58, 237, 0.18);
    border: 1px solid rgba(124, 58, 237, 0.4);
    color: var(--color-primary);
}

.resolution-badge.resolution-sucursal-exact {
    background: rgba(16, 185, 129, 0.18);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: var(--color-success);
}

.resolution-badge.resolution-sucursal-substring {
    background: rgba(245, 158, 11, 0.18);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: var(--color-warning);
}

.resolution-badge.resolution-test {
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: var(--color-danger, #ef4444);
    letter-spacing: 0.5px;
}

.comparativa-test-subsection {
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.06);
}

.comparativa-test-subsection-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px 0;
    font-size: 14px;
    color: var(--color-danger, #ef4444);
}

.comparativa-test-count {
    background: rgba(239, 68, 68, 0.22);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: var(--color-danger, #ef4444);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 999px;
}

.comparativa-test-subsection-desc {
    margin: 0 0 10px 0;
    font-size: 12px;
}

.comparativa-test-subsection-desc code {
    background: rgba(0, 0, 0, 0.25);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11px;
}

.btn-micro-sync-from-branch.is-done {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.7);
}

.group-count--last {
    color: var(--color-success);
    font-style: italic;
}

.contact-link {
    color: var(--color-primary);
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.contact-link:hover {
    border-bottom-color: var(--color-primary);
    color: var(--color-primary);
}

.contact-link-icon {
    font-size: 10px;
    opacity: 0.55;
}

.contact-link:hover .contact-link-icon {
    opacity: 1;
}

/* ===== Tabla de contactos: link al CRM + marca de prueba ===== */
.contact-name-link {
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.contact-name-link:hover {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}
.contact-row-test {
    background: rgba(255, 159, 64, 0.06);
}
.contact-row-test:hover {
    background: rgba(255, 159, 64, 0.10);
}

/* ===== Modal radio list (appSelectFromList) ===== */
.app-modal-radio-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    max-height: 320px;
    overflow-y: auto;
}
.app-modal-radio-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.app-modal-radio-row:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--color-primary, #6366f1);
}
.app-modal-radio-row input[type="radio"] {
    margin-top: 3px;
    accent-color: var(--color-primary, #6366f1);
}
.app-modal-radio-text {
    flex: 1;
}
.app-modal-radio-label {
    font-weight: 500;
    color: var(--text-primary);
}
.app-modal-radio-sublabel {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.app-modal-meta {
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(255, 159, 64, 0.08);
    border: 1px solid rgba(255, 159, 64, 0.2);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Toggle Global de Modo (Dry-Run / Live) ===== */
.global-mode-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1.5px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    cursor: pointer;
    user-select: none;
    margin-right: 8px;
}
.global-mode-toggle.is-dryrun {
    border-color: rgba(34, 197, 94, 0.42);
    background: rgba(34, 197, 94, 0.10);
    color: #4ade80;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
}
.global-mode-toggle.is-dryrun:hover {
    background: rgba(34, 197, 94, 0.16);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
}
.global-mode-toggle.is-live {
    border-color: rgba(239, 68, 68, 0.55);
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    animation: globalModeLivePulse 2.2s ease-in-out infinite;
}
.global-mode-toggle.is-live:hover {
    background: rgba(239, 68, 68, 0.20);
}
@keyframes globalModeLivePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.32); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.04); }
}
.global-mode-icon {
    font-size: 16px;
    display: flex;
    align-items: center;
}
.global-mode-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.global-mode-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.7;
}
.global-mode-value {
    font-size: 13px;
    font-weight: 600;
}
.global-mode-switch {
    margin-left: 4px;
}
.global-mode-toggle .toggle-slider {
    background: rgba(255, 255, 255, 0.18);
}
.global-mode-toggle.is-dryrun .toggle-slider {
    background: rgba(34, 197, 94, 0.45);
}
.global-mode-toggle.is-live input:checked + .toggle-slider {
    background: rgba(239, 68, 68, 0.7);
}
/* Indicador inline para reuso en otros lugares (ej. tab Scripts read-only badge) */
.global-mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid currentColor;
}
.global-mode-pill.is-dryrun {
    color: #4ade80;
    background: rgba(34, 197, 94, 0.08);
}
.global-mode-pill.is-live {
    color: #f87171;
    background: rgba(239, 68, 68, 0.10);
}

/* Badge de Fuente (campo nativo source de Bucefalo) en tabla de contactos */
.source-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.10);
    border: 1px solid rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Botón de dedupe en card Pipelines y Etapas */
.pipeline-overview-actions {
    display: flex;
    justify-content: flex-end;
    margin: 12px 0 8px 0;
}
.pipeline-overview-actions .btn {
    gap: 6px;
}

/* Botones micro nuevos en bucket brand_not_in_any_branch */
.btn-micro-verify,
.btn-micro-create-in-branch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-right: 4px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.btn-micro-verify:hover {
    background: rgba(99, 102, 241, 0.12);
    color: #a5b4fc;
    border-color: rgba(99, 102, 241, 0.35);
}
.btn-micro-create-in-branch:hover {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.35);
}
.btn-micro-verify.is-done,
.btn-micro-create-in-branch.is-done {
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.45);
    cursor: default;
}

/* Sortable workflow table headers */
.workflow-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.workflow-sortable:hover {
    color: #A78BFA;
}
.workflow-sortable .sort-indicator {
    display: inline-block;
    margin-left: 4px;
    font-size: 11px;
    opacity: 0.35;
    transition: opacity 0.15s ease;
}
.workflow-sortable.sort-asc .sort-indicator,
.workflow-sortable.sort-desc .sort-indicator {
    opacity: 1;
    color: #A78BFA;
}
.workflow-sortable .sort-indicator::before {
    content: "⇅";
}
.workflow-sortable.sort-asc .sort-indicator::before {
    content: "▲";
}
.workflow-sortable.sort-desc .sort-indicator::before {
    content: "▼";
}
