/* ============================================================
   REFINEMENT v3 — limpeza de layout (admin + campo)
   ============================================================ */

/* --- Sidebar: contraste e tipografia --- */
.sidebar { background: linear-gradient(180deg, #122e52 0%, #081726 100%); }
/* Mantido o padrao do Gabinete: cartao branco centralizado, nome em dourado. */
.sidebar-header { padding: 18px 20px; border-bottom-color: rgba(197,165,90,0.15); }
.sidebar-header img { width: 200px; height: auto; max-width: 100%; border-radius: 6px; background: #fff; padding: 6px 12px; opacity: 1; object-fit: contain; }
.sidebar-brand h2 { font-size: 18px; font-weight: 700; }
.sidebar-brand small { font-size: 11px; opacity: 0.7; font-weight: 400; }
.nav-section { color: rgba(255,255,255,0.45); font-size: 0.69rem; padding: 1rem 1rem 0.35rem; }
.nav-item { color: rgba(255,255,255,0.82); font-size: 0.86rem; padding: 0.65rem 0.95rem; }
.nav-item:hover { background: rgba(255,255,255,0.07); color: white; }
.nav-item.active { background: rgba(255,255,255,0.1); color: white; box-shadow: inset 3px 0 0 #d4a843; }
.nav-icon { display: inline-flex; opacity: 0.85; }
.nav-item.active .nav-icon { opacity: 1; }
.btn-trocar-perfil { color: rgba(255,255,255,0.85); border-color: rgba(255,255,255,0.18); }
.nav-section[data-role="admin_situacao"],
.nav-item[data-role="admin_situacao"],
.nav-section[data-role="situacao"],
.nav-item[data-role="situacao"] { display: none !important; }

/* --- Top bar: respiro e tipografia --- */
.top-bar { padding: 0 1.5rem; border-bottom-color: var(--border-light); box-shadow: 0 1px 0 rgba(0,0,0,0.02); }
.top-bar-title { font-size: 1.05rem; letter-spacing: -0.015em; color: var(--text); }

/* --- Conteúdo principal: respiro --- */
/* Teto alto para aproveitar monitores largos; a leitura fica protegida porque
   os textos corridos (.template-card-desc, .situacao-subtitle) têm trava própria. */
.content-area { padding: 1.5rem clamp(1.5rem, 2.5vw, 2.75rem); max-width: 1600px; }

/* --- Foco visível por teclado ---
   Só aparece na navegação por teclado (:focus-visible), então o clique de mouse
   continua sem contorno. Usa a paleta existente, sem introduzir cor nova. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Sobre fundo escuro (sidebar, sala de situação) o azul não contrasta. */
.sidebar :where(a, button, [tabindex]):focus-visible,
.situacao-wrap :where(a, button, [tabindex]):focus-visible {
  outline-color: #ffffff;
}
/* Atalho para saltar direto ao conteúdo, visível apenas quando focado. */
.skip-link {
  position: absolute; left: 0.5rem; top: -3rem; z-index: 900;
  background: var(--primary); color: #fff; padding: 0.5rem 0.9rem;
  border-radius: 6px; font-size: 0.85rem; transition: top 0.15s ease;
}
.skip-link:focus { top: 0.5rem; }
.admin-toolbar { margin-bottom: 1.25rem; padding-bottom: 0.875rem; border-bottom: 1px solid var(--border-light); }
.admin-toolbar h3 { font-size: 1.15rem; letter-spacing: -0.015em; }

/* --- Admin cards: layout robusto, sem sobreposição --- */
.admin-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 0.625rem;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.admin-card:hover { transform: none; box-shadow: 0 2px 8px rgba(15,23,42,0.06); border-color: var(--primary-200); }
.admin-card-icon { width: 42px; height: 42px; border-radius: 10px; }
.admin-card-icon svg { width: 22px; height: 22px; }
.admin-card-title { font-size: 0.95rem; font-weight: 600; gap: 0.5rem; }
.admin-card-title .badge { font-size: 0.69rem; padding: 0.18rem 0.55rem; }
.admin-card-sub { font-size: 0.78rem; gap: 0.5rem; row-gap: 0.25rem; margin-top: 0.3rem; }
.admin-card-sub .tag { background: var(--bg); padding: 0.15rem 0.5rem; border-radius: 5px; font-weight: 500; color: var(--text-secondary); }
.admin-card-actions { gap: 0.5rem; }
.admin-card-actions .btn { padding: 0.45rem 0.8rem; font-size: 0.78rem; }
.admin-card-actions .btn-danger { padding: 0.45rem 0.65rem; }

/* Mobile: empilha. Ações vão para o rodapé do card */
@media (max-width: 720px) {
  .admin-card {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "icon body"
      "actions actions";
    row-gap: 0.75rem;
    padding: 0.875rem;
  }
  .admin-card-icon { grid-area: icon; }
  .admin-card-body { grid-area: body; }
  .admin-card-actions {
    grid-area: actions;
    justify-content: flex-end;
    border-top: 1px solid var(--border-light);
    padding-top: 0.625rem;
  }
  .content-area { padding: 1rem; }
  .admin-toolbar { flex-direction: column; align-items: stretch; gap: 0.625rem; }
  .admin-toolbar h3 { font-size: 1.05rem; }
}

/* --- Login PIN: respiração --- */
.login-screen { background: radial-gradient(ellipse at top, #163d6e 0%, #0a1929 70%); }
.login-card { width: 360px; padding: 2.25rem 1.75rem 2rem; }
.login-logo { font-size: 2rem; letter-spacing: -0.03em; margin-bottom: 0.1rem; }
.login-sub { font-size: 0.8rem; margin-bottom: 1.75rem; opacity: 0.7; }
.login-input { font-size: 1.35rem; letter-spacing: 0.55em; padding: 0.95rem 0.5rem 0.95rem 1rem; text-align: center; }
.login-input::placeholder { letter-spacing: 0.15em; font-size: 0.85rem; opacity: 0.55; }
.login-btn { padding: 0.9rem; border-radius: 11px; font-size: 0.95rem; box-shadow: 0 4px 14px rgba(212,168,67,0.25); }

/* --- Wizard (campo): contraste e respiro --- */
body.campo-mode .wiz-step .wiz-label { color: var(--text-secondary); font-weight: 600; }
body.campo-mode .wiz-step:not(.active):not(.done) .wiz-label { color: var(--text-muted); }
body.campo-mode .wiz-content { background: white; border-radius: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); padding: 1.5rem 1.25rem; margin: 0 0.75rem; }
body.campo-mode .wiz-title { font-size: 1.15rem; letter-spacing: -0.015em; color: var(--text); }
body.campo-mode .wiz-content .wiz-title { color: var(--text); }
body.campo-mode .wiz-content > p { color: var(--text-secondary); font-size: 0.88rem; line-height: 1.5; margin-bottom: 1rem; }

/* --- Empty states no campo: tom suave --- */
body.campo-mode .empty { background: #f8fafc; border: 1px dashed var(--border); border-radius: 12px; padding: 1.75rem 1rem; }
body.campo-mode .empty h4 { color: var(--text); font-size: 0.95rem; }
body.campo-mode .empty p { color: var(--text-secondary); font-size: 0.85rem; line-height: 1.5; }

/* --- Templates view (admin): título da view --- */
.view-templates .admin-toolbar h3,
.view-achados .admin-toolbar h3,
.view-checklist .admin-toolbar h3,
.view-processos .admin-toolbar h3 { color: var(--text); }

/* --- Templates admin: painel de gestao --- */
.template-admin-shell { display: flex; flex-direction: column; gap: 1rem; }
.template-page-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 1.25rem;
  align-items: end;
  padding: 1.25rem;
  background: linear-gradient(135deg, #ffffff 0%, #f8fbff 62%, #eef6ff 100%);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.template-page-kicker {
  color: #8a6820;
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}
.template-page-title {
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1.15;
  letter-spacing: 0;
  margin: 0;
}
.template-page-copy {
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.45;
  margin: 0.45rem 0 0;
  max-width: 620px;
}
.template-hero-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.template-stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; }
.template-stat-card {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 2px rgba(15,23,42,0.03);
}
.template-stat-label {
  color: var(--text-muted);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.template-stat-value {
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.15;
  margin-top: 0.25rem;
}
.template-list { display: flex; flex-direction: column; gap: 0.75rem; }
.template-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
  overflow: hidden;
}
.template-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #2563eb;
}
.template-card.template-card-base { background: #fffdf7; border-color: #e7c36e; }
.template-card.template-card-base::before { background: #d4a843; }
.template-card:hover { border-color: var(--primary-200); box-shadow: 0 8px 22px rgba(15,23,42,0.08); }
.template-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1d4ed8;
  background: #eff6ff;
}
.template-card-base .template-card-icon { color: #92400e; background: #fef3c7; }
.template-card-icon svg { width: 23px; height: 23px; }
.template-card-main { min-width: 0; }
.template-card-title-row { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
.template-card-title { font-size: 0.98rem; font-weight: 800; color: var(--text); line-height: 1.25; }
.template-card-desc { color: var(--text-secondary); font-size: 0.8rem; line-height: 1.35; margin-top: 0.28rem; max-width: 760px; }
.template-card-meta { display: flex; gap: 0.45rem; flex-wrap: wrap; align-items: center; margin-top: 0.45rem; }
.template-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--text-secondary);
  font-size: 0.69rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.template-chip-warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.template-card-actions { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; }
.template-card-actions .btn { min-height: 32px; }

@media (max-width: 860px) {
  .template-page-hero { grid-template-columns: 1fr; align-items: start; }
  .template-hero-actions { justify-content: flex-start; }
  .template-stats-grid { grid-template-columns: 1fr; }
  .template-card {
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-areas:
      "icon main"
      "actions actions";
  }
  .template-card-icon { grid-area: icon; width: 44px; height: 44px; }
  .template-card-main { grid-area: main; }
  .template-card-actions {
    grid-area: actions;
    justify-content: flex-end;
    border-top: 1px solid var(--border-light);
    padding-top: 0.75rem;
  }
}

