/* © 2026 Jose Carvalho. Intel Ceasa. Ver LICENSE. */
/* Mapa (planta 2D/3D, barra, painel do box, vistoria, aba de indicadores): as regras do
   ceasa-mapa (assets/styles.css), sem fontes, cores globais, cabecalho e tema escuro antigos,
   que agora vem de tokens.css e ponte-erp.css. Carregado so nas telas de mapa. */
/* ============================================================
   LAYOUT DO APP
   ============================================================ */
/* A linha do cabecalho e minimo, nao valor fixo. Com "var(--header-h) 1fr" o
   que nao coubesse era cortado calado: foi assim que a marca sumiu pela metade
   quando a barra lateral estava aberta. */
.app {
  display: grid;
  grid-template-rows: minmax(var(--header-h), auto) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Corpo: mapa + painel ---------- */
.main {
  display: grid;
  grid-template-columns: 1fr var(--panel-w);
  min-height: 0;
  position: relative;
}
/* A largura que sobra para o mapa e o painel e a da CASCA, nao a da janela. E a
   mesma licao ja anotada acima no .hdr, que nunca chegou aqui embaixo: com a
   barra lateral aberta a janela continua dizendo 1440 enquanto o corpo so tem
   1184, e o painel reservava 400px iguais. Medido com a barra aberta, antes
   desta regra: janela 1440 dava palco de 844px, janela 1280 dava 684 e janela
   1000 dava 404, um palco menor que o painel ao lado. E o "abri a barra e
   quebrou tudo".

   O container fica so no desktop de proposito: container-type liga contencao, e
   contencao faz o position:fixed de dentro se ancorar no container em vez de na
   janela. Abaixo de 861px o painel vira bottom sheet fixo, e ancorar aquilo na
   casca deslocaria a gaveta inteira. */
@media (min-width: 861px) {
  .app {
    container: casca / inline-size;
  }
  /* tres degraus, medidos pelo espaco real do corpo:
     - 1240 ou mais: cabem palco confortavel + painel de 400
     - 1000 a 1240: painel encolhe para 340, palco fica com 660 ou mais
     O degrau de 1240 nao e redondo por acaso: com a barra aberta o corpo fica
     com 1184 numa janela de 1440, e essa tela tem de continuar com o painel
     compacto, exatamente como estava antes desta mudanca.
     - abaixo de 1000: nao cabem duas colunas. O painel desce para baixo do
       palco em vez de espremer os dois. */
  @container casca (min-width: 1240px) {
    .main {
      --panel-w: 400px;
    }
  }
  @container casca (min-width: 1000px) and (max-width: 1239.98px) {
    .main {
      --panel-w: 340px;
    }
  }
  @container casca (max-width: 999.98px) {
    /* Painel embaixo, e o mapa com piso de 320px: em 1024x768 a barra de
       indicadores (duas linhas) e o painel (42% da altura) deixavam 120px para o
       mapa, com zoom e legenda saindo por cima dele. Agora a area rola. */
    .main {
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: minmax(min-content, 1fr) minmax(0, auto);
      overflow-y: auto;
    }
    /* .main > .stage: o .stage solto, mais abaixo neste arquivo, venceria */
    .main > .stage {
      grid-template-rows: auto minmax(320px, 1fr);
    }
    .panel {
      border-left: 0;
      border-top: 1px solid var(--line);
      max-height: 42cqh;
    }
  }
}

.stage {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  /* minmax(0,1fr): coluna implícita "auto" cresce até o min-content do toolbar
     (KPIs sem quebra) e empurra o mapa pra fora da tela no mobile */
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
}
.toolbar {
  min-width: 0;
}

/* ---------- Barra de KPIs + modos ---------- */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
/* Os indicadores desta barra sao o INDICADOR unico do sistema (.erp-kpi, em
   assets/composicao.css, secao 3), na densidade da barra do mapa. As classes
   .kpis, .kpi, .k-eyebrow e .k-trend continuam no markup do index.html so como
   gancho: app.js le o valor e o rotulo por elas para a faixa de operacao
   (#opbar) e o teste do nucleo mede o rotulo cortado. Nenhuma regra de desenho
   mora nelas. */

/* ---------- Segunda linha da toolbar: modos + controles ---------- */
.toolbar-row2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.toolbar-row2-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  order: 1;
}
#btn-vistoria {
  order: 2;
}
.modes,
.viewtoggle,
.daytoggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  height: var(--ctrl-h);
  border-radius: 12px;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  box-sizing: border-box;
}
.mode,
.vt {
  /* borda de 1px sempre presente e transparente: o hover so pinta a cor dela,
     sem mexer em tamanho (a regua pede espessura constante em todo estado) */
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--body);
  font-size: var(--t-md);
  font-weight: var(--fw-semibold);
  color: var(--muted-foreground);
  padding: 0 11px; /* 11 + 1 de borda = os 12px de antes: a fila nao alarga */
  height: 100%;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  letter-spacing: normal;
  transition: var(--transicao-controle, background-color 150ms, box-shadow 150ms);
}
.mode svg {
  width: 14px;
  height: 14px;
}
.mode:hover:not(:disabled),
.vt:hover:not(:disabled) {
  color: var(--green-900);
  border-color: var(--line);
}
/* O ativo tambem responde ao ponteiro: o contorno esverdeia. Antes o ativo
   era o unico segmento sem hover nenhum, e e ele o primeiro da fila. */
.mode[aria-pressed="true"],
.vt[aria-pressed="true"] {
  background: var(--card);
  color: var(--green-900);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.mode[aria-pressed="true"]:hover:not(:disabled),
.vt[aria-pressed="true"]:hover:not(:disabled) {
  border-color: var(--green-300);
}
#btn-vistoria.btn {
  height: var(--ctrl-h);
  box-sizing: border-box;
}

/* ---------- Área do mapa ---------- */
.map-wrap {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(30, 122, 76, 0.06), transparent 60%),
    var(--paper);
  cursor: grab;
  touch-action: none;
}
.map-wrap.dragging {
  cursor: grabbing;
}
.map-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  touch-action: none;
}
.map3d { position: absolute; inset: 0; display: none; touch-action: none; }
.map3d canvas { display: block; width: 100% !important; height: 100% !important; }
.map-wrap.is3d .map3d { display: block; }
.map-wrap.is3d > svg { display: none; }
.map-wrap.is3d { cursor: grab; }
/* .viewtoggle e .vt já estilizados acima, junto com .modes (mesma família visual) */

