/* ============================================================
   Course Business Style — Componentes UI (prefijo cb-)
   Botones, Inputs, Tablas, Chips, Cards, Modales,
   Empty States, Icon Buttons, Progress Bars, Tabs, AI Card.
   ============================================================ */

/* ── BOTONES ─────────────────────────────────────────────── */
.cb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 14px; font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    line-height: 1.4;
    white-space: nowrap;
}

/* Filled — primario */
.cb-btn-filled {
    background: var(--primary);
    color: #fff !important;
}
.cb-btn-filled:hover {
    background: var(--primary-dark);
    box-shadow: var(--elevation-1);
    color: #fff;
    text-decoration: none;
}

/* Tonal — secundario */
.cb-btn-tonal {
    background: var(--primary-surface);
    color: var(--primary);
}
.cb-btn-tonal:hover {
    background: var(--primary-hover);
    color: var(--primary);
    text-decoration: none;
}

/* Outlined */
.cb-btn-outlined {
    background: var(--surface-dim);
    color: var(--on-surface);
    border: 1px solid var(--outline);
}
.cb-btn-outlined:hover {
    background: var(--surface-variant);
    color: var(--on-surface);
    text-decoration: none;
}

/* Text */
.cb-btn-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 13px; font-weight: 500;
    color: var(--primary);
    background: transparent;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background-color 0.2s ease;
}
.cb-btn-text:hover {
    background: var(--primary-surface);
    color: var(--primary);
    text-decoration: none;
}

/* Danger */
.cb-btn-danger {
    background: var(--error);
    color: #fff !important;
}
.cb-btn-danger:hover {
    background: #c62828;
    color: #fff;
    text-decoration: none;
}

/* ── INPUTS Y FORMULARIOS ────────────────────────────────── */
.cb-filter-form { padding: 12px 0; }

.cb-filter-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.cb-filter-field    { flex: 1; min-width: 140px; }
.cb-filter-field-lg { flex: 2; }

.cb-label {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 12px; font-weight: 500;
    color: var(--on-surface-variant);
    margin-bottom: 4px;
}
.cb-label-required::after { content: ' *'; color: var(--error); }

.cb-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--outline);
    border-radius: var(--radius-xs);
    font-family: 'Inter', sans-serif;
    font-size: 13px; font-weight: 400;
    color: var(--on-surface);
    background: var(--surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    height: 38px;
}
.cb-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-surface);
}
.cb-input::placeholder { color: var(--on-surface-variant); }

.cb-textarea { height: auto; min-height: 80px; resize: vertical; }

.cb-form-group   { margin-bottom: 16px; }
.cb-form-row     { display: flex; gap: 12px; margin-bottom: 16px; }
.cb-form-half    { flex: 1; }
.cb-form-actions {
    display: flex; gap: 10px;
    justify-content: flex-end;
    padding-top: 8px;
}

/* ── TABLAS ──────────────────────────────────────────────── */
.cb-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Inter', sans-serif;
}

.cb-table thead tr { background: var(--surface-dim); }

.cb-table thead th {
    font-size: 12px; font-weight: 600;
    color: var(--on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--outline);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-dim);
}

.cb-table tbody tr {
    border-bottom: 1px solid var(--outline-variant);
    transition: background-color 0.15s ease;
}
.cb-table tbody tr:hover { background: rgba(26, 115, 232, 0.02); }
.cb-table tbody tr.cb-row-clickable { cursor: pointer; }

.cb-table tbody td {
    font-size: 13px; font-weight: 400;
    color: var(--on-surface);
    padding: 10px 14px;
    vertical-align: middle;
}

.cb-cell-name { font-weight: 500; color: var(--on-surface); }
.cb-cell-sub  { font-size: 12px; color: var(--on-surface-variant); }

/* ── STATUS CHIPS ────────────────────────────────────────── */
.cb-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 12px; font-weight: 500;
    white-space: nowrap;
}

