/* ══════════════════════════════════════════════════════════════════
   GESTÃO TEVA — AGENDA DA OBRA
   Calendário (semana/mês) + checklist do dashboard.
   Layout: [calendário] | [previsão do tempo fixa em cima, checklist embaixo]
   ══════════════════════════════════════════════════════════════════ */
/* align-items padrão (stretch): a coluna do calendário acompanha a altura da
   coluna da direita (clima + checklist), em vez de ficar baixinha. */
.ag-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 14px;
  margin-bottom: 18px;
}
@media (max-width: 1180px) { .ag-layout { grid-template-columns: 1fr; } }

.ag-main {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Coluna direita: clima em cima (acompanha a rolagem), checklist embaixo */
/* align-self:start mantém o sticky funcionando — sem isso o aside esticaria
   para a altura da linha do grid e o "fixo no topo" não teria efeito. */
.ag-side {
  position: sticky;
  top: 12px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 24px);
  min-width: 0;
}
.ag-side > .clima-card { flex: none; }   /* previsão do tempo não encolhe */
@media (max-width: 1180px) { .ag-side { position: static; max-height: none; } }

/* ── Toolbar ─────────────────────────────────────────────────── */
.ag-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
.ag-tb-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.ag-tb-left h3 { font-size: 16px; font-weight: 800; color: var(--text-dark); white-space: nowrap; }
.ag-range { font-size: 12px; color: var(--text-gray); font-weight: 600; white-space: nowrap; }
.ag-tb-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.ag-view-toggle { display: inline-flex; background: var(--bg-light); border-radius: var(--radius-sm); padding: 2px; }
.ag-view-toggle button {
  display: inline-flex; align-items: center; gap: 5px;
  border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 700; color: var(--text-gray);
  padding: 5px 10px; border-radius: 6px;
}
.ag-view-toggle button svg { width: 14px; height: 14px; }
.ag-view-toggle button.active { background: var(--white); color: var(--primary); box-shadow: var(--shadow-sm); }

.ag-icon-btn, .ag-text-btn {
  border: 1px solid var(--border); background: var(--white); cursor: pointer;
  border-radius: var(--radius-sm); color: var(--text-mid);
  font-family: inherit; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.ag-icon-btn { width: 30px; height: 30px; }
.ag-text-btn { height: 30px; padding: 0 10px; }
.ag-icon-btn:hover, .ag-text-btn:hover { border-color: var(--accent-dark); color: var(--primary); }
.ag-icon-btn svg { width: 15px; height: 15px; }

/* ── Filtros no calendário ───────────────────────────────────── */
/* Mesmo conteúdo do painel do checklist, mas aqui há largura: os selects vão
   lado a lado em vez de empilhados. */
.ag-filtros-cal {
  display: none;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fafbfa;
}
.ag-filtros-cal.open { display: block; }

/* Uma faixa só, com rótulo miúdo em cima de cada campo: cabe tudo em duas
   linhas e dá para ler o que cada caixa filtra sem abrir a lista. */
.ag-f-linha { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; }
.ag-f-linha.rodape { margin-top: 10px; align-items: center; }

.ag-f-campo { flex: 1 1 150px; min-width: 132px; max-width: 210px; }
.ag-f-lab {
  display: block; margin-bottom: 3px;
  font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-gray);
}
.ag-f-campo.on .ag-f-lab { color: var(--accent-dark); }
.ag-f-campo .ag-f, .ag-f-campo .ss-wrap { width: 100%; display: block; }
.ag-f-campo .ag-f { font-size: 12px; padding: 6px 8px; }
/* Campo com filtro ativo fica marcado — senão some no meio dos oito. */
.ag-f-campo.on .ag-f, .ag-f-campo.on .ss-input {
  border-color: var(--accent-dark); background: var(--bg-green); font-weight: 700;
}

.ag-filtros-cal .ag-f-busca { flex: 1 1 220px; font-size: 12px; padding: 6px 9px; }
.ag-filtros-cal .ag-f-check { padding: 5px 10px; }
.ag-filtros-cal .ag-f-limpar { margin: 0; flex: none; }

/* Painel estreito (ao lado do checklist): um campo por linha. */
.ag-check-filtros .ag-f-campo { flex: 1 1 100%; max-width: none; }
.ag-check-filtros .ag-f-busca { flex: 1 1 100%; }

/* ── Grade da semana ─────────────────────────────────────────── */
/* Três faixas empilhadas, todas com 7 colunas alinhadas: cabeçalhos, barras
   de fornecedor (contínuas) e as colunas dos dias. */
.ag-week { flex: 1 1 auto; min-height: 0; overflow-x: auto; display: flex; }
.ag-week-wrap { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 780px; position: relative; }

.ag-week-heads,
.ag-week-spans,
.ag-week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }

