/*
 * MEKI MOBILE DESIGN SYSTEM · v1.0 (14/10/2026)
 * Aprovado: azul-marinho, logo ORIGINAL, ciano e neon discreto.
 * Camada mobile compartilhada. SEM mudanças no desktop, sem dados fictícios.
 *
 * Fonte única dos tokens semânticos e componentes para páginas legadas;
 * Visão Gerencial e Demandas & Check-list premium mantêm suas composições.
 * Novas telas devem usar classes meki-m-* ao invés de copiar CSS.
 */
@media screen and (max-width:760px){
  #app {
    color-scheme:dark;
    --m-bg:#071727;
    --m-bg-deep:#061321;
    --m-surface:#102841;
    --m-surface-raised:#14324d;
    --m-surface-active:#123a55;
    --m-border:#27506c;
    --m-border-strong:#347b9d;
    --m-text:#eff8ff;
    --m-muted:#a8bfd3;
    --m-subtle:#89a9c1;
    --m-primary:#25e7d7;
    --m-primary-hover:#53f6e7;
    --m-secondary:#449eed;
    --m-purple:#b78afa;
    --m-success:#32e5b5;
    --m-warning:#ffce6c;
    --m-danger:#ff798e;
    --m-neutral:#9ab4c9;
    --m-radius-sm:9px;
    --m-radius-md:13px;
    --m-radius-lg:17px;
    --m-radius-xl:21px;
    --m-space-1:4px;
    --m-space-2:8px;
    --m-space-3:12px;
    --m-space-4:16px;
    --m-space-5:20px;
    --m-shadow-card:0 7px 19px rgba(0,0,0,.19);
    --m-shadow-active:0 0 16px rgba(37,231,215,.19);
    font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
    accent-color:var(--m-primary);
    /* Compatibilidade com estilos legados que ainda usam variáveis globais */
    --bg:var(--m-bg);
    --white:var(--m-surface);
    --text:var(--m-text);
    --muted:var(--m-muted);
    --line:var(--m-border);
    --blue:var(--m-secondary);
    --green:var(--m-success);
    --danger:var(--m-danger);
  }

  #app .main{background:var(--m-bg);color:var(--m-text)}
  #app .section.active{color:var(--m-text)}
  #app .section.active *{min-width:0}
  #app .section.active :is(h1,h2,h3){
    color:var(--m-text);
    overflow-wrap:anywhere;
    letter-spacing:-.024em;
  }
  #app .section.active :is(.sub,.muted,.mg-subdued){color:var(--m-muted)}

  /* O logo autorizado é o SVG original azul/turquesa, nunca invertido. */
  #app .mobile-brand img,#app .side .site-logo{filter:none!important}

  /* Cabeçalho padrão para telas que ainda não têm versão premium dedicada. */
  #app:not(:has(#gerencial.active)):not(:has(#liderMobile.active)) .app-topbar{
    background:linear-gradient(125deg,#0c2a47,#081c32)!important;
    border-bottom:1px solid #20445d!important;
    box-shadow:0 4px 15px #020c1533!important;
    min-height:74px!important;
    padding:10px 13px!important;
    margin-bottom:12px!important;
  }
  #app:not(:has(#gerencial.active)):not(:has(#liderMobile.active)) .mobile-app-header{
    gap:8px;
  }
  #app:not(:has(#gerencial.active)):not(:has(#liderMobile.active)) .mobile-brand{
    min-height:38px;
    width:auto;max-width:108px;
    justify-content:flex-start;
  }
  #app:not(:has(#gerencial.active)):not(:has(#liderMobile.active)) .mobile-brand img{
    width:105px;max-height:37px;object-position:left center;
  }
  #app:not(:has(#gerencial.active)):not(:has(#liderMobile.active)) .mobile-header-actions{gap:5px}
  #app:not(:has(#gerencial.active)):not(:has(#liderMobile.active)) .mobile-bell{
    color:var(--m-text);
    width:40px;height:40px;
  }
  #app:not(:has(#gerencial.active)):not(:has(#liderMobile.active)) .mobile-avatar{
    width:39px;height:39px;
    border:1.5px solid var(--m-border-strong);
    background:var(--m-surface-raised);
    color:var(--m-text);
  }
  #app .meki-mobile-page-heading{display:none}
  #app:not(:has(#gerencial.active)):not(:has(#liderMobile.active)) .meki-mobile-page-heading{
    display:flex;flex:1;flex-direction:column;align-items:center;
    justify-content:center;gap:3px;min-width:0;line-height:1.16;
  }
  #app .meki-mobile-page-heading strong{
    font-size:clamp(11px,3.45vw,14px);
    font-weight:840;color:var(--m-text);
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;
  }
  #app .meki-mobile-page-heading small{
    font-size:clamp(9px,2.9vw,11px);font-weight:650;
    color:var(--m-primary);
    white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:100%;
  }
  #app .agenda-mobile-sync-status{color:var(--m-muted)}

  /* Conteúdo das páginas antigas: uma mesma elevação, borda e densidade. */
  #app .section.active:not(#gerencial):not(#liderMobile) > .top{
    background:linear-gradient(135deg,#122e4a,#0b2239)!important;
    color:var(--m-text);
    border:1px solid var(--m-border);
    border-radius:var(--m-radius-lg);
    padding:14px!important;
    margin:0 0 12px!important;
    box-shadow:var(--m-shadow-card);
  }
  #app .section.active:not(#gerencial):not(#liderMobile) > .top h1{
    font-size:clamp(19px,5vw,23px);
    font-weight:850;margin:0 0 4px;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) > .top .sub{
    font-size:11px;line-height:1.45;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) :is(.card,.stat){
    background:linear-gradient(145deg,#112d49,#0d2238 90%);
    border:1px solid var(--m-border);
    border-radius:var(--m-radius-lg);
    box-shadow:var(--m-shadow-card);
    color:var(--m-text);
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .card{
    padding:15px!important;
    margin-top:12px;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) :is(.card,.stat) h2{
    font-weight:830;font-size:16px;line-height:1.3;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .stat{
    padding:14px;overflow:hidden;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .stat small{
    color:var(--m-muted);font-size:11px;line-height:1.36;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .stat b{
    color:var(--m-text);font-size:clamp(19px,5.6vw,26px);
    letter-spacing:-.028em;line-height:1.2;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .stats{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:9px!important;
  }

  /* Botões padronizados: alvos >= 40px e CTA ciano. */
  #app .section.active:not(#gerencial):not(#liderMobile) .btn{
    display:inline-flex;align-items:center;justify-content:center;
    gap:6px;min-height:40px;
    max-width:100%;
    border-radius:var(--m-radius-md);
    font-weight:780;font-size:12px;
    padding:9px 12px;
    white-space:normal;text-align:center;
    transition:filter .15s,border-color .15s;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .btn.primary{
    background:linear-gradient(120deg,#37f1de,#20c9de)!important;
    color:#052d3b!important;border:1px solid #48eadd!important;
    box-shadow:0 4px 13px #25ddc824;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .btn.light{
    background:linear-gradient(135deg,#183851,#142e46)!important;
    color:#cbe9ff!important;
    border:1px solid #315b79!important;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .btn.green{
    background:#116e63!important;color:#e5fff8!important;
    border:1px solid #209c86!important;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .btn.danger{
    background:#482a3a!important;color:#ffabb7!important;
    border:1px solid #945168!important;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) :is(.field input,.field select,.field textarea){
    background:#0b2136;color:var(--m-text);
    border:1px solid #365775;border-radius:var(--m-radius-sm);
    min-height:40px;font-size:13px;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) :is(input[type="date"],input[type="month"],input[type="time"],select){
    color-scheme:dark;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .field label{
    color:#bcd7e9;font-size:11px;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) :is(input,select,textarea)::placeholder{
    color:#8fa9bd;opacity:1;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) :is(.badge,.rate){
    border-radius:999px;line-height:1.35;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .badge.done{
    color:#7af2ce;background:#104a41;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .badge.pending{
    color:#ffdb91;background:#523c19;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .badge.cancel{
    color:#ffacb8;background:#4b2436;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .badge.alter{
    color:#a3cfff;background:#15365b;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) :is(th,td){
    border-bottom-color:#29445d;
    color:#dae9f6;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) th{
    color:#9bbbd0;background:#0f2a43;
    font-size:10px;font-weight:800;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) td{
    font-size:12px;line-height:1.5;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) table{
    max-width:100%;
  }
  #app .section.active:not(#gerencial):not(#liderMobile) .notice{
    background:#153e55;color:#c7f1fd;border:1px solid #2b6475;
    border-radius:var(--m-radius-md);
  }

  /* Navegação inferior compartilha a mesma gramática das telas premium. */
  #app:not(:has(#gerencial.active)):not(:has(#liderMobile.active)) .mobile-bottom-nav{
    background:linear-gradient(180deg,#091e34,#07172a)!important;
    border-top:1px solid #245473!important;
    min-height:76px!important;
    box-shadow:0 -5px 17px #020a173d!important;
    padding:7px 4px calc(6px + env(safe-area-inset-bottom,0px))!important;
  }
  #app:not(:has(#gerencial.active)):not(:has(#liderMobile.active)) .mobile-tab{
    color:#9bb8d1!important;
    position:relative;
  }
  #app:not(:has(#gerencial.active)):not(:has(#liderMobile.active)) .mobile-tab.active{
    background:transparent!important;color:#33f1de!important;
  }
  #app:not(:has(#gerencial.active)):not(:has(#liderMobile.active)) .mobile-tab.active::after{
    content:"";position:absolute;bottom:2px;width:22px;height:3px;
    border-radius:99px;background:#38f8e4;
  }
  #app .side{
    background:#0d2135!important;color:var(--m-text);
    border-right-color:var(--m-border);
  }
  #app .side .nav button{
    color:#b6cce0;
  }
  #app .side .nav button.active{
    color:#55eddf!important;background:#12435a!important;
  }

  /* Componentes reusáveis para qualquer nova tela mobile. */
  #app .meki-m-card{
    min-width:0;padding:var(--m-space-4);
    color:var(--m-text);background:linear-gradient(145deg,var(--m-surface),#0c2037);
    border:1px solid var(--m-border);border-radius:var(--m-radius-lg);
    box-shadow:var(--m-shadow-card);
  }
  #app .meki-m-card[data-status="success"]{border-left:3px solid var(--m-success)}
  #app .meki-m-card[data-status="warning"]{border-left:3px solid var(--m-warning)}
  #app .meki-m-card[data-status="danger"]{border-left:3px solid var(--m-danger)}
  #app .meki-m-card[data-status="neutral"]{border-left:3px solid var(--m-neutral)}
  #app .meki-m-card[data-status="info"]{border-left:3px solid var(--m-secondary)}
  #app .meki-m-stack{display:flex;flex-direction:column;gap:var(--m-space-3)}
  #app .meki-m-row{display:flex;align-items:center;gap:var(--m-space-2);min-width:0}
  #app .meki-m-btn{
    min-height:44px;display:inline-flex;align-items:center;justify-content:center;
    gap:8px;padding:10px 15px;border:1px solid transparent;
    border-radius:var(--m-radius-md);
    background:linear-gradient(115deg,var(--m-primary),#22c3d8);
    color:#052b3a;font-size:12px;font-weight:830;
    cursor:pointer;
  }
  #app .meki-m-btn[data-variant="secondary"]{
    background:var(--m-surface-raised);border-color:var(--m-border-strong);
    color:var(--m-text);
  }
  #app .meki-m-btn[data-variant="danger"]{
    background:#542c3e;border-color:#a65e77;color:#ffc7d1;
  }
  #app .meki-m-chip{
    display:inline-flex;align-items:center;gap:5px;
    border-radius:999px;padding:6px 10px;
    background:#173d57;border:1px solid #2f6780;
    color:#d1eaff;font-size:11px;font-weight:760;
  }
  #app .meki-m-chip[aria-pressed="true"]{
    background:var(--m-primary);border-color:var(--m-primary);color:#092b37;
  }
  #app .meki-m-status{
    display:inline-flex;border-radius:999px;padding:4px 9px;
    font-size:10px;font-weight:800;
  }
  #app .meki-m-status[data-status="success"]{color:#74f0c7;background:#114940}
  #app .meki-m-status[data-status="warning"]{color:#ffdc91;background:#4d3818}
  #app .meki-m-status[data-status="danger"]{color:#ffadbe;background:#4f2838}
  #app .meki-m-status[data-status="neutral"]{color:#c1d5e6;background:#273d51}
  #app .meki-m-status[data-status="info"]{color:#abd4ff;background:#173a59}
  #app :is(button,input,select,textarea,summary):focus-visible{
    outline:2px solid var(--m-primary);outline-offset:2px;
  }
  #app :is(button,input,select,textarea):disabled{opacity:.55;cursor:not-allowed}
  #app .meki-m-sr-only{
    position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;
    clip:rect(0,0,0,0);white-space:nowrap;border:0;
  }
}

