/* ─────────────────────────────────────────────────────────────────────────────────────────────
   Acciones de API — Ajustes → Integraciones → APIs externas, editor de operación, historial y la
   tarjeta de la bandeja. Sólo tokens de base.css; botones, inputs, tablas e insignias son los
   compartidos de product-ui.css. El bloque responsivo va AL FINAL (una media query no añade
   especificidad: escrita a media altura, la deshace cualquier regla base posterior).
   ───────────────────────────────────────────────────────────────────────────────────────────── */

/* ── Piezas sueltas ──────────────────────────────────────────────────────────────────────── */
.apx-muted { color: var(--text-muted); font-size: .8rem; }
.apx-block { display: block; }
.apx-mono, .apx-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.apx-code { font-size: .75rem; color: var(--text-muted); background: var(--bg-subtle); border-radius: 6px; padding: .1rem .4rem; }
.apx-host { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; color: var(--text-muted); word-break: break-all; }
.apx-chip {
    display: inline-flex; align-items: center; gap: .25rem;
    font-size: .72rem; font-weight: 500; color: var(--text-muted);
    background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius-full);
    padding: .12rem .55rem; white-space: nowrap;
}
.apx-count {
    display: inline-flex; min-width: 1.4rem; justify-content: center; font-size: .7rem; font-weight: 600;
    background: var(--bg-subtle); color: var(--text-muted); border-radius: var(--radius-full); padding: .05rem .4rem;
}
.apx-hint-error { color: var(--danger) !important; }
.apx-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; flex: 0 0 32px;
    border: 1px solid transparent; border-radius: var(--radius); background: transparent;
    color: var(--text-muted); cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.apx-icon-btn:hover { background: var(--surface-hover); color: var(--primary); border-color: var(--border); }
.apx-icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.apx-sec-ic, .apx-pick-ic, .apx-head-ic { color: var(--primary); }

/* ── Tarjetas de conexión (panel de Integraciones) ─────────────────────────────────────────── */
.apx-conn-card { text-decoration: none; color: inherit; cursor: pointer; }
.apx-conn-card:hover { border-color: var(--primary-mid); }
.apx-conn-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.apx-conn-card .wc-card-top { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

/* ── Formularios en modal ─────────────────────────────────────────────────────────────────── */
.apx-form { display: flex; flex-direction: column; gap: 1rem; }
.apx-form-error { margin: 0; }
.apx-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem 1rem; }
.apx-field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.apx-field > label { font-size: .8rem; font-weight: 600; color: var(--text); }
.apx-field--wide { grid-column: 1 / -1; }
.apx-secret-saved { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.apx-subsection { display: flex; flex-direction: column; gap: .5rem; padding-top: .25rem; }
.apx-subsection-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.apx-subsection-head h4 { margin: 0; font-size: .85rem; font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; }

.apx-kv-list { display: flex; flex-direction: column; gap: .5rem; }
.apx-kv-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: .5rem; align-items: center; }
.apx-kv-list .apx-kv-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto; }
.apx-kv-row--3 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto; }
.apx-kv-saved { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; color: var(--success); }
.apx-kv-sensitive, .apx-inline-check { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; color: var(--text-muted); white-space: nowrap; }

.apx-toggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 1rem; margin-top: .75rem; }
.apx-toggle-row {
    display: flex; align-items: flex-start; gap: .75rem;
    padding: .75rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card);
}
.apx-toggle-row > span { display: flex; flex-direction: column; gap: .15rem; }
.apx-toggle-row strong { font-size: .85rem; color: var(--text); }
.apx-toggle-row small { font-size: .76rem; color: var(--text-muted); line-height: 1.4; }
.apx-toggle-row--compact { padding: .6rem .75rem; }

