/* GM Admin mobile v3 — fixes actual overflow from .gm-billing-table-wrap.
 * Intentionally scoped to the admin. No changes to billing/auth logic. */
:root { color-scheme: light; }
html, body { width:100%; min-width:0; max-width:100%; margin:0; }
.app-shell, .main-content, .module-panel, .gm-plan-management,
.gm-pix-panel, .gm-billing-table-wrap, .table-wrap {
  min-inline-size:0;
  max-inline-size:100%;
}
.gm-billing-table-wrap {
  width:100%;
  overflow-x:auto;
  overflow-y:hidden;
  overscroll-behavior-inline:contain;
  -webkit-overflow-scrolling:touch;
  border-radius:12px;
  margin-block:12px 16px;
}
.gm-billing-table-wrap > .gm-billing-table {width:100%}
.gm-plan-management {width:100%;box-sizing:border-box}
.gm-plan-editor :is(input,select,textarea),.gm-pix-form :is(input,select,textarea) {
  max-width:100%;
  min-width:0;
}
.gm-billing-actions :is(button,select),
.gm-trial-controls :is(button,select) {touch-action:manipulation}
#assinaturas, #financeiro, #whatsapp, #seguranca {scroll-margin-top:84px}

/* Wide screens keep semantic tables; only their own container scrolls. */
@media(max-width:1300px){
  .gm-billing-table-wrap,.table-wrap {max-width:100%;width:100%;overflow-x:auto}
}

/* At tablet/mobile widths, financial tables become full-width readable cards.
   JavaScript supplies real column names as data-mobile-label, including after refetch. */
