/* ============================================================
   Interfaz móvil: barra superior con logo, menú inferior y
   tarjetas de indicadores. Solo se activa en pantallas de
   768px o menos; en computador todo queda igual.
   Colores: los define /movil/marca.js (MOVIL_COLOR / MOVIL_COLOR_OSCURO).
   ============================================================ */
.m-top, .m-nav, .m-sheet, .m-resumen { display: none; }

@media (max-width: 768px) {
  body.m-app {
    --m-color: #29ABE2;
    --m-oscuro: #0B5A82;
    --m-fondo: #F3F5F8;
    --m-texto: #0F1E2E;
    --m-suave: #5B6675;
    --m-top-h: 64px;
    --m-nav-h: 68px;
    background: var(--m-fondo);
    padding-top: calc(var(--m-top-h) + env(safe-area-inset-top));
    padding-bottom: calc(var(--m-nav-h) + env(safe-area-inset-bottom));
    -webkit-tap-highlight-color: transparent;
  }
  body.m-app .sidebar { display: none !important; }
  body.m-app .layout { display: block; min-height: 0; }
  body.m-app .main { padding: 16px !important; }

  /* ---------- Barra superior ---------- */
  .m-top {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    position: fixed; top: 0; left: 0; right: 0; z-index: 900;
    height: calc(var(--m-top-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 16px 0;
    background: var(--m-oscuro);
    border-bottom: 3px solid var(--m-color);
    text-decoration: none;
  }
  .m-top img { max-height: 38px; max-width: 70vw; object-fit: contain; display: block; }
  .m-top img.m-icono { height: 36px; width: 36px; border-radius: 50%; background: #fff; }
  .m-top img.m-blanco { filter: brightness(0) invert(1); }
  .m-top span {
    color: #fff; font-size: 22px; font-weight: 800; letter-spacing: .5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* ---------- Menú inferior ---------- */
  .m-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    height: calc(var(--m-nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--m-oscuro);
    box-shadow: 0 -2px 12px rgba(0,0,0,.12);
  }
  .m-nav a, .m-nav button {
    flex: 1 1 0; min-width: 0; position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: 0; padding: 6px 2px 0; margin: 0; cursor: pointer;
    color: rgba(255,255,255,.72); font: inherit; font-size: 11.5px; font-weight: 600;
    text-decoration: none;
  }
  .m-nav .m-ico { font-size: 22px; line-height: 1; }
  .m-nav .m-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .m-nav .activo { color: #fff; }
  .m-nav .activo::before {
    content: ""; position: absolute; top: 0; left: 10%; right: 10%; height: 3px;
    background: var(--m-color); border-radius: 0 0 3px 3px;
  }
  .m-nav .m-punto {
    position: absolute; top: 4px; left: calc(50% + 8px);
    min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
    background: #EF4444; color: #fff; font-size: 10.5px; line-height: 17px; text-align: center;
  }
  body.m-chat .m-nav { display: none; }
  body.m-chat { padding-bottom: 0; }
  body.m-chat .chat-wrap { height: calc(100dvh - var(--m-top-h) - env(safe-area-inset-top)) !important; }

  /* ---------- Hoja "Más" ---------- */
  .m-sheet { display: block; position: fixed; inset: 0; z-index: 1000; visibility: hidden; }
  .m-sheet.abierta { visibility: visible; }
  .m-sheet .m-velo { position: absolute; inset: 0; background: rgba(15,30,46,.45); opacity: 0; transition: opacity .2s; }
  .m-sheet.abierta .m-velo { opacity: 1; }
  .m-sheet .m-panel {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: #fff; border-radius: 18px 18px 0 0;
    padding: 10px 12px calc(16px + env(safe-area-inset-bottom));
    transform: translateY(100%); transition: transform .22s ease-out;
  }
  .m-sheet.abierta .m-panel { transform: none; }
  .m-sheet .m-asa { width: 40px; height: 4px; border-radius: 2px; background: #D5DAE1; margin: 2px auto 10px; }
  .m-sheet a {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 12px; border-radius: 12px;
    color: var(--m-texto); font-size: 16px; font-weight: 600; text-decoration: none;
  }
  .m-sheet a:active, .m-sheet a.activo { background: #EEF4FA; }
  .m-sheet a .m-ico { font-size: 22px; width: 28px; text-align: center; }
  .m-sheet a.m-salir { color: #B91C1C; }

  /* ---------- Tarjetas de indicadores ---------- */
  .m-resumen { display: block; margin-bottom: 8px; }
  body.m-app .m-oculto { display: none !important; }
  body.m-dash-ok .main > .topbar h2 { display: none; }
  body.m-dash-ok .main > .topbar { margin-bottom: 10px; color: var(--m-suave); font-size: 14px; }
  .m-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
  .m-card {
    display: block; background: #fff; border-radius: 16px; padding: 18px 16px;
    box-shadow: 0 1px 3px rgba(15,30,46,.06); color: var(--m-texto); text-decoration: none;
  }
  .m-num {
    font-size: 30px; font-weight: 800; line-height: 1.1; color: var(--m-oscuro);
    font-variant-numeric: tabular-nums; letter-spacing: -.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .m-card.dinero .m-num { font-size: 22px; }
  .m-lbl { margin-top: 6px; font-size: 14px; color: var(--m-suave); line-height: 1.3; }
  .m-card.alerta .m-num { color: #B91C1C; }
  .m-hero {
    background: var(--m-oscuro); color: #fff; border-radius: 16px; padding: 20px 18px;
    border-top: 5px solid var(--m-color); margin: 4px 0 22px;
    box-shadow: 0 6px 18px rgba(15,30,46,.18);
  }
  .m-hero .m-num { color: #fff; font-size: 32px; }
  .m-hero .m-lbl { color: rgba(255,255,255,.88); font-size: 15px; }
  .m-sec { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 800; color: var(--m-texto); margin: 6px 0 12px; }


  /* ---------- Tablas como tarjetas (con el nombre de cada columna) ---------- */
  body.m-app .card:has(> table.m-tabla), body.m-app .card:has(> div > table.m-tabla) { background: transparent; box-shadow: none; padding: 0; }
  body.m-app table.m-tabla, body.m-app .m-tabla tbody, body.m-app .m-tabla tr, body.m-app .m-tabla td { display: block; width: 100%; }
  body.m-app table.m-tabla { background: transparent; border-radius: 0; overflow: visible; box-shadow: none; }
  body.m-app .m-tabla thead, body.m-app .m-tabla tr:has(> th) { display: none; }
  body.m-app .m-tabla tr {
    background: #fff; border-radius: 14px; margin: 0 0 12px; padding: 12px 16px;
    box-shadow: 0 1px 3px rgba(15,30,46,.07);
  }
  body.m-app .m-tabla td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border: none; padding: 6px 0; font-size: 14px; text-align: right;
    overflow-wrap: anywhere;
  }
  body.m-app .m-tabla td[data-label]::before {
    content: attr(data-label); flex: 0 0 34%; text-align: left;
    color: var(--m-suave); font-size: 12.5px; font-weight: 600;
  }
  body.m-app .m-tabla td:first-child {
    display: block; text-align: left; font-size: 16px; font-weight: 800; color: var(--m-oscuro);
    padding: 0 0 8px; margin-bottom: 4px; border-bottom: 1px solid #EEF1F5;
  }
  body.m-app .m-tabla td:first-child::before { display: none; }
  body.m-app .m-tabla td:empty { display: none; }
  body.m-app .m-tabla td.m-acciones { justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding-top: 10px; }
  body.m-app .m-tabla td.m-acciones::before { display: none; }
  body.m-app .m-tabla td.m-acciones .btn, body.m-app .m-tabla td.m-acciones button { padding: 10px 14px; font-size: 14px; border-radius: 10px; }
  body.m-app .m-tabla td.m-acciones form { display: inline; margin: 0; }

  /* Filtros (Todos / Abiertos / …) y títulos */
  body.m-app .main h1, body.m-app .main h2 { font-size: 22px; }

  /* Tarjetas viejas del sistema (otras pantallas) con el mismo estilo */
  body.m-app .grid-cards .card { border-radius: 16px; }
  body.m-app .stat-num { font-weight: 800; color: var(--m-oscuro); }

  /* Tablas sin <thead>: oculta la fila de títulos en la vista de tarjetas */
  body.m-app table tr:has(> th) { display: none; }

  /* Botones y enlaces con el color de la marca */
  body.m-app .btn:not(.secondary):not(.danger):not(.success) { background: var(--m-color); }
}
