/* Ajustes da demonstração sobre a folha do sistema real:
   - a barra "Demonstração" da Systemat fica no topo (sticky); o cabeçalho e o menu descem a altura dela
   - telas estreitas: filtros recolhíveis e cabeçalho enxuto */

:root { --demo-h: 34px; --top-h: 57px; }

/* clip (e não hidden): hidden no body quebraria o sticky do cabeçalho */
body { overflow-x: clip; }
body { min-height: 100vh; }

.topbar { top: var(--demo-h); }
.sidebar {
  top: calc(var(--demo-h) + var(--top-h));
  height: calc(100vh - var(--demo-h) - var(--top-h));
}
#detalhe, #detalhe-fundo { top: var(--demo-h); }
.login-fundo { top: var(--demo-h); align-items: flex-start; padding-top: max(20px, 8vh); overflow-y: auto; }
.modal-fundo { top: var(--demo-h); }
.card-lista, .hc-card { scroll-margin-top: calc(var(--demo-h) + var(--top-h) + 14px); }

/* itens do menu que existem no sistema completo mas não entraram na demonstração */
.nav-item.demo-off { opacity: .62; }
.nav-item.demo-off .rotulo::after { content: " ·"; color: var(--text-muted); }

/* login: perfil Gestor × Representante */
.login-perfil { display: flex; margin-bottom: 8px; }
.login-perfil button { flex: 1; padding: 8px 10px; font-size: 13px; margin: 0; }
.login-card .login-perfil button { margin-top: 0; }
.login-dica { font-size: 12px; color: var(--text-secondary); margin: 0 0 16px; line-height: 1.5; min-height: 36px; }
.login-rodape { font-size: 11.5px; color: var(--text-muted); margin: 14px 0 0; text-align: center; }

/* filtros: resumo clicável só em tela estreita */
.filtros-resumo { display: none; }
.filters.inativo .filters-inner { opacity: .55; }
.filters .aviso-filtro { font-size: 11.5px; color: var(--text-muted); align-self: center; }
select:disabled { opacity: .7; cursor: not-allowed; }

/* telas de "sistema completo" */
.so-demo-card { max-width: 760px; }
.so-demo-card .lista-telas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* números e links clicáveis dentro de tabela */
.link { color: var(--series-1); cursor: pointer; text-decoration: none; font-weight: 600; background: none; border: 0; padding: 0; font: inherit; }
.link:hover { text-decoration: underline; background: none; }
td .link { font-weight: 600; }
.temp { display: inline-block; font-size: 11.5px; font-weight: 640; padding: 2px 8px; border-radius: 100px; white-space: nowrap; }
.temp.quente { background: color-mix(in srgb, var(--series-8) 20%, transparent); }
.temp.morno { background: color-mix(in srgb, var(--series-4) 26%, transparent); }
.temp.frio { background: color-mix(in srgb, var(--series-1) 16%, transparent); }
.pill.st-sem { background: color-mix(in srgb, var(--critical) 18%, transparent); border-color: transparent; }
.pill.st-baixo { background: color-mix(in srgb, var(--series-4) 26%, transparent); border-color: transparent; }
.pill.st-ok { background: color-mix(in srgb, var(--good) 15%, transparent); border-color: transparent; }
.pill.st-excesso { background: color-mix(in srgb, var(--series-7) 18%, transparent); border-color: transparent; }
.pill.st-parado { background: var(--surface-2); border-color: transparent; color: var(--text-secondary); }
.pill.pos-bloq { background: color-mix(in srgb, var(--critical) 16%, transparent); border-color: transparent; }
.pill.pos-lib { background: color-mix(in srgb, var(--series-1) 15%, transparent); border-color: transparent; }
.pill.pos-mon { background: color-mix(in srgb, var(--series-3) 18%, transparent); border-color: transparent; }
.pill.pos-pen { background: color-mix(in srgb, var(--series-4) 24%, transparent); border-color: transparent; }

/* positivação: mini gráficos por RCA */
.mini-card { padding: 12px 14px; }
.mini-card h3 { margin: 0 0 2px; font-size: 13px; font-weight: 640; }
.mini-card .hint { margin: 0 0 6px; }

/* modal de ruptura */
.modal-corpo select, .modal-corpo input { width: 100%; max-width: none; }
.modal-corpo .linha2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (max-width: 900px) {
  .sidebar { top: calc(var(--demo-h) + var(--top-h)); height: calc(100dvh - var(--demo-h) - var(--top-h)); }
}

@media (max-width: 640px) {
  .topbar-inner { padding: 8px 12px; gap: 8px; flex-wrap: nowrap; }
  .brand { min-width: 0; }
  .brand h1 { font-size: 15.5px; white-space: nowrap; }
  .brand .sub, .status-chip, #btn-sync { display: none; }
  .usuario-chip { gap: 4px; min-width: 0; }
  .usuario-chip #usuario-nome { max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding: 14px 12px; }
  footer { padding: 14px 12px 32px; }
  .filtros-resumo {
    display: flex; width: 100%; align-items: center; gap: 8px; justify-content: flex-start;
    border: 0; border-radius: 0; background: transparent; padding: 10px 12px; font-weight: 600; text-align: left;
  }
  .filtros-resumo .muted { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
  .filters-inner { display: none; padding: 4px 12px 12px; }
  .filters.aberto .filters-inner { display: flex; }
  .filters-inner .field { flex: 1 1 140px; min-width: 0; }
  .filters-inner .field:first-child { flex-basis: 100%; }
  .filters-inner select, .filters-inner input[type="date"] { min-width: 0; width: 100%; max-width: none; }
  .card { padding: 13px; }
  .card-head { flex-wrap: wrap; }
  .kpi .value { font-size: 23px; }
  .chart-wrap.h420 { height: 380px; }
  .modal-corpo .linha2 { grid-template-columns: 1fr; }
  .truncate { max-width: 200px; }
}

a.chip { text-decoration: none; display: inline-block; }
a.chip:hover { background: var(--surface-2); }
.hc-cabecalho > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.filtros-locais .field.estreito { flex: 0 1 260px; }
.acao-filtros + .subtabs { margin-top: 14px; }
#tb-acao td:nth-child(3), #tb-rc-agenda td:nth-child(3) { white-space: nowrap; }

.acao-curto { display: none; }
@media (max-width: 640px) { .acao-longo { display: none; } .acao-curto { display: inline; } }

/* balões empilhados em vez de sobrepostos */
#toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 95; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
#toast-host .toast { position: static; pointer-events: auto; }
@media (max-width: 640px) {
  #toast-host { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  #toast-host .toast { max-width: none; }
  #detalhe { width: 100vw; }
  #detalhe .detalhe-topo h2 { flex-basis: 100%; order: -1; }
  #detalhe .detalhe-topo .lista-acoes { margin-left: auto; }
}