/* Modais são irmãos do #app no HTML: o escopo de CSS precisa ser explícito.
   Não altera as ações dos botões e não modifica modais em computador. */
@media screen and (max-width:760px){
  body:has(#app:not(.hidden)) .modal.show{
    background:rgba(1,9,21,.76);padding:11px;
    align-items:center;
  }
  body:has(#app:not(.hidden)) .modal .modalbox{
    width:min(100%,500px);max-height:min(90dvh,850px);
    background:linear-gradient(160deg,#112d47,#0a1d31);
    border:1px solid #2b5b76;border-radius:19px;
    color:#f0f8ff;
    box-shadow:0 20px 60px #0009;padding:17px;
  }
  body:has(#app:not(.hidden)) .modal .modalbox :is(h2,h3,b,strong,label){
    color:#eff8ff;
  }
  body:has(#app:not(.hidden)) .modal .modalbox :is(input,select,textarea){
    color-scheme:dark;
  }
  body:has(#app:not(.hidden)) .modal .modalbox .close{
    background:#19394f;color:#d9eeff;width:36px;height:36px;
    border:1px solid #345a75;
  }
  body:has(#app:not(.hidden)) .modal .modalbox .btn.primary{
    background:linear-gradient(115deg,#39f4df,#23d0dc);
    color:#082a37;
  }
  body:has(#app:not(.hidden)) .modal .modalbox .btn.light{
    background:#1b3951;color:#d1e8f8;border:1px solid #315b75;
  }
}
@media print{
  #app .meki-m-card{box-shadow:none!important;background:#fff!important;color:#111!important}
}

/* Botões da navegação preservam o estado de expansão e foco no menu móvel. */
@media screen and (max-width:760px){
  #app.mobile-menu-open .mobile-tab[data-mobile-section="mais"]{
    color:#25e7d7!important;
    background:#143a50!important;
  }
  #app .mobile-tab[data-mobile-section="mais"][aria-expanded="true"]{
    box-shadow:inset 0 0 0 1px #357c8a;
  }
  #app .mobile-bottom-nav button{
    min-height:44px;
    touch-action:manipulation;
  }
}
@media screen and (max-width:360px){
  #app .mobile-bottom-nav .mobile-tab{font-size:9px;gap:2px}
  #app .mobile-bottom-nav .mobile-tab svg{width:20px;height:20px}
}
