/* =========================================================
   Panel de agencia — la hoja entera.

   Estilo: clean y profesional. Superficies planas, bordes de 1 px,
   sombra solo en lo que flota (diálogos, avisos). La marca de cada
   agencia llega por tokens desde agencia-tema.css (--brand, --accent,
   --bg, fuentes); aquí no hay ningún color de MIDAX escrito a mano.

   Usuaria tipo: una administradora desde el celular entre cliente y
   cliente. Todo objetivo táctil mide 40 px o más; los campos usan
   16 px para que iOS no haga zoom al tocarlos.
   ========================================================= */

:root {
  --surface: #FFFFFF;
  --surface-2: #FAF9F6;
  --surface-3: #F1EEE7;
  --border: #E6E1D6;
  --border-strong: #D5CEC0;
  --text: #0F1B2D;
  --text-2: #4B5563;
  --text-3: #8A919C;
  --ok: #1E7A4C;      --ok-wash: #E4F3EA;
  --warn: #8A6100;    --warn-wash: #FBF1D9;
  --danger: #B42318;  --danger-wash: #FDECEA;
  --info: var(--brand); --info-wash: var(--brand-wash, #EAEFF6);

  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --shadow-float: 0 12px 32px -8px rgba(15, 27, 45, .18), 0 2px 6px rgba(15, 27, 45, .06);
  --side-w: 248px;
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent, #C9A227) 35%, transparent);
}

/* ---------- Base ---------- */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
.admin-body {
  min-height: 100vh; min-height: 100dvh;
  background: var(--bg, #F6F4EF); color: var(--text);
  font: 400 14px/1.5 var(--font-ui, system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
:is(button, a, input, select, textarea, summary):focus-visible { outline: none; box-shadow: var(--ring); }

.ic { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-lg { width: 18px; height: 18px; }
i[data-ico] { display: inline-grid; place-items: center; font-style: normal; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 14px; line-height: 1; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); color: var(--brand-ink, #fff); }
.btn-primary:hover { background: var(--brand-hover, var(--brand)); }
.btn-secondary, .ghost-btn { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover, .ghost-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.ghost-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--border); font-weight: 600; cursor: pointer; }
.btn-ancho { width: 100%; }
.btn[disabled] { opacity: .55; cursor: progress; }

.icon-btn, .act-ico {
  width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0;
  border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover, .act-ico:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .ic, .act-ico .ic { width: 17px; height: 17px; }
.del-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 0; background: none; color: var(--text-3); border-radius: var(--r-sm); cursor: pointer; }
.del-btn:hover { background: var(--danger-wash); color: var(--danger); }

/* ---------- Campos ---------- */
/* :where() deja estas reglas con peso mínimo: cualquier componente (buscador,
   contraseña, estado) puede ajustar padding o ancho sin pelear con ellas. */
:where(input:not([type="checkbox"], [type="radio"], [type="file"]), select, textarea) {
  width: 100%; min-height: 40px; padding: 8px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
:where(input, select, textarea):focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
:where(input, textarea)::placeholder { color: var(--text-3); }
:where(select) {
  -webkit-appearance: none; appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234B5563' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); flex: none; }

/* ---------- Entrar ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; display: grid; gap: 14px;
  padding: 32px 28px 26px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.login-logo { display: block; width: 100%; max-width: 200px; height: auto; margin: 0 auto 6px; }
.login-card h1 { font: 400 26px/1.2 var(--font-title, Georgia, serif); color: var(--text); text-align: center; }
.login-sub { color: var(--text-2); text-align: center; margin-top: -8px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 44px; }
.pw-eye { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 36px; height: 34px; display: grid; place-items: center; border: 0; background: none; color: var(--text-3); cursor: pointer; border-radius: var(--r-sm); }
.pw-eye:hover { color: var(--text); }
.submit-btn { width: 100%; min-height: 44px; margin-top: 4px; }
.form-status { font-size: 13px; color: var(--text-2); }
.form-status:empty { display: none; }
.form-status.err { color: var(--danger); background: var(--danger-wash); padding: 9px 12px; border-radius: var(--r-sm); }
.login-help { font-size: 12px; color: var(--text-3); text-align: center; }

/* =========================================================
   ESTRUCTURA: menú lateral + contenido
   ========================================================= */
.app { min-height: 100vh; min-height: 100dvh; }
.side {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.side-brand { flex: none; display: flex; align-items: center; }
.ag-logo { display: block; height: 34px; width: auto; }
.side-user { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.side-user .ag-txt { min-width: 0; text-align: right; }
.usr-nombre { display: block; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usr-corto { display: none; }
.ag-linea { display: none; }
.ag-select { margin-top: 4px; min-height: 32px; padding: 4px 28px 4px 8px; font-size: 13px; }
.side-acts { display: flex; gap: 2px; flex: none; }
.side .avatar-sm { display: none; }

/* Secciones: barra fija abajo en el celular */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 50px; border: 0; background: none; color: var(--text-3); font-size: 11px; font-weight: 600; cursor: pointer; border-radius: var(--r-sm);
}
.tab .ic { width: 20px; height: 20px; }
.tab[aria-selected="true"] { color: var(--brand); }
.badge {
  position: absolute; top: 4px; left: calc(50% + 5px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; font-style: normal;
}

.main { padding: 20px 16px calc(84px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }

@media (max-width: 600px) {
  .usr-completo { display: none; } .usr-corto { display: inline; }
  .ag-logo { height: 30px; }
}

@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .side {
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    flex-direction: column; align-items: stretch; gap: 0; padding: 20px 12px 14px;
    border-bottom: 0; border-right: 1px solid var(--border);
  }
  .side-brand { padding: 2px 10px 22px; }
  .ag-logo { height: 46px; }
  .tabs {
    position: static; display: flex; flex-direction: column; gap: 2px;
    padding: 0; background: none; border: 0;
  }
  .tab {
    flex-direction: row; justify-content: flex-start; gap: 10px;
    min-height: 40px; padding: 0 12px; font-size: 14px; font-weight: 500; color: var(--text-2);
  }
  .tab .ic { width: 18px; height: 18px; }
  .tab:hover { background: var(--surface-3); color: var(--text); }
  .tab[aria-selected="true"] { background: var(--brand-wash, #EAEFF6); color: var(--brand); font-weight: 600; }
  .tab[aria-selected="true"]::before {
    content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent, var(--brand));
  }
  .badge { position: static; margin-left: auto; }
  .side-user {
    margin-top: auto; flex: none; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px;
    padding: 12px 8px 0; border-top: 1px solid var(--border);
  }
  .side .avatar-sm { display: grid; }
  .side-user .ag-txt { text-align: left; }
  .usr-completo { display: inline; } .usr-corto { display: none; }
  .ag-linea { display: flex; align-items: center; gap: 6px; min-width: 0; margin-top: 1px; }
  .ag-nombre { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-acts { grid-column: 1 / -1; justify-content: space-between; padding-top: 6px; }
  .main { padding: 28px 36px 48px; margin: 0; max-width: 1180px; }
}

/* ---------- Cabecera de cada sección ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { font: 400 26px/1.15 var(--font-title, Georgia, serif); color: var(--text); letter-spacing: -.01em; }
.page-sub { margin-top: 4px; color: var(--text-2); font-size: 14px; }
.page-sub .nota-aviso { color: var(--accent-ink, var(--warn)); font-weight: 600; }
.page-acts { display: flex; gap: 8px; }
@media (max-width: 600px) {
  .page-title { font-size: 23px; }
  .page-acts { width: 100%; }
  .page-acts .btn { flex: 1; }
}

/* ---------- Filtros: control segmentado ---------- */
.seg { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.seg::-webkit-scrollbar { display: none; }
.chip {
  position: relative; flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 12px; border: 0; background: none; color: var(--text-2); font-size: 14px; font-weight: 500; cursor: pointer;
}
.chip b { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 600; line-height: 20px; text-align: center; }
.chip:hover { color: var(--text); }
.chip.on { color: var(--brand); font-weight: 600; }
.chip.on::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand); }
.chip.on b { background: var(--brand); color: var(--brand-ink, #fff); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 260px; display: block; }
.search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search input { padding-left: 36px; }
.toolbar select { flex: 0 1 220px; }
@media (max-width: 600px) { .toolbar select { flex-basis: 100%; } }

/* ---------- Contenedor de listas ---------- */
.panel-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.panel-card:has(> :empty) { display: none; }
.empty { padding: 40px 20px; text-align: center; color: var(--text-2); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); }

/* =========================================================
   SOLICITUDES: tabla en computadora, filas compactas en celular
   ========================================================= */
.rows-head, .lead {
  display: grid; align-items: center; gap: 4px 16px;
  /* Anchos fijos al final: si una columna es "auto", cada fila la calcula
     distinto (Delegar es más ancho que Abrir) y la tabla se desalinea. */
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.2fr) minmax(0, 1.2fr) 140px 164px;
  padding: 12px 16px;
}
.rows-head {
  padding-top: 10px; padding-bottom: 10px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em;
}
.lead { border-bottom: 1px solid var(--border); cursor: default; transition: background-color .12s; }
.lead:last-child { border-bottom: 0; }
.lead.abrible { cursor: pointer; }
.lead.abrible:hover { background: var(--surface-2); }
.lead.st-descartado .r-nombre { color: var(--text-2); }

.c-cliente { display: flex; align-items: center; gap: 12px; min-width: 0; }
.c-cliente > div { min-width: 0; }
.r-nombre { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-main { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-sub { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-msg { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-sin { color: var(--warn); font-weight: 600; }
.r-wa { color: var(--ok); }
.c-acts { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.c-acts .btn { min-height: 34px; padding: 0 12px; font-size: 13px; margin-left: 6px; }

/* Estado: un select que parece etiqueta */
.status-select {
  width: auto; min-height: 30px; padding: 3px 28px 3px 10px; border-radius: 999px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; background-position: right 9px center;
}
.status-select.st-nuevo      { background-color: var(--info-wash);   color: var(--info); }
.status-select.st-contactado { background-color: var(--warn-wash);   color: var(--warn); }
.status-select.st-cerrado    { background-color: var(--ok-wash);     color: var(--ok); }
.status-select.st-descartado { background-color: var(--surface-3);   color: var(--text-2); }
.status-select:focus { border-color: var(--brand); }

@media (max-width: 860px) {
  .rows-head { display: none; }
  .lead {
    grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 14px;
    grid-template-areas: "cliente estado" "detalle detalle" "acts acts";
  }
  .c-cliente { grid-area: cliente; }
  .c-estado { grid-area: estado; }
  .c-seguro, .c-asig { display: none; }
  .c-detalle { grid-area: detalle; display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--text-2); padding-left: 48px; }
  .c-acts { grid-area: acts; justify-content: flex-start; padding-left: 42px; }
  .c-acts .btn { margin-left: auto; }
}
@media (min-width: 861px) { .c-detalle { display: none; } }

/* ---------- Avatar ---------- */
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; background: var(--surface-3); color: var(--text-2);
  font-size: 13px; font-weight: 600; letter-spacing: .02em;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-sm { width: 36px; height: 36px; font-size: 12px; background: var(--brand-wash, #EAEFF6); color: var(--brand); }
.avatar-xl { width: 88px; height: 88px; font-size: 24px; position: relative; }
.avatar-xl.subiendo::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 3px solid var(--brand); border-right-color: transparent; animation: gira .9s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .avatar-xl.subiendo::after { animation: none; } }

/* =========================================================
   LISTAS (equipo, reseñas, accesos)
   ========================================================= */
.fila { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.fila:last-child { border-bottom: 0; }
.fila.oculta .avatar, .fila.oculta .fila-txt { opacity: .55; }
.fila-txt { min-width: 0; }
.fila-nombre { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; color: var(--text); }
.fila-sub { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila-sub2 { font-size: 13px; color: var(--text-3); margin-top: 1px; }
.fila-sub2 b { color: var(--text-2); font-weight: 600; }
.fila-acts { display: flex; align-items: center; gap: 8px; }
.resena-txt { color: var(--text-2); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.estrellas { display: inline-flex; gap: 1px; color: var(--accent, #C9A227); vertical-align: -2px; margin-right: 4px; }
.estrellas .ic { width: 13px; height: 13px; fill: currentColor; stroke: none; }
.estrellas .ic.vacia { fill: none; stroke: var(--border-strong); stroke-width: 2; }

/* Etiquetas */
.fila-tag, .rol-pill {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em; text-transform: none;
  background: var(--accent-wash, #F7F0DC); color: var(--accent-ink, #6E5410);
}
.fila-tag.off { background: var(--surface-3); color: var(--text-2); }
.fila-tag.bloq { background: var(--danger-wash); color: var(--danger); }
.rol-pill { background: var(--surface-3); color: var(--text-2); text-transform: capitalize; }

/* El ojito: interruptor */
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ico { display: inline-grid; place-items: center; color: var(--text-3); }
.switch-ico .ic { width: 17px; height: 17px; }
.switch-pista { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); transition: background-color .15s; }
.switch-pista::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(15, 27, 45, .25); transition: transform .15s; }
.switch input:checked ~ .switch-pista { background: var(--brand); }
.switch input:checked ~ .switch-pista::after { transform: translateX(16px); }
.switch input:checked ~ .switch-ico { color: var(--brand); }
.switch input:focus-visible ~ .switch-pista { box-shadow: var(--ring); }
.switch input:disabled ~ * { opacity: .45; cursor: not-allowed; }
.switch-txt { width: 52px; font-size: 13px; color: var(--text-2); }
@media (max-width: 600px) {
  .fila { gap: 10px; padding: 12px; }
  .switch-txt, .switch-ico { display: none; }
  .fila-sub { white-space: normal; }
}

/* =========================================================
   DIÁLOGOS
   ========================================================= */
dialog.editor {
  width: min(560px, calc(100vw - 32px)); max-height: min(88vh, 900px); padding: 0;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-float);
}
dialog.editor::backdrop { background: rgba(15, 27, 45, .45); }
dialog.editor form { position: relative; display: grid; gap: 14px; padding: 22px 22px 0; max-height: min(88vh, 900px); overflow: auto; }
dialog.editor h2 { font: 400 22px/1.2 var(--font-title, Georgia, serif); color: var(--text); padding-right: 40px; }
.dlg-x { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: none; color: var(--text-3); border-radius: var(--r-sm); cursor: pointer; z-index: 2; }
.dlg-x:hover { background: var(--surface-3); color: var(--text); }
dialog.editor label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.ayuda { display: block; font-size: 12px; font-weight: 400; color: var(--text-3); line-height: 1.45; }
.dos-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog.editor .fila-check { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: 14px; font-weight: 500; color: var(--text); }
.aviso-real { font-size: 13px; color: var(--accent-ink, var(--warn)); background: var(--accent-wash, var(--warn-wash)); padding: 8px 12px; border-radius: var(--r-sm); }
.dlg-sub { font-size: 13px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding-top: 6px; border-top: 1px solid var(--border); }

/* Acciones fijas abajo: Guardar siempre a la vista */
dialog.editor .dlg-acts {
  position: sticky; bottom: 0; z-index: 1; display: flex; justify-content: flex-end; gap: 8px;
  margin: 4px -22px 0; padding: 14px 22px; background: var(--surface); border-top: 1px solid var(--border);
}
.peligro { margin: 0 -22px; padding: 10px 22px 18px; }
.peligro button { border: 0; background: none; color: var(--danger); font-weight: 600; font-size: 13px; padding: 8px 0; cursor: pointer; }
.peligro button:hover { text-decoration: underline; }
dialog.editor .dlg-acts + .peligro { background: var(--surface); }

@media (max-width: 600px) {
  dialog.editor { width: 100vw; max-width: none; height: 100%; max-height: none; margin: 0; border-radius: 0; border: 0; }
  dialog.editor form { max-height: 100dvh; padding: 18px 16px 0; }
  dialog.editor .dlg-acts { margin: 4px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  dialog.editor .dlg-acts .btn { flex: 1; }
  .peligro { margin: 0 -16px; padding: 10px 16px 20px; }
  .dos-col { grid-template-columns: 1fr; }
}

/* Seguimiento de una solicitud */
.lead-meta { margin-top: -8px; font-size: 13px; color: var(--text-2); }
.card-msg { padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); white-space: pre-wrap; word-break: break-word; }
.lead-contacto { display: flex; gap: 8px; flex-wrap: wrap; }
.lead-asignada { align-self: end; padding-bottom: 10px; color: var(--text-2); }
.notas { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 34vh; overflow: auto; }
.notas li { position: relative; padding: 10px 40px 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); }
.nota-txt { color: var(--text); white-space: pre-wrap; word-break: break-word; }
.nota-quien { margin-top: 4px; font-size: 12px; color: var(--text-3); }
.nota-del { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; display: grid; place-items: center; border: 0; background: none; color: var(--text-3); border-radius: var(--r-sm); cursor: pointer; }
.nota-del:hover { background: var(--danger-wash); color: var(--danger); }
.notas .vacio { background: none; border: 0; padding: 2px 0; color: var(--text-3); }

/* Foto del equipo */
.foto-edit { display: flex; align-items: center; gap: 16px; }
.foto-acts { display: grid; gap: 6px; justify-items: start; }

/* Accesos */
.pass-fila { display: flex; gap: 8px; }
.pass-fila input { flex: 1; min-width: 0; }
.pass-fila input[name="password"] { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; }
.pass-fila .btn { flex: none; }
.acceso-listo { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 28px 22px 0; }
.acceso-listo h2 { padding-right: 0; }
.acceso-listo .lead-contacto { justify-content: center; }
.acceso-listo .dlg-acts { width: calc(100% + 44px); justify-content: center; }
.listo-ic { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--ok-wash); color: var(--ok); }
.listo-ic .ic { width: 24px; height: 24px; }
.mensaje-wa { width: 100%; margin: 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); text-align: left; white-space: pre-wrap; word-break: break-word; font: 500 14px/1.55 var(--font-ui, system-ui, sans-serif); color: var(--text); }

/* =========================================================
   IMPORTAR (fase 2D)
   ========================================================= */
dialog.editor.editor-ancho { width: min(860px, calc(100vw - 32px)); }
.imp-paso { display: grid; gap: 14px; }
.ayuda-grande { color: var(--text-2); }
.dropzone {
  position: relative; display: grid; justify-items: center; gap: 6px; padding: 28px 16px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2); color: var(--text-2);
  transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.encima { border-color: var(--brand); background: var(--brand-wash, #EAEFF6); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-ic { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); color: var(--brand); }
.dropzone-ic .ic { width: 20px; height: 20px; }
.dropzone-txt b { color: var(--brand); }
.imp-links { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.historial { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.historial li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.historial li:last-child { border-bottom: 0; }
.historial .h-fuente { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.historial .h-meta { font-size: 12px; color: var(--text-3); }
.historial .h-deshecha { font-size: 12px; color: var(--text-3); }
.historial .vacio { display: block; color: var(--text-3); border: 0; }
.historial:has(.vacio) { border: 0; }
.imp-archivo { font-weight: 600; color: var(--text); }
.imp-archivo span { font-weight: 400; color: var(--text-2); }
.mapa { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 14px; }
.mapa label { display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 3px; row-gap: 4px; }
.mapa label select { grid-column: 1 / -1; }
.mapa label b { color: var(--danger); font-weight: 600; }
.resumen { display: flex; flex-wrap: wrap; gap: 8px; }
.resumen span { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.resumen .r-ok { background: var(--ok-wash); color: var(--ok); }
.resumen .r-bad { background: var(--danger-wash); color: var(--danger); }
.resumen .r-dup { background: var(--surface-3); color: var(--text-2); }
.preview-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); container-type: inline-size; }
.preview { width: 100%; border-collapse: collapse; font-size: 13px; }
.preview th { text-align: left; padding: 8px 10px; background: var(--surface-2); color: var(--text-3); font-weight: 600; font-size: 12px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.preview td { padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.preview tr:last-child td { border-bottom: 0; }
.preview .p-mal td { background: var(--danger-wash); }
.preview .p-mal td:last-child { color: var(--danger); font-weight: 600; }
.preview .p-dup td { color: var(--text-3); }
/* Angosto: se sacan Correo y luego Seguro, para que siempre se lea el motivo del problema */
@container (max-width: 720px) { .preview :is(th, td):nth-child(4) { display: none; } }
@container (max-width: 480px) {
  .preview :is(th, td):nth-child(5) { display: none; }
  .preview :is(th, td) { padding-inline: 7px; }
  .preview td { max-width: 110px; }
  .preview td:last-child { white-space: normal; max-width: none; min-width: 78px; }
}
.fila-consent { align-items: flex-start !important; line-height: 1.45; }
.fila-consent input { margin-top: 1px; }
.progreso { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progreso span { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .3s; }
.progreso-txt { color: var(--text-2); }
.resultado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.resultado div { padding: 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.resultado b { display: block; font: 400 28px/1.1 var(--font-title, Georgia, serif); color: var(--text); }
.resultado span { font-size: 13px; color: var(--text-2); }
.resultado .res-ok b { color: var(--ok); }
.errores { list-style: none; margin: 0; padding: 0; max-height: 30vh; overflow: auto; font-size: 13px; color: var(--text-2); display: grid; gap: 4px; }
.errores li b { color: var(--text); }
@media (max-width: 600px) { .resultado { grid-template-columns: 1fr; } }

/* ---------- Aviso flotante ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  max-width: min(92vw, 440px); padding: 11px 16px; border-radius: var(--r);
  background: #111827; color: #fff; font-weight: 500; text-align: center; line-height: 1.4; box-shadow: var(--shadow-float);
}
.toast.--danger { background: var(--danger); }
@media (min-width: 1024px) { .toast { bottom: 24px; left: calc(50% + var(--side-w) / 2); } }