/* Legenda flutuante */
.legend {
  position: absolute;
  left: 16px;
  bottom: 16px;
  /* Superficie flutuante do tema, nao branco fixo: o texto daqui segue o tema, e no escuro
     virava claro sobre branco -- 1,03:1, legenda e zoom invisiveis (juiz final, 11/09/2026). */
  background: var(--popover, var(--card));
  background: color-mix(in srgb, var(--popover, var(--card)) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 170px;
  z-index: 3;
}
.legend h4 {
  font-family: var(--mono);
  font-size: var(--t-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-bottom: 2px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--t-sm);
  color: var(--ink);
}
.legend-row i {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(10, 40, 25, 0.18);
  flex: none;
}
.legend-row em {
  margin-left: auto;
  font-style: normal;
  font-family: var(--mono);
  font-weight: var(--fw-medium);
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}
.legend-scale {
  height: 10px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--m-adimplente), var(--m-leve), var(--m-medio), var(--m-inad));
  border: 1px solid rgba(10, 40, 25, 0.12);
}
.legend-scale-lbl {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  color: var(--muted-foreground);
}

/* Controles de zoom */
.zoom {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  z-index: 3;
  border-radius: 12px;
  /* Superficie flutuante do tema, nao branco fixo: o texto daqui segue o tema, e no escuro
     virava claro sobre branco -- 1,03:1, legenda e zoom invisiveis (juiz final, 11/09/2026). */
  background: var(--popover, var(--card));
  background: color-mix(in srgb, var(--popover, var(--card)) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.zoom button {
  width: 36px;
  height: 36px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--foreground, var(--ink));
  font-family: var(--sora); /* "+"/"-" é glifo, não texto de corpo */
  font-size: 18px;
  font-weight: var(--fw-bold);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: var(--transicao-controle, background-color 150ms);
}
.zoom button:last-child {
  border-bottom: none;
}
.zoom button:hover {
  background: rgba(30, 122, 76, 0.08);
  color: var(--green-700);
}
.zoom button svg {
  width: 16px;
  height: 16px;
}
#zfull svg { transform: rotate(0deg); }
/* sem a toolbar, o mapa vira o 1º item do grid e cairia na linha "auto" (altura 0) */
body.fullscreen .stage {
  grid-template-rows: 1fr;
}
body.fullscreen #zfull svg { transform: rotate(180deg); }

/* ---------- Dia/noite ---------- */
.daytoggle .vt:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Minimapa 2D ---------- */
#minimap {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  width: 200px;
  height: 80px;
  /* mesma superficie da legenda e do zoom: o branco fixo acendia no tema escuro */
  background: var(--popover, var(--card));
  background: color-mix(in srgb, var(--popover, var(--card)) 92%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: crosshair;
  z-index: 4;
}
.map-wrap.is3d #minimap { display: block; }
#minimap svg { width: 100%; height: 100%; display: block; }
#minimap rect { fill: #cfe0d3; stroke: none; }
#mm-view { fill: rgba(30, 122, 76, .18); stroke: var(--green); stroke-width: 8; }
#mm-target { fill: var(--citrus); }
body.fullscreen #minimap { top: 64px; }

/* ---------- Faixa de operação (tela cheia) ---------- */
#opbar {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 6;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(11, 59, 42, .82);
  color: #fff;
  font-family: var(--body);
  font-size: var(--t-md);
  backdrop-filter: blur(6px);
}
body.fullscreen #opbar { display: flex; }
#opbar img { width: 22px; height: 22px; border-radius: 6px; }
#opbar > span { font-family: var(--body); font-weight: var(--fw-semibold); font-size: var(--t-md); }
#opbar-clock { font-variant-numeric: tabular-nums; margin-left: 6px; }
.opbar-kpis { display: flex; gap: 14px; margin-left: auto; font-size: var(--t-xs); flex-wrap: wrap; }
.opbar-kpis b { font-variant-numeric: tabular-nums; }

body.fullscreen .hdr,
body.fullscreen .panel,
body.fullscreen .toolbar { display: none; }
body.fullscreen .main { grid-template-columns: 1fr; }
body.fullscreen .app { grid-template-rows: 1fr; }

@media (max-width: 860px) {
  #minimap { width: 120px; height: 48px; }
}

/* Tooltip do hover */
.tip {
  position: absolute;
  pointer-events: none;
  background: var(--forest);
  color: #fff;
  border-radius: 10px;
  padding: 8px 11px;
  font-size: var(--t-sm);
  line-height: 1.35;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, -8px) scale(0.96);
  transition: opacity var(--dur-media, 200ms) var(--ease), transform var(--dur-media, 200ms) var(--ease);
  z-index: 5;
  white-space: nowrap;
  max-width: 260px;
}
.tip.on {
  opacity: 1;
  transform: translate(-50%, -12px) scale(1);
}
.tip-eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lime);
  margin-bottom: 2px;
}
.tip-name {
  font-size: var(--fs-13);
  font-weight: var(--fw-semibold);
  color: #fff;
}
.tip-status {
  font-size: var(--fs-11);
  color: #c8dccb;
  margin-top: 2px;
}

/* ---------- SVG: boxes ---------- */
.box {
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform var(--dur-media, 200ms) var(--ease), filter var(--dur-media, 200ms) var(--ease);
}
.box rect.b {
  stroke: rgba(10, 40, 25, 0.35);
  stroke-width: 1;
  /* a troca de modo repinta 176 boxes de uma vez: e troca de painel, dur-lenta */
  transition: fill var(--dur-lenta, 300ms) var(--ease), stroke var(--dur-rapida, 150ms) var(--ease), stroke-width var(--dur-rapida, 150ms) var(--ease);
}
.box text {
  font-family: var(--sora);
  font-weight: 700;
  fill: var(--green-900);
  text-anchor: middle;
  pointer-events: none;
  dominant-baseline: central;
  /* halo fino: ajuda os rótulos rotacionados (especiais), que não têm chip */
  paint-order: stroke fill;
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 1.2px;
  stroke-linejoin: round;
}
.box text.sub {
  font-family: var(--body);
  font-weight: 600;
  fill: var(--ink);
  font-size: 7.5px;
  stroke-width: 1.8px;
}
.box:hover {
  transform: translateY(-2px) scale(1.03);
  filter: drop-shadow(0 6px 10px rgba(10, 45, 28, 0.22));
}
.box:hover rect.b {
  stroke: var(--green-900);
  stroke-width: 1.6;
}
.box.sel rect.b {
  stroke: var(--green);
  stroke-width: 2.4;
}
.box.sel {
  filter: drop-shadow(0 0 0 rgba(30, 122, 76, 0)) drop-shadow(0 8px 14px rgba(30, 122, 76, 0.35));
}
.box.dim {
  opacity: 0.22;
}
.box.hit rect.b {
  stroke: var(--citrus);
  stroke-width: 2.6;
}
.box.vago rect.b {
  stroke-dasharray: 3 2;
}
.box.vago text {
  fill: var(--faint);
}
.box.inad-strong text {
  fill: var(--green-900); /* com o halo, texto escuro lê em cima do vermelho (branco dava 3,4:1) */
}

