/*
 * Painel super-admin do Combinado — tokens e helpers.
 * Fonte: "Combinado - Painel super admin.dc.html" (Claude Design). Os tokens
 * abaixo são exatamente os do design; hover/focus vivem aqui porque não existem
 * em style="" inline.
 */
html { color-scheme: dark light; }
body { margin: 0; background: #081F1C; font-family: 'Manrope', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
html[data-tema="light"] body { background: #FBF8F3; }
* { box-sizing: border-box; }
input, button, select, textarea { font-family: inherit; }
a { color: #6BD3C2; text-decoration: none; }
a:hover { color: #EDA85A; }
[hidden] { display: none !important; }

[data-cmb] {
  --sf: #081F1C; --sf2: #0B2724; --cd: #0E2F2A; --bd: #1C403A; --bd2: #173731;
  --tx: #E8F1EF; --mu: #9BB5B0; --pr: #6BD3C2; --prs: #123F39; --onpr: #062522;
  --ac: #D9892F; --acu: #EDA85A; --acbg: #33291B; --al: #E4739A; --albg: #3A2029;
  --gy: #A9BFC6; --gybg: #1B2E33; --ne: #9A968B; --nebg: #22292A;
  --sb: #061A18; --sbmu: #79A9A1; --logo: #FBF8F3; --sbact: rgba(107,211,194,.14);
  --sh: 0 1px 2px rgba(0,0,0,.3); --rowpy: 13px;
}
[data-cmb][data-theme="light"] {
  --sf: #FBF8F3; --sf2: #F4EFE7; --cd: #FFFFFF; --bd: #E4DED4; --bd2: #EFE9E0;
  --tx: #10231F; --mu: #55635F; --pr: #0E4B43; --prs: #E3F0EC; --onpr: #FBF8F3;
  --ac: #D9892F; --acu: #A05E1B; --acbg: #F7EBDC; --al: #AA3A62; --albg: #F7E4EA;
  --gy: #5E7079; --gybg: #E9EDEF; --ne: #8C877B; --nebg: #EEEBE4;
  --sb: #0E4B43; --sbmu: #8FBDB4; --logo: #0E4B43; --sbact: rgba(251,248,243,.12);
  --sh: 0 1px 2px rgba(16,35,31,.05);
}
[data-cmb][data-density="Compacta"] { --rowpy: 8px; }

@keyframes cmbIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes cmbSpin { to { transform: rotate(360deg); } }
@keyframes cmbShimmer { to { background-position: -200% 0; } }

/* Estados de interação (o design usa style-hover / style-focus) */
.hv-bd:hover { border-color: var(--pr) !important; }
.hv-op:hover { opacity: .9; }
.hv-side:hover { background: rgba(251,248,243,.14) !important; }
.hv-danger:hover { border-color: var(--al) !important; color: var(--al) !important; }
.fc:focus { outline: none; border-color: var(--pr) !important; }
.fc-plain:focus { outline: none; }
a[style], button[style] { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--pr); outline-offset: 2px;
}
.fc:focus-visible, .fc-plain:focus-visible { outline: none; }
button:disabled { opacity: .55; cursor: not-allowed; }
select.fc { appearance: auto; }
input[type="date"] { color-scheme: dark; }
[data-theme="light"] input[type="date"] { color-scheme: light; }

/* Entrada suave das páginas e cartões (movimento: 120–320ms, só transform/opacity) */
.a-in { animation: cmbIn .28s cubic-bezier(.2,.7,.2,1) both; }

/* Skeleton enquanto o mapa (ou outro bloco assíncrono) carrega */
.a-skel { border-radius: 12px; background: linear-gradient(90deg, var(--sf2) 25%, var(--bd2) 37%, var(--sf2) 63%); background-size: 200% 100%; animation: cmbShimmer 1.4s linear infinite; }

/* Diálogos (formulários em modal) */
dialog.a-modal { padding: 0; border: 1px solid var(--bd); border-radius: 16px; background: var(--cd); color: var(--tx); width: min(520px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(0,0,0,.35); }
dialog.a-modal::backdrop { background: rgba(4, 16, 14, .62); backdrop-filter: blur(2px); }
dialog.a-modal[open] { animation: cmbIn .22s cubic-bezier(.2,.7,.2,1) both; }

/* Seleção de linha / detalhes expansíveis */
details.a-det > summary { list-style: none; cursor: pointer; }
details.a-det > summary::-webkit-details-marker { display: none; }

/* Barra de rolagem discreta nos blocos roláveis */
.a-scroll { scrollbar-width: thin; scrollbar-color: var(--bd) transparent; }

/* Toasts (mensagens flash) */
.a-toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; max-width: min(420px, calc(100vw - 32px)); animation: cmbIn .25s cubic-bezier(.2,.7,.2,1) both; }

/* ------------------------------------------------------------------
 * Celular e tablet pequeno (até 900px) — fonte: "Combinado - Painel super
 * admin mobile v2" (Claude Design). A sidebar vira gaveta, entram a barra
 * superior e a barra de abas inferior, e as tabelas viram cartões.
 * Acima de 900px tudo isso fica escondido (o desktop não muda).
 * ------------------------------------------------------------------ */
.a-mbar, .a-mhead, .a-bottomnav, .a-cartoes, .a-so-mobile, .a-so-mobile-i { display: none; }
.a-drawer { display: none; }
.a-ic-sol, .a-ic-lua { display: none; }
[data-theme="dark"] .a-ic-sol, [data-theme="light"] .a-ic-lua { display: block; }
.a-gira { animation: cmbSpin .7s linear infinite; }
html.a-trava { overflow: hidden; }

@media (max-width: 900px) {
  .a-side, .a-topbar-d, .a-so-desktop { display: none !important; }
  .a-mbar { display: flex; }
  .a-mhead { display: flex; }
  .a-bottomnav { display: flex; }
  .a-drawer { display: block; }
  .a-cartoes { display: flex; }
  .a-so-mobile { display: block; }
  .a-so-mobile-i { display: inline; }
  .a-span2 { grid-column: auto !important; }
  .a-toast { bottom: calc(84px + env(safe-area-inset-bottom)); right: 16px; }

  /* Barra superior: linha fixa (menu, marca, tema, atualizar, avatar) */
  .a-mbar { position: sticky; top: 0; z-index: 50; align-items: center; gap: 8px; padding: 10px 12px; background: var(--cd); }
  .a-mbtn { width: 40px; height: 40px; flex: none; display: flex; align-items: center; justify-content: center; padding: 0; background: var(--sf2); border: 1px solid var(--bd); border-radius: 11px; color: var(--mu); cursor: pointer; }
  .a-mbtn:hover { border-color: var(--pr); }
  .a-mbtn-menu { width: 44px; height: 44px; border-radius: 12px; color: var(--tx); }
  .a-mbtn svg { width: 17px; height: 17px; }
  .a-mbtn-menu svg { width: 19px; height: 19px; }
  .a-ic-sol { color: var(--acu); }
  .a-ic-lua { color: var(--pr); }
  .a-mavatar { width: 40px; height: 40px; flex: none; border-radius: 999px; background: var(--prs); display: flex; align-items: center; justify-content: center; font: 700 12.5px/1 'Manrope', sans-serif; color: var(--pr); }
  /* Busca + migalha + título (rolam junto com a página) */
  .a-mhead { flex-direction: column; gap: 10px; padding: 2px 12px 12px; background: var(--cd); border-bottom: 1px solid var(--bd); }
  .a-mbusca { display: flex; align-items: center; gap: 9px; min-height: 44px; padding: 0 13px; background: var(--sf2); border: 1px solid var(--bd); border-radius: 12px; }
  .a-mbusca svg { width: 15px; height: 15px; flex: none; color: var(--mu); }
  .a-mbusca input { flex: 1; min-width: 0; height: 42px; background: transparent; border: none; font: 500 13.5px/1 'Manrope', sans-serif; color: var(--tx); }

  /* Barra de abas inferior */
  .a-bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; gap: 4px; padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); background: var(--cd); border-top: 1px solid var(--bd); }
  .a-aba { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 56px; padding: 0 2px; border: none; border-radius: 13px; background: transparent; color: var(--mu); font: 600 10px/1.2 'Manrope', sans-serif; text-decoration: none; cursor: pointer; transition: background .15s; }
  .a-aba:hover { color: var(--tx); }
  .a-aba svg { width: 20px; height: 20px; }
  .a-aba[aria-current="page"], .a-aba[aria-expanded="true"], .a-aba[aria-current="page"]:hover, .a-aba[aria-expanded="true"]:hover { background: var(--prs); color: var(--pr); font-weight: 700; }

  /* Gaveta (menu lateral) — entra e sai por transform/opacity */
  .a-drawer { position: fixed; inset: 0; z-index: 80; background: rgba(8, 31, 28, .52); visibility: hidden; opacity: 0; transition: opacity .2s ease, visibility 0s linear .2s; }
  .a-drawer[data-aberto] { visibility: visible; opacity: 1; transition: opacity .2s ease; }
  .a-drawer-painel { width: 272px; max-width: 84%; height: 100%; display: flex; flex-direction: column; gap: 18px; padding: 18px 14px calc(18px + env(safe-area-inset-bottom)); background: var(--cd); border-right: 1px solid var(--bd); overflow-y: auto; transform: translateX(-100%); transition: transform .22s cubic-bezier(.22, .7, .3, 1); }
  .a-drawer[data-aberto] .a-drawer-painel { transform: none; }
  .a-mgrupo { display: flex; flex-direction: column; gap: 2px; }
  .a-mgrupo-rotulo { padding: 0 11px; margin-bottom: 5px; font: 700 9.5px/1.3 'Manrope', sans-serif; letter-spacing: .15em; text-transform: uppercase; color: var(--mu); }
  .a-mnav { display: flex; align-items: center; gap: 11px; min-height: 48px; padding: 0 11px; width: 100%; border-radius: 12px; color: var(--mu); font: 600 13.5px/1.25 'Manrope', sans-serif; text-decoration: none; transition: background .15s; }
  .a-mnav:hover { color: var(--tx); background: var(--sf2); }
  .a-mnav svg { width: 17px; height: 17px; flex: none; }
  .a-mnav[aria-current="page"], .a-mnav[aria-current="page"]:hover { background: var(--prs); color: var(--pr); font-weight: 700; }
  .a-mnav-n { margin-left: auto; font: 700 10.5px/1.3 'Manrope', sans-serif; color: var(--mu); background: var(--sf2); border: 1px solid var(--bd); padding: 3px 7px; border-radius: 6px; }

  /* Conteúdo: respiro menor e espaço para a barra inferior */
  .a-conteudo { padding: 14px 14px calc(96px + env(safe-area-inset-bottom)) !important; gap: 14px !important; }
  .a-card { padding: 15px !important; }

  /* Abas/período: uma linha rolável, sem moldura */
  .a-toolbar { flex-direction: column; align-items: stretch !important; gap: 10px !important; }
  .a-tabs { flex-wrap: nowrap !important; overflow-x: auto; gap: 7px !important; padding: 0 0 2px !important; background: none !important; border: none !important; border-radius: 0 !important; max-width: 100%; scrollbar-width: none; }
  .a-tabs::-webkit-scrollbar { display: none; }
  .a-tabs > a, .a-tabs > button { flex: none; }
  .a-dica, .a-busca-pagina { display: none !important; }
  .a-acoes { margin-left: 0 !important; display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px !important; width: 100%; }
  .a-acoes > * { justify-content: center; min-height: 44px; }

  /* Painel: KPIs compactos (2 por linha), listas e gráficos enxutos */
  .a-kpi { padding: 13px !important; gap: 8px !important; }
  .a-kpi-vd { flex-direction: column !important; align-items: flex-start !important; gap: 8px !important; }
  .a-kpi-v { font-size: 23px !important; }
  .a-kpi-spark { height: 26px !important; gap: 2px !important; }
  .a-kpi-dica, .a-kpi-ponto { display: none !important; }
  .a-mes-6:nth-child(-n+6), .a-mes-4:nth-child(-n+4) { display: none !important; }
  .a-grafico { gap: 8px !important; }
  .a-donut { flex-wrap: nowrap !important; gap: 16px !important; }
  .a-donut > div:last-child { flex: 1 1 0 !important; min-width: 0 !important; }
  .a-pct { display: none !important; }
  .a-mapa-stats { margin-left: 0 !important; width: 100%; gap: 10px !important; }
  .a-mapa-stats > div { flex: 1; }
  [data-mapa-clinicas] { height: auto !important; min-height: 660px !important; }
  .a-cobr { grid-template-columns: 1fr auto !important; }
  .a-proj { grid-template-columns: 52px 1fr auto !important; }
  .a-rodape-acoes { margin-left: 0 !important; width: 100%; }
  .a-rodape-acoes > * { flex: 1; justify-content: center; min-height: 46px; }

  /* Tabelas viram cartões */
  .a-tabela { display: none !important; }
  .a-tabela-cartao { background: none !important; border: none !important; box-shadow: none !important; overflow: visible !important; display: flex; flex-direction: column; gap: 12px; }
  .a-cartoes { flex-direction: column; gap: 10px; }
  .a-cartao { background: var(--cd); border: 1px solid var(--bd); border-radius: 13px; padding: 13px 14px; box-shadow: var(--sh); display: flex; flex-direction: column; gap: 10px; }
  .a-cartao-topo { display: flex; align-items: flex-start; gap: 9px; }
  .a-cartao-titulo { min-width: 0; font: 700 13.5px/1.3 'Manrope', sans-serif; color: var(--tx); overflow-wrap: anywhere; }
  .a-cartao-fim { margin-left: auto; flex: none; }
  .a-cartao-campos { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; }
  .a-cartao-campo { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
  .a-cartao-k { font: 700 9px/1.3 'Manrope', sans-serif; letter-spacing: .12em; text-transform: uppercase; color: var(--mu); }
  .a-cartao-v { font: 600 12.5px/1.35 'Manrope', sans-serif; color: var(--tx); overflow-wrap: anywhere; }
  .a-totais { background: var(--cd); border: 1px solid var(--bd); border-radius: 13px; padding: 14px 15px !important; }
  .a-contagem { font: 500 11.5px/1.3 'Manrope', sans-serif; color: var(--mu); }
  .a-pag { padding: 0 !important; }
  .a-so-mobile.a-acao-fim { display: flex; flex-direction: column; gap: 8px; }
  .a-acao-fim > *, .a-acao-fim form > button { width: 100%; min-height: 48px; justify-content: center; border-radius: 12px !important; font-size: 13.5px !important; }

  /* Diálogos e campos */
  .a-kpis { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  dialog.a-modal { max-height: calc(100dvh - 24px); overflow-y: auto; }
  input, select, textarea { font-size: 16px !important; } /* evita o zoom automático do iOS ao focar */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