.cb-chip-success { background: var(--success-surface); color: var(--success); }
.cb-chip-warning { background: var(--warning-surface); color: #b45309; }
.cb-chip-danger  { background: var(--error-surface);   color: var(--error); }
.cb-chip-info    { background: var(--info-surface);    color: var(--info); }
.cb-chip-primary { background: var(--primary-surface); color: var(--primary); }
.cb-chip-neutral { background: var(--surface-variant); color: var(--on-surface-variant); }

.cb-chip-sm { padding: 2px 8px; font-size: 10px; }

/* ── CARDS ───────────────────────────────────────────────── */
.cb-card {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius-xs);
    padding: 1.25rem 1.5rem;
    transition: box-shadow 0.2s ease;
}
.cb-card:hover { box-shadow: var(--elevation-2); }

.cb-card-title {
    font-family: 'Google Sans', 'Inter', 'Roboto', sans-serif;
    font-size: 16px; font-weight: 500;
    color: var(--on-surface);
    margin: 0;
}

.cb-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

/* ── KPI GRID ────────────────────────────────────────────── */
.cb-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 12px 0;
}

@media (max-width: 1200px) { .cb-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px)  { .cb-kpi-grid { grid-template-columns: 1fr; } }

/* ── MODALES ─────────────────────────────────────────────── */
.cb-modal-content {
    border-radius: var(--radius-sm);
    border: none;
    overflow: hidden;
}