/* Anel de chamado aberto — pulso SVG */
.ring {
  fill: none;
  stroke: var(--citrus);
  stroke-width: 2;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
  animation: ringPulse 1.8s var(--ease) infinite;
}
.ring.urg {
  stroke: var(--danger);
  animation-duration: 0.9s;
}
@keyframes ringPulse {
  0% {
    transform: scale(0.6);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}
.badge {
  cursor: pointer;
}
.badge text {
  pointer-events: none;
}
/* chip atrás do rótulo do box — leitura garantida sobre qualquer cor do mapa de calor */
.box rect.chip {
  fill: rgba(255, 255, 255, 0.86);
  stroke: rgba(10, 40, 25, 0.08);
  stroke-width: 0.6;
  transition: fill var(--dur-lenta, 300ms) var(--ease);
}
.box.vago rect.chip {
  fill: rgba(255, 255, 255, 0.6);
}
.badge circle {
  fill: #963c0a; /* branco sobre --citrus dava 3,2:1 */
  stroke: #fff;
  stroke-width: 1.2;
}
.badge.urg circle {
  fill: var(--danger);
}
.badge text {
  fill: #fff;
  font-family: var(--sora);
  font-weight: 700;
  font-size: 8px;
  text-anchor: middle;
  dominant-baseline: central;
}

/* Rótulos e chão do mapa */
.ground {
  fill: #e6ede5;
}
.building {
  fill: #f8faf7;
  stroke: rgba(10, 40, 25, 0.22);
  stroke-width: 1.2;
}
.aisle {
  fill: #eef3ec;
}
.lbl {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  fill: var(--faint);
  pointer-events: none;
}
.lbl.big {
  font-size: 11px;
  letter-spacing: 2px;
  fill: var(--muted-foreground);
}
.deco {
  fill: none;
  stroke: rgba(10, 40, 25, 0.16);
  stroke-width: 1;
  pointer-events: none;
}
.pilar {
  fill: #b4bab6;
  stroke: #5f6963;
  stroke-width: 0.6;
  pointer-events: none;
}
.viga {
  fill: rgba(124, 132, 128, 0.25);
  pointer-events: none;
}
.deco-tree {
  fill: #b9d9bf;
  pointer-events: none;
}
.deco-table {
  fill: #fff;
  stroke: rgba(10, 40, 25, 0.18);
  pointer-events: none;
}

/* Entrada em cascata */
.box.enter {
  animation: boxIn 0.55s var(--ease) both;
}
@keyframes boxIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.85);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Flash quando o ERP atualiza um box */
@keyframes erpFlash {
  0% {
    stroke: var(--lime);
    stroke-width: 6;
    filter: drop-shadow(0 0 0 rgba(201, 233, 107, 0));
  }
  30% {
    filter: drop-shadow(0 0 12px rgba(201, 233, 107, 0.9));
  }
  100% {
    stroke: rgba(10, 40, 25, 0.35);
    stroke-width: 1;
    filter: none;
  }
}
.box.flash rect.b {
  animation: erpFlash 1.4s var(--ease);
}

/* ---------- Painel lateral ---------- */
.panel {
  background: var(--card);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* conteúdo re-renderizado a cada seleção — a alça (#sheet-handle) fica fora
   para sobreviver ao panel.replaceChildren() do app.js */
.panel-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
/* alça do bottom sheet — só visível/arrastável no mobile (ver media query) */
.sheet-handle {
  display: none;
  flex: none;
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  border: none;
  padding: 0;
  margin: 10px auto 6px;
}
.panel-in {
  animation: panelIn 0.35s var(--ease) both;
}
@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.p-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.p-head .row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.p-eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 2px;
}
.p-num {
  font-family: var(--sora);
  font-size: var(--fs-34);
  font-weight: var(--fw-black);
  color: var(--green-900);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.p-name {
  font-family: var(--sora);
  font-size: var(--t-xl);
  font-weight: var(--fw-bold);
  color: var(--ink);
  line-height: 1.2;
}
.p-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted-foreground);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.p-close:hover {
  color: var(--ink);
  border-color: var(--green-500);
}
.p-close svg {
  width: 14px;
  height: 14px;
}
.p-body {
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.p-sec h4 {
  font-family: var(--mono);
  font-size: var(--t-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.p-sec h4 .tag {
  margin-left: auto;
}
.p-sec-n {
  color: var(--faint);
}
.app .kv {
  display: grid;
  /* minmax(0, 1fr), e nao 1fr: "1fr" e minmax(AUTO, 1fr), entao o rotulo mais
     comprido empurra a coluna dele e as duas deixam de ser iguais (medido: 174
     contra 236px). Sem colunas iguais o indicador de 50% nao encaixa. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}
.app .kv > div {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 8px 11px;
}
.app .kv > div.wide {
  grid-column: 1 / -1;
}
/* so o rotulo do campo. Nao usar ".kv span": pega tambem o <span class="tag">
   dentro do <b>, que virava bloco cinza da largura toda no lugar da pilula. */
.app .kv > div > span {
  display: block;
  font-size: var(--t-xs);
  color: var(--muted-foreground);
  font-weight: var(--fw-regular);
  margin-bottom: 2px;
}
.app .kv b {
  font-size: var(--t-base);
  font-weight: var(--fw-semibold);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.app .kv b.danger {
  color: var(--danger-text);
}
.app .kv b.good {
  color: var(--good);
}
.erp-src {
  font-size: var(--t-xs);
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.erp-src i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-500);
}

/* Barra de dias em atraso */
.bar {
  height: 8px;
  border-radius: 99px;
  background: var(--line-soft);
  overflow: hidden;
  margin-top: 6px;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--m-leve), var(--m-medio), var(--m-inad));
  transform-origin: left;
  animation: barIn 0.7s var(--ease) both;
}
.bar-lbl {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  color: var(--muted-foreground);
  margin-top: 4px;
}
/* dentro de .kv > div.wide, ".kv span" (rótulo, 400) bateria em cima do <span> do
   próprio .bar-lbl — reforça a herança do mono/600 daqui */
.bar-lbl span {
  font: inherit;
  letter-spacing: inherit;
}
@keyframes barIn {
  from {
    transform: scaleX(0);
  }
}

/* Lista de chamados */
.ch-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ch {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 5px;
  animation: itemIn 0.35s var(--ease) both;
}
@keyframes itemIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.ch .top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--t-xs);
  color: var(--muted-foreground);
}
.ch-eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  color: var(--green-900);
}
.ch .top .tag {
  margin-left: auto;
}
.ch .ttl {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-13);
  color: var(--ink);
}
.ch .desc {
  font-size: var(--fs-12);
  color: var(--muted-foreground);
  line-height: 1.4;
}
.ch-foot {
  font-family: var(--mono);
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  color: var(--faint);
}
.ch.new {
  border-color: var(--green-500);
  background: linear-gradient(0deg, #fff, #f0f8f2);
}
.app .empty {
  font-size: var(--t-sm);
  color: var(--faint);
  padding: 10px 0;
}

/* Ações */
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.actions .btn {
  justify-content: center;
}
.actions .btn.wide {
  grid-column: 1 / -1;
}

/* Form de chamado */
.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  animation: itemIn 0.3s var(--ease) both;
}
/* O campo e o rotulo deste formulario sao o Campo de sistema.css (secao 4):
   altura, contorno, raio, fonte, hover, foco e desabilitado vem de la. Aqui
   fica so o arranjo: rotulo por cima do campo, e a descricao que cresce so
   para baixo. Antes havia um segundo desenho de campo aqui (contorno #e2e8e1,
   1,25:1 no branco, raio 9px, 13px, alturas 34 e 36 misturadas). */
