/* =========================================================
   SSO · camada mobile centralizada
   Carregado após cohidro-pro.css. Desktop permanece intacto.
   ========================================================= */
@media (max-width: 991.98px){
  :root{--coh-mobile-gap:12px;--coh-mobile-radius:22px;}
  html,body{width:100%;max-width:100%;overflow-x:hidden!important;-webkit-text-size-adjust:100%;}
  body.coh-auth,
  body:has(.coh-wrap),
  body:has(.wrap){
    min-height:100dvh!important;
    align-items:flex-start!important;
    justify-content:flex-start!important;
    padding:calc(env(safe-area-inset-top,0px) + 14px) var(--coh-mobile-gap) calc(env(safe-area-inset-bottom,0px) + 18px)!important;
    background-attachment:fixed!important;
  }
  .coh-bg-orb{opacity:.22!important;filter:blur(34px)!important;}
  .coh-orb-1{width:260px!important;height:260px!important;left:-95px!important;top:6%!important;}
  .coh-orb-2{width:330px!important;height:330px!important;right:-135px!important;bottom:-90px!important;}
  .coh-wrap,.wrap{width:100%!important;max-width:100%!important;margin:0 auto!important;}
  .glass,.coh-header-card,.coh-card,.card{border-radius:var(--coh-mobile-radius)!important;}
  .coh-top{padding:14px 14px 16px!important;gap:8px!important;}
  .coh-top-actions{justify-content:center!important;margin-bottom:2px!important;}
  .coh-brand,.coh-brand-center{gap:6px!important;text-align:center!important;}
  .coh-logo{height:38px!important;max-width:min(74vw,260px)!important;object-fit:contain!important;}
  .coh-top .h5,.titles .h5{font-size:1.04rem!important;line-height:1.18!important;}
  .coh-userline,.coh-subtitle{font-size:.84rem!important;white-space:normal!important;line-height:1.25!important;}
  .coh-body{padding:16px 14px 18px!important;}
  .coh-hint,.coh-systems-title{font-size:.94rem!important;line-height:1.28!important;}
  .coh-systems-grid{display:grid!important;grid-template-columns:1fr!important;gap:12px!important;width:100%!important;}
  .coh-system-col{width:100%!important;max-width:100%!important;flex:1 1 100%!important;}
  .coh-system-card{min-height:auto!important;transform:none!important;box-shadow:0 12px 30px rgba(15,23,42,.13)!important;}
  .coh-system-card:hover{transform:none!important;}
  .coh-system-card a,.coh-system-card .card-body{min-height:96px!important;}
  .coh-system-head,.coh-system-card .d-flex{gap:10px!important;align-items:center!important;}
  .coh-system-icon{width:42px!important;height:42px!important;min-width:42px!important;font-size:1.1rem!important;}
  .coh-system-title,.coh-system-card h5{font-size:1rem!important;line-height:1.18!important;}
  .coh-system-desc,.coh-system-card p{font-size:.84rem!important;line-height:1.35!important;}
  .grid-2{display:grid!important;grid-template-columns:1fr!important;gap:12px!important;}
  .form-control,.form-select,.input-group>.btn{min-height:46px!important;font-size:16px!important;}
  .coh-btn,.btn{min-height:44px;touch-action:manipulation;}
  .coh-links{display:flex!important;flex-direction:column!important;gap:8px!important;align-items:center!important;}
  .coh-footer{font-size:.76rem!important;line-height:1.35!important;padding:12px 4px 0!important;color:rgba(255,255,255,.92)!important;}
  .table-responsive,.table-wrap,.coh-table-wrap{overflow-x:auto!important;-webkit-overflow-scrolling:touch!important;border-radius:16px;}
  table{max-width:100%;}
  .modal-dialog{margin:calc(env(safe-area-inset-top,0px) + 12px) 10px 12px!important;}
  .modal-content{border-radius:20px!important;max-height:calc(100dvh - 24px);overflow:auto;}
}
@media (max-width: 575.98px){
  body.coh-auth,body:has(.coh-wrap),body:has(.wrap){padding-left:10px!important;padding-right:10px!important;}
  .coh-top{border-radius:20px 20px 0 0!important;}
  .coh-body{padding:14px 12px 16px!important;}
  .coh-logo{height:34px!important;}
  .coh-logout{width:100%;display:inline-flex!important;justify-content:center!important;}
}