/* Header con gradiente — único uso permitido de gradientes */
.cb-modal-header {
    background: linear-gradient(135deg, #1a73e8, #1557b0);
    padding: 16px 20px;
    border-bottom: none;
}

.cb-modal-header .cb-modal-title {
    font-family: 'Google Sans', 'Inter', 'Roboto', sans-serif;
    font-size: 18px; font-weight: 500;
    color: #fff;
    margin: 0;
}

.cb-modal-close { color: rgba(255,255,255,0.8); text-shadow: none; opacity: 1; }
.cb-modal-close:hover { color: #fff; }

.cb-modal-body   { background: var(--surface); padding: 20px; }
.cb-modal-footer {
    background: #f0f4ff;
    border-top: 1px solid var(--outline-variant);
    padding: 12px 20px;
}

/* ── MODAL LOADING OVERLAY ──────────────────────────────── */
.cb-modal-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.cb-modal-loading-overlay.is-visible {
    display: flex;
    opacity: 1;
}
.cb-modal-loading-card {
    text-align: center;
    padding: 24px 32px;
    max-width: 340px;
}
.cb-modal-loading-icon-wrap {
    position: relative;
    width: 76px;
    height: 76px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cb-modal-loading-spinner {
    position: absolute;
    inset: 0;
    border: 3px solid var(--primary-surface);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: cb-loading-spin 0.9s linear infinite;
}
.cb-modal-loading-icon {
    color: var(--primary);
    font-size: 32px !important;
    animation: cb-loading-send 1.6s ease-in-out infinite;
}
.cb-modal-loading-icon-success {
    display: none;
    color: var(--success);
    font-size: 36px !important;
}
.cb-modal-loading-overlay.is-success .cb-modal-loading-spinner {
    border-color: var(--success-surface);
    border-top-color: var(--success);
    animation: none;
}
.cb-modal-loading-overlay.is-success .cb-modal-loading-icon { display: none; }
.cb-modal-loading-overlay.is-success .cb-modal-loading-icon-success {
    display: inline-block;
    animation: cb-loading-pop 0.4s ease;
}
.cb-modal-loading-title {
    font-family: 'Google Sans', 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: var(--on-surface);
    margin: 0 0 6px;
}
.cb-modal-loading-subtitle {
    font-size: 13px;
    color: var(--on-surface-variant);
    margin: 0;
    line-height: 1.45;
}
.cb-modal-loading-dots {
    display: inline-flex;
    gap: 4px;
    margin-top: 12px;
}
.cb-modal-loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0.4;
    animation: cb-loading-dot 1.2s ease-in-out infinite;
}
.cb-modal-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.cb-modal-loading-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cb-loading-spin { to { transform: rotate(360deg); } }
@keyframes cb-loading-send {
    0%, 100% { transform: translate(0, 0) rotate(-12deg); opacity: 1; }
    50%      { transform: translate(3px, -3px) rotate(-12deg); opacity: 0.6; }
}
@keyframes cb-loading-pop {
    0%   { transform: scale(0.4); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes cb-loading-dot {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
    40%           { opacity: 1;   transform: scale(1); }
}
[data-theme="dark"] .cb-modal-loading-overlay { background: rgba(32, 33, 36, 0.92); }

/* ── EMPTY STATES ────────────────────────────────────────── */
.cb-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    color: var(--on-surface-variant);
}

.cb-empty-icon {
    font-size: 48px;
    color: var(--on-surface-variant);
    margin-bottom: 8px;
}

.cb-empty-text {
    font-size: 14px;
    color: var(--on-surface-variant);
    margin: 0;
}

/* ── ICON BUTTONS ────────────────────────────────────────── */
.cb-icon-btn {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: var(--radius-full);
    color: var(--on-surface-variant);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    text-decoration: none;
    border: none;
    background: transparent;
}
.cb-icon-btn:hover {
    background: var(--surface-container);
    color: var(--primary);
    text-decoration: none;
}
.cb-icon-btn i { font-size: 14px; }

/* ── PROGRESS BARS ───────────────────────────────────────── */
.cb-progress-track {
    height: 6px;
    background: var(--surface-variant);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.cb-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

.cb-progress-success { background: var(--success); }
.cb-progress-info    { background: var(--info); }
.cb-progress-warning { background: var(--warning); }
.cb-progress-danger  { background: var(--error); }

.cb-progress-list { display: flex; flex-direction: column; gap: 12px; }

.cb-progress-row {
    display: grid;
    grid-template-columns: 160px 1fr 56px;
    align-items: center;
    gap: 12px;
}

.cb-progress-label {
    font-size: 13px;
    color: var(--on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cb-progress-pct {
    font-size: 13px;
    font-weight: 500;
    color: var(--on-surface-variant);
    text-align: right;
}

/* ── TABS ────────────────────────────────────────────────── */
.cb-stats-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--outline);
    margin-bottom: 16px;
}

.cb-stats-tab {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 14px; font-weight: 500;
    color: var(--on-surface-variant);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s;
    border-radius: 8px 8px 0 0;
}
.cb-stats-tab:hover {
    background: var(--primary-hover);
    color: var(--primary);
    text-decoration: none;
}
.cb-stats-tab.cb-stats-tab-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ── AI ANALYSIS CARD ────────────────────────────────────── */
.cb-ai-analysis-card {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--outline);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    min-height: 380px;
}

/* Gradiente oscuro — excepción permitida */
.cb-ai-analysis-header {
    position: relative;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 40%, #0f3460 70%, #1a73e8 100%);
    padding: 20px 20px 16px;
    overflow: hidden;
}

.cb-ai-analysis-title {
    margin: 0 0 2px;
    font-family: 'Google Sans', 'Inter', sans-serif;
    font-size: 15px; font-weight: 600;
    color: #fff;
    letter-spacing: 0.01em;
}

.cb-ai-analysis-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.cb-ai-meta-chip {
    display: flex; align-items: center; gap: 5px;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-full);
    padding: 4px 10px;
    font-size: 12px;
    color: rgba(255,255,255,0.85);
}

.cb-ai-analysis-body {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 28px 24px;
}

/* ── DARK MODE ───────────────────────────────────────────── */
[data-theme="dark"] .cb-card,
[data-theme="dark"] .cb-modal-body {
    background: var(--surface) !important;
    border-color: var(--outline) !important;
    color: var(--on-surface) !important;
}

[data-theme="dark"] .cb-input {
    background: var(--surface-container) !important;
    color: var(--on-surface) !important;
    border-color: var(--outline) !important;
}

[data-theme="dark"] .cb-table thead th {
    background: var(--surface-dim) !important;
    color: var(--on-surface-variant) !important;
    border-bottom-color: var(--outline) !important;
}

[data-theme="dark"] .cb-table tbody td { color: var(--on-surface) !important; }
[data-theme="dark"] .cb-table tbody tr { border-bottom-color: var(--outline) !important; }

[data-theme="dark"] .cb-modal-footer { background: var(--surface-dim) !important; }


/* ── SHIPMENT CARDS (customer portal) ───────────────────── */
.cp-shipment-card:hover {
    border-color: var(--outline-variant, #c8cacf) !important;
    background: var(--surface-dim) !important;
}
.cp-shipment-card:active {
    transform: scale(0.99);
}
.cp-shipment-card[data-state="REQUIRES_ACTION"] {
    border-color: #D97706 !important;
    background: #FFFBEB !important;
}
.cp-shipment-card[data-state="REQUIRES_ACTION"]:hover {
    border-color: #B45309 !important;
}

/* ── STATE INDICATOR CHIPS (active overrides) ───────────── */
.cp-chip-state-active .cp-state-dot {
    background: rgba(255, 255, 255, 0.75) !important;
}
.cp-chip-state-active .cp-state-badge {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
}


/* ── COLOR SWATCHES ──────────────────────────────────────── */
.cp-color-swatch-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}
.cp-color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: outline 0.15s, transform 0.12s;
}
.cp-color-swatch input[type="radio"] {
    display: none;
}
.cp-color-swatch:has(input:checked) {
    outline: 3px solid var(--on-surface);
    outline-offset: 3px;
    transform: scale(1.15);
}
.cp-color-swatch:hover {
    transform: scale(1.12);
}

/* ── Task document preview spinner ──────────────────────────── */
@keyframes tdSpinner {
    to { transform: rotate(360deg); }
}

/* ── Active stage pulse ─────────────────────────────────────── */
@keyframes cpd-stage-pulse {
    0%   { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--primary); }
    50%  { box-shadow: 0 0 0 3px var(--surface), 0 0 0 9px rgba(26,115,232,0.25); }
    100% { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--primary); }
}
.cpd-stage-active-circle {
    animation: cpd-stage-pulse 2s ease-in-out infinite;
}