.ag-week-heads { border-bottom: 1px solid var(--border); }
.ag-head {
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  padding: 8px 4px; border-right: 1px solid var(--border);
}
.ag-head:last-child { border-right: none; }
.ag-head.is-weekend { background: #fafbfa; }
.ag-head.is-today { background: var(--bg-green); }
.ag-head.is-today .ag-col-num { color: var(--accent-dark); }

/* Faixa do Gantt: linha do fornecedor/etapa e, sob ela, uma linha por ação.
   grid-row é explícito no JS pra manter grupo → itens na ordem certa. */
.ag-week-spans {
  position: relative;
  gap: 3px 0; padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.ag-span-bg { grid-row: 1 / -1; border-right: 1px solid var(--border); }
.ag-span-bg:nth-child(7) { border-right: none; }
.ag-span-bg.drop { background: rgba(95, 168, 130, .14); }
.ag-week-vazio {
  grid-column: 1 / -1; grid-row: 1; padding: 14px 12px;
  text-align: center; font-size: 12px; color: var(--text-gray);
}

/* Barra de fornecedor: uma linha só, atravessando os dias com ação dele */
.ag-span {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 8px;
  margin: 0 2px; padding: 6px 9px;
  border-radius: 6px; border-left: 4px solid #ccc;
  cursor: pointer; overflow: hidden; min-width: 0;
}
.ag-span:hover { filter: brightness(0.96); }
.ag-span.done { opacity: .55; }
/* Barra sólida na cor da etapa. A cor do texto vem inline (corTextoSobre),
   calculada pela luminância do fundo — herdar aqui mantém tudo legível. */
.ag-span-nome {
  flex: 1 1 auto; min-width: 0;
  font-size: 12.5px; font-weight: 800; color: inherit;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ag-span.done .ag-span-nome { text-decoration: line-through; }
.ag-span-cont {
  flex: none; font-size: 10.5px; font-weight: 800; color: inherit;
  background: rgba(255, 255, 255, .28); border-radius: 20px; padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.ag-span-obra {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; color: inherit; opacity: .92;
  max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ag-span-etapa {
  font-weight: 700; opacity: .9; font-size: 10.5px; margin-left: 6px;
  text-transform: uppercase; letter-spacing: .03em;
}

.ag-span-alca {
  position: absolute; top: 0; bottom: 0; width: 8px;
  cursor: ew-resize; opacity: 0; transition: opacity .12s; background: rgba(0, 0, 0, .18);
}
.ag-span-alca.esq { left: 0; }
.ag-span-alca.dir { right: 0; }
.ag-span:hover .ag-span-alca { opacity: 1; }
.ag-span-alca:hover { background: var(--accent-dark); }

.ag-week-grid { flex: 1 1 auto; }
.ag-col { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 240px; min-width: 0; }
.ag-col:last-child { border-right: none; }
.ag-col.is-weekend { background: #fafbfa; }
.ag-col.is-today { background: var(--bg-green); }
.ag-col.drop { outline: 2px dashed var(--accent-dark); outline-offset: -3px; }
.ag-col-head {
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  padding: 8px 4px; border-bottom: 1px solid var(--border);
}
.ag-col-dow { font-size: 10px; font-weight: 800; color: var(--text-gray); letter-spacing: .06em; }
.ag-col-num { font-size: 15px; font-weight: 800; color: var(--text-dark); }
.ag-col.is-today .ag-col-num { color: var(--accent-dark); }
.ag-col-body { flex: 1; padding: 6px 5px; display: flex; flex-direction: column; gap: 5px; }

.ag-add-btn {
  margin-top: auto; border: 1px dashed var(--border); background: none; cursor: pointer;
  color: var(--text-gray); font-size: 15px; line-height: 1; padding: 5px 0;
  border-radius: 6px; font-family: inherit; opacity: 0; transition: opacity .12s;
}
.ag-col:hover .ag-add-btn { opacity: 1; }
.ag-add-btn:hover { border-color: var(--accent-dark); color: var(--accent-dark); }

/* Card do dia: UM por empresa. Topo = nome do prestador, corpo = checklist */
.ag-gcard {
  border-radius: 7px; border-left: 3px solid #ccc; padding: 5px 6px 4px;
  font-size: 11.5px; line-height: 1.3;
}
.ag-gcard.done { opacity: .6; }
.ag-gcard-head { display: flex; align-items: baseline; gap: 5px; }
.ag-gcard-nome {
  flex: 1; min-width: 0; font-size: 11px; font-weight: 800; color: #1f2937;
  letter-spacing: .01em; word-break: break-word;
}
.ag-gcard-nome.teva { color: var(--accent-dark, #166534); }
.ag-gcard-cont {
  flex: none; font-size: 9.5px; font-weight: 800; color: #4b5563;
  background: rgba(255, 255, 255, .7); border-radius: 20px; padding: 0 5px;
}
.ag-gcard-sub {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 2px;
  font-size: 9.5px; font-weight: 700; color: #4b5563;
}
.ag-gcard-obra { display: inline-flex; align-items: center; gap: 4px; }
.ag-gcard-etapa { opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-gcard-itens { margin-top: 4px; display: flex; flex-direction: column; gap: 1px; }

/* Item = uma ação. Clique abre, arrasta muda o dia, alças esticam as datas */
.ag-gitem {
  position: relative; display: flex; align-items: flex-start; gap: 4px;
  padding: 3px 4px; border-radius: 5px; cursor: pointer;
  background: rgba(255, 255, 255, .55);
}
.ag-gitem:hover { background: rgba(255, 255, 255, .95); }
.ag-gitem.done { opacity: .55; }
.ag-gitem.done .ag-gitem-txt { text-decoration: line-through; }

.ag-gitem-alca {
  position: absolute; top: 0; bottom: 0; width: 6px;
  cursor: ew-resize; opacity: 0; transition: opacity .12s;
  background: rgba(0, 0, 0, .16);
}
.ag-gitem-alca.esq { left: 0; border-radius: 5px 0 0 5px; }
.ag-gitem-alca.dir { right: 0; border-radius: 0 5px 5px 0; }
.ag-gitem:hover .ag-gitem-alca { opacity: 1; }
.ag-gitem-alca:hover { background: var(--accent-dark); }

/* Check sempre à vista: é o gesto do dia a dia dentro do checklist. */
.ag-gitem-ok {
  flex: none; margin-top: 1px; width: 15px; height: 15px; padding: 0; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 4px;
  background: rgba(255, 255, 255, .92); color: transparent;
  font-size: 10px; font-weight: 800; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.ag-gitem:hover .ag-gitem-ok { color: var(--text-gray); }
.ag-gitem-ok:hover { background: var(--accent-dark, #166534); border-color: var(--accent-dark, #166534); color: #fff; }
.ag-gitem-ok.on { background: #16a34a; border-color: #16a34a; color: #fff; }
.ag-gitem:hover .ag-gitem-ok.on { color: #fff; }

.ag-gitem-body { flex: 1; min-width: 0; }
.ag-gitem-top { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.ag-gitem-prio {
  flex: none; width: 6px; height: 6px; border-radius: 50%;
  align-self: center; margin-top: 1px;
}
.ag-gitem-hora { font-size: 9.5px; font-weight: 800; color: var(--text-mid); opacity: .85; }
.ag-gitem-txt { flex: 1; min-width: 0; font-weight: 700; color: #1f2937; word-break: break-word; }
.ag-gitem-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.ag-gitem-tags .ag-dot { width: 6px; height: 6px; }

/* Ação de vários dias: no meio do checklist ela vira BARRA — cor cheia da
   etapa e borda de prioridade, a mesma leitura das barras do Gantt. A cor do
   texto vem inline (corTextoSobre), então os filhos herdam. */
.ag-gitem.barra {
  border-radius: 6px; border-left: 3px solid #ccc;
  padding: 4px 6px; margin: 1px 0;
}
.ag-gitem.barra:hover { filter: brightness(0.96); }
.ag-gitem.barra .ag-gitem-txt,
.ag-gitem.barra .ag-gitem-hora { color: inherit; }
.ag-gitem.barra .ag-gitem-txt { font-weight: 800; }
.ag-gitem.barra.done .ag-gitem-txt { text-decoration: line-through; }
.ag-gitem.barra .ag-gitem-ok { background: rgba(255, 255, 255, .9); }
.ag-gitem.barra .ag-gitem-alca { background: rgba(255, 255, 255, .45); }
/* Em que dia do período estamos: mesmo contador das barras do Gantt. */
.ag-gitem-dias {
  flex: none; font-size: 9px; font-weight: 800; color: inherit;
  background: rgba(255, 255, 255, .28); border-radius: 20px; padding: 0 5px;
  font-variant-numeric: tabular-nums;
}
.ag-chip-prio {
  font-size: 8.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  color: #fff; border-radius: 20px; padding: 1px 6px;
}
.ag-chip-cat, .ag-chip-resp {
  font-size: 9px; font-weight: 700; color: #374151;
  background: rgba(255, 255, 255, .65); border: 1px solid transparent;
  border-radius: 20px; padding: 1px 6px;
}
.ag-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.ag-dot.lg { width: 18px; height: 18px; }
.ag-dot-more { font-size: 9px; font-weight: 800; color: var(--text-gray); }

/* Rodapé de pagamentos do dia — só o valor; o controle é no Financeiro */
.ag-col-pag {
  border-top: 1px solid var(--border); padding: 5px 6px; min-height: 30px;
  cursor: pointer; text-align: center;
}
.ag-col-pag.empty { cursor: default; }
.ag-col-pag:hover:not(.empty) { background: rgba(0, 0, 0, .03); }
/* Valor do dia por situação: vermelho vencido, amarelo a pagar, verde pago */
.ag-pag {
  font-size: 10.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap;
  font-variant-numeric: tabular-nums; border-radius: 4px; padding: 1px 5px; margin-bottom: 2px;
}
.ag-pag:last-child { margin-bottom: 0; }
.ag-pag.vencido { color: #b91c1c; background: #fee2e2; }
.ag-pag.apagar  { color: #92400e; background: #fef3c7; }
.ag-pag.pago    { color: #15803d; background: #dcfce7; }

.ag-m-pag.vencido { color: #b91c1c; }
.ag-m-pag.apagar  { color: #b45309; }
.ag-m-pag.pago    { color: #15803d; }

.ag-pag-dots { display: inline-flex; gap: 2px; align-items: center; }
.ag-pag-prev { font-size: 9.5px; font-weight: 700; color: var(--text-gray); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ── Grade do mês ────────────────────────────────────────────── */
.ag-month {
  flex: 1 1 auto; align-content: stretch;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
}
.ag-m-dow {
  padding: 8px 4px; text-align: center; font-size: 10px; font-weight: 800;
  color: var(--text-gray); letter-spacing: .06em; border-bottom: 1px solid var(--border);
  background: var(--bg-light);
}
.ag-m-cell {
  min-height: 96px; padding: 4px 5px; border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border); cursor: pointer; min-width: 0;
  display: flex; flex-direction: column; gap: 3px;
}
.ag-m-cell:hover { background: #fafbfa; }
.ag-m-cell.fora { background: #fcfcfc; }
.ag-m-cell.fora .ag-m-num { color: #cbd5e1; }
.ag-m-cell.is-today { background: var(--bg-green); }
.ag-m-cell.drop { outline: 2px dashed var(--accent-dark); outline-offset: -3px; }
.ag-m-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.ag-m-num {
  font-size: 12px; font-weight: 800; color: var(--text-dark);
  cursor: pointer; border-radius: 6px; padding: 0 5px; line-height: 18px;
}
.ag-m-num:hover { background: var(--accent-dark, #166534); color: #fff; }
.ag-m-cell.is-today .ag-m-num { color: var(--accent-dark); }
.ag-m-pag { font-size: 9.5px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.ag-m-pag.prev { color: var(--text-gray); font-weight: 700; }
.ag-m-ev {
  border-radius: 4px; border-left: 3px solid #ccc; padding: 2px 5px;
  font-size: 10.5px; font-weight: 600; color: #1f2937;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ag-m-ev.done { opacity: .5; text-decoration: line-through; }
.ag-m-more { font-size: 9.5px; font-weight: 700; color: var(--text-gray); padding-left: 3px; }
/* "⏰3d" na célula do mês: a linha é estreita e cortada por ellipsis, então o
   atraso vira sigla. O texto por extenso fica no title do card. */
.ag-m-atraso {
  font-size: 9px; font-weight: 800; color: #991b1b;
  background: #fee2e2; border: 1px solid #fca5a5; border-radius: 20px; padding: 0 4px;
}
.ag-m-ev.done .ag-m-atraso {
  opacity: 1; text-decoration: none;
  color: #78350f; background: #fef3c7; border-color: #fcd34d;
}

/* ── Checklist ───────────────────────────────────────────────── */
/* O clima fica fixo no topo da coluna; o checklist toma a altura que sobrar
   e rola por dentro — assim a coluna nunca estoura a altura da tela. */
.ag-check-card {
  display: flex; flex-direction: column;
  flex: 1 1 auto; min-height: 240px; overflow: hidden;
}
.ag-check-head {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.ag-check-head h3 { font-size: 14px; font-weight: 800; color: var(--text-dark); }
.ag-check-resumo { font-size: 11px; color: var(--text-gray); margin-top: 3px; font-weight: 600; }
.ag-late { color: #b91c1c; }

/* Painel de filtros: fechado por padrão, abre pelo botão do cabeçalho.
   Assim a lista de ações fica com quase toda a altura da coluna. */
.ag-check-filtros { display: none; padding: 9px 12px; border-bottom: 1px solid var(--border); background: #fafbfa; }
.ag-check-filtros.open { display: block; }

.ag-check-head-btns { display: flex; gap: 6px; flex: none; }
.ag-f-btn { position: relative; }
.ag-f-btn-txt { gap: 5px; }
.ag-f-btn-txt svg { width: 14px; height: 14px; }
.ag-f-btn.ativo { border-color: var(--accent-dark); color: var(--primary); background: var(--bg-green); }
.ag-f-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 10px; background: #dc2626; color: #fff;
  font-size: 10px; font-weight: 800; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px var(--white);
}
.ag-f-row { display: flex; gap: 6px; margin-bottom: 6px; }
.ag-f-row:last-of-type { margin-bottom: 0; }
.ag-f {
  flex: 1; min-width: 0; font-family: inherit; font-size: 11.5px;
  padding: 5px 7px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--white); color: var(--text-mid); outline: none;
}
.ag-f:focus { border-color: var(--accent-dark); }
.ag-f-check {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  font-size: 11px; font-weight: 700; color: var(--text-gray); cursor: pointer;
  border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; background: var(--white);
}
.ag-f-check input { accent-color: var(--accent-dark); cursor: pointer; }
.ag-f-limpar {
  margin-top: 7px; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 11px; font-weight: 700; color: var(--accent-dark);
  padding: 0; text-decoration: underline;
}

.ag-check-list { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
@media (max-width: 1180px) { .ag-check-list { max-height: 60vh; } }
.ag-ck-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--bg-light);
}
.ag-ck-item:last-child { border-bottom: none; }
.ag-ck-item:hover { background: #fafbfa; }
.ag-ck-item.done .ag-ck-txt, .ag-ck-item.cancel .ag-ck-txt { text-decoration: line-through; color: var(--text-gray); }
.ag-ck-item.done, .ag-ck-item.cancel { opacity: .6; }
.ag-ck-box { flex: none; width: 16px; height: 16px; margin-top: 2px; cursor: pointer; accent-color: var(--accent-dark); }
.ag-ck-prio { flex: none; width: 4px; align-self: stretch; border-radius: 3px; }
.ag-ck-body { flex: 1; min-width: 0; cursor: pointer; }
.ag-ck-txt { font-size: 12.5px; font-weight: 600; line-height: 1.35; color: var(--text-dark); word-break: break-word; }
.ag-ck-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; align-items: center; }
.ag-ck-date {
  font-size: 10px; font-weight: 800; color: var(--text-gray);
  background: var(--bg-light); border-radius: 20px; padding: 2px 7px;
  font-variant-numeric: tabular-nums;
}
.ag-ck-date.late { background: #fee2e2; color: #b91c1c; }
.ag-ck-date.today { background: #fef3c7; color: #92400e; }
.ag-ck-tag {
  font-size: 9.5px; font-weight: 700; color: #374151;
  border: 1px solid var(--border); border-radius: 20px; padding: 2px 7px;
  display: inline-flex; align-items: center; gap: 4px;
}
.ag-ck-tag.resp { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }
.ag-ck-tag.obra { background: var(--bg-light); }
.ag-ck-tag.etapa { background: #f1f5f9; border-color: #cbd5e1; color: #475569; }
.ag-ck-tag.forn { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
/* Ação da casa: verde da marca, para separar do que é de fornecedor */
.ag-ck-tag.teva { background: #eaf5ee; border-color: #9dcfad; color: #2f6b47; font-weight: 800; }
.ag-chip-teva {
  font-size: 9px; font-weight: 800; color: #2f6b47;
  background: rgba(157, 207, 173, .45); border: 1px solid #9dcfad;
  border-radius: 20px; padding: 1px 6px;
}
.ag-ck-tag.forn::before { content: '🔧'; }
.ag-ck-del {
  flex: none; border: none; background: none; cursor: pointer; padding: 0 2px;
  color: #cbd5e1; font-size: 17px; line-height: 1; opacity: 0; transition: opacity .12s;
}
.ag-ck-item:hover .ag-ck-del { opacity: 1; }
.ag-ck-del:hover { color: #dc2626; }
.ag-ck-empty { padding: 28px 16px; text-align: center; color: var(--text-gray); font-size: 12.5px; line-height: 1.5; }

.ag-check-add { display: flex; gap: 6px; padding: 9px 12px; border-top: 1px solid var(--border); background: #fafbfa; }
.ag-check-add input[type=text] { flex: 1; min-width: 0; }
/* min-width:0 aqui também: a coluna é estreita e, sem isso, o campo de data
   espreme o de texto até o nome digitado sumir. */
.ag-check-add input[type=date] { flex: 0 1 122px; min-width: 0; }
.ag-check-add input {
  font-family: inherit; font-size: 12px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--white); outline: none;
}
.ag-check-add input:focus { border-color: var(--accent-dark); }
.ag-check-add button {
  flex: none; width: 32px; border: none; border-radius: 6px; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 17px; line-height: 1; font-family: inherit;
}
.ag-check-add button:hover { background: var(--primary-mid); }

/* Barra do que não foi salvo. Fica enquanto houver pendência — é o oposto do
   toast que sumia em 8s e levava junto a única pista de que algo deu errado. */
.ag-nao-salvas {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 890;
  max-width: min(620px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 14px;
  background: #b45309; color: #fff; padding: 11px 14px; border-radius: 10px;
  box-shadow: 0 10px 28px -8px rgba(0, 0, 0, .45); font-size: 13px;
}
.ag-nao-salvas .ans-txt { flex: 1; min-width: 0; }
.ag-nao-salvas strong { display: block; font-weight: 800; }
.ag-nao-salvas span {
  display: block; font-size: 12px; opacity: .9; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ag-nao-salvas button {
  flex: none; border: 1px solid rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .14);
  color: #fff; font-family: inherit; font-size: 12.5px; font-weight: 700;
  padding: 7px 12px; border-radius: 7px; cursor: pointer;
}
.ag-nao-salvas button:hover { background: rgba(255, 255, 255, .26); }

.ag-nao-salva {
  display: inline-block; margin-left: 6px; vertical-align: 1px;
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  color: #fff; background: #b45309; border-radius: 20px; padding: 1px 6px;
}

/* Aviso de servidor desatualizado — fica até ser fechado, de propósito:
   perder trabalho digitado é pior do que uma tarja na tela. */
.ag-aviso-servidor {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 900;
  max-width: min(680px, calc(100vw - 32px));
  display: flex; align-items: flex-start; gap: 12px;
  background: #7f1d1d; color: #fff; padding: 13px 16px; border-radius: 10px;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, .5);
  font-size: 13px; line-height: 1.45;
}
.ag-aviso-servidor strong { display: block; font-weight: 800; margin-bottom: 3px; }
.ag-aviso-servidor span { display: block; opacity: .92; font-size: 12.5px; }
.ag-aviso-servidor button {
  flex: none; background: none; border: none; color: #fff; opacity: .7;
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.ag-aviso-servidor button:hover { opacity: 1; }

/* ── Modal do checklist do fornecedor (clique na barra) ──────── */
.fxm-topo {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12.5px; color: var(--text-gray); margin-bottom: 12px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.fxm-topo strong { color: var(--text-dark); font-weight: 800; }
.fxm-lista { max-height: 46vh; overflow-y: auto; margin-bottom: 12px; }
.fxm-item {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 9px 2px; border-bottom: 1px solid var(--bg-light);
}
.fxm-item:last-child { border-bottom: none; }
.fxm-item.done { opacity: .55; }
.fxm-item.done .fxm-txt { text-decoration: line-through; }
.fxm-item input[type=checkbox] { flex: none; width: 17px; height: 17px; margin-top: 2px; cursor: pointer; accent-color: var(--accent-dark); }
.fxm-prio { flex: none; width: 4px; align-self: stretch; border-radius: 3px; }
.fxm-txt {
  flex: 1; min-width: 0; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-dark); line-height: 1.35; word-break: break-word;
}
.fxm-etapa, .fxm-obra, .fxm-sub {
  display: block; font-size: 10px; font-weight: 700; margin-top: 2px; color: var(--text-gray);
}
.fxm-obra { color: var(--accent-dark); }
.fxm-sub { color: #3730a3; }
.fxm-data {
  flex: none; font-size: 10.5px; font-weight: 800; color: var(--text-gray);
  background: var(--bg-light); border-radius: 20px; padding: 2px 8px;
  font-variant-numeric: tabular-nums; white-space: nowrap; margin-top: 1px;
}
.fxm-data.late { background: #fee2e2; color: #b91c1c; }
.fxm-vazio { padding: 22px 8px; text-align: center; color: var(--text-gray); font-size: 13px; }
.fxm-add { display: flex; gap: 7px; padding-top: 12px; border-top: 1px solid var(--border); }
.fxm-add input[type=text] { flex: 1 1 auto; min-width: 0; }
.fxm-add input[type=date] { flex: 0 1 140px; min-width: 0; }
.fxm-add input {
  font-family: inherit; font-size: 13px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--white); outline: none;
}
.fxm-add input:focus { border-color: var(--accent-dark); }
.fxm-add button {
  flex: none; width: 38px; border: none; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--primary); color: #fff; font-size: 18px; line-height: 1; font-family: inherit;
}
.fxm-add button:hover { background: var(--primary-mid); }

/* ── Menu do botão direito ───────────────────────────────────── */
/* z-index abaixo do modal (.modal-bg) pra nunca boiar sobre um formulário. */
.ag-menu {
  position: fixed; z-index: 400;
  min-width: 226px; max-width: 280px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 34px -8px rgba(0, 0, 0, .34);
  padding: 5px; overflow: hidden;
}
.ag-menu-tit {
  font-size: 11px; font-weight: 800; color: var(--text-gray);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 6px 9px 7px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ag-menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text-dark);
  padding: 8px 9px; border-radius: 6px;
}
.ag-menu button:hover { background: var(--bg-green); }
.ag-menu button.perigo { color: #dc2626; }
.ag-menu button.perigo:hover { background: #fee2e2; }
.ag-menu button.is-atual { font-weight: 800; color: var(--primary); }
.ag-menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.ag-menu-atual {
  font-size: 11px; font-weight: 700; color: var(--text-gray);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none;
}
.ag-menu-voltar {
  font-size: 11.5px !important; font-weight: 700 !important;
  color: var(--accent-dark) !important; padding: 5px 9px !important;
}
.ag-menu-lista { max-height: 320px; overflow-y: auto; }

/* ── Modal de ação ───────────────────────────────────────────── */
/* Nada dentro do modal pode empurrar largura: input[type=date] e select têm
   largura mínima própria e criavam rolagem horizontal. */
#agModal .modal-body { overflow-x: hidden; }
#agModal .field input, #agModal .field select, #agModal .field textarea { max-width: 100%; }

/* Prioridade e status são semáforo: alta vermelha, média amarela, baixa verde.
   A cor sai inline (vem da lista PRIORIDADES/STATUS); aqui fica só a forma. */
.ag-sel-cor { border: 1.5px solid transparent !important; }
.ag-sel-cor option { padding: 4px 6px; }
.ag-form-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ag-form-row2 > *, .ag-form-row3 > * { min-width: 0; }
.ag-form-row3 { display: grid; grid-template-columns: 1fr 1fr 110px; gap: 12px; }
.ag-form-row3.eq { grid-template-columns: 1.2fr 1fr 1fr; }   /* sem campo de hora */
@media (max-width: 560px) { .ag-form-row2, .ag-form-row3 { grid-template-columns: 1fr; } }
.ag-opt { font-weight: 400; color: var(--text-gray); }
.ag-mini-link {
  border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: 11px; font-weight: 700; color: var(--accent-dark); text-decoration: underline;
  margin-left: 6px; padding: 0;
}
/* Combobox digitável + botão de criar. O .ss-wrap é inserido pelo
   makeSearchableSelect (app.js) logo depois do <select>, que fica oculto. */
.ag-combo { display: flex; gap: 6px; align-items: flex-start; }
.ag-combo .ss-wrap { flex: 1 1 auto; min-width: 0; }
.ag-combo-add {
  flex: none; width: 34px; height: 33px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--white); color: var(--accent-dark);
  font-family: inherit; font-size: 18px; font-weight: 700; line-height: 1; cursor: pointer;
}
.ag-combo-add:hover { background: var(--bg-green); border-color: var(--accent-dark); }

/* Checklist da própria ação (abaixo de Observações) */
.ag-sub { margin-bottom: 8px; }
.ag-sub-cont {
  font-size: 11px; font-weight: 800; color: var(--text-gray);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px;
}
/* Grid em vez de flex: o input[type=date] nativo tem largura mínima própria e,
   num flex, empurrava o campo de texto para perto de zero — o item ficava sem
   o nome à vista e o modal ganhava rolagem horizontal. */
.ag-sub-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 128px auto;
  align-items: center; gap: 7px; margin-bottom: 5px;
}
.ag-sub-item input[type=checkbox] { flex: none; width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent-dark); }
.ag-sub-txt {
  min-width: 0; width: 100%; font-family: inherit; font-size: 13px;
  padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--white); color: var(--text-dark); outline: none;
}
@media (max-width: 560px) {
  /* Estreito: data desce para a linha de baixo em vez de espremer o nome. */
  .ag-sub-item { grid-template-columns: auto minmax(0, 1fr) auto; }
  .ag-sub-data { grid-column: 2 / 4; }
}
.ag-sub-txt:focus { border-color: var(--accent-dark); }
.ag-sub-data {
  min-width: 0; width: 100%; font-family: inherit; font-size: 12px;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--white); color: var(--text-mid); outline: none;
}
.ag-sub-data:focus { border-color: var(--accent-dark); }
/* Mesma regra na linha de adicionar: o campo de texto manda, a data cede. */
.ag-sub-add { display: flex; gap: 6px; align-items: center; }
.ag-sub-add input[type=text] { flex: 1 1 auto; min-width: 0; }
.ag-sub-add input[type=date] { flex: 0 1 128px; min-width: 0; }
.ag-sub-item.done .ag-sub-txt { text-decoration: line-through; color: var(--text-gray); background: var(--bg-light); }
.ag-sub-del {
  flex: none; border: none; background: none; cursor: pointer;
  color: #cbd5e1; font-size: 18px; line-height: 1; padding: 0 4px;
}
.ag-sub-del:hover { color: #dc2626; }
.ag-sub-vazio { font-size: 12px; color: var(--text-gray); padding: 2px 0 6px; }
.ag-sub-add { display: flex; gap: 6px; }
.ag-sub-add input {
  flex: 1; min-width: 0; font-family: inherit; font-size: 13px;
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--white); outline: none;
}
.ag-sub-add input:focus { border-color: var(--accent-dark); }
.ag-sub-add button {
  flex: none; width: 34px; border: none; border-radius: 6px; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 17px; line-height: 1; font-family: inherit;
}
.ag-sub-add button:hover { background: var(--primary-mid); }

/* Ação concluída antes do previsto: o check trouxe ela para o dia em que foi
   feita e esta marca diz de onde ela veio (senão o adiantamento some). */
.ag-adiantada {
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
  font-size: 9px; font-weight: 800; color: #075985;
  background: #e0f2fe; border: 1px solid #bae6fd; border-radius: 20px; padding: 1px 6px;
}
.ag-gitem.barra .ag-adiantada { background: rgba(255,255,255,.85); border-color: rgba(255,255,255,.6); }

/* Dias em atraso no card do calendário. Vermelho e nunca esmaecido: o servidor
   traz a tarefa vencida para hoje (agendaEmpurrarAtrasadas), e sem este selo
   ela passaria por tarefa nascida hoje — o atraso ficaria invisível. */
.ag-atrasada {
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
  font-size: 9px; font-weight: 800; color: #991b1b;
  background: #fee2e2; border: 1px solid #fca5a5; border-radius: 20px; padding: 1px 6px;
}
/* Já concluída: o atraso é histórico, não é mais cobrança — sai do vermelho. */
.ag-atrasada.feita {
  color: #78350f; background: #fef3c7; border-color: #fcd34d;
}
.ag-gitem.barra .ag-atrasada { background: rgba(255,255,255,.9); border-color: rgba(255,255,255,.65); }
/* O card concluído inteiro fica com opacidade baixa; o selo do atraso é a
   informação que ainda importa ali, então ele não acompanha o esmaecimento. */
.ag-gitem.done .ag-atrasada { opacity: 1; }

/* Contador de subitens no card do calendário e no checklist */
.ag-chip-sub, .ag-ck-tag.sub {
  font-size: 9px; font-weight: 800; color: #3730a3;
  background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 20px; padding: 1px 6px;
}

.ag-cat-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-cat-op {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; color: #374151;
  border: 1.5px solid transparent; border-radius: 20px; padding: 4px 10px; cursor: pointer;
  opacity: .6;
}
.ag-cat-op.active { opacity: 1; box-shadow: 0 0 0 2px rgba(0, 0, 0, .06); }
.ag-cat-op:hover { opacity: 1; }
.ag-cat-edit { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.ag-cat-edit input {
  flex: 1; font-family: inherit; font-size: 13px; padding: 7px 10px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); outline: none;
}
.ag-cat-edit input:focus { border-color: var(--accent-dark); }
.ag-modal-hint { font-size: 12.5px; color: var(--text-gray); margin-bottom: 14px; line-height: 1.5; }
.ag-dia-sec { font-size: 13px; font-weight: 800; color: var(--text-dark); margin-bottom: 8px; }
.ag-dia-resumo { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; }
.ag-dia-resumo .ag-pag { display: inline-flex; padding: 3px 9px; font-size: 11.5px; margin: 0; }
.modal-table .ag-pag { display: inline-flex; padding: 2px 7px; font-size: 10.5px; margin: 0; }
.ag-dia-prev {
  margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg-light); font-size: 12.5px; color: var(--text-mid);
}
.ag-dia-prev span { font-size: 11.5px; color: var(--text-gray); }

/* ══ MARCO CRÍTICO ══════════════════════════════════════════════════════
   Liberação de início e aprovação de fim de etapa. O vermelho aqui não é
   "categoria": é a única coisa da agenda que TRAVA a etapa, e por isso passa
   na frente da cor do fornecedor e da categoria. A bandeira ⚑ acompanha em
   todo lugar — quem não distingue a cor continua vendo o marcador.          */
.ag-gitem.marco,
.ag-m-ev.marco,
.ag-ck-item.marco {
  border-left-color: #dc2626 !important;
  background: #fee2e2;
}
.ag-gitem.marco { box-shadow: inset 0 0 0 1px #fca5a5; }
.ag-gitem.marco .ag-gitem-txt { font-weight: 700; color: #7f1d1d; }
.ag-m-ev.marco { font-weight: 700; color: #7f1d1d; }
.ag-ck-item.marco { box-shadow: inset 0 0 0 1px #fecaca; }
.ag-gitem.marco.done,
.ag-ck-item.marco.done { background: #f0fdf4; box-shadow: inset 0 0 0 1px #bbf7d0; }

.ag-marco-flag { color: #dc2626; font-weight: 800; margin-right: 2px; }
.ag-chip-marco {
  background: #dc2626; color: #fff; border-radius: 999px;
  padding: 1px 7px; font-size: 10px; font-weight: 800; letter-spacing: .02em;
}
.ag-marco-tag {
  display: inline-block; background: #dc2626; color: #fff;
  border-radius: 4px; padding: 1px 5px; margin-right: 5px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .05em; vertical-align: 1px;
}
.ag-ck-tag.marco { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; font-weight: 700; }

.ag-marco-aviso {
  display: block; margin: 4px 0 14px; padding: 11px 13px;
  border-radius: 8px; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  font-size: 12.5px; line-height: 1.5;
}
.ag-marco-aviso strong { display: inline; font-weight: 800; }
.ag-marco-aviso span { display: block; margin-top: 3px; color: #b91c1c; }

/* Fotos da pendência (câmera do diário de obra) */
.ag-fotos { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; align-items: center; }
.ag-fotos a { display: block; width: 42px; height: 42px; border-radius: 6px; overflow: hidden; border: 1px solid #e5e7eb; background: #f4f6f4; }
.ag-fotos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ag-fotos-mais { font-size: 11px; font-weight: 700; color: #6b7280; padding: 0 4px; }
.ckf-txt .ag-fotos a { width: 34px; height: 34px; }
.modal .ag-fotos a, .field .ag-fotos a { width: 84px; height: 84px; }

/* Fotos no modal da ação */
.ag-fotos-modal { gap: 8px; }
.ag-foto-cx { position: relative; display: inline-block; }
.ag-foto-x {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  border: none; border-radius: 10px; background: #374151; color: #fff; font-size: 13px; line-height: 20px;
  cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.ag-foto-x.armado { background: #dc2626; font-size: 11px; font-weight: 700; }
.ag-foto-add {
  width: 84px; height: 84px; border: 1.5px dashed #cbd5d0; border-radius: 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #4b7a5f; background: #f6faf7; font-size: 22px;
}
.ag-foto-add small { font-size: 11px; font-weight: 700; }
.ag-foto-add:hover { border-color: #5fa882; background: #eef7f1; }
.ag-fotos-vazio { font-size: 12px; color: #6b7280; margin-top: 6px; }

/* Miniatura da foto no card do calendário */
.ag-gitem-tags .ag-fotos { margin-top: 0; gap: 3px; flex-basis: 100%; }
.ag-gitem-tags .ag-fotos a { width: 44px; height: 44px; border-radius: 5px; }

/* ── Busca de cards (calendário, checklist e cards de fornecedor) ──
   As três caixas são o mesmo filtro "texto" do agenda.js. */
.ag-busca {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--white); padding: 0 9px; height: 32px;
  color: var(--text-gray); cursor: text;
}
.ag-busca svg { width: 14px; height: 14px; flex: none; }
.ag-busca-inp {
  border: none; outline: none; background: none; min-width: 0; width: 100%;
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-dark);
}
.ag-busca:focus-within { border-color: var(--accent-dark); }
.ag-busca.on { border-color: var(--accent-dark); background: var(--bg-green); color: var(--primary); }
.ag-busca-cal { width: 200px; }
.ag-busca-ckf { width: 240px; }
.ag-check-busca { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.ag-check-busca .ag-busca { display: flex; width: 100%; }
@media (max-width: 720px) {
  .ag-busca-cal, .ag-busca-ckf { width: 100%; order: -1; }
}