/* =========================================================
   Gestão de Usuários · mobile refinado
   Escopo restrito às telas /app/admin/users.php e user_view.php
   ========================================================= */
@media (max-width: 991.98px){
  body.coh-user-mgmt-page{
    padding:0!important;
    background-attachment:scroll!important;
  }
  body.coh-user-mgmt-page .coh-bg-orb{
    display:none!important;
  }
  body.coh-user-mgmt-page .coh-wrap,
  body.coh-user-mgmt-page .wrap{
    padding:10px 10px calc(env(safe-area-inset-bottom,0px) + 18px)!important;
  }
  body.coh-user-mgmt-page .container{
    max-width:100%!important;
    padding-left:0!important;
    padding-right:0!important;
  }
  body.coh-user-mgmt-page .card.glass{
    border-radius:22px!important;
    overflow:hidden!important;
    box-shadow:0 12px 28px rgba(15,23,42,.16)!important;
    backdrop-filter:none!important;
  }
  body.coh-user-mgmt-page .topbar{
    min-height:66px!important;
    padding:10px 10px!important;
    gap:8px!important;
    align-items:center!important;
    border-radius:0!important;
  }
  body.coh-user-mgmt-page .topbar .brand,
  body.coh-user-mgmt-page .brand{
    gap:8px!important;
    min-width:0!important;
    flex:1 1 auto!important;
  }
  body.coh-user-mgmt-page .topbar img,
  body.coh-user-mgmt-page .brand img{
    height:28px!important;
    max-width:116px!important;
    object-fit:contain!important;
    flex:0 0 auto!important;
  }
  body.coh-user-mgmt-page .topbar .titles,
  body.coh-user-mgmt-page .titles{
    min-width:0!important;
    flex:1 1 auto!important;
  }
  body.coh-user-mgmt-page .topbar .titles .h5,
  body.coh-user-mgmt-page .titles .h5{
    font-size:.98rem!important;
    line-height:1.12!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
    font-weight:800!important;
  }
  body.coh-user-mgmt-page .topbar .titles .sub,
  body.coh-user-mgmt-page .titles .sub{
    max-width:100%!important;
    font-size:.74rem!important;
    line-height:1.15!important;
    opacity:.90!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }
  body.coh-user-mgmt-page .topbar > .d-flex{
    gap:6px!important;
    flex:0 0 auto!important;
  }
  body.coh-user-mgmt-page .topbar .btn-soft,
  body.coh-user-mgmt-page .topbar .btn-soft-icon,
  body.coh-user-mgmt-page .topbar .coh-theme-toggle{
    width:42px!important;
    height:42px!important;
    min-width:42px!important;
    min-height:42px!important;
    padding:0!important;
    border-radius:15px!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    font-size:0!important;
  }
  body.coh-user-mgmt-page .topbar .btn-soft i,
  body.coh-user-mgmt-page .topbar .btn-soft-icon i,
  body.coh-user-mgmt-page .topbar .coh-theme-toggle i{
    margin:0!important;
    font-size:1.1rem!important;
    line-height:1!important;
  }
  body.coh-user-mgmt-page .p-3{
    padding:12px!important;
  }
  body.coh-user-mgmt-page .nav-pills{
    width:100%!important;
    flex-wrap:nowrap!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    padding:2px 2px 8px!important;
    margin-right:0!important;
    -webkit-overflow-scrolling:touch!important;
    scrollbar-width:none!important;
  }
  body.coh-user-mgmt-page .nav-pills::-webkit-scrollbar{display:none!important;}
  body.coh-user-mgmt-page .nav-pills .nav-link{
    white-space:nowrap!important;
    padding:.55rem .82rem!important;
    font-size:.86rem!important;
    font-weight:800!important;
    border-radius:999px!important;
  }
  body.coh-user-mgmt-page .coh-btn-primary{
    width:100%!important;
    min-height:44px!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    border-radius:14px!important;
    font-size:.94rem!important;
    font-weight:800!important;
    box-shadow:0 8px 18px rgba(47,108,246,.18)!important;
  }
  body.coh-user-mgmt-list form.row{
    margin-top:8px!important;
  }
  body.coh-user-mgmt-page .form-control,
  body.coh-user-mgmt-page .form-select{
    min-height:46px!important;
    border-radius:14px!important;
    font-size:16px!important;
  }
  body.coh-user-mgmt-page .pill{
    max-width:100%!important;
    font-size:.76rem!important;
    font-weight:800!important;
    padding:.36rem .58rem!important;
    white-space:normal!important;
  }

  /* Lista de usuários em cards: remove rolagem lateral no mobile */
  body.coh-user-mgmt-list .table-responsive{
    overflow:visible!important;
    border-radius:0!important;
  }
  body.coh-user-mgmt-list table,
  body.coh-user-mgmt-list thead,
  body.coh-user-mgmt-list tbody,
  body.coh-user-mgmt-list tr,
  body.coh-user-mgmt-list th,
  body.coh-user-mgmt-list td{
    display:block!important;
    width:100%!important;
  }
  body.coh-user-mgmt-list thead{
    display:none!important;
  }
  body.coh-user-mgmt-list tbody{
    display:grid!important;
    gap:10px!important;
  }
  body.coh-user-mgmt-list tbody tr{
    background:rgba(255,255,255,.92)!important;
    border:1px solid rgba(15,23,42,.08)!important;
    border-radius:18px!important;
    padding:10px!important;
    box-shadow:0 8px 18px rgba(15,23,42,.08)!important;
  }
  body.coh-user-mgmt-list tbody td{
    border:0!important;
    padding:7px 4px!important;
    min-height:0!important;
    display:flex!important;
    justify-content:space-between!important;
    align-items:flex-start!important;
    gap:12px!important;
    text-align:right!important;
    color:#0f172a!important;
    word-break:break-word!important;
  }
  body.coh-user-mgmt-list tbody td::before{
    content:attr(data-label);
    flex:0 0 34%;
    text-align:left!important;
    color:#64748b!important;
    font-size:.74rem!important;
    font-weight:800!important;
    text-transform:uppercase!important;
    letter-spacing:.02em!important;
  }
  body.coh-user-mgmt-list tbody td:nth-child(1),
  body.coh-user-mgmt-list tbody td:nth-child(2),
  body.coh-user-mgmt-list tbody td:nth-child(3){
    font-size:.94rem!important;
  }
  body.coh-user-mgmt-list .perm-wrap,
  body.coh-user-mgmt-list td .d-flex.flex-wrap{
    justify-content:flex-end!important;
    gap:5px!important;
  }
  body.coh-user-mgmt-list .perm-badge,
  body.coh-user-mgmt-list .badge,
  body.coh-user-mgmt-list .pill{
    white-space:nowrap!important;
    max-width:100%!important;
  }
  body.coh-user-mgmt-list .table-actions{
    padding-top:10px!important;
    border-top:1px solid rgba(15,23,42,.08)!important;
    justify-content:flex-end!important;
    gap:8px!important;
    text-align:right!important;
  }
  body.coh-user-mgmt-list .table-actions::before{
    display:none!important;
  }
  body.coh-user-mgmt-list .table-actions .d-inline,
  body.coh-user-mgmt-list .table-actions form{
    display:inline-flex!important;
    margin:0!important;
  }
  body.coh-user-mgmt-list .icon-btn{
    width:42px!important;
    height:42px!important;
    min-width:42px!important;
    border-radius:14px!important;
  }

  /* Tela de edição/criação */
  body.coh-user-mgmt-form .section-title{
    font-size:1rem!important;
    justify-content:center!important;
    text-align:center!important;
    padding:10px 8px!important;
    margin:4px 0 10px!important;
    border-radius:16px!important;
    background:rgba(47,108,246,.08)!important;
  }
  body.coh-user-mgmt-form .hint{
    font-size:.78rem!important;
    line-height:1.28!important;
  }
  body.coh-user-mgmt-form .divider{
    margin:12px 0!important;
  }
  body.coh-user-mgmt-form .row.g-2 > [class*="col-"]{
    margin-bottom:2px!important;
  }
  body.coh-user-mgmt-form label.form-label{
    font-size:.78rem!important;
    font-weight:800!important;
    color:#475569!important;
    margin-bottom:5px!important;
  }
  body.coh-user-mgmt-form form .d-flex.justify-content-end,
  body.coh-user-mgmt-form form .d-flex.gap-2.justify-content-end{
    position:sticky!important;
    bottom:calc(env(safe-area-inset-bottom,0px) + 8px)!important;
    z-index:30!important;
    background:rgba(255,255,255,.92)!important;
    border:1px solid rgba(15,23,42,.08)!important;
    border-radius:18px!important;
    box-shadow:0 12px 26px rgba(15,23,42,.16)!important;
    padding:8px!important;
    flex-wrap:wrap!important;
  }
  body.coh-user-mgmt-form form .d-flex.justify-content-end .btn,
  body.coh-user-mgmt-form form .d-flex.gap-2.justify-content-end .btn,
  body.coh-user-mgmt-form form .d-flex.justify-content-end a,
  body.coh-user-mgmt-form form .d-flex.gap-2.justify-content-end a{
    flex:1 1 140px!important;
    min-height:44px!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
  }
}

