/* SIC 2.0 - ajustes de visualizacion para telefonos y tabletas.
   No cambia consultas, estados, permisos ni comportamiento de formularios. */
@media (max-width: 992px) {
  html, body { max-width:100%; overflow-x:hidden; }
  body #res { min-width:0!important; max-width:100%!important; box-sizing:border-box!important; }
  body #res img, body #res video, body #res canvas { max-width:100%; height:auto; }
  body #res .row { min-width:0; }
  body #res .row > .col { min-width:0; }
  .vipg-topbar, .vipc-topbar { box-sizing:border-box; max-width:100%; }
  .vipg-topbar-left, .vipg-topbar-right, .vipc-top-left, .vipc-top-right { min-width:0; }
  .vip-gest { min-width:0!important; padding:16px!important; min-height:auto!important; }
  .vip-gest .header { padding:18px!important; }
  .vip-gest .chart-grid { grid-template-columns: minmax(0,1fr)!important; }
  .vip-gest .metrics { grid-template-columns:repeat(2,minmax(0,1fr))!important; }
  .vip-gest .pane { min-width:0; }
  .vip-gest .creategrid, .vip-gest #vip-create-form .creategrid { grid-template-columns: minmax(0,1fr)!important; }
  .vip-gest .vip-create-progress { grid-template-columns:repeat(2,minmax(0,1fr))!important; }
  .vip-gest #vip-create, .vip-gest #vip-bulk { width:100%!important; max-width:100%!important; box-sizing:border-box!important; padding:20px!important; }
  .vip-gest .vip-upload-form { align-items:stretch!important; }
  .vip-gest .vip-upload-form label { min-width:0!important; width:100%; }
  .vip-gest .tablewrap { max-width:100%; overflow-x:auto!important; -webkit-overflow-scrolling:touch; }
  .vip-gest .tablewrap table { min-width:680px; }
  .vip-e { max-width:100%!important; min-width:0!important; }
  .vip-e .etable { max-width:100%; overflow-x:auto!important; -webkit-overflow-scrolling:touch; }
  .vip-e .etable table { min-width:760px; }
  .vip-ent-overlay { padding:12px!important; }
  .vip-ent-dialog { width:100%!important; max-height:calc(100dvh - 24px)!important; height:auto!important; min-height:0!important; }
  .vip-ent-modal-content { max-height:calc(100dvh - 100px); overflow:auto!important; -webkit-overflow-scrolling:touch; }
  .vip-ent-overlay .vip-e { padding:0 8px!important; }
  .vip-ent-overlay .vip-e .egrid { grid-template-columns: repeat(12,minmax(0,1fr))!important; }
  .vip-ent-overlay .vip-e .egrid .half,.vip-ent-overlay .vip-e .egrid .third,.vip-ent-overlay .vip-e .egrid .quarter,.vip-ent-overlay .vip-e .egrid .small { grid-column:span 12!important; }
  .modal:not(.bottom-sheet) { max-width:calc(100vw - 24px)!important; max-height:calc(100dvh - 30px)!important; }
  .modal:not(.bottom-sheet) .modal-content { overflow-wrap:break-word; }
  .modal:not(.bottom-sheet) .modal-footer { height:auto; min-height:56px; }
  #res .responsive-table, #res .table-responsive, #res .dataTables_wrapper, #res .tablewrap { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
}
@media (max-width: 600px) {
  html { -webkit-text-size-adjust:100%; }
  body #res { margin:10px!important; }
  .vipg-topbar, .vipc-topbar { padding-left:10px!important; padding-right:10px!important; }
  .vipg-topbar .vipg-username-display, .vipc-user { display:none!important; }
  .vipc-saldo-restante { white-space:normal!important; line-height:1.2; max-width:115px; padding-right:5px!important; }
  .vipc-title { max-width:110px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
  .vipg-grid, .vipc-tiles { grid-template-columns:minmax(0,1fr)!important; }
  .vipc-hero-gestion, .vipc-mini-grid { grid-template-columns:minmax(0,1fr)!important; }
  .vipc-welcome { padding:18px!important; }
  .vip-gest { padding:10px!important; }
  .vip-gest .header { padding:16px!important; border-radius:14px!important; }
  .vip-gest .header h2 { font-size:23px!important; }
  .vip-gest .metrics { grid-template-columns:repeat(2,minmax(0,1fr))!important; gap:9px!important; }
  .vip-gest .tile { padding:13px!important; }
  .vip-gest .tile b { font-size:24px!important; }
  .vip-gest .pane { padding:14px!important; }
  .vip-gest .toolbar { align-items:stretch!important; }
  .vip-gest .toolbar > * { max-width:100%; }
  .vip-gest .actions { gap:8px!important; }
  .vip-gest .actions button,.vip-gest .actions a { justify-content:center; }
  .vip-gest #vip-create,.vip-gest #vip-bulk { margin:12px auto!important; padding:15px!important; border-radius:14px!important; }
  .vip-gest .vip-section-intro { gap:10px!important; }
  .vip-gest .vip-section-icon { width:39px!important; flex-basis:39px!important; height:39px!important; }
  .vip-gest .vip-section-intro h3 { font-size:19px!important; }
  .vip-gest .vip-create-progress { grid-template-columns:minmax(0,1fr)!important; }
  .vip-gest .bar-row { grid-template-columns:minmax(0,1fr)!important; }
  .vip-gest .ring-wrap { gap:14px!important; }
  .vip-gest .ring { margin:auto; }
  .vip-e { margin:12px auto!important; padding:0 4px!important; }
  .vip-e h2 { font-size:22px!important; }
  .vip-e .epanel { padding:14px!important; }
  .vip-e .efield { min-width:0!important; width:100%; flex-basis:100%; }
  .vip-e .filters { align-items:stretch!important; }
  .vip-e .vip-status-cards { grid-template-columns:minmax(0,1fr)!important; gap:9px!important; }
  .vip-e .vip-status-card { min-height:90px!important; }
  .vip-e .foot { align-items:stretch!important; }
  .vip-ent-overlay { padding:5px!important; }
  .vip-ent-dialog { border-radius:12px!important; max-height:calc(100dvh - 10px)!important; }
  .vip-ent-modal-top { padding:9px 12px!important; }
  .vip-ent-modal-content { max-height:calc(100dvh - 68px)!important; }
  .vip-ent-overlay .vip-e .epanel { padding:12px!important; }
  .vip-e .actions { justify-content:stretch!important; }
  .vip-ent-overlay .vip-e .actions .btn-vip { flex:1; justify-content:center; }
  .modal:not(.bottom-sheet) { width:calc(100vw - 12px)!important; max-width:calc(100vw - 12px)!important; top:6px!important; }
  .modal:not(.bottom-sheet) .modal-content { padding:14px!important; }
  .modal:not(.bottom-sheet) .modal-footer { padding:6px!important; }
  #res input:not([type=checkbox]):not([type=radio]),#res textarea,#res select { max-width:100%; box-sizing:border-box; }
  #res input[type=file] { max-width:100%; }
}
@media (max-width: 360px) {
  .vip-gest .metrics { grid-template-columns:minmax(0,1fr)!important; }
  .vipc-title { display:none!important; }
}

/* SIC 2.0 | Menu lateral movil: el overlay de Materialize se crea en body
   y quedaba por encima del header (z-index:9), bloqueando los toques. */
@media (max-width: 992px) {
  body > header { position: relative !important; z-index: 1000 !important; }
  body > header #slide-out.sidenav {
    z-index: 1002 !important;
    pointer-events: auto !important;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }
  body > .sidenav-overlay, .sidenav-overlay { z-index: 997 !important; }
  body > header #slide-out a,
  body > header #slide-out .collapsible-header { pointer-events: auto !important; }
}