.form label {
  display: flex;
  flex-direction: column;
}
.form textarea {
  resize: vertical;
}
.form .row2 {
  display: grid;
  /* Duas colunas so quando cada uma cabe a opcao mais longa do select.
     Historico: com 1fr puro as colunas saiam de larguras diferentes; com
     repeat(2, minmax(0, 1fr)) ficavam iguais, mas o campo novo (14px, padding
     12px) encolheu para 131px e cortou "Porta/Fechadura" em "Porta/Fecha" --
     o texto pede 113px mais a seta (medido em 10/09/2026). auto-fit com piso de
     11rem (176px) poe os dois lado a lado onde ha espaco e empilha onde nao ha,
     e nenhum dos dois caminhos corta o valor escolhido. */
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 8px;
}
.form .fbtns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Pesquisa: mini-gráfico */
.pq {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pq-row {
  display: grid;
  grid-template-columns: 1fr 90px 28px;
  align-items: center;
  gap: 8px;
  font-size: var(--t-md);
  color: var(--ink);
}
.pq-row .pbar {
  height: 7px;
  border-radius: 99px;
  background: var(--line-soft);
  overflow: hidden;
}
.pq-row .pbar i {
  display: block;
  height: 100%;
  background: var(--green-500);
  border-radius: 99px;
  transform-origin: left;
  animation: barIn 0.7s var(--ease) both;
}
.pq-row b {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.quote {
  font-size: var(--t-sm);
  color: var(--muted-foreground);
  border-left: 3px solid var(--green-300);
  padding: 4px 10px;
  font-style: italic;
  line-height: 1.45;
}

/* Painel vazio (nada selecionado) */
.p-empty {
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.p-empty h3 {
  font-size: var(--t-2xl);
}
.p-empty p {
  font-size: var(--t-md);
  color: var(--muted-foreground);
  line-height: 1.55;
}
.feed h4 {
  font-family: var(--mono);
  font-size: var(--t-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-bottom: 8px;
}
.feed-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--t-sm);
  color: var(--ink);
  animation: itemIn 0.35s var(--ease) both;
  cursor: pointer;
}
.feed-item:hover {
  color: var(--green-900);
}
.feed-item i {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--green-500);
  flex: none;
}
.feed-item i.c {
  background: var(--citrus);
}
.feed-item i.d {
  background: var(--danger);
}
.feed-item small {
  display: block;
  color: var(--faint);
  font-size: var(--t-xs);
}
.top-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.top-item {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0; /* item de flex-column sem isso cresce pro conteúdo e vaza do painel */
  font-size: var(--t-md);
  padding: 7px 10px 10px;
  border-radius: 9px;
  border: 1px solid var(--line-soft);
  background: var(--paper);
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--dur-rapida, 150ms) var(--ease);
}
.top-item:hover {
  border-color: var(--danger);
  transform: translateX(2px);
}
.top-item .n {
  font-family: var(--mono);
  font-weight: var(--fw-medium);
  font-size: var(--fs-12);
  font-variant-numeric: tabular-nums;
  color: var(--muted-foreground);
  min-width: 20px;
}
.top-bar {
  position: absolute;
  max-width: calc(100% - 20px);
  left: 10px;
  bottom: 3px;
  height: 4px;
  border-radius: 99px;
  background: var(--green-300);
}
.top-item small {
  min-width: 0;
  flex: 1;
  font-size: var(--t-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-item .v {
  margin-left: auto;
  flex: none;
  font-weight: var(--fw-semibold);
  color: var(--danger-text);
  font-variant-numeric: tabular-nums;
}
.top-item small {
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Aviso ----------
   O aviso do mapa (chamado registrado, pesquisa salva, vistoria concluida) e o
   do sistema: ui.aviso(), chamado pela ponte do ERP (assets/erp/ponte-mapa.js),
   desenhado em sistema.css, secao 8. O .toast verde-floresta que morava aqui
   era uma segunda implementacao, sem icone por tipo, sem botao de fechar e sem
   teclado. */

/* ---------- Rodapé compacto ---------- */
.foot {
  position: absolute;
  left: 16px;
  top: 12px;
  /* Para antes do minimapa (200px a 16px da borda, so no 3D), em vez de passar
     por baixo dele: numa linha o texto tinha 735px e o palco de 1440 tem 844.
     Com pouco espaco quebra em mais linhas. Fundo da legenda para ler sobre o 3D. */
  max-width: calc(100% - 32px);
  width: max-content;
  padding: 2px 8px;
  border-radius: var(--radius-md, 8px);
  background: var(--popover, var(--card));
  background: color-mix(in srgb, var(--popover, var(--card)) 85%, transparent);
  z-index: 3;
  font-family: var(--mono);
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  color: var(--faint);
  /* texto corrido, e nao flex: quebrando, o separador ficava solto no fim */
  display: block;
}
.map-wrap.is3d .foot {
  max-width: calc(100% - 200px - 48px);
}
.foot a {
  color: var(--green);
  font-weight: var(--fw-semibold);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* ---------- Responsivo ---------- */
@media (max-width: 1080px) {
  :root {
    --panel-w: 340px;
  }
}
@media (max-width: 860px) {
  :root {
    --header-h: calc(56px + env(safe-area-inset-top));
    --tabbar-h: calc(56px + env(safe-area-inset-bottom));
  }
  .hdr {
    gap: 10px;
    padding: 0 12px;
    padding-top: env(safe-area-inset-top);
  }
  .brand small,
  .user span,
  .sync,
  .foot,
  .hdr-tabs {
    display: none; /* .htab continua no DOM (o verificador usa), só some visualmente: a tabbar assume a navegação */
  }
  .brand b {
    white-space: nowrap;
  }
  .hdr-search {
    flex: 1 1 auto;
    margin-left: 0;
  }
  /* a busca sobe para 16px (sem zoom do Safari) e 44px no Campo de sistema.css, secao 9 */
  /* modo de busca (Buscar na tabbar, ou foco no campo): header vira só logo + campo cheio */
  body.mobile-search .brand b {
    display: none;
  }

  .tabbar {
    display: flex;
  }

  .main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  /* painel vira bottom sheet fixo sobre o mapa: fechado (fora da tela) por padrão,
     a classe .peek/.open (aplicada por assets/mobile.js) traz pra cima */
  .panel {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: var(--tabbar-h);
    height: 34vh;
    max-height: 88vh;
    border-left: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: var(--shadow-lg);
    z-index: var(--z-painel, 40);
    transform: translateY(120%);
    /* Fechada, a folha tambem fica invisivel: so o transform deixava a alca e os
       botoes do painel alcancaveis pelo Tab fora da tela. O visibility espera a
       folha sair (atraso de --dur-lenta) e volta na hora ao abrir.
       gaveta: dur-lenta e a curva unica. Height anima aqui (e so aqui) porque
       e o gesto de puxar a folha; nao ha como fazer com transform sem cortar o
       conteudo que rola dentro dela. */
    visibility: hidden;
    transition:
      transform var(--dur-lenta, 300ms) var(--ease),
      height var(--dur-lenta, 300ms) var(--ease),
      visibility 0s linear var(--dur-lenta, 300ms);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.peek,
  .panel.open {
    transform: translateY(0);
    visibility: visible;
    transition:
      transform var(--dur-lenta, 300ms) var(--ease),
      height var(--dur-lenta, 300ms) var(--ease),
      visibility 0s linear 0s;
  }
  .panel.open {
    height: 88vh;
  }
  .sheet-handle {
    display: block;
    cursor: grab;
    touch-action: none;
  }
  .panel-content {
    -webkit-overflow-scrolling: touch;
  }

  .toolbar {
    padding: 8px 12px;
    gap: 8px;
  }
  /* indicadores em faixa que rola de lado: assets/composicao.css, secao 3 */
  /* modos + 3D/2D + Auto/Dia/Noite + Vistoria: uma faixa rolável só, 40px, com fade nas bordas */
  .toolbar-row2 {
    flex-wrap: nowrap;
    height: 40px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
  }
  .toolbar-row2::-webkit-scrollbar {
    display: none;
  }
  .toolbar-row2-right {
    order: 0;
    margin-left: 0;
    flex: none;
  }
  #btn-vistoria {
    order: 0;
    flex: none;
  }
  .modes {
    margin-left: 0;
    flex: none;
    min-width: 0;
  }
  .mode {
    white-space: nowrap;
    padding: 0 10px;
    font-size: var(--t-sm);
  }
  .vt {
    padding: 0 14px; /* garante largura real >= 44px nos rótulos curtos (3D/2D, Dia/Noite) */
  }
  .viewtoggle,
  .daytoggle {
    flex: none;
  }
  /* alvo de toque >= 44px sem inchar o visual: o botão continua ~36px de altura,
     a área clicável real cresce por um ::before invisível (não dá pra medir com
     getBoundingClientRect — verificado reconstruindo o retângulo a partir de
     getComputedStyle(el, "::before") e clicando dentro da faixa expandida) */
  .mode,
  .vt,
  #btn-vistoria.btn {
    position: relative;
  }
  .mode::before,
  .vt::before,
  #btn-vistoria.btn::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -10px;
    bottom: -10px;
  }

  /* legenda: linha compacta rolável, acima da tabbar */
  .legend {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: calc(var(--tabbar-h) + 8px);
    height: 32px;
    min-width: 0;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .legend::-webkit-scrollbar {
    display: none;
  }
  .legend h4 {
    display: none; /* sem espaço pro título na faixa de 32px */
  }
  .legend-row {
    flex: none;
    font-size: var(--t-xs);
    gap: 5px;
  }
  .legend-row i {
    width: 11px;
    height: 11px;
  }
  .legend-row em {
    margin-left: 3px;
  }
  .legend-scale {
    flex: none;
    width: 90px;
  }
  .legend-scale-lbl {
    display: none; /* rótulos 0/30/90d somem junto com o título, mesma lógica de espaço */
  }

  /* zoom: só +/-, alvo de 44px, acima da tabbar; enquadrar/tela cheia somem (ficam no DOM) */
  .zoom {
    right: 8px;
    bottom: calc(var(--tabbar-h) + 8px);
    flex-direction: row;
  }
  .zoom button {
    width: 44px;
    height: 44px;
    border-bottom: none;
    border-right: 1px solid var(--line);
  }
  .zoom button:last-child {
    border-right: none;
  }
  #zfit,
  #zfull {
    display: none;
  }

  /* mapa (2D e 3D) reserva a altura da tabbar, sem ficar atrás dela */
  .map-wrap {
    padding-bottom: var(--tabbar-h);
  }
  .map3d {
    bottom: var(--tabbar-h);
  }
}

@media (max-width: 600px) {
  .map-wrap.is3d #minimap {
    display: none;
  }
}

/* Movimento reduzido: tudo instantâneo, nada some */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .ring {
    display: none;
  }
}

