/* ==========================================================================
   Módulo Cursor (Administrar sistema → Sistema → Configuración → Cursor)
   Prefijo pca-. Prioridad: celular (max-width: 767px) sin desbordes.
   ========================================================================== */

/* Cuerpo del modal cuando la subpestaña Cursor está activa: el chat llena el alto */
.mpt-body.mpt-body--cursor {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 0 4px;
}
/* La solapa Cursor no debe mostrar la sección que estaba abierta antes
   (sucursales, puestos, cronograma). Esas vistas siguen montadas para
   no perder el estado, pero no se ven mientras Cursor está activo. */
.mpt-body.mpt-body--cursor > *:not(.mpt-config-pane--cursor) {
    display: none !important;
}
.mpt-body--cursor .mpt-config-root {
    flex: 1 1 auto;
    min-height: 0;
}
.mpt-body--cursor .mpt-config-subtabs {
    padding: 4px 10px 6px;
}
.mpt-config-pane--cursor {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/* Fila de subpestañas con scroll horizontal suave: la sexta (Cursor) nunca rompe la fila */
.mpt-head-tabs {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}
.mpt-head-tabs::-webkit-scrollbar { display: none; }
.mpt-head-tab { flex: 0 0 auto; }
.mpt-head-tab:focus,
.mpt-head-tab:focus-visible,
.mpt-head-tab:active {
    outline: none !important;
}
.mpt-head-tab-active:focus,
.mpt-head-tab-active:focus-visible,
.mpt-head-tab-active:active {
    outline: none !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* Subpestañas de Configuración: se acomodan en varias filas */
.mpt-config-subtabs {
    flex-wrap: wrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}
.mpt-config-subtabs::-webkit-scrollbar { display: none; }
.mpt-config-subtab { flex: 0 0 auto; }

.pca-root,
.pca-root *,
.pca-root *::before,
.pca-root *::after,
.pca-ov,
.pca-ov *,
.pca-pop-overlay,
.pca-pop-overlay * {
    box-sizing: border-box;
}

.pca-root {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    padding: 0 10px 6px;
    overflow: hidden;
    color: #1f2937;
    font-size: 14px;
}

/* ---------- Botones base ---------- */
.pca-root button,
.pca-ov button,
.pca-pop-overlay button {
    font-family: inherit;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}
.pca-root button:focus,
.pca-root button:focus-visible,
.pca-root button:active,
.pca-ov button:focus,
.pca-ov button:focus-visible,
.pca-ov button:active,
.pca-pop-overlay button:focus,
.pca-pop-overlay button:focus-visible,
.pca-pop-overlay button:active {
    outline: none !important;
    box-shadow: none;
}
.pca-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    flex: 0 0 auto;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    background: linear-gradient(135deg, #5B21B6 0%, #7c3aed 100%);
    cursor: pointer;
    white-space: nowrap;
}
.pca-btn:hover { background: linear-gradient(135deg, #4c1d95 0%, #6d28d9 100%); }
.pca-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pca-btn .material-icons { font-size: 17px; }
.pca-btn--soft { background: #f5f3ff; color: #5B21B6; }
.pca-btn--soft:hover { background: #ede9fe; }
.pca-btn--danger { background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%); }
.pca-actions-end {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}
.pca-icon-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #5B21B6;
    cursor: pointer;
}
.pca-icon-btn:hover { background: #f5f3ff; }
.pca-icon-btn .material-icons { font-size: 20px; }
.pca-spin {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2.5px solid #ddd6fe;
    border-top-color: #7c3aed;
    animation: pca-rot 0.8s linear infinite;
    flex: 0 0 auto;
}
.pca-spin--lg { width: 30px; height: 30px; border-width: 3px; }
@keyframes pca-rot { to { transform: rotate(360deg); } }

.pca-center {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    text-align: center;
    color: #6b7280;
}

/* ---------- Estado del módulo: cuadro centrado, también en el celular ---------- */
.pca-ov--float { align-items: center; }
.pca-panel--float { max-width: 440px; }
.pca-panel--float .pca-panel-foot { justify-content: flex-end; }
.pca-checks { list-style: none; margin: 0 0 8px; padding: 0; }
.pca-checks li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}
.pca-checks li .material-icons { font-size: 18px; flex: 0 0 auto; }
.pca-checks li.ok .material-icons { color: #059669; }
.pca-checks li.bad .material-icons { color: #dc2626; }
.pca-checks li.info .material-icons { color: #7c3aed; }
.pca-checks li small { display: block; color: #6b7280; }
.pca-steps-result { margin: 0 0 8px; padding-left: 18px; font-size: 0.8rem; color: #4b5563; }
.pca-steps-result li.bad { color: #b91c1c; }
.pca-steps-result small { display: block; overflow-wrap: anywhere; }

/* ---------- Estructura principal ---------- */
.pca-main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 6px;
}
.pca-split-row {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
}
.pca-main--drag,
.pca-main--drag .pca-split { cursor: col-resize; }
.pca-main--drag .pca-preview-frame { pointer-events: none; }
.pca-preview {
    flex: 0 0 46%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1.5px solid #ede9fe;
    border-radius: 12px;
    overflow: hidden;
}
.pca-preview-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px;
    background: #faf8ff;
    border-bottom: 1px solid #ede9fe;
}
.pca-preview-path {
    flex: 1 1 auto;
    min-width: 0;
    height: 32px;
    border: 1.5px solid #ddd6fe;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 0.82rem;
    background: #fff;
}
.pca-preview-path:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.pca-preview-frame {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    border: 0;
    background: #fff;
}
.pca-split {
    flex: 0 0 18px;
    width: 18px;
    align-self: stretch;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #5B21B6;
    cursor: col-resize;
    touch-action: none;
    outline: none;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
}
.pca-split::before {
    content: '';
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    border-radius: 2px;
    background: #ddd6fe;
}
.pca-split svg {
    position: relative;
    width: 22px;
    height: 22px;
    display: block;
    fill: #5B21B6;
    background: #fff;
    border-radius: 999px;
    padding: 3px;
    box-shadow: 0 1px 4px rgba(91, 33, 182, 0.28);
}
.pca-split:hover svg,
.pca-split.on svg { fill: #fff; background: #5B21B6; }
.pca-split:hover::before,
.pca-split.on::before { background: #c4b5fd; }
.pca-split:focus,
.pca-split:focus-visible,
.pca-split:active { outline: none; box-shadow: none; }
.pca-chat {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1.5px solid #ede9fe;
    border-radius: 12px;
    overflow: hidden;
}

/* ---------- Encabezado del chat ---------- */
.pca-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border-bottom: 1px solid #f3f0ff;
    min-width: 0;
}
.pca-session-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    border: none;
    border-radius: 8px;
    padding: 0 8px;
    background: transparent;
    color: #5B21B6;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
}
.pca-session-btn:hover { background: #f5f3ff; }
.pca-session-btn .material-icons { font-size: 19px; flex: 0 0 auto; }
.pca-session-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.pca-status {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 24px;
    padding: 0 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
    background: #f3f4f6;
    color: #6b7280;
}
.pca-status .pca-spin { width: 12px; height: 12px; border-width: 2px; }
.pca-status--running { background: #ede9fe; color: #5B21B6; }
.pca-status--completed { background: #d1fae5; color: #047857; }
.pca-status--failed { background: #fee2e2; color: #b91c1c; }
.pca-publish {
    display: flex;
    flex: 0 0 auto;
    align-self: stretch;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin: -12px -10px 0;
    padding: 8px 12px;
    background: #f5f3ff;
    color: #5B21B6;
    font-size: 12.5px;
    line-height: 1.35;
}
.pca-publish strong { font-weight: 700; }
.pca-publish span { flex: 1 1 220px; text-align: right; color: #6b7280; }
.pca-publish .pca-btn { width: auto; flex: 0 0 auto; }
.pca-publish--in_production { background: #ecfdf5; color: #047857; }
.pca-publish--repo_only, .pca-publish--in_repo { background: #f5f3ff; color: #5B21B6; }
.pca-publish--failed, .pca-publish--needs_review { background: #fff7ed; color: #c2410c; }
.pca-cost {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 8px;
    border-radius: 12px;
    background: #faf8ff;
    color: #5B21B6;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}
.pca-cost-bar {
    width: 38px;
    height: 5px;
    border-radius: 3px;
    background: #ede9fe;
    overflow: hidden;
}
.pca-cost-bar i {
    display: block;
    height: 100%;
    background: linear-gradient(135deg, #5B21B6, #7c3aed);
}
.pca-cost--warn { background: #fef3c7; color: #b45309; }
.pca-cost--warn .pca-cost-bar i { background: #f59e0b; }
.pca-cost--full { background: #fee2e2; color: #b91c1c; }
.pca-cost--full .pca-cost-bar i { background: #dc2626; }

/* ---------- Mensajes ---------- */
.pca-msgs {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
    background: #fdfcff;
}
.pca-row { display: flex; min-width: 0; }
.pca-row--user { justify-content: flex-end; }
.pca-row--assistant,
.pca-row--system { justify-content: flex-start; }
.pca-msg {
    max-width: 92%;
    min-width: 0;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.pca-msg--user {
    background: linear-gradient(135deg, #5B21B6 0%, #7c3aed 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.pca-msg--assistant,
.pca-msg--system {
    background: #f5f3ff;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}
.pca-md pre {
    max-width: 100%;
    margin: 6px 0;
    padding: 8px 10px;
    overflow-x: auto;
    border-radius: 8px;
    background: #1e1b4b;
    color: #e9e5ff;
    font-size: 0.76rem;
    line-height: 1.4;
}
.pca-md pre code { background: transparent; color: inherit; padding: 0; white-space: pre; }
.pca-md code {
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(91, 33, 182, 0.12);
    font-size: 0.82em;
    word-break: break-all;
}
.pca-msg--user .pca-md code { background: rgba(255, 255, 255, 0.2); }
.pca-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.pca-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    background: #ede9fe;
    display: block;
}
.pca-meta { margin-top: 4px; font-size: 0.7rem; color: #8b5cf6; }
.pca-changed { margin-top: 8px; display: flex; justify-content: flex-end; }
.pca-live {
    align-self: flex-start;
    max-width: 92%;
    min-width: 0;
    padding: 9px 12px;
    border-radius: 12px;
    background: #f5f3ff;
    color: #5B21B6;
    font-size: 0.82rem;
}
.pca-live-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.pca-live-steps { margin: 6px 0 0; padding: 0; list-style: none; font-size: 0.74rem; color: #6b7280; }
.pca-live-steps li {
    display: flex;
    gap: 6px;
    align-items: baseline;
    min-width: 0;
}
.pca-live-steps b { flex: 0 0 auto; color: #5B21B6; font-weight: 600; }
.pca-live-steps span {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.pca-done {
    align-self: stretch;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 12px;
    background: #ecfdf5;
    color: #047857;
    font-size: 0.82rem;
    font-weight: 600;
}
.pca-done .pca-actions-end { margin-left: auto; }
.pca-error-box {
    align-self: stretch;
    padding: 9px 12px;
    border-radius: 12px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}
.pca-empty {
    margin: auto;
    max-width: 320px;
    text-align: center;
    color: #6b7280;
    font-size: 0.86rem;
}
.pca-empty-ic {
    width: 54px;
    height: 54px;
    margin: 0 auto 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ede9fe, #ddd6fe);
    color: #5B21B6;
}
.pca-empty-ic .material-icons { font-size: 28px; }

/* ---------- Compositor ---------- */
.pca-composer {
    flex: 0 0 auto;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #ede9fe;
    background: #fff;
    min-width: 0;
}
.pca-attach-row,
.pca-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.pca-attach-row::-webkit-scrollbar,
.pca-chips::-webkit-scrollbar { display: none; }
.pca-attach-row { padding-bottom: 6px; }
.pca-attach {
    position: relative;
    flex: 0 0 auto;
    width: 54px;
    height: 54px;
}
.pca-attach img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}
.pca-attach button {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #5B21B6;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.pca-attach button .material-icons { font-size: 14px; }
.pca-input {
    display: block;
    width: 100%;
    min-height: 44px;
    max-height: 140px;
    resize: none;
    border: 1.5px solid #ddd6fe;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 16px; /* evita el zoom automático en iOS */
    line-height: 1.35;
    background: #fff;
    color: #1f2937;
}
.pca-input:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.pca-controls {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 4px;
    margin-top: 6px;
    min-width: 0;
}
.pca-chips {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 4px;
}
.pca-chips > * { flex: 0 0 auto; }
.pca-picker { display: inline-flex; }
.pca-composer-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 4px;
}
.pca-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 28px;
    max-width: 108px;
    padding: 0 6px;
    border: 1.5px solid #ede9fe;
    border-radius: 8px;
    background: #fff;
    color: #5B21B6;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.pca-chip:hover { background: #faf8ff; }
.pca-chip:disabled { opacity: 0.55; cursor: not-allowed; }
.pca-chip .material-icons { font-size: 15px; flex: 0 0 auto; }
.pca-chip-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pca-chip--set { background: #f5f3ff; border-color: #c4b5fd; }
.pca-chip--open { box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.28); }
.pca-chip--icon { padding: 0; width: 28px; justify-content: center; }
.pca-tool,
.pca-send,
.pca-stop {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.pca-tool {
    border: 1.5px solid #ede9fe;
    background: #fff;
    color: #5B21B6;
}
.pca-tool:hover { background: #faf8ff; }
.pca-tool--on { background: #f5f3ff; border-color: #c4b5fd; }
.pca-tool:focus,
.pca-tool:focus-visible { outline: none; box-shadow: none; }
.pca-tool:disabled { opacity: 0.55; cursor: not-allowed; }
.pca-tool .material-icons,
.pca-send .material-icons,
.pca-stop .material-icons { font-size: 16px; }
.pca-chip-badge {
    flex: 0 0 auto;
    font-size: 0.66rem;
    padding: 1px 5px;
    border-radius: 8px;
    background: #fee2e2;
    color: #b91c1c;
}
.pca-chip-caret { color: #a78bfa; }
.pca-send {
    border: none;
    color: #fff;
    background: linear-gradient(135deg, #5B21B6 0%, #7c3aed 100%);
}
.pca-send:disabled { opacity: 0.45; cursor: not-allowed; }
.pca-stop { border: none; color: #fff; background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%); }

/* ---------- Popover de pastillas (se teleporta al body) ---------- */
.pca-pop-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--wf-child-z, 100520);
    background: rgba(15, 6, 38, 0.35);
}
.pca-pop {
    position: fixed;
    display: flex;
    flex-direction: column;
    width: 320px;
    max-width: calc(100vw - 16px);
    max-height: 60vh;
    padding: 10px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.5);
}
.pca-pop--sheet {
    left: 0;
    right: 0;
    bottom: calc(var(--wf-taskbar-height, 0px) + var(--wf-bottom-reserve, 0px));
    width: 100%;
    max-width: none;
    max-height: calc(70vh - var(--wf-taskbar-height, 0px) - var(--wf-bottom-reserve, 0px));
    border-radius: 16px 16px 0 0;
}
.pca-pop-title {
    flex: 0 0 auto;
    padding: 2px 4px 8px;
    font-weight: 700;
    color: #5B21B6;
}
.pca-pop-search {
    flex: 0 0 auto;
    width: 100%;
    height: 36px;
    margin-bottom: 8px;
    padding: 0 10px;
    border: 1.5px solid #ddd6fe;
    border-radius: 8px;
    font-size: 16px;
}
.pca-pop-search:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.pca-pop-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pca-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    border: none;
    border-radius: 16px;
    padding: 8px 12px;
    background: #f5f3ff;
    color: #6d28d9;
    text-align: left;
    cursor: pointer;
}
.pca-pill:hover,
.pca-pill--on {
    background: linear-gradient(135deg, #5B21B6 0%, #7c3aed 100%);
    color: #fff;
}
.pca-pill:disabled { opacity: 0.5; cursor: not-allowed; }
.pca-pill--danger { color: #b91c1c; background: #fef2f2; }
.pca-pill .material-icons { font-size: 19px; flex: 0 0 auto; }
.pca-pill-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.pca-pill-label { font-weight: 600; font-size: 0.85rem; overflow-wrap: anywhere; }
.pca-pill-main small { font-size: 0.72rem; opacity: 0.85; overflow-wrap: anywhere; }
.pca-pill-badge {
    flex: 0 0 auto;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 0.68rem;
    font-weight: 700;
    background: #ede9fe;
    color: #5B21B6;
}
.pca-pill-badge--alto { background: #fee2e2; color: #b91c1c; }
.pca-pill-badge--medio { background: #fef3c7; color: #b45309; }
.pca-pill-badge--bajo { background: #d1fae5; color: #047857; }

/* ---------- Paneles superpuestos (diff, backups, historial) ---------- */
.pca-ov {
    position: fixed;
    inset: 0;
    z-index: var(--wf-child-z, 100520);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 16px calc(16px + var(--wf-taskbar-height, 0px) + var(--wf-bottom-reserve, 0px));
    background: rgba(15, 6, 38, 0.6);
}
.pca-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 560px;
    max-height: 100%;
    min-height: 0;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}
.pca-panel--wide { max-width: 1100px; height: 100%; }
.pca-panel-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 10px 10px 14px;
    background: linear-gradient(135deg, #5B21B6 0%, #7c3aed 100%);
    color: #fff;
}
.pca-panel-head strong {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.95rem;
}
.pca-panel-head .pca-icon-btn { color: #fff; }
.pca-panel-head .pca-icon-btn:hover { background: rgba(255, 255, 255, 0.18); }
.pca-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
    background: #fdfcff;
}
.pca-panel-foot {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #ede9fe;
    background: #fff;
}
.pca-sub { font-size: 0.75rem; color: #6b7280; }
.pca-panel-head .pca-sub { color: rgba(255, 255, 255, 0.82); }
.pca-warns {
    flex: 0 0 auto;
    padding: 8px 12px;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.78rem;
    max-height: 28%;
    overflow-y: auto;
}
.pca-warns div { display: flex; gap: 6px; align-items: flex-start; padding: 2px 0; overflow-wrap: anywhere; }
.pca-warns .material-icons { font-size: 17px; flex: 0 0 auto; }
.pca-diff-body { flex: 1 1 auto; min-height: 0; display: flex; }
.pca-files {
    flex: 0 0 300px;
    min-width: 0;
    overflow-y: auto;
    padding: 6px;
    border-right: 1px solid #ede9fe;
    background: #faf8ff;
}
.pca-file-all {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 8px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #5B21B6;
}
.pca-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    min-width: 0;
}
.pca-file:hover { background: #f5f3ff; }
.pca-file--cur { background: #ede9fe; }
.pca-file--blocked { opacity: 0.55; }
.pca-file-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.pca-file-name {
    font-size: 0.8rem;
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.pca-file-dir {
    font-size: 0.68rem;
    color: #8b8fa3;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.pca-file-num { flex: 0 0 auto; font-size: 0.7rem; font-style: normal; white-space: nowrap; }
.pca-file-num em { color: #047857; font-style: normal; }
.pca-file-num b { color: #b91c1c; }
.pca-st {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 800;
    color: #fff;
}
.pca-st--M { background: #7c3aed; }
.pca-st--A { background: #059669; }
.pca-st--D { background: #dc2626; }
.pca-hunks { flex: 1 1 auto; min-width: 0; min-height: 0; overflow: auto; background: #fff; }
.pca-hunk-head {
    position: sticky;
    left: 0;
    padding: 4px 10px;
    background: #f5f3ff;
    color: #6d28d9;
    font: 0.72rem/1.4 Consolas, Menlo, monospace;
}
.pca-ln {
    white-space: pre;
    min-width: max-content;
    padding: 0 10px;
    font: 0.74rem/1.45 Consolas, Menlo, monospace;
}
.pca-ln--add { background: #ecfdf5; color: #065f46; }
.pca-ln--del { background: #fef2f2; color: #991b1b; }
.pca-note { padding: 12px; font-size: 0.82rem; color: #6b7280; }

/* Lista de historial y backups */
.pca-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 6px;
    border: 1.5px solid #ede9fe;
    border-radius: 10px;
    background: #fff;
    text-align: left;
    cursor: pointer;
    min-width: 0;
}
.pca-list-item:hover { background: #faf8ff; }
.pca-list-item--on { border-color: #7c3aed; background: #f5f3ff; }
.pca-list-main { flex: 1 1 auto; min-width: 0; }
.pca-list-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.pca-list-title {
    flex: 1 1 auto;
    font-weight: 600;
    font-size: 0.85rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.pca-rename {
    width: 28px;
    height: 28px;
    margin-left: auto;
    color: #5B21B6;
}
.pca-rename:focus,
.pca-rename:focus-visible,
.pca-rename:active {
    outline: none;
    box-shadow: none;
}
.pca-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 6px 0 4px;
    border: 1.5px solid #ede9fe;
    border-radius: 8px;
    background: #fff;
    color: #5B21B6;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}
.pca-switch:focus,
.pca-switch:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.28);
}
.pca-switch-track {
    position: relative;
    width: 28px;
    height: 16px;
    border-radius: 8px;
    background: #ddd6fe;
    flex: 0 0 auto;
}
.pca-switch-track i {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
}
.pca-switch--on { background: #f5f3ff; border-color: #c4b5fd; }
.pca-switch--on .pca-switch-track { background: #7c3aed; }
.pca-switch--on .pca-switch-track i { left: 14px; }
.pca-list-sub { font-size: 0.72rem; color: #6b7280; overflow-wrap: anywhere; }
.pca-bk-files {
    margin: 4px 0 0;
    padding: 6px 8px;
    max-height: 140px;
    overflow: auto;
    border-radius: 8px;
    background: #faf8ff;
    font: 0.7rem/1.4 Consolas, Menlo, monospace;
    color: #4b5563;
}
.pca-bk-files div { white-space: nowrap; }
.pca-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: #d1d5db; }
.pca-dot--running { background: #7c3aed; }
.pca-dot--completed { background: #10b981; }
.pca-dot--failed { background: #ef4444; }

/* ==========================================================================
   Celular (≤ 767px): solo el chat, sin desbordes
   ========================================================================== */
@media (max-width: 767px) {
    .mpt-config-subtabs {
        flex-wrap: nowrap;
        white-space: nowrap;
        scrollbar-width: thin;
    }
    .pca-root { padding: 0 6px 4px; font-size: 14px; }
    .pca-main { margin-top: 4px; }
    .pca-chat { border-radius: 10px; }
    .pca-cost-bar { display: none; }
    .pca-msg { max-width: 94%; }
    .pca-chips { flex-wrap: nowrap; overflow-x: auto; }
    .pca-chip,
    .pca-switch,
    .pca-tool,
    .pca-send {
        opacity: 1;
        pointer-events: auto;
    }
    .pca-chip { max-width: 92px; }

    .pca-ov { padding: 0 0 calc(var(--wf-taskbar-height, 0px) + var(--wf-bottom-reserve, 0px)); align-items: flex-end; }
    .pca-ov.pca-ov--float {
        align-items: center;
        padding: 16px 16px calc(16px + var(--wf-taskbar-height, 0px) + var(--wf-bottom-reserve, 0px));
    }
    .pca-panel { max-width: none; border-radius: 16px 16px 0 0; }
    .pca-panel.pca-panel--float {
        max-width: 440px;
        border-radius: 14px;
    }
    .pca-panel--wide { height: 100%; border-radius: 0; }

    .pca-diff-body { flex-direction: column; }
    .pca-files {
        flex: 0 0 auto;
        max-height: 38%;
        border-right: none;
        border-bottom: 1px solid #ede9fe;
    }
    .pca-hunks { flex: 1 1 auto; }
    .pca-panel-foot { justify-content: flex-end; }
    .pca-panel-foot .pca-sub { flex: 1 1 100%; }
    .pca-panel-foot .pca-actions-end { width: 100%; }
}
@media (max-width: 380px) {
    .pca-cost { padding: 0 6px; }
    .pca-chip { max-width: 84px; padding: 0 5px; }
}

/* Recorte de pantalla: encima de la ventana, en cualquier ancho */
.pca-crop {
    position: fixed;
    inset: 0;
    z-index: var(--wf-child-z, 100520);
    cursor: crosshair;
    background: rgba(15, 6, 38, 0.35);
    touch-action: none;
    user-select: none;
    outline: none;
}
.pca-crop:focus,
.pca-crop:focus-visible { outline: none; box-shadow: none; }
.pca-crop-hint {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    margin: 0;
    padding: 8px 12px;
    border-radius: 10px;
    background: #fff;
    color: #5B21B6;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    pointer-events: none;
    box-shadow: 0 12px 32px rgba(15, 6, 38, 0.28);
}
.pca-crop-box {
    position: fixed;
    border: 2px solid #7c3aed;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7);
    pointer-events: none;
}