/* SIC 2.0: ajustes puntuales de Entidades, Sesiones y menu administrativo en telefono.
   Mantiene visibles las columnas y evita superponer los filtros. */
@media (max-width: 767px) {
  /* Entidades: los tres controles deben disponer de su propia fila/espacio. */
  #vip-entidades .filters {
    display:grid!important;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;
    gap:14px 12px!important;
    align-items:stretch!important;
  }
  #vip-entidades .filters > div {
    display:flex!important;
    flex-direction:column!important;
    min-width:0!important;
    width:100%!important;
    max-width:100%!important;
    margin:0!important;
  }
  #vip-entidades .filters > div:first-child {grid-column:1 / -1!important;}
  #vip-entidades .filters label {
    position:static!important;
    display:block!important;
    width:auto!important;
    height:auto!important;
    padding:0!important;
    margin:0 0 7px!important;
    transform:none!important;
    line-height:1.4!important;
    white-space:normal!important;
    font-size:12px!important;
    pointer-events:auto!important;
  }
  #vip-entidades .filters input,
  #vip-entidades .filters select.browser-default {
    display:block!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    height:44px!important;
    margin:0!important;
    box-sizing:border-box!important;
  }
  /* Las tablas con varias metricas se desplazan horizontalmente, no se aplastan. */
  #vip-entidades .etable {width:100%!important;max-width:100%!important;overflow-x:auto!important;overflow-y:hidden!important;-webkit-overflow-scrolling:touch!important;touch-action:pan-x pan-y;}
  #vip-entidades .etable table {width:max-content!important;min-width:940px!important;table-layout:auto!important;}
  #vip-entidades .etable th,
  #vip-entidades .etable td {white-space:nowrap!important;vertical-align:middle!important;}
  #vip-entidades .etable th:first-child,
  #vip-entidades .etable td:first-child {white-space:normal!important;min-width:240px!important;width:240px!important;line-height:1.5!important;}
  #vip-entidades .etable th:nth-child(2),
  #vip-entidades .etable td:nth-child(2) {min-width:130px!important;}
  #vip-entidades .etable .vip-e-col-num {min-width:115px!important;text-align:center!important;}
  #vip-entidades .etable .vip-e-metric {white-space:nowrap!important;display:inline-flex!important;align-items:center!important;gap:4px!important;}
  /* Sesiones: cabecera apilada y tabla legible con scroll propio. */
  #vip-sesiones {width:100%!important;max-width:100%!important;min-width:0!important;margin:12px auto 24px!important;}
  #vip-sesiones .vip-ses-header {display:flex!important;flex-direction:column!important;align-items:stretch!important;gap:14px!important;}
  #vip-sesiones .vip-ses-header h2 {font-size:22px!important;line-height:1.25!important;overflow-wrap:break-word;}
  #vip-sesiones .vip-ses-box {min-width:0!important;max-width:100%!important;padding:14px!important;}
  #vip-sesiones .vip-ses-headrow {align-items:stretch!important;gap:12px!important;}
  #vip-sesiones .vip-ses-headrow > label {width:100%!important;min-width:0!important;}
  #vip-sesiones .vip-ses-headrow input {max-width:100%!important;}
  #vip-sesiones .vip-ses-scroll {display:block!important;width:100%!important;max-width:100%!important;overflow-x:auto!important;-webkit-overflow-scrolling:touch!important;touch-action:pan-x pan-y;}
  #vip-sesiones .vip-ses-scroll table {min-width:650px!important;width:650px!important;table-layout:auto!important;}
  #vip-sesiones .vip-ses-scroll th,
  #vip-sesiones .vip-ses-scroll td {white-space:nowrap!important;min-width:100px!important;}
  #vip-sesiones .vip-ses-scroll th:nth-child(3),
  #vip-sesiones .vip-ses-scroll td:nth-child(3) {min-width:155px!important;}
  #vip-sesiones .vip-ses-scroll th:nth-child(4),
  #vip-sesiones .vip-ses-scroll td:nth-child(4) {min-width:130px!important;}
  /* Menu: se puede recorrer incluso con varias secciones desplegadas. */
  body > header #slide-out.sidenav {height:100dvh!important;max-height:100dvh!important;overflow-y:auto!important;overscroll-behavior:contain;}
  body > header #slide-out .collapsible-body {overflow:visible;}
  body > header #slide-out .collapsible-header,
  body > header #slide-out .collapsible-body a {min-height:42px;line-height:1.35;}
}
@media (max-width: 380px) {
  #vip-entidades .filters {grid-template-columns:minmax(0,1fr)!important;}
  #vip-entidades .filters > div:first-child {grid-column:1!important;}
}
@media (max-width:767px) {
  #vip-entidades .etable::before,
  #vip-sesiones .vip-ses-scroll::before {
    content:'Desliza la tabla hacia los lados para ver todas las columnas';
    display:block;
    width:max-content;
    max-width:100%;
    padding:0 0 9px;
    font-size:11px;
    line-height:1.35;
    color:#68809e;
    font-weight:600;
  }
}
