/* ============================================================
   MOBILE C v2 — Solo se aplica a viewports ≤ 640px
   No toca nada del desktop. Estilo Linear/Stripe compact.
   ============================================================ */

/* Por defecto en desktop, los elementos mobile están ocultos */
.m-only, .m-topbar, .m-overlay, .m-bottom-cta { display: none; }

/* Activar en mobile */
@media (max-width: 640px) {
  /* Visibilidad swap */
  .d-only { display: none !important; }
  .m-only { display: block; }

  /* Reset márgenes que el header desktop pueda tener */
  body { padding-top: 0 !important; }

  /* Scroll suave + offset para evitar que la topbar+m-tabs sticky
     tapen el inicio de la sección al hacer click en un anchor.
     Medido con Playwright @ iPhone 375: topbar 52px + tabs 48.6px = 100.6px.
     104px deja un respiro visual de ~3px bajo los tabs. */
  html { scroll-behavior: smooth; }
  .m-section, #m-hero, [id^="m-"] { scroll-margin-top: 104px; }

  /* === TOP APP BAR === */
  .m-topbar {
    position: sticky; top: 0; z-index: 50;
    height: 52px; display: flex !important; align-items: center;
    padding: 0 12px 0 16px; gap: 12px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
  }
  .m-topbar .m-logo { flex: 1; line-height: 0; }
  .m-topbar .m-logo img { height: 26px; width: auto; display: block; }
  .m-topbar .m-menu-btn {
    width: 36px; height: 36px; border-radius: 6px;
    background: transparent; border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; padding: 0; flex-shrink: 0;
  }
  .m-topbar .m-menu-btn span,
  .m-topbar .m-menu-btn span::before,
  .m-topbar .m-menu-btn span::after {
    display: block; width: 14px; height: 1.5px;
    background: var(--text-primary); position: relative;
  }
  .m-topbar .m-menu-btn span::before { content:""; position: absolute; left:0; top:-5px; width:14px; }
  .m-topbar .m-menu-btn span::after  { content:""; position: absolute; left:0; top: 5px; width:14px; }
  .m-topbar .m-top-cta {
    background: var(--accent-500); color: #fff;
    padding: 9px 14px; font-family: var(--font-mono);
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; border-radius: 6px; text-decoration: none;
    flex-shrink: 0; white-space: nowrap;
  }

  /* === ANCHOR TABS STICKY === */
  .m-tabs-wrap {
    position: sticky; top: 52px; z-index: 49;
    background: #fff; border-bottom: 1px solid var(--border);
  }
  .m-tabs-wrap::after {
    content: ""; position: absolute; top: 0; right: 0; bottom: 0;
    width: 28px; background: linear-gradient(to right, rgba(255,255,255,0), #fff 70%);
    pointer-events: none; z-index: 1;
  }
  .m-tabs {
    display: flex; gap: 0; overflow-x: auto;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .m-tabs::-webkit-scrollbar { display: none; }
  .m-tabs a {
    flex-shrink: 0; padding: 14px 16px;
    font-family: var(--font-mono); font-size: 11px; font-weight: 500;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
    text-decoration: none; border-bottom: 2px solid transparent;
  }
  .m-tabs a.active, .m-tabs a:hover {
    color: var(--text-primary); border-bottom-color: var(--accent-500);
  }

  /* === HERO COMPACTO === */
  .m-hero { padding: 28px 20px 24px; }
  .m-eyebrow {
    display: inline-block; font-family: var(--font-mono);
    font-size: 10px; color: var(--accent-500);
    text-transform: uppercase; letter-spacing: 0.1em;
    padding: 4px 8px; background: var(--accent-50);
    border-radius: 4px; margin-bottom: 16px;
  }
  .m-h1 {
    font-size: 36px; line-height: 1.05; letter-spacing: -0.03em;
    font-weight: 600; color: var(--text-primary); margin: 0 0 12px;
  }
  .m-h1 .accent { color: var(--accent-500); }
  .m-sub {
    font-size: 15px; line-height: 1.5; color: var(--text-body);
    margin: 0 0 20px;
  }
  .m-sub strong { color: var(--text-primary); font-weight: 600; }
  .m-cta-row { display: flex; gap: 8px; margin-bottom: 20px; }
  .m-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 16px; font-family: var(--font-mono);
    font-size: 12px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; border-radius: 8px; min-height: 44px;
    border: 1px solid var(--border); background: #fff;
    color: var(--text-primary); text-decoration: none;
  }
  .m-btn-primary {
    background: var(--accent-500); color: #fff;
    border-color: var(--accent-500); flex: 1;
  }
  .m-btn-secondary { color: var(--text-primary); }

  /* === MÉTRICAS INLINE === */
  .m-stats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 1px; background: var(--border);
    border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  }
  .m-stat { background: var(--gray-50); padding: 10px 8px; text-align: center; }
  .m-stat .v {
    font-size: 18px; font-weight: 600; color: var(--text-primary);
    letter-spacing: -0.02em; line-height: 1;
  }
  .m-stat .v .accent { color: var(--accent-500); }
  .m-stat .k {
    font-family: var(--font-mono); font-size: 9px;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.04em; margin-top: 4px; line-height: 1.2;
  }

  /* === SECCIÓN BASE === */
  .m-section {
    padding: 32px 20px; border-top: 1px solid var(--border);
  }
  .m-section-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 16px; gap: 12px;
  }
  .m-section-head h2 {
    font-size: 22px; line-height: 1.15; letter-spacing: -0.02em;
    font-weight: 600; color: var(--text-primary); margin: 0;
  }
  .m-section-head .more {
    font-family: var(--font-mono); font-size: 11px;
    color: var(--accent-500); text-transform: uppercase;
    letter-spacing: 0.04em; text-decoration: none; flex-shrink: 0;
  }

  /* === SERVICIOS · LIST VIEW con SVGs === */
  .m-services {
    background: var(--gray-50); border: 1px solid var(--border);
    border-radius: 12px; overflow: hidden;
  }
  .m-service-row {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 14px; background: #fff;
    border-bottom: 1px solid var(--border);
    cursor: pointer; text-decoration: none; color: inherit;
    transition: background 140ms;
  }
  .m-service-row:last-child { border-bottom: none; }
  .m-service-row:hover, .m-service-row:active { background: var(--gray-50); }
  .m-service-row .icon {
    width: 36px; height: 36px; border-radius: 8px;
    background: var(--gray-50); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; color: var(--text-primary);
    transition: background 140ms, color 140ms, border-color 140ms;
  }
  .m-service-row:hover .icon, .m-service-row:active .icon {
    background: var(--accent-50); border-color: var(--accent-300); color: var(--accent-700);
  }
  .m-service-row .icon svg { width: 18px; height: 18px; }
  .m-service-row .body { flex: 1; min-width: 0; }
  .m-service-row .body h3 {
    font-size: 14px; font-weight: 600; color: var(--text-primary);
    line-height: 1.2; margin: 0 0 2px;
  }
  .m-service-row .body p {
    font-size: 12px; color: var(--text-muted); line-height: 1.3; margin: 0;
  }
  .m-service-row .chev { color: var(--text-muted); font-size: 16px; flex-shrink: 0; }

  /* === CASOS · TABLA COMPACTA === */
  .m-cases { display: flex; flex-direction: column; gap: 8px; }
  .m-case-row {
    display: grid; grid-template-columns: 1fr auto; gap: 12px;
    padding: 14px; background: #fff; border: 1px solid var(--border);
    border-radius: 10px; text-decoration: none; color: inherit;
    align-items: center;
  }
  .m-case-row .left { min-width: 0; }
  .m-case-row .sector {
    font-family: var(--font-mono); font-size: 10px;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.06em; margin-bottom: 4px;
  }
  .m-case-row .title {
    font-size: 14px; font-weight: 500; color: var(--text-primary); line-height: 1.3;
  }
  .m-case-row .right { text-align: right; flex-shrink: 0; }
  .m-case-row .metric {
    font-size: 22px; font-weight: 600; color: var(--accent-500);
    letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums;
  }
  .m-case-row .label {
    font-family: var(--font-mono); font-size: 9px;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.04em; margin-top: 2px;
  }

  /* === PROCESO · TIMELINE === */
  .m-process { display: flex; flex-direction: column; gap: 12px; }
  .m-step {
    display: grid; grid-template-columns: 28px 1fr; gap: 12px;
    padding: 12px; background: var(--gray-50);
    border-radius: 8px; align-items: start;
  }
  .m-step .n {
    width: 28px; height: 28px; border-radius: 14px;
    background: #fff; border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-size: 11px; font-weight: 600;
    color: var(--text-primary);
  }
  .m-step.active .n {
    background: var(--accent-500); color: #fff; border-color: var(--accent-500);
  }
  .m-step .body h4 {
    font-size: 13px; font-weight: 600; color: var(--text-primary); margin: 0 0 2px;
  }
  .m-step .body .when {
    font-family: var(--font-mono); font-size: 10px;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.05em; margin-bottom: 4px;
  }
  .m-step .body p {
    font-size: 12px; line-height: 1.4; color: var(--text-body); margin: 0;
  }

  /* === FAQ ACORDEÓN === */
  .m-faq-item { border-bottom: 1px solid var(--border); }
  .m-faq-item:first-child { border-top: 1px solid var(--border); }
  .m-faq-item summary {
    padding: 14px 0; cursor: pointer;
    font-size: 14px; font-weight: 500; color: var(--text-primary);
    display: flex; justify-content: space-between; align-items: center;
    list-style: none;
  }
  .m-faq-item summary::-webkit-details-marker { display: none; }
  .m-faq-item summary::after {
    content: "+"; color: var(--text-muted); font-size: 18px;
    font-weight: 300; transition: transform 180ms;
  }
  .m-faq-item[open] summary::after { transform: rotate(45deg); }
  .m-faq-item p {
    padding: 0 0 14px; font-size: 13px; line-height: 1.55;
    color: var(--text-body); margin: 0;
  }

  /* === CTA FINAL === */
  .m-final {
    background: var(--accent-500); color: #fff;
    padding: 32px 20px; text-align: left;
  }
  .m-final h2 {
    font-size: 28px; line-height: 1.1; letter-spacing: -0.02em;
    color: #fff; margin: 0 0 8px; font-weight: 600;
  }
  .m-final p {
    font-size: 14px; opacity: 0.9; margin: 0 0 20px;
  }
  .m-final .m-btn-primary {
    background: #fff; color: var(--accent-700);
    border-color: #fff; width: 100%; padding: 14px;
  }

  /* === FOOTER MOBILE === */
  .m-footer-m {
    background: var(--gray-1000); color: var(--gray-400);
    padding: 24px 20px;
  }
  .m-footer-m .brand {
    font-size: 22px; color: #fff; font-weight: 600;
    letter-spacing: -0.02em; margin-bottom: 16px;
  }
  .m-footer-m .brand span { color: var(--accent-500); }
  .m-footer-m ul {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 8px;
  }
  .m-footer-m ul a { color: var(--gray-400); font-size: 13px; text-decoration: none; }
  .m-footer-m .meta {
    font-family: var(--font-mono); font-size: 10px;
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-top: 16px; padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
  }

  /* === MENU OVERLAY === */
  .m-overlay {
    position: fixed; inset: 0;
    background: var(--gray-1000); z-index: 200;
    padding: 24px; transform: translateY(-100%);
    transition: transform 240ms cubic-bezier(0.2,0,0,1);
    color: #fff; overflow-y: auto;
    display: block !important;
  }
  .m-overlay.open { transform: translateY(0); }
  .m-overlay-close {
    position: absolute; top: 16px; right: 16px;
    background: rgba(255,255,255,0.08); border: none; color: #fff;
    width: 36px; height: 36px; border-radius: 6px;
    font-size: 20px; cursor: pointer;
  }
  .m-overlay nav {
    display: flex; flex-direction: column; gap: 4px; margin-top: 56px;
  }
  .m-overlay nav a {
    color: #fff; font-size: 18px; font-weight: 500;
    padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,0.1);
    text-decoration: none;
  }
  .m-overlay nav a.cta { color: var(--accent-500); margin-top: 12px; }
  body.m-menu-open { overflow: hidden; }
}

/* En desktop, el overlay siempre oculto sin importar el estado */
@media (min-width: 641px) {
  .m-overlay { display: none !important; }
}