@media(max-width:1024px){
  html {overflow-x:clip}
  body {overflow-x:clip}
  .admin-mobile-top {width:100%;max-width:100%;box-sizing:border-box}
  .app-shell,.main-content {width:100%!important;max-width:100%!important;min-width:0!important}
  .app-shell > .main-content {box-sizing:border-box}
  .main-content > :is(section,div,header,footer) {min-width:0;max-width:100%}
  .module-panel,.products-panel,.lower-grid>.panel,.gm-plan-management,
  .gm-pix-panel,.gm-billing-header,.finance-product-grid,.security-grid {
    min-width:0;
    width:auto;
    max-width:100%;
    box-sizing:border-box;
  }
  .gm-billing-header{gap:12px;flex-wrap:wrap}
  .gm-billing-header>div{flex:1 1 220px;min-width:0}
  .gm-billing-header .gm-billing-price{flex:0 1 auto;white-space:normal}
  .gm-billing-table-wrap,
  #assinaturas > .table-wrap,
  #pix-charges > .table-wrap,
  #financeiro .gm-pix-panel > .table-wrap {
    overflow:visible!important;
    width:100%;
    max-width:100%;
    margin-block:12px 16px;
    border:0;
    background:transparent;
  }
  .gm-billing-table-wrap > .gm-billing-table,
  .table-wrap > table.gm-billing-table,
  table.gm-billing-table {
    display:block!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    margin:0!important;
    border-collapse:separate;
  }
  table.gm-billing-table thead {display:none!important}
  table.gm-billing-table tbody {
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr));
    align-items:stretch;
    gap:12px;
    width:100%;
    min-width:0;
  }
  table.gm-billing-table tbody tr {
    display:block!important;
    min-width:0;
    width:100%;
    padding:15px;
    border:1px solid #e5e9f1;
    border-radius:13px;
    background:#fff;
    box-shadow:0 4px 15px #1026490c;
    box-sizing:border-box;
  }
  table.gm-billing-table tbody td {
    display:block!important;
    width:100%!important;
    min-width:0;
    box-sizing:border-box;
    padding:9px 0!important;
    border-top:0!important;
    border-bottom:1px solid #eef1f6;
    font-size:14px;
    line-height:1.6;
    white-space:normal;
    overflow-wrap:anywhere;
    color:#43506a;
    vertical-align:top;
  }
  table.gm-billing-table tbody td:first-child {padding-top:0!important}
  table.gm-billing-table tbody td:last-child {border-bottom:0;padding-bottom:0!important}
  table.gm-billing-table tbody td:not([colspan])::before {
    content:attr(data-mobile-label);
    display:block;
    font:800 10px/1.5 'DM Sans',sans-serif;
    letter-spacing:.7px;
    text-transform:uppercase;
    color:#71809c;
    margin-bottom:4px;
  }
  table.gm-billing-table tbody td[colspan]::before {display:none}
  table.gm-billing-table tbody td strong {display:block;font-size:15px;color:#182945;line-height:1.45}
  table.gm-billing-table tbody td small {display:block;font-size:12px;line-height:1.5;color:#647189;margin-top:4px}
  table.gm-billing-table tbody td .gm-id {font-size:11px;overflow-wrap:anywhere}
  table.gm-billing-table tbody td :is(select,input:not([type="checkbox"]),textarea) {
    display:block;
    width:100%;
    max-width:100%!important;
    min-width:0;
    min-height:46px;
    padding:10px 12px;
    border:1px solid #d5dbeb;
    border-radius:9px;
    background:#fff;
    color:#203452;
    font:500 16px/1.4 'DM Sans',sans-serif;
    box-sizing:border-box;
  }
  table.gm-billing-table tbody td .gm-billing-actions {
    display:flex;
    flex-wrap:wrap;
    flex-direction:column;
    align-items:stretch;
    gap:8px;
    width:100%;
    margin-top:10px;
  }
  table.gm-billing-table tbody td :is(button,.row-action) {
    min-height:44px;
    min-width:0;
    max-width:100%;
    border-radius:9px;
    padding:10px 14px;
    font:700 13px/1.4 'DM Sans',sans-serif;
    overflow-wrap:anywhere;
    white-space:normal;
    touch-action:manipulation;
    cursor:pointer;
  }
  table.gm-billing-table tbody td .gm-billing-actions button {width:100%;margin:0}
  table.gm-billing-table tbody td .gm-trial-controls {
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    width:100%;
    gap:8px;
    align-items:stretch;
    margin-top:8px;
  }
  table.gm-billing-table tbody td .gm-trial-controls select {grid-column:1/-1}
  table.gm-billing-table tbody td .gm-trial-controls button {width:100%}
  .gm-plan-editor {min-width:0;max-width:100%}
  .gm-plan-editor > label{font-size:13px;line-height:1.45;min-width:0}
  .gm-plan-editor :is(input:not([type="checkbox"]),select,textarea) {
    display:block;
    width:100%!important;
    min-width:0;
    min-height:46px;
    max-width:100%;
    border:1px solid #d6dceb;
    border-radius:9px;
    padding:10px 12px;
    background:#fff;
    color:#1e2b45;
    font:500 16px 'DM Sans',sans-serif;
  }
  .gm-plan-editor .gm-plan-toggle{font-size:13px;gap:10px}
  .gm-plan-editor .gm-plan-toggle input{width:20px;height:20px;flex:none}
  .gm-plan-editor-actions{min-width:0;display:flex;flex-wrap:wrap;gap:10px}
  .gm-plan-editor-actions button, #rotas-billing-refresh {
    min-height:46px;
    padding:10px 15px;
    border:1px solid #d5d7f5;
    border-radius:9px;
    background:#f1efff;
    color:#4738aa;
    font:700 13px 'DM Sans',sans-serif;
  }
  .gm-plan-editor-actions button[type="submit"]{background:#7057ef;color:white}
  .gm-billing-actions > button {min-height:44px}
  #financeiro .gm-pix-form {min-width:0}
  #financeiro .gm-pix-form label {font-size:13px;line-height:1.45}
  #financeiro .gm-pix-form :is(input:not([type="checkbox"]),select,textarea){
    min-height:46px;width:100%;max-width:100%;font-size:16px;
  }
  #financeiro .gm-pix-form button {min-height:46px;font-size:14px}
  .gm-feedback, .module-placeholder, .module-placeholder p{font-size:12px;line-height:1.6}
  #financeiro [hidden],#assinaturas [hidden]{display:none!important}
  .panel-heading p,.gm-billing-header p,.gm-pix-panel p{font-size:13px;line-height:1.6}
  .panel-heading h2 {font-size:20px;line-height:1.3}
  .welcome p,.quick-panel p {font-size:13px;line-height:1.6}
  .quick-panel li {font-size:12px;line-height:1.7}
  .pending-pill {font-size:11px}
  .gm-card {width:min(100%,420px);max-height:calc(100dvh - 32px);overflow-y:auto;padding:clamp(18px,5vw,28px)}
  .gm-card label{font-size:13px}
  .gm-card input{min-height:46px;font-size:16px}
  .gm-card p{font-size:13px}
  .gm-card button{min-height:46px;font-size:14px}
}
@media(max-width:720px){
  .main-content {padding-inline:12px!important}
  .stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .stat-card{min-width:0;padding:14px}
  .stat-top{font-size:11px}
  .stat-card>strong{font-size:clamp(20px,6vw,27px)}
  .stat-card>small{font-size:11px;line-height:1.5}
  table.gm-billing-table tbody {grid-template-columns:minmax(0,1fr)!important;gap:10px}
  table.gm-billing-table tbody tr {padding:15px}
  .gm-plan-management {padding:14px 12px}
  .gm-plan-editor{grid-template-columns:minmax(0,1fr)!important;gap:13px}
  .gm-plan-editor .gm-plan-description{grid-column:auto}
  .gm-plan-editor-actions{flex-direction:row;align-items:stretch}
  .gm-plan-editor-actions button {flex:1 1 120px}
  .gm-pix-panel{padding:16px 12px}
  .gm-pix-form{grid-template-columns:minmax(0,1fr)!important}
  .panel-heading{gap:12px}
  .panel-heading .integration-state{font-size:11px}
  .admin-mobile-top {padding-inline:12px}
  .admin-mobile-home{font-size:13px}
  .product-tabs{grid-template-columns:repeat(2,minmax(0,1fr))}
  .product-tab {font-size:12px;min-height:48px}
  .product-tab>span:nth-child(2){font-size:12px}
  .gm-feedback{overflow-wrap:anywhere}
}
@media(max-width:390px){
  .main-content{padding-inline:10px!important}
  .module-panel,.products-panel,.lower-grid>.panel{padding:14px 11px}
  .gm-billing-header{padding:14px}
  table.gm-billing-table tbody tr{padding:13px}
  .gm-trial-controls button{font-size:12px!important}
}
@media(prefers-reduced-motion:reduce){
  table.gm-billing-table tbody tr {transition:none}
}