/* ---------- Vistoria (rota a pé) ---------- */
.rota-linha {
  stroke: var(--green);
  stroke-width: 4;
  stroke-dasharray: 10 6;
  fill: none;
  animation: rota-marcha 1s linear infinite;
}
@keyframes rota-marcha {
  to { stroke-dashoffset: -32; }
}
.rota-num {
  fill: #963c0a; /* branco sobre --citrus dava 3,2:1 */
  stroke: #fff;
  stroke-width: 1.5;
}
.rota-num-lbl {
  fill: #fff;
  font-family: var(--sora);
  font-weight: 700;
  font-size: 11px;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.box.vist rect.b {
  stroke: var(--citrus);
  stroke-width: 2.4px;
}
body.vistoria #mapwrap {
  cursor: crosshair;
}
#vist-card {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  z-index: 20;
  /* Superficie flutuante do tema, nao branco fixo: o texto daqui segue o tema, e no escuro
     virava claro sobre branco -- 1,03:1, legenda e zoom invisiveis (juiz final, 11/09/2026). */
  background: var(--popover, var(--card));
  background: color-mix(in srgb, var(--popover, var(--card)) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  width: min(420px, calc(100% - 24px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--body);
}
.vist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.vist-eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green);
}
.vist-hint {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--t-sm);
}
.vist-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 78px;
  overflow-y: auto;
}
.vist-chip {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  font-family: var(--mono);
  font-size: var(--t-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  color: var(--ink);
}
.vist-chip.atual {
  background: var(--citrus);
  border-color: var(--citrus);
  color: #fff;
  font-weight: 600;
}
.vist-total {
  font-size: var(--t-sm);
  color: var(--muted-foreground);
}
.vist-total b {
  /* inline num pequeno em texto corrido — mono/valor, não Sora (Sora não tem degrau <17px) */
  font-family: var(--mono);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  color: var(--green-900);
}
.vist-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.vist-btns .btn {
  height: 36px;
  box-sizing: border-box;
}

@media (max-width: 860px) {
  #vist-card {
    bottom: 132px;
    width: calc(100% - 16px);
    padding: 10px 12px;
  }
  .vist-chips {
    max-height: 54px;
  }
}

