:root{
    --sidebar-width:280px;
    --sidebar-collapsed-width:76px;
    --sidebar-bg:#102236;
    --sidebar-bg-2:#0b1b2c;
    --sidebar-text:#d9e4ef;
    --sidebar-muted:#8fa4b8;
    --sidebar-active:#0d6efd;
}
*{box-sizing:border-box}
body{margin:0;background:#f5f7fb;color:#172033;min-height:100vh}
.app-shell{display:flex;min-height:100vh;width:100%}
.sidebar{
    position:fixed;inset:0 auto 0 0;z-index:1030;
    width:var(--sidebar-width);height:100vh;
    background:linear-gradient(180deg,var(--sidebar-bg),var(--sidebar-bg-2));
    color:var(--sidebar-text);padding:16px 12px;
    transition:width .25s ease,transform .25s ease;
    overflow-x:hidden;overflow-y:auto;
    box-shadow:4px 0 18px rgba(3,18,33,.10)
}
.sidebar-header{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:20px;min-height:52px}
.brand{display:flex;align-items:center;gap:11px;color:#fff;text-decoration:none;min-width:0;padding:4px 6px}
.brand:hover{color:#fff}
.brand-icon{display:grid;place-items:center;flex:0 0 38px;width:38px;height:38px;font-size:27px;color:#f1ad36}
.brand-text{display:flex;flex-direction:column;line-height:1.02;white-space:nowrap;overflow:hidden}
.brand-text strong{font-size:22px;letter-spacing:.4px}
.brand-text span{font-size:15px;letter-spacing:.6px}
.sidebar-toggle{flex:0 0 38px;width:38px;height:38px;border:0;border-radius:50%;background:#fff;color:#102236;font-size:17px;display:grid;place-items:center;box-shadow:0 3px 10px rgba(0,0,0,.16);transition:transform .2s ease,background .2s ease}
.sidebar-toggle:hover{background:#eaf2fb}
.sidebar-nav{display:flex;flex-direction:column;gap:4px}
.sidebar-link{display:flex;align-items:center;gap:13px;min-height:44px;padding:10px 12px;border-radius:8px;color:var(--sidebar-text);text-decoration:none;white-space:nowrap;transition:background .16s,color .16s,transform .16s}
.sidebar-link:hover{background:rgba(255,255,255,.08);color:#fff}
.sidebar-link.active{background:linear-gradient(90deg,#1178e8,#0d63c9);color:#fff;box-shadow:0 4px 12px rgba(0,94,201,.22)}
.sidebar-link .menu-icon{flex:0 0 25px;width:25px;text-align:center;font-size:19px}
.sidebar-link .menu-text{overflow:hidden;text-overflow:ellipsis}
.menu-section-title{margin:17px 12px 5px;color:var(--sidebar-muted);font-size:11px;letter-spacing:.55px;white-space:nowrap;overflow:hidden}
.menu-bottom-section{margin-top:22px}
.sidebar-logout{color:#ffced2}
.sidebar-logout:hover{background:rgba(220,53,69,.18);color:#fff}
.main-content{margin-left:var(--sidebar-width);width:calc(100% - var(--sidebar-width));min-height:100vh;transition:margin-left .25s ease,width .25s ease}
.page-content{padding:28px}
.mobile-topbar{height:60px;background:#fff;border-bottom:1px solid #e7ebf0;align-items:center;gap:12px;padding:0 16px;position:sticky;top:0;z-index:1020}
.sidebar-overlay{display:none}

/* Menu recolhido */
body.sidebar-collapsed .sidebar{width:var(--sidebar-collapsed-width);padding-left:10px;padding-right:10px}
body.sidebar-collapsed .main-content{margin-left:var(--sidebar-collapsed-width);width:calc(100% - var(--sidebar-collapsed-width))}
body.sidebar-collapsed .sidebar-header{justify-content:center;flex-direction:column;gap:8px;margin-bottom:16px}
body.sidebar-collapsed .brand{justify-content:center;padding:2px}
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .menu-text,
body.sidebar-collapsed .menu-section-title{display:none}
body.sidebar-collapsed .sidebar-toggle{position:static;width:34px;height:34px;flex-basis:34px}
body.sidebar-collapsed .sidebar-toggle i{transform:rotate(180deg)}
body.sidebar-collapsed .sidebar-link{justify-content:center;padding:10px 8px;gap:0}
body.sidebar-collapsed .sidebar-link .menu-icon{width:24px;flex-basis:24px}

.card-kpi{border:0;box-shadow:0 4px 18px rgba(0,0,0,.06)}
.table thead th{white-space:nowrap}
.required:after{content:' *';color:#dc3545}

@media (max-width:991.98px){
    .sidebar{transform:translateX(-100%);width:var(--sidebar-width)!important}
    .main-content,.sidebar-collapsed .main-content{margin-left:0!important;width:100%!important}
    body.sidebar-mobile-open .sidebar{transform:translateX(0)}
    body.sidebar-mobile-open .sidebar-overlay{display:block;position:fixed;inset:0;background:rgba(6,19,32,.5);z-index:1025}
    body.sidebar-collapsed .sidebar-header{flex-direction:row;justify-content:space-between}
    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .menu-text,
    body.sidebar-collapsed .menu-section-title{display:initial}
    body.sidebar-collapsed .sidebar-link{justify-content:flex-start;padding:10px 12px;gap:13px}
    body.sidebar-collapsed .sidebar-toggle i{transform:none}
    .mobile-topbar{display:flex!important}
    .page-content{padding:18px}
}
.kpi-icon{width:44px;height:44px;border-radius:12px;display:grid;place-items:center;background:#eef4ff;color:#0d6efd;font-size:21px}
.card-header{border-bottom:1px solid #eef1f5!important}

/* Identidade MasterGest BPO */
.brand{width:200px;max-width:calc(100% - 46px);padding:0}
.brand-logo{display:block;object-fit:contain}
.brand-logo-expanded{width:198px;height:54px;object-position:left center}
.brand-logo-collapsed{display:none;width:46px;height:46px}
.mobile-brand-logo{width:178px;height:42px;object-fit:contain;object-position:left center;background:#102236;border-radius:7px;padding:4px 8px}
body.sidebar-collapsed .brand{width:46px;max-width:46px}
body.sidebar-collapsed .brand-logo-expanded{display:none}
body.sidebar-collapsed .brand-logo-collapsed{display:block}
.auth-brand{max-width:330px;width:100%;height:auto;background:linear-gradient(135deg,#123b59,#071d31);border-radius:14px;padding:12px 18px}
.company-copy-icon{width:68px;height:68px;border-radius:50%;display:grid;place-items:center;background:#eaf3ff;color:#0d6efd;font-size:30px;margin:0 auto 16px}
.company-copy-note{background:#f7f9fc;border:1px solid #e6ebf2;border-radius:10px;padding:12px 14px;color:#526173}
@media (max-width:991.98px){
  body.sidebar-collapsed .brand{width:200px;max-width:calc(100% - 46px)}
  body.sidebar-collapsed .brand-logo-expanded{display:block}
  body.sidebar-collapsed .brand-logo-collapsed{display:none}
}

/* Listagens responsivas: tabelas no desktop e cards em telas pequenas */
.min-w-0{min-width:0}
.mobile-entity-list{display:grid;gap:12px}
.mobile-entity-card{border-radius:14px;overflow:hidden}
.mobile-entity-card .card-body{padding:16px}
.mobile-entity-icon{width:42px;height:42px;flex:0 0 42px;border-radius:12px;display:grid;place-items:center;background:#eaf3ff;color:#0d6efd;font-size:19px}
.mobile-entity-info{display:grid;gap:7px;color:#536273;font-size:.9rem}
.mobile-entity-info span{display:flex;align-items:flex-start;gap:8px;min-width:0;overflow-wrap:anywhere}
.mobile-entity-info i{width:18px;flex:0 0 18px;color:#7a8998;margin-top:1px;text-align:center}
@media (max-width:767.98px){
  .page-content{padding:14px}
  .mobile-entity-card .btn{min-height:42px}
}


/* Tabela responsiva universal em cards: padrao MasterGest para telas pequenas */
@media (max-width:767.98px){
  .table-responsive.mobile-card-table-wrap{overflow:visible}
  .mobile-card-table{display:block;border:0!important;background:transparent!important}
  .mobile-card-table thead{display:none}
  .mobile-card-table tbody{display:grid;gap:12px}
  .mobile-card-table tbody tr{display:block;background:#fff;border:1px solid #e8edf3;border-radius:14px;padding:12px 14px;box-shadow:0 3px 12px rgba(16,34,54,.06)}
  .mobile-card-table tbody tr:has(td[colspan]){padding:0}
  .mobile-card-table tbody td{display:flex!important;align-items:flex-start;justify-content:space-between;gap:14px;width:100%!important;border:0!important;padding:7px 0!important;text-align:right!important;white-space:normal!important;overflow-wrap:anywhere}
  .mobile-card-table tbody td::before{content:attr(data-label);font-size:.78rem;font-weight:700;color:#6c7b8a;text-transform:uppercase;letter-spacing:.02em;text-align:left;flex:0 0 38%;max-width:38%}
  .mobile-card-table tbody td[colspan]::before{display:none}
  .mobile-card-table tbody td[colspan]{display:block!important;text-align:center!important;padding:18px!important}
  .mobile-card-table tbody td:last-child:not([colspan]){border-top:1px solid #eef1f5!important;margin-top:5px;padding-top:12px!important;justify-content:flex-end;flex-wrap:wrap}
  .mobile-card-table tbody td:last-child:not([colspan])::before{display:none}
  .mobile-card-table .btn{min-height:38px}
}


/* Formulários em modal - padrão MasterGest BPO */
.crud-form-modal .modal-content{border-radius:16px;overflow:hidden}
.crud-form-modal .modal-header{background:#fff;border-bottom:1px solid #edf1f5;padding:16px 20px}
.crud-form-modal .modal-body{padding:20px;max-height:calc(100vh - 150px);overflow-y:auto}
.crud-form-modal .modal-body form{margin:0}
.crud-form-modal .modal-body form > button,
.crud-form-modal .modal-body form > a.btn{margin-top:6px}
.crud-modal-actionbar .btn{min-width:150px}
@media (max-width:575.98px){
  .crud-form-modal .modal-content{border-radius:0}
  .crud-form-modal .modal-body{max-height:none;padding:16px}
  .crud-modal-actionbar{position:sticky;top:68px;z-index:1010;background:#f5f7fb;padding:4px 0 8px}
  .crud-modal-actionbar .btn{width:100%}
}

/* MasterGest: selects pesquisaveis */
.mg-search-select { position: relative; }
.mg-search-select .mg-search-input { padding-right: 2.4rem; cursor: text; background-color: #fff; }
.mg-search-select .mg-search-chevron { position:absolute; right:.8rem; top:50%; transform:translateY(-50%); pointer-events:none; color:#6c757d; }
.mg-search-select-menu { position:absolute; z-index:1085; left:0; right:0; top:calc(100% + 3px); max-height:260px; overflow-y:auto; background:#fff; border:1px solid #dee2e6; border-radius:.5rem; box-shadow:0 .5rem 1rem rgba(0,0,0,.15); padding:.3rem; }
.mg-search-option { display:block; width:100%; border:0; background:transparent; text-align:left; padding:.5rem .65rem; border-radius:.35rem; color:#212529; }
.mg-search-option:hover, .mg-search-option:focus { background:#f1f4f8; outline:0; }
.mg-search-option.is-selected { font-weight:600; background:#e9f2ff; }
.mg-search-empty { padding:.65rem; color:#6c757d; font-size:.875rem; }
.mg-native-select-hidden { position:absolute !important; width:1px !important; height:1px !important; padding:0 !important; margin:-1px !important; overflow:hidden !important; clip:rect(0,0,0,0) !important; white-space:nowrap !important; border:0 !important; }


/* Alertas modernos globais MasterGest */
.mg-alert-host{
    position:fixed;
    top:18px;
    left:50%;
    transform:translateX(-50%);
    z-index:20050;
    width:min(560px,calc(100vw - 28px));
    display:grid;
    gap:10px;
    pointer-events:none;
}
.mg-top-alert,.mg-confirm-alert{
    pointer-events:auto;
    background:rgba(255,255,255,.98);
    border:1px solid rgba(16,34,54,.10);
    border-radius:16px;
    box-shadow:0 14px 40px rgba(16,34,54,.18),0 2px 8px rgba(16,34,54,.06);
    overflow:hidden;
    opacity:0;
    transform:translateY(-14px) scale(.985);
    transition:opacity .18s ease,transform .18s ease;
    backdrop-filter:blur(8px);
}
.mg-top-alert.show,.mg-confirm-alert.show{opacity:1;transform:translateY(0) scale(1)}
.mg-top-alert-body{display:flex;align-items:center;gap:12px;padding:13px 14px}
.mg-top-alert-icon{
    width:38px;height:38px;flex:0 0 38px;border-radius:50%;
    display:grid;place-items:center;font-size:1.08rem;line-height:1;
}
.mg-top-alert-copy{min-width:0;flex:1;display:flex;flex-direction:column;gap:2px;line-height:1.28}
.mg-top-alert-copy strong{font-size:.91rem;font-weight:700;color:#172635}
.mg-top-alert-copy span{font-size:.86rem;color:#5f6d7a;overflow-wrap:anywhere}
.mg-top-alert-close{
    width:30px;height:30px;flex:0 0 30px;border:0;background:transparent;color:#8a96a1;
    padding:0;display:grid;place-items:center;line-height:1;border-radius:9px;transition:.15s ease;
}
.mg-top-alert-close:hover{background:#f0f3f6;color:#233444}
.mg-top-alert-success{border-left:4px solid #198754}.mg-top-alert-success .mg-top-alert-icon{background:#e8f6ef;color:#198754}
.mg-top-alert-danger{border-left:4px solid #dc3545}.mg-top-alert-danger .mg-top-alert-icon{background:#fdecef;color:#dc3545}
.mg-top-alert-warning{border-left:4px solid #e0a000}.mg-top-alert-warning .mg-top-alert-icon{background:#fff6d9;color:#b47f00}
.mg-top-alert-info{border-left:4px solid #0d6efd}.mg-top-alert-info .mg-top-alert-icon{background:#eaf2ff;color:#0d6efd}
.mg-top-alert-progress{height:3px;background:#eef2f5;overflow:hidden}
.mg-top-alert-progress span{display:block;height:100%;width:100%;background:currentColor;transform-origin:left center;animation:mgAlertProgress linear forwards}
.mg-top-alert-success .mg-top-alert-progress{color:#198754}.mg-top-alert-danger .mg-top-alert-progress{color:#dc3545}.mg-top-alert-warning .mg-top-alert-progress{color:#e0a000}.mg-top-alert-info .mg-top-alert-progress{color:#0d6efd}
@keyframes mgAlertProgress{from{transform:scaleX(1)}to{transform:scaleX(0)}}

.mg-confirm-alert{display:grid;grid-template-columns:42px 1fr 30px;align-items:start;gap:12px;padding:15px}
.mg-confirm-icon{width:42px;height:42px;border-radius:13px;background:#fff4d6;color:#a16e00;display:grid;place-items:center;font-size:1.15rem}
.mg-confirm-copy{min-width:0;display:grid;gap:4px}.mg-confirm-copy strong{font-size:.94rem;color:#172635}.mg-confirm-copy>span{font-size:.88rem;color:#5f6d7a;overflow-wrap:anywhere}
.mg-confirm-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:10px}
.mg-confirm-actions .btn{border-radius:9px;padding:.38rem .75rem;font-weight:600}

@media(max-width:575.98px){
    .mg-alert-host{top:10px;width:calc(100vw - 16px)}
    .mg-top-alert-body{padding:12px}
    .mg-confirm-alert{grid-template-columns:38px 1fr 28px;padding:13px}
    .mg-confirm-icon{width:38px;height:38px}
    .mg-confirm-actions{grid-column:1/-1;justify-content:stretch}
    .mg-confirm-actions .btn{flex:1}
}

/* Contratos BPO: modais sólidos e legíveis */
.contract-modal .modal-content{
  background-color:#fff !important;
  color:#172033 !important;
  opacity:1 !important;
  border:0;
}
.contract-modal .modal-header,
.contract-modal .modal-body,
.contract-modal .modal-footer{
  background-color:#fff !important;
}
.contract-modal .modal-backdrop{opacity:.5}
.contract-modal .contract-option{background:#fff;transition:background .15s,border-color .15s}
.contract-modal .contract-option:hover{background:#f7f9fc;border-color:#cfd7e2!important}


/* Navegação separada: operação dos clientes x gerenciamento MasterGest BPO */
.menu-group-label{margin:14px 12px 4px;color:#aab9c8;font-size:10px;font-weight:700;letter-spacing:.55px;white-space:nowrap;overflow:hidden}
.sidebar-group-toggle{width:100%;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.035);text-align:left}
.sidebar-group-toggle.active-group{background:rgba(13,110,253,.14);color:#fff;border-color:rgba(65,145,255,.28)}
.sidebar-group-toggle .menu-group-chevron{transition:transform .18s ease;font-size:.8rem}
.sidebar-group-toggle[aria-expanded="true"] .menu-group-chevron{transform:rotate(180deg)}
.sidebar-submenu{margin-left:10px;padding-left:8px;border-left:1px solid rgba(255,255,255,.12)}
.sidebar-submenu .sidebar-link{min-height:39px;padding-top:8px;padding-bottom:8px;font-size:.93rem}
.sidebar-submenu .sidebar-link .menu-icon{font-size:16px}
body.sidebar-collapsed .menu-group-label{display:none}
body.sidebar-collapsed .sidebar-submenu{margin-left:0;padding-left:0;border-left:0}
body.sidebar-collapsed .sidebar-group-toggle .menu-group-chevron{display:none}
@media(max-width:991.98px){body.sidebar-collapsed .menu-group-label{display:block}.sidebar-submenu{margin-left:10px;padding-left:8px}}

/* Fase 8.2.2 - identificação visual do ambiente */
.mg-env-banner{position:sticky;top:0;z-index:22000;background:#fff3cd;color:#664d03;border-bottom:1px solid #ffecb5;text-align:center;font-size:.78rem;font-weight:800;letter-spacing:.06em;padding:6px 10px}
.mg-env-banner i{margin-right:6px}