/* ── Plantillas ───────────────────────────────────────────────────────────────────────────── */
.apx-tpl-grid { display: grid; gap: .75rem; }
.apx-tpl-card {
    display: flex; align-items: center; gap: .9rem; width: 100%; text-align: left;
    padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-card);
    cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.apx-tpl-card:hover { border-color: var(--primary-mid); box-shadow: 0 6px 18px rgba(15, 23, 42, .06); }
.apx-tpl-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.apx-tpl-ic {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 44px; height: 44px;
    border-radius: var(--radius); background: var(--primary-light); color: var(--primary);
}
.apx-tpl-body { display: flex; flex-direction: column; gap: .3rem; flex: 1; min-width: 0; }
.apx-tpl-body strong { font-size: .95rem; color: var(--text); }
.apx-tpl-body > span { font-size: .8rem; color: var(--text-muted); line-height: 1.45; }
.apx-tpl-ops { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .15rem; }
.apx-tpl-go { color: var(--text-light); }
.apx-tpl-note { display: flex; align-items: flex-start; gap: .5rem; }

/* ── Página de conexión / editor ──────────────────────────────────────────────────────────── */
.apx-page { display: flex; flex-direction: column; gap: 1rem; max-width: 1240px; }
.apx-topbar { display: flex; }
.apx-topbar .btn-ghost { display: inline-flex; align-items: center; gap: .25rem; }
.apx-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.apx-head-ic {
    display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px;
    border-radius: var(--radius-lg); background: var(--primary-light);
}
.apx-head-id { flex: 1; min-width: 220px; }
.apx-head-id h1 { margin: 0; font-size: 1.35rem; color: var(--text); }
.apx-head-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .25rem; }
.apx-head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.apx-head-actions button { display: inline-flex; align-items: center; gap: .35rem; }
.apx-test-banner { display: flex; align-items: center; gap: .5rem; }