/* ============================================================
   ABA DASHBOARD
   ============================================================ */
.hdr-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.htab {
  /* borda transparente reservada: o hover pinta a cor, o tamanho nao muda */
  border: 1px solid transparent;
  background: transparent;
  color: #c8dccb;
  font-family: var(--body);
  font-size: var(--t-md);
  font-weight: var(--fw-semibold);
  padding: 6px 13px; /* 6/13 + 1 de borda = os 7/14 de antes */
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transicao-controle, background-color 150ms);
}
.htab:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
}
.htab[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.htab[aria-pressed="true"]:hover {
  border-color: rgba(255, 255, 255, 0.32);
}

.dash {
  display: none;
}
body.tab-dashboard .stage,
body.tab-dashboard .panel {
  display: none;
}
body.tab-dashboard .main {
  grid-template-columns: 1fr;
}
body.tab-dashboard .dash {
  display: block;
  grid-column: 1 / -1;
  overflow-y: auto;
  background: var(--paper);
}

.dash-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.dfilter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dfilter span.dfilter-lbl {
  font-family: var(--mono);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-right: 4px;
}
.dchip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--t-sm);
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 99px;
  cursor: pointer;
  transition: var(--transicao-controle, background-color 150ms);
}
.dchip:hover {
  border-color: var(--green-300);
}
.dchip[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.dhero {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.dtile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dtile .dt-val {
  font-family: var(--sora);
  font-size: 32px;
  font-weight: 800;
  color: var(--green-900);
  letter-spacing: -0.6px;
  line-height: 1.05;
}
.dtile .dt-lbl {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink);
}
.dtile .dt-ctx {
  font-size: var(--t-xs);
  color: var(--muted-foreground);
}
.dtile.danger .dt-val {
  color: var(--danger);
}
.dtile.citrus .dt-val {
  color: var(--citrus);
}

.dgrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  align-items: start;
}
.dgrid .dcard.wide {
  grid-column: 1 / -1;
}

.dcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  min-width: 0;
}
.dcard .dc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.dcard h3 {
  font-family: var(--sora);
  font-size: var(--t-lg);
  font-weight: 700;
  color: var(--green-900);
  line-height: 1.3;
}
.dc-side {
  flex: 0 0 auto;
  text-align: right;
}
.dc-side b {
  display: block;
  font-family: var(--sora);
  font-size: var(--t-xl);
  color: var(--green);
}
.dc-side span {
  font-size: var(--t-xs);
  color: var(--muted-foreground);
}
.dc-toggle {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted-foreground);
  font-size: var(--t-xs);
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.dc-toggle:hover {
  color: var(--ink);
  border-color: var(--green-300);
}
.dc-body {
  position: relative;
}
.dc-quotes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.dc-quote {
  font-size: var(--t-sm);
  color: var(--ink);
  background: var(--paper);
  border-left: 3px solid var(--green-300);
  padding: 8px 11px;
  border-radius: 0 8px 8px 0;
  line-height: 1.45;
}
.dc-note {
  margin-top: 10px;
  font-size: var(--t-sm);
  color: var(--ink);
  background: var(--danger-soft);
  border-radius: 8px;
  padding: 9px 12px;
}
.dc-note b {
  color: var(--danger);
}
.dc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 10px;
}
.dc-legend .li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-xs);
  color: var(--muted-foreground);
}
.dc-legend .li i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: currentColor;
  display: inline-block;
}