@media (max-width: 575.98px){
  body.coh-user-mgmt-page .coh-wrap,
  body.coh-user-mgmt-page .wrap{
    padding-left:8px!important;
    padding-right:8px!important;
  }
  body.coh-user-mgmt-page .topbar img,
  body.coh-user-mgmt-page .brand img{
    height:26px!important;
    max-width:104px!important;
  }
  body.coh-user-mgmt-page .topbar .titles .h5,
  body.coh-user-mgmt-page .titles .h5{
    font-size:.9rem!important;
  }
  body.coh-user-mgmt-page .topbar .titles .sub,
  body.coh-user-mgmt-page .titles .sub{
    display:none!important;
  }
  body.coh-user-mgmt-list tbody td{
    flex-direction:column!important;
    align-items:stretch!important;
    text-align:left!important;
    gap:3px!important;
  }
  body.coh-user-mgmt-list tbody td::before{
    flex:0 0 auto!important;
  }
  body.coh-user-mgmt-list .perm-wrap,
  body.coh-user-mgmt-list td .d-flex.flex-wrap{
    justify-content:flex-start!important;
  }
  body.coh-user-mgmt-list .table-actions{
    flex-direction:row!important;
    justify-content:flex-end!important;
  }
}

@media (max-width: 991.98px){
  html[data-bs-theme="dark"] body.coh-user-mgmt-list tbody tr{
    background:linear-gradient(180deg,rgba(15,23,42,.94),rgba(13,24,41,.90))!important;
    border-color:rgba(148,163,184,.20)!important;
    box-shadow:0 10px 24px rgba(0,0,0,.24)!important;
  }
  html[data-bs-theme="dark"] body.coh-user-mgmt-list tbody td{
    color:#e6edf7!important;
  }
  html[data-bs-theme="dark"] body.coh-user-mgmt-list tbody td::before,
  html[data-bs-theme="dark"] body.coh-user-mgmt-form label.form-label{
    color:#9aa8bd!important;
  }
  html[data-bs-theme="dark"] body.coh-user-mgmt-list .table-actions{
    border-top-color:rgba(148,163,184,.18)!important;
  }
  html[data-bs-theme="dark"] body.coh-user-mgmt-form .section-title{
    background:rgba(59,130,246,.14)!important;
  }
  html[data-bs-theme="dark"] body.coh-user-mgmt-form form .d-flex.justify-content-end,
  html[data-bs-theme="dark"] body.coh-user-mgmt-form form .d-flex.gap-2.justify-content-end{
    background:rgba(15,23,42,.94)!important;
    border-color:rgba(148,163,184,.20)!important;
  }
}