/* ── Permission row groups (required / others) ──────────────── */
.cpd-perm-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--outline-variant);
}
.cpd-perm-group .cpd-perm-row:last-child {
    border-bottom: none;
}
.cpd-perm-group.is-empty {
    display: none !important;
}

/* ── CUSTOMER MOBILE BOTTOM NAV ─────────────────────────────── */
.customer-mobile-nav {
    display: none;
}

@media (max-width: 800px) {
    .customer-mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--surface);
        border-top: 1px solid var(--outline);
        z-index: 1000;
        box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    }

    .customer-mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: var(--on-surface-variant);
        text-decoration: none;
        font-family: 'Inter', sans-serif;
        font-size: 10px;
        font-weight: 500;
        transition: color 0.2s ease, background-color 0.2s ease;
        position: relative;
    }

    .customer-mobile-nav-item .material-symbols-outlined {
        font-size: 22px;
        line-height: 1;
    }

    .customer-mobile-nav-item:hover {
        color: var(--on-surface);
        background: var(--surface-container);
        text-decoration: none;
    }

    .customer-mobile-nav-item.active {
        color: var(--primary);
    }

    .customer-mobile-nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 20%;
        right: 20%;
        height: 3px;
        background: var(--primary);
        border-radius: 0 0 var(--radius-xs) var(--radius-xs);
    }

    /* Padding inferior para que el contenido no quede tapado por el nav */
    .b2b-content-area {
        padding-bottom: 60px;
    }
}

/* --- Help Drawer (lateral FAQ panel) --- */
.cb-help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.cb-help-overlay.cb-help-open {
    opacity: 1;
    visibility: visible;
}