/* gráficos SVG */
.dchart {
  width: 100%;
  height: auto;
  overflow: visible;
  font-family: var(--body);
}
.dchart text {
  fill: var(--muted-foreground);
  font-size: 11px;
}
.dchart text.dv-strong {
  fill: var(--ink);
  font-weight: 600;
}
.dchart .dv-grid {
  stroke: var(--line-soft);
  stroke-width: 1;
}
.dchart .dv-hit {
  fill: transparent;
  cursor: pointer;
}
.dchart .dv-hit:hover ~ .dv-bar,
.dv-row:hover .dv-bar {
  filter: brightness(1.06);
}
.dv-tip {
  position: absolute;
  pointer-events: none;
  background: var(--forest);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: var(--t-xs);
  line-height: 1.4;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity var(--dur-rapida, 150ms) var(--ease);
  z-index: 3;
  white-space: nowrap;
  transform: translate(-50%, -100%);
}
.dv-tip.on {
  opacity: 1;
}
.dv-tip b {
  color: var(--lime);
}

/* tabelas dos gráficos e das seções de tabela */
.dtable {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
}
.dtable th,
.dtable td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.dtable th {
  color: var(--muted-foreground);
  font-weight: 600;
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.dtable td.num,
.dtable th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.dtable tbody tr.clickable {
  cursor: pointer;
}
.dtable tbody tr.clickable:hover {
  background: var(--paper);
}
.dtable-wrap {
  overflow-x: auto;
}
.dcard .empty {
  color: var(--muted-foreground);
  font-size: var(--t-sm);
  padding: 6px 0;
}

@media (max-width: 860px) {
  .hdr-tabs {
    /* a tabbar assume a navegação no mobile; .htab continua no DOM (o verificador usa) */
    display: none;
    gap: 0;
    padding: 2px;
  }
  .htab {
    padding: 7px 9px;
    font-size: 0;
  }
  .htab::before {
    font-family: var(--body);
    font-size: var(--fs-13);
    font-weight: var(--fw-semibold);
    content: "Mapa";
  }
  .htab[data-tab="dashboard"]::before {
    content: "Painel";
  }
  .dhero {
    grid-template-columns: repeat(2, 1fr);
  }
  .dtile {
    min-width: 0;
  }
  .dtile .dt-val {
    font-size: 24px;
  }
  .dgrid {
    grid-template-columns: 1fr;
  }
  .dash-inner {
    padding: 14px;
    gap: 12px;
    max-width: 100%;
  }
  .dcard {
    padding: 14px;
    min-width: 0;
  }
  .dtable-wrap {
    max-width: 100%;
  }
}

/* refino 09/2026: foco de teclado visivel em todos os controles do mapa (a casca do ERP ja tinha).
   Duas cores, pela superficie: sobre o verde-escuro do cabecalho e da barra de
   baixo vale o lima (9,8:1 sobre o --forest); sobre a barra clara do mapa vale
   o --ring da regua. Lima sobre branco dava 1,3:1, o anel sumia. O .btn saiu
   daqui: o foco dele mora em sistema.css. */
.mode:focus-visible,
.vt:focus-visible,
.zoom button:focus-visible,
.p-close:focus-visible {
  outline: var(--anel-largura, 3px) solid var(--ring, var(--green-500));
  outline-offset: 2px;
}
/* a caixa do zoom tem overflow: hidden (cantos redondos): anel por dentro */
.zoom button:focus-visible {
  outline-offset: -3px;
}
.htab:focus-visible,
.tabbar-item:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}
.box:focus-visible rect.b {
  stroke: var(--lime);
  stroke-width: 3;
}

/* ---------- painel do mapa: o conteudo reage a largura do painel ----------
   O painel encolhe de 400px para 340px quando a casca do ERP ocupa a esquerda.
   Nos 340px a grade de 2 colunas deixa 146px por campo: o CNPJ quebra no meio
   e os dois botoes de acao viram duas linhas cada. Container query resolve pela
   largura real do painel, nao pela largura da janela. */
.panel {
  container: painel / inline-size;
}
@container painel (max-width: 380px) {
  .panel .kv {
    grid-template-columns: minmax(0, 1fr);
  }
  .actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- TROCA DE ENTREPOSTO: UM CONTROLE SO ----------
   Antes eram dois controles diferentes para o mesmo trabalho. No Piaui Polo,
   um link solto com um quadradinho desenhado na borda, que parecia uma terceira
   aba do grupo "Mapa / Dashboard" mas navegava para outro lugar, e que sumia no
   celular. No Central do Varejo, outro par de botoes com estilo proprio. Quem
   olhava nao sabia que os dois mapas eram irmaos.

   Agora e um controle segmentado: as duas opcoes aparecem sempre, a atual fica
   marcada com aria-current e um indicador desliza entre elas. Duas colunas
   IGUAIS (grid 1fr 1fr) de proposito, e nao largura por texto: com colunas
   iguais o indicador anda exatamente 100% e nao precisa de JavaScript medindo
   nada a cada troca de tela ou de fonte.

   Serve nos dois fundos: sem atributo usa as fichas do tema (painel claro), e
   com data-fundo="escuro" usa branco translucido (cabecalho verde). */
.hseg {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  isolation: isolate;
}
.hseg::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 3px 50% 3px 3px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-media, 200ms) var(--ease);
}
.hseg[data-ativo="1"]::before {
  transform: translateX(calc(100% + 0px));
}
/* filho DIRETO: o rotulo do cabecalho tem spans aninhados (longo e curto), e
   sem o '>' cada span de dentro tambem ganhava padding e engordava o segmento
   (medido: 174 contra 236px em vez de duas colunas iguais) */
.hseg > a,
.hseg > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted-foreground);
  font-family: var(--body);
  font-size: var(--t-md);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  white-space: nowrap;
  transition: var(--transicao-controle, background-color 150ms); /* a cor troca na hora, ver sistema.css */
}
.hseg > a:hover {
  color: var(--green-700);
}
.hseg > [aria-current="page"] {
  color: var(--green-900);
}
.hseg > a:focus-visible {
  outline: 2px solid var(--green-500);
  outline-offset: 2px;
}
/* variante do cabecalho verde */
.hseg[data-fundo="escuro"] {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
}
.hseg[data-fundo="escuro"]::before {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}
.hseg[data-fundo="escuro"] > a,
.hseg[data-fundo="escuro"] > span {
  color: #c8dccb;
}
.hseg[data-fundo="escuro"] > a:hover,
.hseg[data-fundo="escuro"] > [aria-current="page"] {
  color: #fff;
}
.hseg[data-fundo="escuro"] > a:focus-visible {
  outline-color: var(--lime);
}
/* folga maior que a de dentro dos grupos: colado, "Mapa | Dashboard" e
   "Piaui Polo | Central do Varejo" liam como um grupo so de quatro opcoes. Sao
   dois controles diferentes (que tela ver, e qual entreposto), e o espaco e o
   que diz isso sem precisar de titulo. */