/* =========================================================
   Gestão de Usuários · correção listagem mobile
   Renderiza cards mobile reais e mantém a tabela apenas no desktop.
   ========================================================= */
.coh-mobile-users-list{display:none;}

@media (max-width: 991.98px){
  body.coh-user-mgmt-list .coh-user-table-desktop,
  body.coh-user-mgmt-list .table-responsive.coh-user-table-desktop{
    display:none!important;
  }

  body.coh-user-mgmt-list .coh-mobile-users-list{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:10px!important;
    width:100%!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-card{
    display:block!important;
    width:100%!important;
    background:rgba(255,255,255,.94)!important;
    border:1px solid rgba(15,23,42,.08)!important;
    border-radius:18px!important;
    padding:12px!important;
    box-shadow:0 8px 18px rgba(15,23,42,.08)!important;
    color:#0f172a!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-head{
    display:flex!important;
    align-items:flex-start!important;
    justify-content:space-between!important;
    gap:10px!important;
    padding-bottom:9px!important;
    margin-bottom:8px!important;
    border-bottom:1px solid rgba(15,23,42,.08)!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-main{
    min-width:0!important;
    display:flex!important;
    flex-direction:column!important;
    gap:2px!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-main strong{
    font-size:.98rem!important;
    line-height:1.16!important;
    font-weight:900!important;
    color:#0f172a!important;
    overflow-wrap:anywhere!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-main span{
    font-size:.78rem!important;
    line-height:1.2!important;
    color:#64748b!important;
    overflow-wrap:anywhere!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-id{
    flex:0 0 auto!important;
    font-size:.72rem!important;
    font-weight:900!important;
    border-radius:999px!important;
    padding:.28rem .48rem!important;
    background:rgba(47,108,246,.10)!important;
    color:#2450c8!important;
    border:1px solid rgba(47,108,246,.16)!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-fields{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:6px!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-field{
    display:grid!important;
    grid-template-columns:minmax(84px,34%) 1fr!important;
    gap:10px!important;
    align-items:start!important;
    min-width:0!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-field > span{
    font-size:.72rem!important;
    font-weight:900!important;
    text-transform:uppercase!important;
    letter-spacing:.02em!important;
    color:#64748b!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-field > strong{
    min-width:0!important;
    font-size:.84rem!important;
    line-height:1.22!important;
    font-weight:800!important;
    color:#0f172a!important;
    text-align:right!important;
    overflow-wrap:anywhere!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-field .perm-wrap,
  body.coh-user-mgmt-list .coh-mobile-user-field .d-flex.flex-wrap{
    justify-content:flex-end!important;
    gap:5px!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-actions{
    display:flex!important;
    justify-content:flex-end!important;
    align-items:center!important;
    gap:8px!important;
    margin-top:10px!important;
    padding-top:10px!important;
    border-top:1px solid rgba(15,23,42,.08)!important;
  }

  body.coh-user-mgmt-list .coh-mobile-user-actions form,
  body.coh-user-mgmt-list .coh-mobile-user-actions .d-inline{
    display:inline-flex!important;
    margin:0!important;
  }

  body.coh-user-mgmt-list .coh-mobile-empty{
    border-radius:18px!important;
    padding:18px!important;
    text-align:center!important;
    background:rgba(255,255,255,.9)!important;
    color:#64748b!important;
    font-weight:800!important;
  }
}

@media (max-width: 575.98px){
  body.coh-user-mgmt-list .coh-mobile-user-field{
    grid-template-columns:1fr!important;
    gap:2px!important;
  }
  body.coh-user-mgmt-list .coh-mobile-user-field > strong{
    text-align:left!important;
  }
  body.coh-user-mgmt-list .coh-mobile-user-field .perm-wrap,
  body.coh-user-mgmt-list .coh-mobile-user-field .d-flex.flex-wrap{
    justify-content:flex-start!important;
  }
}

@media (max-width: 991.98px){
  html[data-bs-theme="dark"] body.coh-user-mgmt-list .coh-mobile-user-card{
    background:linear-gradient(180deg,rgba(15,23,42,.94),rgba(13,24,41,.90))!important;
    border-color:rgba(148,163,184,.20)!important;
    box-shadow:0 10px 24px rgba(0,0,0,.24)!important;
    color:#e6edf7!important;
  }
  html[data-bs-theme="dark"] body.coh-user-mgmt-list .coh-mobile-user-head,
  html[data-bs-theme="dark"] body.coh-user-mgmt-list .coh-mobile-user-actions{
    border-color:rgba(148,163,184,.18)!important;
  }
  html[data-bs-theme="dark"] body.coh-user-mgmt-list .coh-mobile-user-main strong,
  html[data-bs-theme="dark"] body.coh-user-mgmt-list .coh-mobile-user-field > strong{
    color:#e6edf7!important;
  }
  html[data-bs-theme="dark"] body.coh-user-mgmt-list .coh-mobile-user-main span,
  html[data-bs-theme="dark"] body.coh-user-mgmt-list .coh-mobile-user-field > span{
    color:#9aa8bd!important;
  }
  html[data-bs-theme="dark"] body.coh-user-mgmt-list .coh-mobile-user-id{
    background:rgba(59,130,246,.16)!important;
    color:#bcd3ff!important;
    border-color:rgba(96,165,250,.22)!important;
  }
  html[data-bs-theme="dark"] body.coh-user-mgmt-list .coh-mobile-empty{
    background:rgba(15,23,42,.90)!important;
    color:#9aa8bd!important;
  }
}


/* =========================================================
   PATCH 22-05 · Mobile SSO: centralização e botões proporcionais
   Mantém desktop intacto.
   ========================================================= */
@media (max-width: 991.98px){
  body.coh-auth{
    min-height:100dvh!important;
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    padding:calc(env(safe-area-inset-top,0px) + 14px) 12px calc(env(safe-area-inset-bottom,0px) + 18px)!important;
  }
  body.coh-auth .coh-wrap,
  body.coh-auth .wrap{
    width:min(100%, 580px)!important;
    max-width:580px!important;
    margin:auto!important;
  }
  body.coh-auth .coh-system-card a.coh-btn,
  body.coh-auth .coh-system-card .btn.coh-btn{
    min-height:46px!important;
    height:auto!important;
    padding:.64rem 1rem!important;
    border-radius:14px!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    font-size:.96rem!important;
    line-height:1.15!important;
  }
  body.coh-auth .coh-system-card a:not(.coh-btn){
    min-height:0!important;
  }
}
@media (max-width: 575.98px){
  body.coh-auth .coh-wrap,
  body.coh-auth .wrap{
    width:100%!important;
    max-width:100%!important;
  }
  body.coh-auth .coh-top-actions{
    display:grid!important;
    grid-template-columns:42px 1fr!important;
    gap:8px!important;
    align-items:center!important;
  }
  body.coh-auth .coh-top-actions .coh-theme-toggle{
    width:42px!important;
    height:42px!important;
    min-width:42px!important;
    justify-self:start!important;
  }
  body.coh-auth .coh-top-actions .coh-logout{
    width:100%!important;
    justify-content:center!important;
  }
}