.cb-help-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 460px;
    max-width: 100vw;
    background: var(--surface, #fff);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
    border-left: 1px solid var(--outline, #dadce0);
}
.cb-help-drawer.cb-help-open {
    transform: translateX(0);
}

.cb-help-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--outline, #dadce0);
    background: var(--surface, #fff);
    flex-shrink: 0;
}

.cb-help-drawer-title {
    font-family: 'Google Sans', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: var(--on-surface);
    margin: 0;
}

.cb-help-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius-full, 9999px);
    color: var(--on-surface-variant);
    cursor: pointer;
    transition: background 0.2s ease;
}
.cb-help-drawer-close:hover {
    background: var(--surface-container, #f1f3f4);
}

.cb-help-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.cb-help-drawer-footer {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-top: 1px solid var(--outline, #dadce0);
    flex-shrink: 0;
}

@media (max-width: 500px) {
    .cb-help-drawer {
        width: 100vw;
    }
}

[data-theme="dark"] .cb-help-drawer {
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
}

/* --- Tabs (Bootstrap nav-tabs) en tema claro --- */
.nav-tabs {
    border-bottom: 1px solid var(--outline);
}

.nav-tabs .nav-item {
    margin-right: 4px;
}

.nav-tabs .nav-link,
.nav-tabs li.nav-item > a.nav-link {
    color: var(--on-surface) !important;
    background-color: transparent !important;
    border: 1px solid transparent !important;
    border-top-left-radius: var(--radius-xs);
    border-top-right-radius: var(--radius-xs);
    padding: 10px 16px !important;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    opacity: 1 !important;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.nav-tabs .nav-link:hover,
.nav-tabs li.nav-item > a.nav-link:hover {
    color: var(--primary) !important;
    background-color: var(--surface-container) !important;
    border-color: transparent !important;
}

.nav-tabs .nav-link.active,
.nav-tabs li.nav-item > a.nav-link.active {
    color: var(--primary) !important;
    background-color: var(--primary-surface) !important;
    border-color: transparent !important;
    border-bottom: 2px solid var(--primary) !important;
}

/* ────────────────────────────────────────────────────────────
   Close-procedure modal: progress bar + success animation
   ──────────────────────────────────────────────────────────── */

.cpd-close-progress-icon {
    animation: cpd-close-icon-pulse 1.4s ease-in-out infinite;
}

@keyframes cpd-close-icon-pulse {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50%      { transform: scale(1.08); opacity: 1; }
}

.cpd-close-progress-track {
    width: 100%;
    height: 8px;
    background: var(--surface-container);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.cpd-close-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--info) 100%);
    border-radius: var(--radius-full);
    transition: width 0.35s ease;
    position: relative;
}

.cpd-close-progress-fill.cpd-close-progress-active::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.45) 50%, transparent 100%);
    animation: cpd-close-progress-shimmer 1.1s linear infinite;
}

@keyframes cpd-close-progress-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.cpd-close-success-burst {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--success-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cpd-close-success-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.cpd-close-success-burst::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--success);
    opacity: 0;
    animation: cpd-close-success-ring 1s ease-out 0.25s forwards;
}

@keyframes cpd-close-success-pop {
    0%   { transform: scale(0.4); opacity: 0; }
    60%  { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes cpd-close-success-ring {
    0%   { transform: scale(0.85); opacity: 0.7; }
    100% { transform: scale(1.25); opacity: 0; }
}

.cpd-close-success-svg {
    width: 80px;
    height: 80px;
}

.cpd-close-success-circle {
    stroke: var(--success);
    stroke-width: 4;
    stroke-dasharray: 220;
    stroke-dashoffset: 220;
    animation: cpd-close-success-draw 0.55s ease-out 0.1s forwards;
}

.cpd-close-success-check {
    stroke: var(--success);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 70;
    stroke-dashoffset: 70;
    animation: cpd-close-success-draw 0.4s ease-out 0.55s forwards;
}

@keyframes cpd-close-success-draw {
    to { stroke-dashoffset: 0; }
}

/* ────────────────────────────────────────────────────────────
   Closed procedure: banner + read-only state
   ──────────────────────────────────────────────────────────── */

.cpd-readonly-banner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--error-surface);
    border: 1px solid #fecaca;
    border-radius: var(--radius-xs);
    max-width: 100%;
    min-width: 0;
}

.cpd-readonly-banner-icon {
    font-size: 18px;
    color: var(--error);
    flex-shrink: 0;
}

.cpd-readonly-banner-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.cpd-readonly-banner-title {
    font-family: 'Google Sans', 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--error);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cpd-readonly-banner-subtitle {
    font-size: 11px;
    color: var(--on-surface-variant);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 1200px) {
    .cb-card-header .cpd-readonly-banner-subtitle { display: none; }
}

