/* ===== Experiencia de app en teléfono =====
   En pantallas angostas (≤768px) el panel se comporta como una app: barra de secciones ABAJO (con «Más»), cabecera compacta,
   menús que suben desde abajo, botones y campos cómodos para el dedo y respeto de las zonas seguras (muesca y barra inferior). */
html { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
body { -webkit-text-size-adjust: 100%; }
@keyframes tabEntra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tab-panel.active { animation: tabEntra .2s ease; }

/* elementos que solo existen en el teléfono */
#btnMasHeader, #navMas { display: none; }

/* hojas que suben desde abajo («Más» y el menú ⋯) */
.sheet-fondo { position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; }
.sheet { width: 100%; max-height: 80vh; overflow: auto; background: var(--bg-base); border-top: 1px solid var(--glass-border); border-radius: 22px 22px 0 0;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); animation: sheetSube .22s ease; }
@keyframes sheetSube { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-asa { width: 40px; height: 4px; border-radius: 2px; background: var(--glass-border); margin: 2px auto 10px; }
.sheet-tit { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 6px 6px; }
.sheet-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 10px; background: none; border: 0; border-radius: 12px; color: var(--text-main);
  font-family: inherit; font-size: 1rem; text-align: left; cursor: pointer; }
.sheet-item:active { background: var(--card-bg); }
.sheet-item svg { width: 22px; height: 22px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sheet-item.activo { background: rgba(0,240,255,.12); color: var(--neon-primary); }
.sheet-item.peligro { color: var(--danger); }
.sheet-sep { height: 1px; background: var(--glass-border); margin: 6px 0; }

@media (max-width: 768px) {
  /* marco: contenido arriba, barra de secciones abajo */
  .layout { flex-direction: column; }
  .contenido { order: 1; flex: 1 1 0; min-height: 0; }
  .sidebar { order: 2; width: 100%; flex-direction: row; justify-content: space-around; align-items: stretch; gap: 0; overflow: visible; z-index: 600;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--glass-border); }
  .sidebar .logo-container { display: none; }
  .nav-item { flex: 1 1 0; width: auto; min-width: 0; padding: 7px 2px 5px; border-radius: 14px; }
  .nav-item svg { width: 22px; height: 22px; margin: 0 auto 2px; }
  .nav-item .label { display: block !important; font-size: .62rem; text-transform: none; letter-spacing: 0; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-item.activo { background: rgba(0,240,255,.14); color: var(--neon-primary); box-shadow: none; }
  .nav-item.bloqueado, .nav-item.desactivado, .nav-item.nav-extra { display: none !important; }
  #navMas { display: block; }
  .nav-item .dot { top: 0; right: 14%; }

  /* cabecera compacta: título y botones en una fila, el cliente debajo */
  .contenido-header { padding: calc(8px + env(safe-area-inset-top)) 12px 8px; gap: 8px; flex-wrap: wrap; }
  .contenido-header h1 { order: 0; flex: 1 1 0; min-width: 0; font-size: 1.1rem; }
  .controles-header { display: contents; }
  #btnRefrescar, #btnCampana, #btnMasHeader { order: 1; width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%; justify-content: center; align-items: center; display: inline-flex; }
  #btnRefrescar span { display: none; }
  #btnMasHeader { font-size: 1.3rem; line-height: 1; }
  select#clienteSelect { order: 5; flex: 1 1 100%; width: 100%; height: 42px; }
  #btnApp, #btnTema, #btnFuente, #btnSalir { display: none !important; }       /* viven en el menú ⋯ */

  /* contenido */
  .scroll { padding: 12px 12px 18px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .btn { min-height: 40px; }
  input, select, textarea { font-size: 16px !important; }                         /* iPhone no hace zoom al escribir */
  .panel { border-radius: 14px; }

  /* ventanas: pantalla completa */
  .overlay { padding: 0; align-items: stretch; }
  .modal-box { max-width: none; width: 100%; height: 100%; max-height: 100%; border-radius: 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .app-modal { padding: 0; align-items: flex-end; }
  .app-caja { width: 100%; max-height: 90vh; border-radius: 22px 22px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .campana-panel { top: calc(56px + env(safe-area-inset-top)); right: 8px; left: 8px; width: auto; }

  /* flotantes por encima de la barra inferior */
  .as-fab { bottom: calc(84px + env(safe-area-inset-bottom)) !important; right: 14px; }
  .as-panel, .ia-sug { bottom: calc(142px + env(safe-area-inset-bottom)); right: 12px; }
  .toast-container { bottom: calc(82px + env(safe-area-inset-bottom)); right: 12px; left: 12px; }
}
@media (display-mode: standalone) { #vistaLogin { padding-top: env(safe-area-inset-top); } }

/* ===== CRM en el teléfono ===== */
.cv-card .acc .llamar { display: none; }
@media (max-width: 768px) {
  #tabCRM > .panel { padding: 10px 10px 8px; }
  .crm-head { margin-bottom: 8px; }
  .seg { height: auto; width: 100%; flex-wrap: nowrap; }
  .seg button { flex: 1 1 0; justify-content: center; padding: 9px 4px; height: auto; min-width: 0; font-size: .8rem; gap: 5px; }
  .seg-mod button svg { display: none; }
  .crm-bar { gap: 8px; }
  .crm-buscar { width: 100%; }
  .crm-acc { width: 100%; justify-content: space-between; }

  /* kanban: etapas como pestañas y una sola lista de tarjetas */
  #cvSecKanban, #pvSecKanban { overflow-y: auto; }
  .mv-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px; scrollbar-width: none; flex-shrink: 0; }
  .mv-chips::-webkit-scrollbar { display: none; }
  .mv-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 99px; border: 1px solid var(--glass-border); background: var(--card-bg); color: var(--text-muted); font: inherit; font-size: .84rem; font-weight: 600; white-space: nowrap; cursor: pointer; }
  .mv-chip b { font-weight: 700; color: var(--text-main); font-size: .78rem; background: rgba(255,255,255,.08); border-radius: 99px; padding: 1px 7px; }
  .mv-chip.activo { border-color: var(--neon-primary); color: var(--neon-primary); background: rgba(0,240,255,.10); }
  .mv-pto { width: 8px; height: 8px; border-radius: 50%; }
  .cv-board.mv-una { display: block; overflow: visible; min-height: 0; flex: none; padding: 0 0 90px; }
  .cv-board.mv-una .cv-col { display: none; background: none; border: 0; }
  .cv-board.mv-una .cv-col.mv-sel { display: block; }
  .cv-board.mv-una .cv-col h3 { display: none; }
  .cv-board.mv-una .cv-lista { padding: 0; overflow: visible; max-height: none; min-height: 0; }
  .cv-card { padding: 14px; margin-bottom: 12px; cursor: default; border-radius: 14px; }
  .cv-card .nom { font-size: 1rem; }
  .cv-card .cp, .cv-card .emp { font-size: .86rem; }
  .cv-card .cab { font-size: .72rem; }
  .cv-card .acc { gap: 8px; margin-top: 10px; }
  .cv-card .acc .wa, .cv-card .acc .llamar { display: inline-flex; width: 42px; height: 42px; border-radius: 12px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); align-items: center; justify-content: center; padding: 0; font-size: 1.1rem; color: #F9FAFB; text-decoration: none; }
  .cv-card .acc .wa { color: #25D366; }
  .cv-card .menu-btn { width: 42px; height: 42px; border-radius: 12px; font-size: 18px; }
  .cv-card details { font-size: .84rem; }
  .cv-card summary { padding: 4px 0; }

  /* menú de la tarjeta: hoja que sube desde abajo */
  .menu-dropdown { position: fixed !important; }
  .menu-dropdown.abierto { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: 100%; min-width: 0; border-radius: 22px 22px 0 0; padding: 14px 14px calc(16px + env(safe-area-inset-bottom)); z-index: 3100; max-height: 75vh; overflow-y: auto; box-shadow: 0 -12px 40px rgba(0,0,0,.6); }
  .menu-dropdown button { padding: 14px 12px; font-size: 1rem; }
  .menu-dropdown select { padding: 12px; font-size: 1rem; }
}
:is([data-theme="light"],[data-theme="suave"]) .cv-card .acc .wa, :is([data-theme="light"],[data-theme="suave"]) .cv-card .acc .llamar { background: rgba(15,23,42,.05); border-color: rgba(15,23,42,.12); color: #0F172A; }
:is([data-theme="light"],[data-theme="suave"]) .mv-chip b { background: rgba(15,23,42,.08); }
/* ===== CRM en el teléfono: barra de herramientas compacta ===== */
@media (max-width: 768px) {
  .crm-head .crm-titulo { display: none; }
  .crm-head { margin-bottom: 8px; }
  .crm-bar { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px; margin-bottom: 10px; }
  .crm-bar > .seg { grid-column: 1; grid-row: 1; width: auto; }
  .crm-bar > .seg button { flex: 0 0 auto; padding: 8px 12px; }
  .crm-acc { display: contents; }
  .crm-acc .ibg { grid-column: 3; grid-row: 1; }
  .crm-acc > .btn-solid { grid-column: 4; grid-row: 1; height: 42px; padding: 0 14px; white-space: nowrap; }
  .crm-acc .crm-buscar { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .crm-pop { position: fixed; left: 12px; right: 12px; top: auto; bottom: calc(86px + env(safe-area-inset-bottom)); width: auto; z-index: 3100; }

  /* botones flotantes del CRM (pendientes y asistente): más chicos y uno sobre otro */
  .as-fab { width: 48px; height: 48px; font-size: 1.05rem; right: 14px; opacity: .96; }
  .as-fab-ia { bottom: calc(84px + env(safe-area-inset-bottom)) !important; }
  .as-fab-pend { bottom: calc(142px + env(safe-area-inset-bottom)) !important; }
  .as-panel { left: 8px; right: 8px; width: auto; bottom: calc(142px + env(safe-area-inset-bottom)); max-height: calc(100dvh - 240px); }
}

/* ===== CRM en el teléfono: próximas actividades como tarjetas ===== */
.cv-act .llamar { display: none; }
@media (max-width: 768px) {
  .cv-act { background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 14px; padding: 12px; margin-bottom: 10px; flex-direction: column; align-items: stretch; gap: 10px; }
  .cv-act .btn-row { display: flex; gap: 8px; flex-wrap: nowrap; }
  .cv-act .btn-xs { flex: 1 1 0; min-height: 42px; font-size: .84rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; }
  .cv-act .llamar { display: inline-flex; flex: 0 0 46px; min-height: 42px; align-items: center; justify-content: center; border-radius: 12px; border: 1px solid var(--glass-border); background: var(--card-bg); color: var(--text-main); font-size: 1.1rem; text-decoration: none; }
  .cv-kpis { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Prospección en el teléfono: filas como tarjetas ===== */
@media (max-width: 768px) {
  .pr-tabla { overflow: visible; }
  .pr-tabla table { min-width: 0 !important; width: 100%; display: block; }
  .pr-tabla thead { display: none; }
  .pr-tabla tbody { display: block; }
  .pr-tabla tr { display: block; background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
  .pr-tabla td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0 !important; padding: 5px 0 !important; text-align: right; font-size: .88rem; white-space: normal !important; max-width: none; }
  .pr-tabla td::before { content: attr(data-label); color: var(--text-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .03em; text-align: left; flex-shrink: 0; }
  .pr-tabla td:first-child { font-weight: 700; font-size: 1rem; justify-content: flex-start; text-align: left; padding-bottom: 8px !important; }
  .pr-tabla td:first-child::before { display: none; }
  .pr-tabla td:last-child { justify-content: flex-end; padding-top: 10px !important; }
  .pr-tabla td:last-child::before { display: none; }
  .pr-tabla td:last-child .btn, .pr-tabla td:last-child .menu-btn, .pr-tabla td:last-child .btn-whatsapp { min-height: 42px; }
  .pr-fb { max-width: none; }
  .pr-hoy { grid-template-columns: 1fr; }
  .cv-act a.btn { text-decoration: none; }
}

/* ===== Leads en el teléfono: cada contacto como tarjeta ===== */
.ld-contacto { display: none; }
@media (max-width: 768px) {
  #tabLeads .table-wrapper { overflow: visible; border: 0; }
  .ld-tabla { display: block; width: 100%; }
  .ld-tabla thead { display: none; }
  .ld-tabla tbody { display: block; }
  .ld-tabla tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
  .ld-tabla tr.ld-dia { display: block; background: none; border: 0; padding: 14px 2px 4px; margin: 0; font-weight: 700; color: var(--neon-primary); font-size: .9rem; }
  .ld-tabla td { display: block; border: 0 !important; padding: 0 !important; font-size: .88rem; white-space: normal !important; }
  .ld-tabla td.ld-cli { order: 1; flex: 1 1 0; min-width: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
  .ld-tabla td.ld-hora { order: 2; font-size: .78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
  .ld-tabla td.ld-lead { order: 3; flex: 1 0 100%; font-size: 1.1rem; margin-top: 2px; }
  .ld-tabla td.ld-tel { order: 4; flex: 1 0 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
  .ld-tabla td.ld-tel span { font-size: 1rem; font-variant-numeric: tabular-nums; }
  .ld-tabla td.ld-datos { order: 5; flex: 1 0 100%; display: flex; flex-direction: column; gap: 2px; margin-top: 6px; padding-top: 8px !important; border-top: 1px solid var(--glass-border) !important; color: var(--text-muted); }
  .ld-tabla td.ld-datos i { font-style: normal; color: var(--text-muted); opacity: .8; }
  .ld-tabla td.ld-datos span { display: block; margin: 0; }
  .ld-tabla td.ld-origen { order: 6; flex: 1 0 100%; font-size: .74rem; color: var(--text-muted); opacity: .85; }
  .ld-tabla td::before { display: none !important; }
  .ld-contacto { display: inline-flex; gap: 8px; }
  .ld-btn { display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center; border-radius: 12px; border: 1px solid var(--glass-border); background: var(--card-bg); color: var(--text-main); font-size: 1.1rem; text-decoration: none; }
  .ld-btn.ld-wa { color: #25D366; }
}

/* Leads: los controles (días, cliente, Actualizar) se apilan y caben en el ancho de la pantalla */
@media (max-width: 768px) {
  #tabLeads .panel { overflow-x: hidden; }
  #tabLeads .ld-ctrl { width: 100%; display: grid !important; grid-template-columns: 1fr; gap: 8px; }
  #tabLeads .ld-ctrl #ldDias { flex-wrap: wrap; min-width: 0; }
  #tabLeads .ld-ctrl #ldCliente { width: 100% !important; max-width: 100%; min-width: 0; }
  #tabLeads .ld-ctrl #ldActualizar { width: 100%; min-height: 44px; }
}
@media (max-width: 768px) {
  #tabLeads .table-wrapper table, .ld-tabla { min-width: 0 !important; width: 100% !important; }
  .ld-tabla tr { box-sizing: border-box; width: 100%; }
  #tabLeads .table-wrapper { max-height: none !important; }
}

/* ===== Google Ads, SEO y demás pantallas en el teléfono ===== */
@media (max-width: 768px) {
  /* filtro de fechas: Desde y Hasta lado a lado, Aplicar debajo, todo más bajo */
  .filtros-fecha { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px 10px; align-items: end; padding: 12px; }
  .filtros-fecha > div { min-width: 0; }
  .filtros-fecha label { font-size: .68rem; }
  .filtros-fecha input[type=date] { width: 100%; min-width: 0; padding: 10px 8px; }
  .filtros-fecha .btn, .filtros-fecha button { grid-column: 1 / -1; min-height: 44px; }

  /* tarjetas de resultados: más compactas */
  .card-grid { gap: 10px; }
  .card { padding: 12px; }
  .card .valor { font-size: 1.35rem; }

  /* tabla de campañas: cada campaña es una tarjeta con sus cifras en dos columnas */
  #tablaCampanas { overflow: visible; }
  #tablaCampanas table, #tablaCampanas tbody { display: block; width: 100%; min-width: 0 !important; }
  #tablaCampanas thead { display: none; }
  #tablaCampanas tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
  #tablaCampanas td { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; border: 0 !important; padding: 0 !important; text-align: left; font-size: .95rem; font-variant-numeric: tabular-nums; }
  #tablaCampanas td::before { content: attr(data-label); color: var(--text-muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .03em; }
  #tablaCampanas td:first-child { grid-column: 1 / -1; font-weight: 700; font-size: 1rem; }
  #tablaCampanas td:first-child::before { display: none; }
  #tablaCampanas td .badge { margin-left: 6px; }

  /* menos relleno en las cajas anidadas («Qué hacer» y escalera) */
  .panel { padding: 14px; }
  .panel .panel { padding: 10px; }
  canvas { max-height: 220px; }
}

/* barra de saltos de Google Ads en el teléfono */
.mv-saltos { display: none; }
@media (max-width: 768px) {
  .mv-saltos { display: flex; gap: 8px; overflow-x: auto; position: sticky; top: -12px; z-index: 20; margin: -12px -12px 10px; padding: 10px 12px 8px; background: var(--bg-base); border-bottom: 1px solid var(--glass-border); scrollbar-width: none; }
  .mv-saltos[hidden] { display: none; }
  .mv-saltos::-webkit-scrollbar { display: none; }
  .panel h3 .muted { display: block; margin-top: 2px; }
}

/* pantalla del cliente: tablas como tarjetas */
@media (max-width: 768px) {
  #adsCliente .table-wrapper { overflow: visible; }
  #adsCliente table, #adsCliente tbody { display: block; width: 100%; min-width: 0 !important; }
  #adsCliente thead { display: none; }
  #adsCliente tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
  #adsCliente td { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; border: 0 !important; padding: 0 !important; text-align: left; font-size: .95rem; font-variant-numeric: tabular-nums; }
  #adsCliente td::before { content: attr(data-label); color: var(--text-muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .03em; }
  #adsCliente td:first-child { grid-column: 1 / -1; font-weight: 700; font-size: 1rem; }
  #adsCliente td:first-child::before { display: none; }
}

/* SEO y tablas simples en el teléfono */
@media (max-width: 768px) {
  .cli-kpis4 { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .cli-kpis4 .cli-kpi { padding: 12px; }
  .cli-kpis4 .cli-kpi .v { font-size: 1.5rem; }
  .cli-kpis4 .cli-kpi .s { display: none; }
  .cli-kpi { padding: 14px; }
  .cli-kpi .v { font-size: 1.7rem; }
  /* tablas de pocas columnas: caben en la pantalla */
  .table-wrapper table { min-width: 0; width: 100%; font-size: .85rem; }
  .table-wrapper th, .table-wrapper td { padding: 8px 6px; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* pestañas internas (Pizarra, captación...) en una sola fila deslizable */
@media (max-width: 768px) {
  .cap-tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; }
  .cap-tabs::-webkit-scrollbar { display: none; }
  .cap-tabs button { flex: 0 0 auto; white-space: nowrap; }
}

/* Clientes y accesos en el teléfono: cada cliente es una tarjeta con sus interruptores */
@media (max-width: 768px) {
  #tabClientes .table-wrapper { overflow: visible; }
  #tabClientes table, #tabClientes tbody { display: block; width: 100%; min-width: 0 !important; }
  #tabClientes thead { display: none; }
  #tabClientes tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
  #tabClientes td { display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 0 !important; padding: 6px 0 !important; text-align: left; font-size: .9rem; }
  #tabClientes td::before { content: attr(data-label); color: var(--text-muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; }
  #tabClientes td:first-child { grid-column: 1 / -1; font-weight: 700; font-size: 1rem; justify-content: flex-start; }
  #tabClientes td:first-child::before { display: none; }
  #tabClientes td:last-child { grid-column: 1 / -1; justify-content: flex-end; }
  #tabClientes td:last-child::before { display: none; }
  #tabClientes input[type=checkbox] { width: 22px; height: 22px; }
}

/* ===== Ajuste fino del teléfono: las pantallas solo se mueven hacia abajo/arriba, nunca de lado ===== */
@media (max-width: 768px) {
  .scroll { overflow-x: hidden; }
  .scroll.ancho #tabLeads.active > .panel, .scroll.ancho #tabSistema.active > .panel, .scroll.ancho #tabInformes.active > .panel, .scroll.ancho #tabClientes.active > .panel, .scroll.ancho #tabAlertas.active > .panel,
  .scroll.ancho #tabPizarra.active > .panel { overflow-x: hidden; overscroll-behavior: contain; }
  .scroll.ancho #tabLeads.active > .panel, .scroll.ancho #tabSistema.active > .panel, .scroll.ancho #tabInformes.active > .panel, .scroll.ancho #tabClientes.active > .panel, .scroll.ancho #tabAlertas.active > .panel { touch-action: pan-y; }
  .inf-grid { grid-template-columns: 1fr; }
  .inf-btns { grid-template-columns: 1fr 1fr; }
  #tabSistema .table-wrapper { overflow-x: auto; }
  /* CRM: el buscador y el botón «Añadir» no deben ensanchar la fila más que la pantalla */
  .crm-bar > *, .crm-buscar, .crm-buscar input { min-width: 0; max-width: 100%; }
  .crm-buscar input { width: 100%; }
  /* Leads: cabecera más compacta y espacio al final para que la última tarjeta no quede tapada por la barra de abajo */
  #tabLeads .panel > div:first-child { margin-bottom: 8px !important; gap: 8px !important; }
  #tabLeads #ldLista { padding-bottom: 12px; }
  #ldCliente { flex: 1 1 0; min-width: 0; }
}

/* iPhone/Android: los menús y ventanas «fijos» se anclan a la pantalla (antes los anclaba el panel con desenfoque y se iban hacia abajo al desplazar) */
@media (max-width: 768px) {
  .panel { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .tab-panel.active { animation: none !important; transform: none !important; }
  .menu-dropdown.abierto { max-height: 75dvh; }
  .overlay { height: 100dvh; }
  .modal-box { padding-bottom: calc(26px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
}

/* menú de acciones en la capa superior (popover): se ancla al borde inferior de la pantalla, por encima de la barra */
@media (max-width: 768px) {
  .menu-dropdown[popover] { margin: 0; border: 0; inset: auto 0 0 0; color: var(--text-main); overflow-y: auto; }
  .menu-dropdown[popover]::backdrop { background: rgba(0,0,0,.35); }
}
