/* ============================================================
   sitePMO · v6.3 — Navegación tipo app en celulares (≤ 760 px)
   En escritorio no cambia nada: todo lo de aquí está dentro de
   media queries o en elementos que solo existen en móvil.
   ============================================================ */
.m-tabbar, .m-sheet, .m-menu-btn { display: none; }
.pwa-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 950; display: flex; align-items: center; gap: 10px;
  max-width: calc(100vw - 24px); width: max-content; background: #1f2630; color: #fff; font: 13px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  padding: 10px 10px 10px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.28); }
.pwa-bar-t b { color: #fff; }
.pwa-bar-a { border: 0; background: #fff; color: #1f2630; font: 700 13px/1 inherit; padding: 9px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.pwa-bar-x { border: 0; background: none; color: #c9d1da; font-size: 20px; line-height: 1; cursor: pointer; padding: 4px 6px; }
[data-pwa-install][hidden] { display: none !important; }

@media (max-width: 760px) {
  html, body { overscroll-behavior-y: none; }
  body { -webkit-tap-highlight-color: transparent; }
  .window { height: 100vh; height: 100dvh; }
  .content-pad { padding: 14px 14px 28px; }
  .statusbar { display: none; }

  /* ---------- barra superior compacta ---------- */
  .titlebar { height: calc(50px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 12px 0; background: var(--chrome); }
  .titlebar .title-center { position: static; justify-content: flex-start; font-size: 14px; pointer-events: auto; flex: 1; min-width: 0; }
  .titlebar .title-center .app-logo { height: 22px; max-width: 130px; }
  .titlebar .title-center .dim { display: none; }
  .titlebar .title-center .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .titlebar .tb-right { gap: 6px; }
  .titlebar .tb-right .tb-ico-btn, .titlebar .tb-right > .btn, .titlebar .tb-right > span.btn { display: none; }
  .titlebar .user-chip { padding: 2px; }
  .titlebar .user-chip b { display: none; }
  .titlebar .user-av { width: 32px; height: 32px; }

  /* ---------- PORTAL: barra inferior de pestañas ---------- */
  body.is-portal .menubar { display: none; }
  body.is-portal .m-tabbar { display: flex; flex: 0 0 auto; align-items: stretch; background: var(--card); border-top: 1px solid var(--line);
    padding: 0 4px env(safe-area-inset-bottom, 0px); box-shadow: 0 -2px 12px rgba(20,28,40,.06); z-index: 40; }
  .m-tab { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 58px;
    color: var(--ink-3); text-decoration: none; font: 600 10.5px/1.1 var(--ui); border: 0; background: none; cursor: pointer; padding: 0 2px; }
  .m-tab svg { width: 23px; height: 23px; }
  .m-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-tab.on { color: var(--accent-d); }
  .m-tab.on svg { color: var(--accent); }
  .m-tab:active { transform: scale(.94); }
  body.is-portal .demo-bar { font-size: 11px !important; padding: 5px 12px !important; }
  body.is-portal .demo-bar > span:nth-child(2) { flex-basis: 100%; order: 3; }
  body.is-portal .bill-bar { font-size: 11.5px; }

  /* hoja «Más» */
  .m-sheet { display: block; position: fixed; inset: 0; z-index: 800; background: rgba(15,22,32,.45); opacity: 0; pointer-events: none; transition: opacity .18s; }
  .m-sheet.on { opacity: 1; pointer-events: auto; }
  .m-sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; background: var(--card); border-radius: 18px 18px 0 0; padding: 8px 10px calc(12px + env(safe-area-inset-bottom, 0px));
    max-height: 82vh; overflow-y: auto; transform: translateY(100%); transition: transform .22s ease; box-shadow: 0 -10px 30px rgba(0,0,0,.18); }
  .m-sheet.on .m-sheet-panel { transform: none; }
  .m-sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
  .m-sheet-user { display: flex; align-items: center; gap: 12px; padding: 6px 10px 12px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
  .m-sheet-user .user-av { width: 40px; height: 40px; font-size: 16px; }
  .m-sheet-user b { display: block; font-size: 15px; }
  .m-sheet-user small { color: var(--ink-3); font-size: 12px; }
  .m-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 50px; padding: 0 12px; border: 0; background: none; border-radius: 10px;
    color: var(--ink); text-decoration: none; font: 500 15px/1.2 var(--ui); cursor: pointer; text-align: left; }
  .m-item svg { width: 21px; height: 21px; color: var(--ink-2); flex: none; }
  .m-item.on { background: var(--accent-soft); color: var(--accent-d); font-weight: 700; }
  .m-item.on svg { color: var(--accent); }
  .m-item:active { background: var(--panel-2); }
  .m-item.danger { color: var(--danger); } .m-item.danger svg { color: var(--danger); }
  .m-sep { height: 1px; background: var(--line-soft); margin: 6px 4px; }
  body.sheet-open { overflow: hidden; }

  /* el asistente y los avisos flotan por encima de la barra inferior */
  body.is-portal .spai-fab { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); right: 14px; width: 50px; height: 50px; padding: 0; justify-content: center; border-radius: 16px; }
  body.is-portal .spai-fab span { display: none; }
  body.is-portal .pwa-bar { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  body.is-portal .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important; }

  /* modales como hoja inferior */
  .modal-bg { align-items: flex-end !important; }
  .modal-bg .modal { width: 100% !important; max-width: 100% !important; border-radius: 16px 16px 0 0 !important; max-height: 92vh; overflow-y: auto; }

  /* ---------- ADMIN: menú lateral como cajón ---------- */
  body.is-admin .m-menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 0; background: none; border-radius: 10px; color: var(--ink); cursor: pointer; margin-right: 4px; }
  body.is-admin .m-menu-btn svg { width: 22px; height: 22px; }
  body.is-admin .titlebar .tb-left { display: flex; }
  body.is-admin .rail { position: fixed; top: 0; bottom: 0; left: 0; width: 272px; z-index: 900; transform: translateX(-102%); transition: transform .22s ease;
    padding-top: calc(10px + env(safe-area-inset-top, 0px)); box-shadow: 10px 0 30px rgba(0,0,0,.2); }
  body.is-admin.rail-open .rail { transform: none; }
  body.is-admin .rail-item { min-height: 44px; font-size: 14.5px; }
  body.is-admin::after { content: ''; position: fixed; inset: 0; background: rgba(15,22,32,.4); z-index: 890; opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.is-admin.rail-open::after { opacity: 1; pointer-events: auto; }
  body.is-admin .spai-fab { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
  body.is-admin .panel table { display: block; overflow-x: auto; }

  /* ajustes de contenido del portal */
  body.is-portal .section-head { flex-wrap: wrap; row-gap: 8px; }
  body.is-portal .section-head input { flex: 1 1 160px; width: auto !important; }
  body.is-portal .card.pad > div:first-child { flex-wrap: wrap; row-gap: 6px; }
  body.is-portal .card .btn.sm span { display: none; }
  body.is-portal .card .btn.sm { padding: 0 9px; }

  /* v6.5: lista de proyectos como filas apiladas (sin tabla ancha) */
  body.is-portal .proj-table thead { display: none; }
  body.is-portal .proj-table tbody tr { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; padding: 10px 2px; border-bottom: 1px solid var(--line-soft); }
  body.is-portal .proj-table tbody td { border: 0; padding: 0; }
  body.is-portal .proj-table td.pt-name { flex: 1 1 100%; margin-bottom: 4px; font-size: 14.5px; }
  body.is-portal .proj-table td.pt-dim { font-size: 12px; }
  body.is-portal .proj-table td.pt-actions { flex: 1 1 100%; text-align: left; white-space: normal; margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
  body.is-portal .proj-table td.pt-actions .btn { margin: 0; }
  body.is-portal .proj-table td .badge { font-size: 10px; }

  /* ---------- EDITOR ---------- */
  body.is-app .titlebar .title-center .app-ico { display: none; }
  body.is-app .titlebar .dirty { display: none; }
  body.is-app .titlebar .title-center { justify-content: center; }
  body.is-app .spai-fab { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}

/* app instalada: respeta las zonas seguras del teléfono también en pantallas grandes */
.pwa-standalone .statusbar { padding-bottom: env(safe-area-inset-bottom, 0px); height: calc(var(--status-h) + env(safe-area-inset-bottom, 0px)); }