/* Lock interactions inside the read-only operation view.
   The Cerrar Trámite button is allow-listed so the reopen flow can still run. */
#cpd-view-operation.is-readonly .cpd-step-check,
#cpd-view-operation.is-readonly .cpd-step-permit-required-check,
#cpd-view-operation.is-readonly .cpd-step-permit-started-check,
#cpd-view-operation.is-readonly .cpd-step-permit-ended-check,
#cpd-view-operation.is-readonly .cpd-step-upload-btn,
#cpd-view-operation.is-readonly .cpd-step-delete-btn,
#cpd-view-operation.is-readonly .cpd-step-document-delete-btn,
#cpd-view-operation.is-readonly .cpd-doc-delete-btn,
#cpd-view-operation.is-readonly .cpd-edit-document-btn,
#cpd-view-operation.is-readonly .cpd-delete-document-btn,
#cpd-view-operation.is-readonly #cpd-add-document-btn,
#cpd-view-operation.is-readonly .cpd-perm-delete-btn,
#cpd-view-operation.is-readonly .cpd-perm-required-check,
#cpd-view-operation.is-readonly .cpd-perm-start-btn,
#cpd-view-operation.is-readonly .cpd-perm-end-btn,
#cpd-view-operation.is-readonly .cpd-field-edit-btn,
#cpd-view-operation.is-readonly #cpd-advance-stage-btn,
#cpd-view-operation.is-readonly #cpd-force-advance-confirm-btn,
#cpd-view-operation.is-readonly #cpd-steps-add-permission-btn,
#cpd-view-operation.is-readonly #cpd-steps-mark-all-btn,
#cpd-view-operation.is-readonly [data-target="#cpd-force-advance-confirm-panel"],
#cpd-view-operation.is-readonly .cpd-permission-add-btn,
#cpd-view-operation.is-readonly .cpd-doc-upload-btn,
#cpd-view-operation.is-readonly .cpd-note-add-btn {
    pointer-events: none !important;
    opacity: 0.45 !important;
    cursor: not-allowed !important;
    filter: grayscale(0.4);
}

#cpd-view-operation.is-readonly input[type="checkbox"]:not(.cpd-readonly-allow),
#cpd-view-operation.is-readonly input[type="text"]:not(.cpd-readonly-allow),
#cpd-view-operation.is-readonly input[type="number"]:not(.cpd-readonly-allow),
#cpd-view-operation.is-readonly input[type="file"],
#cpd-view-operation.is-readonly textarea:not(.cpd-readonly-allow),
#cpd-view-operation.is-readonly select:not(.cpd-readonly-allow) {
    pointer-events: none !important;
    background-color: var(--surface-dim) !important;
    cursor: not-allowed !important;
}

/* ============================================================
   Liquidation batch panel — processing & minimize animations
   ============================================================ */

/* Smooth resize/reposition of the floating panel card */
.liquidationBatchCard {
    transition: width 0.25s ease, box-shadow 0.25s ease;
    will-change: transform, opacity;
}

/* One-shot animation when minimizing to the corner (card has transform:none) */
.liquidationBatchCard.liq-anim-minimize {
    animation: liqPanelMinimize 0.28s ease;
}

/* One-shot animation when restoring to the center (card stays centered via translate) */
.liquidationBatchCard.liq-anim-restore {
    animation: liqPanelRestore 0.28s ease;
}

@keyframes liqPanelMinimize {
    0%   { transform: scale(1);    opacity: 0.7; }
    55%  { transform: scale(0.92); opacity: 0.9; }
    100% { transform: scale(1);    opacity: 1; }
}

@keyframes liqPanelRestore {
    0%   { transform: translate(-50%, -50%) scale(0.9);  opacity: 0.5; }
    100% { transform: translate(-50%, -50%) scale(1);    opacity: 1; }
}

/* Processing chip — soft pulse while OCR runs on that item */
.liq-chip-processing {
    animation: liqChipPulse 1.1s ease-in-out infinite;
}

@keyframes liqChipPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}