.apx-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); }
.apx-tabs button {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .6rem .9rem; border: none; background: transparent; cursor: pointer;
    font-size: .85rem; font-weight: 500; color: var(--text-muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.apx-tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.apx-tabs button:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 6px 6px 0 0; }

.apx-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.apx-section-head h3 { margin: 0 0 .2rem; font-size: 1rem; }
.apx-section-head .btn-primary { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }

.apx-table-wrap { width: 100%; overflow-x: auto; }
.apx-table td { vertical-align: middle; }
.apx-row { cursor: pointer; }
.apx-row:focus-visible td { box-shadow: inset 0 0 0 2px var(--primary-mid); }
.apx-row-off td { opacity: .55; }
.apx-row-actions { white-space: nowrap; text-align: right; }
.apx-op-link { color: var(--text); text-decoration: none; }
.apx-op-link:hover { color: var(--primary); }
.apx-cell-detail { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.apx-method {
    display: inline-flex; align-items: center; justify-content: center; min-width: 52px;
    font: 600 .7rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    padding: .3rem .45rem; border-radius: 6px; border: 1px solid var(--border);
    background: var(--bg-subtle); color: var(--text-muted); margin-right: .35rem;
}
.apx-method--get { color: var(--success); background: var(--success-light); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.apx-method--post { color: var(--primary); background: var(--primary-light); border-color: var(--primary-mid); }
.apx-method--put, .apx-method--patch { color: var(--warning); background: var(--warning-light); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.apx-method--delete { color: var(--danger); background: var(--danger-light); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }

.apx-toolbar { display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.apx-toolbar .lw-search { flex: 1 1 260px; max-width: 420px; }
.apx-status-filter { width: auto; min-width: 190px; }
.apx-pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .75rem; }
.apx-pager-btns { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--text-muted); }

/* ── Editor de operación ──────────────────────────────────────────────────────────────────── */
.apx-editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1rem; align-items: start; }
.apx-editor-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.apx-block-head { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: 1rem; }
.apx-block-head h3 { margin: 0 0 .15rem; font-size: 1rem; color: var(--text); }
.apx-block-head .settings-hint { margin: 0; }
.apx-step {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 28px; height: 28px;
    border-radius: var(--radius-full); background: var(--primary-light); color: var(--primary);
    font-size: .8rem; font-weight: 700;
}
.apx-step--ai { background: var(--ai-action-gradient, var(--primary)); color: var(--bg-card); }

.apx-method-picker { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .9rem; }
.apx-method-picker .apx-method { cursor: pointer; min-width: 64px; padding: .45rem .6rem; margin: 0; opacity: .6; }
.apx-method-picker .apx-method.on { opacity: 1; box-shadow: 0 0 0 2px currentColor inset; }
.apx-method-picker .apx-method:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.apx-url { display: flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; background: var(--bg-card); }
.apx-url:focus-within { border-color: var(--primary); box-shadow: var(--focus-ring); }
.apx-url-base {
    display: flex; align-items: center; padding: 0 .65rem; max-width: 45%;
    font: .78rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text-muted);
    background: var(--bg-subtle); border-right: 1px solid var(--border);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.apx-url .settings-input { border: none; border-radius: 0; box-shadow: none; flex: 1; min-width: 0; }
.apx-url .settings-input:focus { box-shadow: none; }

.apx-body-format { width: auto; min-width: 150px; }
.apx-chips-row { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.apx-param-chip {
    font: 500 .72rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    padding: .2rem .5rem; border-radius: var(--radius-full); cursor: pointer;
    border: 1px dashed var(--primary-mid); background: var(--primary-light); color: var(--primary);
}
.apx-param-chip:hover { border-style: solid; }
.apx-code-area { font-size: .8rem; line-height: 1.5; resize: vertical; min-height: 140px; white-space: pre; }

.apx-rule-row {
    display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, .9fr) minmax(0, .7fr) minmax(0, 1fr) minmax(0, 1.2fr) auto;
    gap: .5rem; align-items: center;
}

.apx-effect-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.apx-effect {
    display: flex; align-items: flex-start; gap: .7rem; text-align: left; cursor: pointer;
    padding: .9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-card);
    color: var(--text-muted); transition: border-color .15s, background .15s;
}
.apx-effect > span { display: flex; flex-direction: column; gap: .2rem; }
.apx-effect strong { color: var(--text); font-size: .9rem; }
.apx-effect small { font-size: .76rem; line-height: 1.4; }
.apx-effect.on { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.apx-effect:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.apx-effect-picker + .apx-toggles, .apx-effect-picker ~ .settings-notice, .apx-effect-picker ~ .apx-form-grid { margin-top: .85rem; }

.apx-savebar {
    position: sticky; bottom: 0; z-index: 2;
    display: flex; justify-content: flex-end; gap: .5rem;
    padding: .75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: var(--bg-card); box-shadow: 0 -6px 18px rgba(15, 23, 42, .05);
}

.apx-test { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.apx-test > label { font-size: .8rem; font-weight: 600; }
.apx-test-run { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.apx-test-result { display: flex; flex-direction: column; gap: .6rem; border-top: 1px solid var(--border); padding-top: .75rem; }
.apx-errors { margin: 0; padding-left: 1.1rem; font-size: .78rem; color: var(--danger); }

/* ── Editor de parámetros ─────────────────────────────────────────────────────────────────── */
.apx-params { display: flex; flex-direction: column; gap: .6rem; }
.apx-params--nested { padding-left: .9rem; border-left: 2px solid var(--border); }
.apx-param { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); padding: .6rem; }
.apx-params--nested .apx-param { background: var(--bg-subtle); }
.apx-param-head { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto; gap: .5rem; align-items: center; }
.apx-param-name { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.apx-param-summary { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-top: .45rem; }
.apx-param-body { display: flex; flex-direction: column; gap: .75rem; margin-top: .75rem; padding-top: .75rem; border-top: 1px dashed var(--border); }
.apx-nested { display: flex; flex-direction: column; gap: .5rem; }
.apx-add-param { align-self: flex-start; display: inline-flex; align-items: center; gap: .3rem; }

/* ── Panel lateral de detalle ─────────────────────────────────────────────────────────────── */
.apx-drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 1200; }
.apx-drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 1201;
    width: min(520px, 100vw); display: flex; flex-direction: column;
    background: var(--bg-card); box-shadow: -12px 0 32px rgba(15, 23, 42, .14);
    animation: apx-slide .18s ease-out;
}
@keyframes apx-slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.apx-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); }
.apx-drawer-head h3 { margin: .15rem 0; font-size: 1.05rem; }
.apx-drawer-kicker { font-size: .72rem; font-weight: 600; color: var(--primary); letter-spacing: .02em; }
.apx-drawer-body { flex: 1; overflow-y: auto; padding: 1rem 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.apx-detail-status { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.apx-detail-block h4 { margin: 0 0 .4rem; font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: none; letter-spacing: 0; }
.apx-detail-block p { margin: 0; font-size: .85rem; color: var(--text); }
.apx-summary { font-size: .85rem; line-height: 1.55; color: var(--text); background: var(--bg-subtle); border-radius: var(--radius); padding: .7rem .85rem; }
.apx-summary ul, .apx-summary ol { margin: .25rem 0 0; padding-left: 1.1rem; }
.apx-files { display: flex; flex-wrap: wrap; gap: .4rem; }
.apx-files .btn-secondary { display: inline-flex; align-items: center; gap: .35rem; }
.apx-timeline { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; margin: 0; font-size: .8rem; }
.apx-timeline dt { color: var(--text-muted); }
.apx-timeline dd { margin: 0; color: var(--text); }
.apx-note { margin-top: .5rem !important; font-style: italic; color: var(--text-muted) !important; }
.apx-detail-code { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
.apx-detail-code > summary { cursor: pointer; padding: .55rem .75rem; font-size: .8rem; font-weight: 600; color: var(--text); }
.apx-detail-code pre {
    margin: 0; padding: .75rem; max-height: 320px; overflow: auto; border-top: 1px solid var(--border);
    font: .74rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text);
    background: var(--bg-subtle); white-space: pre-wrap; word-break: break-word;
}
.apx-decide { display: flex; flex-direction: column; gap: .5rem; padding: .9rem; border-radius: var(--radius-lg); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); background: var(--warning-light); }
.apx-decide-actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.apx-open-conv { align-self: flex-start; display: inline-flex; align-items: center; gap: .35rem; }

/* ── Tarjeta en la bandeja ─────────────────────────────────────────────────────────────────── */
.apx-card {
    margin: .5rem auto; max-width: 560px; width: calc(100% - 2rem);
    border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-card);
    box-shadow: 0 2px 10px rgba(15, 23, 42, .04); overflow: hidden;
}
.apx-card--compact { display: flex; align-items: center; gap: .5rem; padding: .45rem .75rem; max-width: 460px; border-style: dashed; box-shadow: none; }
.apx-card--compact .apx-card-line { flex: 1; min-width: 0; font-size: .78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apx-card--compact .apx-card-line strong { color: var(--text); font-weight: 600; }
.apx-card-head { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; border-bottom: 1px solid var(--border-light); }
.apx-card-ic { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--radius); background: var(--primary-light); color: var(--primary); flex: 0 0 30px; }
.apx-card-title { flex: 1; min-width: 0; }
.apx-card-title strong { display: block; font-size: .85rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apx-card-title span { font-size: .72rem; color: var(--text-muted); }
.apx-card-body { padding: .75rem .9rem; display: flex; flex-direction: column; gap: .55rem; font-size: .82rem; }
.apx-card-body .apx-summary { font-size: .8rem; }
.apx-card-hint { font-size: .76rem; color: var(--text-muted); display: flex; gap: .35rem; align-items: flex-start; }
.apx-card-actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; padding: .6rem .9rem; border-top: 1px solid var(--border-light); background: var(--bg-subtle); }
.apx-card-actions button { display: inline-flex; align-items: center; gap: .35rem; }
.apx-card--warning { border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.apx-card--danger { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.apx-card--success { border-color: color-mix(in srgb, var(--success) 35%, transparent); }

/* ── Panel del agente ─────────────────────────────────────────────────────────────────────── */
.apx-agent-panel { margin-top: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.apx-agent-panel .apx-section-head { margin-bottom: 0; }
.apx-agent-panel .apx-section-head .btn-ghost { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.apx-pending-row {
    display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; cursor: pointer;
    padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card);
}
.apx-pending-row:hover { border-color: var(--primary-mid); background: var(--surface-hover); }
.apx-pending-row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.apx-pending-main { flex: 1; min-width: 0; font-size: .82rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apx-pending-main strong { color: var(--text); }

/* ── Firma HMAC (formulario de conexión) ───────────────────────────────────────────────────── */
.apx-hmac { border-top: 1px solid var(--border); padding-top: .85rem; margin-top: .35rem; }
.apx-hmac .apx-form-grid { margin-top: .25rem; }
.apx-hmac-template { min-height: 96px; }
.apx-hmac-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 11rem); gap: .5rem; }
.apx-hmac-preview {
    display: flex; flex-direction: column; gap: .35rem; margin-top: .35rem;
    background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem .85rem;
}
.apx-hmac-preview-title { font-size: .78rem; font-weight: 600; color: var(--text); }
.apx-hmac-preview pre {
    margin: 0; font-size: .76rem; line-height: 1.5; color: var(--text); white-space: pre-wrap; word-break: break-all;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; padding: .5rem .6rem; max-height: 180px; overflow: auto;
}
.apx-hmac-headers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; }
.apx-hmac-headers li { font-size: .76rem; color: var(--text-muted); word-break: break-all; }
.apx-hmac-headers strong { color: var(--text); font-weight: 600; }

/* ── Rangos y archivos con nombre dinámico ─────────────────────────────────────────────────── */
.apx-range { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: .4rem; align-items: center; }
.apx-range > span { color: var(--text-muted); }
.apx-file-field { display: flex; flex-direction: column; gap: .4rem; padding: .6rem 0; border-bottom: 1px dashed var(--border); }
.apx-file-field:last-child { border-bottom: 0; }
.apx-file-dynamic { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }

/* ── Orígenes de solo lectura y datos copiables ───────────────────────────────────────────── */
.apx-readonly-source {
    display: flex; flex-direction: row; align-items: flex-start; gap: .45rem; margin: 0; font-size: .8rem;
    background: var(--bg-subtle); border: 1px solid var(--border); color: var(--text-muted);
}
.apx-readonly-source svg { flex: 0 0 auto; margin-top: .15rem; }
.apx-select-all { user-select: all; word-break: break-all; }

/* ── Verificación automática de inciertas ─────────────────────────────────────────────────── */
.apx-verify-note { display: flex; align-items: center; gap: .4rem; margin: .4rem 0 0; font-size: .8rem; color: var(--text-muted); }
.apx-verify-note.is-warn { color: #92400e; }

/* ── Importar operaciones desde la documentación ──────────────────────────────────────────── */
.apx-import-tabs { margin-bottom: .25rem; }
.apx-import-text { min-height: 220px; white-space: pre-wrap; }
.apx-import-drop {
    position: relative; display: flex; align-items: center; gap: .8rem; cursor: pointer;
    padding: 1.1rem 1rem; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--bg-subtle); color: var(--text-muted);
}
.apx-import-drop:hover { border-color: var(--primary); color: var(--primary); }
.apx-import-drop span { display: flex; flex-direction: column; gap: .15rem; }
.apx-import-drop strong { color: var(--text); font-size: .88rem; }
.apx-import-drop small { font-size: .76rem; }
.apx-import-file { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.apx-import-how {
    display: flex; gap: .5rem; align-items: flex-start; font-size: .8rem; color: var(--text-muted);
    background: var(--bg-subtle); border-radius: var(--radius); padding: .6rem .75rem;
}
.apx-import-how svg { flex: 0 0 auto; margin-top: .1rem; }
.apx-import-busy { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: 2.2rem 1rem; text-align: center; }
.apx-import-bar { width: min(360px, 100%); height: 6px; border-radius: var(--radius-full); background: var(--bg-subtle); overflow: hidden; }
.apx-import-bar span { display: block; height: 100%; background: var(--primary); border-radius: var(--radius-full); transition: width .4s ease; }
.apx-import-summary { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.apx-import-summary > div:first-child { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.apx-import-counts, .apx-import-bulk, .apx-import-chips, .apx-import-fields { display: flex; gap: .35rem; flex-wrap: wrap; }
.apx-chip--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-light); }
.apx-import-notice { margin: 0; }
.apx-import-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.apx-import-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); padding: .7rem .8rem; }
.apx-import-item.is-on { border-color: var(--primary-mid); }
.apx-import-item.is-error { background: color-mix(in srgb, var(--danger) 4%, var(--bg-card)); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.apx-import-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .7rem; align-items: start; }
.apx-import-row > .cell-select { margin-top: .3rem; }
.apx-import-main { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.apx-import-title { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.apx-import-title strong { font-size: .9rem; color: var(--text); }
.apx-import-warn, .apx-import-error { display: flex; gap: .35rem; align-items: flex-start; margin: 0; font-size: .78rem; }
.apx-import-warn { color: #92400e; }
.apx-import-error { color: #b91c1c; }
.apx-import-warn svg, .apx-import-error svg { flex: 0 0 auto; margin-top: .1rem; }
.apx-import-detail { margin-top: .65rem; padding-top: .65rem; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: .35rem; }
.apx-import-detail h5 { margin: .45rem 0 .15rem; font-size: .76rem; font-weight: 600; color: var(--text); }
.apx-import-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; align-items: end; }
.apx-import-controls .apx-field span { font-size: .78rem; color: var(--text-muted); }
.apx-import-desc { margin: 0; font-size: .82rem; color: var(--text-muted); }
.apx-import-params { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; }
.apx-import-param { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding-left: calc(var(--depth, 0) * 1.1rem); font-size: .8rem; }
.apx-import-cta { display: flex; flex-direction: column; align-items: center; gap: .4rem; margin-top: .6rem; text-align: center; }

/* ── Reimportar: conflictos, cambios, renombres, dependencias y retiradas ─────────────────── */
.apx-chip--warn { color: #92400e; border-color: color-mix(in srgb, var(--warning) 35%, transparent); background: var(--warning-light); }
.apx-inline-spinner { width: 14px; height: 14px; border-width: 2px; }
.apx-import-item.is-busy { opacity: .75; }
.apx-import-item > .apx-deps { margin-top: .65rem; }

.apx-rename {
    display: flex; flex-direction: column; gap: .45rem; margin-top: .35rem; padding: .65rem .75rem;
    border: 1px solid var(--primary-mid); border-radius: var(--radius); background: var(--primary-light);
}
.apx-rename.is-pending { border-color: color-mix(in srgb, var(--warning) 45%, transparent); background: color-mix(in srgb, var(--warning) 7%, var(--bg-card)); }
.apx-rename-question { display: flex; align-items: flex-start; gap: .4rem; margin: 0; font-size: .84rem; font-weight: 600; color: var(--text); }
.apx-rename-question svg { flex: 0 0 auto; margin-top: .15rem; color: var(--primary); }
.apx-rename-actions { display: inline-flex; flex-wrap: wrap; gap: .4rem; }
.apx-seg {
    display: inline-flex; align-items: center; gap: .35rem; padding: .38rem .8rem; font-size: .8rem; font-weight: 500;
    color: var(--text-muted); background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: var(--radius-full);
    cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.apx-seg:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.apx-seg.on { border-color: var(--primary); background: var(--primary); color: #fff; }
.apx-seg.on:hover:not(:disabled) { color: #fff; }
.apx-seg:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.apx-seg:disabled { opacity: .6; cursor: default; }

.apx-changes { display: flex; flex-direction: column; gap: .45rem; padding-bottom: .5rem; border-bottom: 1px dashed var(--border); }
.apx-changes-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.apx-changes-head h5 { margin: .2rem 0 0; }
.apx-changes-bulk { display: flex; gap: .3rem; flex-wrap: wrap; }
/* Aviso con icono a la izquierda: .settings-notice apila en columna. */
.settings-notice.apx-notice-row { flex-direction: row; align-items: flex-start; gap: .45rem; margin: 0; font-size: .8rem; }
.settings-notice.apx-notice-row > svg { flex: 0 0 auto; margin-top: .15rem; }
.settings-notice.info.apx-notice-row { background: var(--primary-light); border: 1px solid var(--primary-mid); color: var(--text); }
.settings-notice.info.apx-notice-row > svg { color: var(--primary); }
.apx-conflict {
    margin: 0; padding: .55rem .65rem .65rem; min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem;
    border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); border-radius: var(--radius);
    background: color-mix(in srgb, var(--warning) 5%, var(--bg-card));
}
.apx-conflict legend { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding: 0 .25rem; font-size: .8rem; color: var(--text); }
.apx-conflict-opt {
    display: flex; align-items: flex-start; gap: .5rem; min-width: 0; padding: .5rem .6rem; cursor: pointer;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); transition: border-color .15s, background .15s;
}
.apx-conflict-opt input { margin-top: .2rem; accent-color: var(--primary); flex: 0 0 auto; }
.apx-conflict-opt > span { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.apx-conflict-opt strong { font-size: .8rem; color: var(--text); }
.apx-conflict-opt small { font-size: .76rem; color: var(--text-muted); overflow-wrap: anywhere; }
.apx-conflict-opt.on { border-color: var(--primary); background: var(--primary-light); }
.apx-conflict-opt:focus-within { box-shadow: var(--focus-ring); }
.apx-conflict:disabled .apx-conflict-opt { cursor: default; opacity: .7; }

.apx-change-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.apx-change { padding: .45rem .6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-subtle); }
.apx-change.is-risk { border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.apx-change-head { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .8rem; color: var(--text); }
.apx-change-values { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: .45rem; align-items: center; margin-top: .3rem; font-size: .76rem; }
.apx-change-values svg { color: var(--text-light); }
.apx-change-val { min-width: 0; overflow-wrap: anywhere; color: var(--text-muted); }
.apx-change-val.is-before { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text-muted) 45%, transparent); }
.apx-change-val.is-after { color: var(--text); }
.apx-change-val.is-empty { font-style: italic; color: var(--text-light); }
.apx-kept summary { cursor: pointer; font-size: .78rem; color: var(--text-muted); padding: .2rem 0; }
.apx-kept summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius); }
.apx-kept[open] summary { margin-bottom: .35rem; }
.apx-kept .apx-change-val.is-before { text-decoration: none; color: var(--text); }
.apx-kept .apx-change-val.is-after { color: var(--text-muted); text-decoration: line-through; }

.apx-deps {
    padding: .6rem .7rem; font-size: .8rem; color: var(--text);
    border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent); border-radius: var(--radius);
    background: color-mix(in srgb, var(--warning) 7%, var(--bg-card));
}
.apx-deps-title { display: flex; align-items: center; gap: .4rem; margin: 0 0 .35rem; color: #92400e; }
.apx-deps ul { margin: 0 0 .5rem; padding-left: 1.15rem; display: flex; flex-direction: column; gap: .2rem; }
.apx-deps a, .apx-missing-deps a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.apx-deps a svg, .apx-missing-deps a svg { vertical-align: -1px; }
.apx-deps-ack { display: inline-flex; align-items: center; gap: .45rem; font-weight: 500; cursor: pointer; }

.apx-import-missing { display: flex; flex-direction: column; gap: .5rem; margin-top: .4rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.apx-missing-head { display: flex; align-items: flex-start; gap: .6rem; }
.apx-missing-head h5 { margin: 0; font-size: .85rem; font-weight: 600; color: var(--text); }
.apx-missing-head p { margin: .15rem 0 0; }
.apx-missing-icon {
    display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: 0 0 auto;
    border-radius: var(--radius); background: var(--bg-subtle); color: var(--text-muted);
}
.apx-import-row--missing { grid-template-columns: auto minmax(0, 1fr); }
.apx-missing-deps { list-style: none; margin: .1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; }
.apx-import-blockers > span { display: flex; flex-direction: column; gap: .1rem; }

/* ── Responsivo (al final, a propósito) ───────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .apx-editor-grid { grid-template-columns: minmax(0, 1fr); }
    .apx-test { position: static; }
    .apx-rule-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
    .apx-rule-row .apx-rule-label { grid-column: 1 / 3; }
}

@media (max-width: 720px) {
    .apx-form-grid, .apx-toggles, .apx-effect-picker, .apx-hmac-pair, .apx-file-dynamic, .apx-import-controls { grid-template-columns: minmax(0, 1fr); }
    .apx-conflict { grid-template-columns: minmax(0, 1fr); }
    .apx-change-values { grid-template-columns: minmax(0, 1fr); gap: .15rem; }
    .apx-change-values svg { transform: rotate(90deg); }
    .apx-rename-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
    .apx-seg { justify-content: center; }
    .apx-kv-row, .apx-kv-list .apx-kv-row, .apx-kv-row--3 { grid-template-columns: minmax(0, 1fr) auto; }
    .apx-kv-row > .settings-input:first-child { grid-column: 1 / -1; }
    .apx-param-head { grid-template-columns: minmax(0, 1fr) auto auto; }
    .apx-param-head .apx-param-name { grid-column: 1 / -1; }
    .apx-param-head .apx-inline-check { justify-self: start; }
    .apx-rule-row { grid-template-columns: minmax(0, 1fr) auto; }
    .apx-rule-row > .settings-input:first-child, .apx-rule-row .apx-rule-label { grid-column: 1 / -1; }
    .apx-head-actions { width: 100%; }
    .apx-head-actions button { flex: 1 1 auto; justify-content: center; }
    .apx-section-head { flex-direction: column; }
    .apx-url { flex-direction: column; }
    .apx-url-base { max-width: none; border-right: none; border-bottom: 1px solid var(--border); padding: .45rem .65rem; }
    .apx-toolbar .lw-search { max-width: none; }
    .apx-status-filter { width: 100%; }
    .apx-savebar { border-radius: var(--radius); }

    /* La tabla pasa a tarjetas: cada celda con su etiqueta. */
    .apx-table thead { display: none; }
    .apx-table, .apx-table tbody, .apx-table tr, .apx-table td { display: block; width: 100%; }
    .apx-table tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .6rem; padding: .35rem .25rem; background: var(--bg-card); }
    .apx-table td { border: none; padding: .35rem .75rem; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
    .apx-table td::before { content: attr(data-label); font-size: .72rem; font-weight: 600; color: var(--text-muted); text-align: left; }
    .apx-table td.apx-row-actions { justify-content: flex-end; }
    .apx-table td.apx-row-actions::before { content: none; }
    .apx-cell-detail { max-width: none; white-space: normal; }
    .apx-card { width: calc(100% - 1rem); }
}