.htab-mapa {
  margin-left: 22px;
}
/* dois rotulos em vez de encolher a fonte: "font-size: 0" no pai furava o piso
   de 12px que o teste responsivo cobra em todo texto da tela. O rotulo curto
   entra por "@container cabecalho (max-width: 1120px)", la em cima: a decisao e
   de espaco do cabecalho, nao de janela. */
.htab-curto {
  display: none;
}
/* No celular o controle FICA. Antes ele sumia e o segundo mapa so existia pra
   quem abrisse o menu e soubesse que ele existia. Encolhe e usa o rotulo curto
   em vez de desaparecer. */
@media (max-width: 860px) {
  .htab-mapa {
    margin-left: 0;
  }
  .hseg > a,
  .hseg > span {
    padding: 0 10px;
    font-size: var(--fs-12);
  }
}
@media (prefers-reduced-motion: reduce) {
  .hseg::before {
    transition: none;
  }
}

/* ---------- piso de toque do mapa e do dashboard, pelo aparelho ----------
   Mesma razao do bloco 19 de erp.css: as regras de toque desta folha estavam
   presas a "max-width: 860px" e nenhum tablet entrava. */
@media (pointer: coarse) {
  /* os segmentos, e nao so a caixa: medido 122x38 no celular, e o piso e 44 */
  .hseg > a,
  .hseg > span {
    min-height: 44px;
  }
  .htab,
  .htab-mapa,
  .mode,
  .vt,
  .nc-seg-btn,
  .user,
  .sync {
    min-height: 44px;
  }
  .user .avatar {
    width: 40px;
    height: 40px;
  }
  .nc-list-row {
    min-height: 44px;
  }
}

/* correcao dos alvos de toque abaixo de 44px apontados pela varredura de
   07/09/2026 no cabecalho e no painel do mapa (scripts/varrer-layout.mjs,
   tipos "alvo pequeno" e "fora da caixa") — cada regra abaixo resolve um
   achado especifico da lista de correcao daquele dia */
@media (pointer: coarse) {
  /* .viewtoggle/.daytoggle/.modes tinham "height" travado em --ctrl-h (36px);
     com os filhos (.mode/.vt) exigindo 44px de alvo, o botao estourava do
     pai ("fora da caixa", 13px pra fora). Altura minima deixa o pai crescer
     junto em vez de recortar o filho */
  .viewtoggle,
  .daytoggle,
  .modes {
    height: auto;
    min-height: 44px;
    align-items: stretch;
  }

  /* .vt ja herdava min-height: 44px do bloco de toque acima; faltava
     largura (medido 42px, abaixo do piso de 44px) */
  .vt {
    min-width: 44px;
  }

  /* alca do bottom sheet (arrasta o painel pra cima no celular): 36x24
     medido, abaixo do piso nos dois eixos */
  .sheet-handle {
    min-height: 44px;
    min-width: 44px;
  }

  /* #btn-vistoria (texto "Vistoria", classes btn.btn-ghost): a lista original
     supunha que ficava dentro de .panel, mas o grep mostra que e inserido
     logo depois de .modes, no cabecalho do mapa (ver assets/vistoria.js,
     "$('.modes').after(btn)") — nao existe elemento .panel no caminho ate a
     raiz. Atinge pelo id, mesmo seletor ja usado nas regras acima dele
     neste arquivo */
  #btn-vistoria.btn {
    min-height: 44px;
  }

  /* botoes de zoom do mapa (+ / - / enquadrar / tela cheia): 36x36 fora do
     bloco de largura maxima 860px, entao tablet grande com toque (ex.: iPad
     Pro em paisagem) nunca recebia o piso de 44px */
  .zoom button {
    min-height: 44px;
    min-width: 44px;
  }

  /* link "Desenvolvido por Carvalho" no rodape do mapa: o <a> nao tem classe
     propria, so o pai ".foot" tem — mesmo seletor que ja estiliza esse link
     mais acima neste arquivo (".foot a") */
  .foot a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* o rotulo do indicador ja quebra linha em vez de cortar (composicao.css) */
}

/* ---------- barra do mapa: decide pelo espaco da area, e o mapa tem piso ----------
   Mesmo erro do cabecalho, em outro lugar. As regras que compactam a barra do
   mapa estavam presas a "@media (max-width: 860px)", ou seja, a largura da
   JANELA. Num iPhone deitado (932x430) com a barra lateral aberta, a area do
   mapa fica com 336px de largura: os seis indicadores empilhavam, a barra
   chegava a 464px e a area toda tem 366px. O grid resolvia dando 463,75px para a
   barra e ZERO para o mapa. O mapa sumia da tela, sem erro nenhum no console.

   Duas regras: a barra passa a responder ao espaco do palco, e o palco reserva
   um piso para o mapa em tela baixa, rolando se ainda assim nao couber. */
.stage {
  container: palco / inline-size;
}
@container palco (max-width: 720px) {
  /* os indicadores caem para 3 colunas aqui tambem: composicao.css, secao 3 */
  .toolbar-row2 {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .toolbar-row2::-webkit-scrollbar {
    display: none;
  }
  .toolbar-row2-right {
    order: 0;
    margin-left: 0;
  }
}
@container palco (max-width: 430px) {
  /* indicadores em 2 colunas: composicao.css, secao 3 */
  .toolbar {
    padding: 10px 12px;
  }
}
@media (max-height: 560px) {
  .stage {
    grid-template-rows: auto minmax(160px, 1fr);
    overflow-y: auto;
  }
  /* Em 430px de altura a area toda tem 366px. Com a barra em grade de duas
     linhas ela ficava com 337 e o mapa com 29 uteis: melhor que zero, ainda
     inutil. Deitado, os indicadores viram uma faixa que rola de lado, e a barra
     nao passa de 140px: sobram 226px para o mapa. */
  .toolbar {
    padding: 8px 12px;
    gap: 6px;
    max-height: 140px;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  /* os indicadores viram faixa que rola de lado: composicao.css, secao 3 */
  /* modos e alternadores em linha unica: a faixa rola de lado em vez de
     empilhar e roubar altura do mapa */
  .modes,
  .viewtoggle,
  .daytoggle {
    flex-wrap: nowrap;
  }
  .toolbar-row2 {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
}