/* Processed chip — quick pop-in when an item completes */
.liq-chip-pop {
    animation: liqChipPop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes liqChipPop {
    0%   { transform: scale(0.6); opacity: 0; }
    60%  { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Row flash when an item finishes (success / error tint) */
.liquidationBatchTbody tr.liq-row-ok {
    animation: liqRowFlashOk 0.9s ease both;
}

.liquidationBatchTbody tr.liq-row-error {
    animation: liqRowFlashError 0.9s ease both;
}

@keyframes liqRowFlashOk {
    0%   { background-color: var(--success-surface); }
    100% { background-color: transparent; }
}

@keyframes liqRowFlashError {
    0%   { background-color: var(--error-surface); }
    100% { background-color: transparent; }
}


/* ─────────────────────────────────────────────────────────────────────────
   Sage export panel (minimizable) — used by the accounting invoice detail
   ───────────────────────────────────────────────────────────────────────── */
.cb-sage-export-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius-md);
    box-shadow: var(--elevation-2);
    z-index: 1080;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    animation: cbSageSlideUp 0.25s ease;
}
@keyframes cbSageSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

.cb-sage-export-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    background: var(--surface-dim);
    border-bottom: 1px solid var(--outline);
}
.cb-sage-export-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--on-surface);
}
.cb-sage-export-title .material-symbols-outlined {
    font-size: 20px;
    color: var(--primary);
}
.cb-sage-export-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}
.cb-sage-export-actions button {
    border: none;
    background: transparent;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--on-surface-variant);
    transition: background 0.2s ease;
}
.cb-sage-export-actions button:hover {
    background: var(--surface-container);
}
.cb-sage-export-actions .material-symbols-outlined {
    font-size: 18px;
}

.cb-sage-export-body {
    padding: 14px;
    max-height: 60vh;
    overflow-y: auto;
}

/* Minimized state — only the header stays visible, docked to the corner */
.cb-sage-export-panel--min {
    width: 300px;
}
.cb-sage-export-panel--min .cb-sage-export-body {
    display: none;
}
.cb-sage-export-panel--min .cb-sage-export-header {
    cursor: pointer;
}

/* Status banner */
.cb-sage-export-status {
    display: flex;
    gap: 10px;
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}
.cb-sage-export-status:empty {
    display: none;
}
.cb-sage-export-status-icon {
    font-size: 22px;
    flex-shrink: 0;
}
.cb-sage-export-status-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}
.cb-sage-export-status-msg {
    font-size: 12.5px;
    line-height: 1.45;
}
.cb-sage-export-status--success {
    background: var(--success-surface);
    color: var(--success);
}
.cb-sage-export-status--success .cb-sage-export-status-icon { color: var(--success); }
.cb-sage-export-status--info {
    background: var(--info-surface);
    color: var(--primary-dark);
}
.cb-sage-export-status--info .cb-sage-export-status-icon { color: var(--info); }
.cb-sage-export-status--warning {
    background: var(--warning-surface);
    color: #b45309;
}
.cb-sage-export-status--warning .cb-sage-export-status-icon { color: #b45309; }
.cb-sage-export-status--error {
    background: var(--error-surface);
    color: var(--error);
}
.cb-sage-export-status--error .cb-sage-export-status-icon { color: var(--error); }

/* Steps list */
.cb-sage-export-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cb-sage-export-step {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: cbSageStepIn 0.25s ease both;
}
@keyframes cbSageStepIn {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: none; }
}
.cb-sage-export-step-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--on-surface-variant);
}
.cb-sage-export-step--ok .cb-sage-export-step-icon    { color: var(--success); }
.cb-sage-export-step--error .cb-sage-export-step-icon { color: var(--error); }
.cb-sage-export-step--info .cb-sage-export-step-icon  { color: var(--info); }
.cb-sage-export-step-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--on-surface);
}
.cb-sage-export-step-detail {
    font-size: 12px;
    color: var(--on-surface-variant);
    margin-top: 1px;
    line-height: 1.4;
    word-break: break-word;
}

/* Spinner used by the in-progress banner icon */
.cb-sage-spin {
    animation: cbSageSpin 1s linear infinite;
}
@keyframes cbSageSpin {
    to { transform: rotate(360deg); }
}