/* Remaining customer, summary and QR confirmation panels. */
@media(max-width:1024px){
  .finance-product-grid article,.security-grid article{padding:15px;min-width:0}
  .finance-product-grid b,.security-grid b{font-size:14px;line-height:1.4}
  .finance-product-grid small,.security-grid small{font-size:12px;line-height:1.5}
  .finance-product-grid span,.security-grid span{font-size:12px;line-height:1.6}
  .lower-grid .product-row b{font-size:13px}
  .lower-grid .product-row small{font-size:11px;line-height:1.5}
  .lower-grid .product-open{font-size:12px;min-height:44px;white-space:normal}
  .product-status{font-size:11px;line-height:1.4}
  .date-chip,.table-footer,.integration-state{font-size:11px;line-height:1.5}
  .gm-pix-panel h3{font-size:17px;line-height:1.4}
  .gm-pix-form .gm-pix-toggle{font-size:13px}
  .topbar .crumb,.topbar b{font-size:12px}
  #gm-billing-qr-dialog{max-width:100%;overflow-y:auto;overscroll-behavior:contain}
  #gm-billing-qr-dialog>div{
    box-sizing:border-box;
    min-width:0;
    max-width:min(480px,100%)!important;
    max-height:calc(100dvh - 30px);
    overflow-y:auto;
    overflow-wrap:anywhere;
    padding:clamp(15px,4vw,24px)!important;
  }
  #gm-billing-qr-dialog textarea{
    box-sizing:border-box;
    max-width:100%;
    min-width:0;
    font-size:14px;
  }
  #gm-billing-qr-dialog button{min-height:44px;margin-top:8px;max-width:100%}
}
