:root {
  --brand: #1565c0;
  --brand-dark: #0d47a1;
  --brand-light: #42a5f5;
  --accent: #00bfa5;
  --bg: #eef2f9;
  --card: #ffffff;
  --text: #1f2a37;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(21, 101, 192, 0.08);
  --shadow-hover: 0 12px 28px rgba(21, 101, 192, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, #eaf1fb 0%, #f5f8fd 220px, #f5f8fd 100%);
  background-attachment: fixed;
  color: var(--text);
  overflow-x: hidden;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.15);
}

.topbar {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand) 55%, var(--brand-light));
  color: #fff;
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 8px 24px rgba(13, 71, 161, 0.28);
  position: relative;
  z-index: 2;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.topbar p {
  margin: 0;
  opacity: 0.9;
  word-break: break-word;
}

.topbar-cidade {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.16);
  padding: 6px 12px;
  border-radius: 12px;
}

.topbar-cidade label {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
}

.topbar-cidade select {
  min-width: 190px;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
}

.topbar-cidade select:disabled {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  opacity: 1;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

button,
select,
input,
textarea {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease,
    filter 0.15s ease;
}

textarea {
  width: 100%;
  min-height: 90px;
  margin-top: 8px;
  margin-bottom: 10px;
  font-family: inherit;
}

button {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(21, 101, 192, 0.22);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
  filter: brightness(1.03);
}

button:active {
  transform: translateY(0);
}

button.ghost {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand);
  box-shadow: none;
}

button.ghost:hover {
  background: rgba(21, 101, 192, 0.06);
}

.container {
  padding: 20px;
}

#painel {
  width: 100%;
}

.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: start;
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #536173;
}

.sidebar-item {
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-weight: 600;
  box-shadow: none;
  white-space: normal;
  word-break: break-word;
}

.sidebar-item:hover {
  background: rgba(21, 101, 192, 0.06);
  border-color: var(--brand-light);
  transform: none;
  box-shadow: none;
  filter: none;
}

.sidebar-item.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(21, 101, 192, 0.32);
}

.admin-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.admin-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(21, 101, 192, 0.06);
  min-width: 0;
}

.card h3 {
  color: var(--brand-dark);
}

.card h3::after {
  content: "";
  display: block;
  width: 42px;
  height: 3px;
  margin-top: 8px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.hidden {
  display: none !important;
}

.filters {
  display: flex;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters > div {
  min-width: 160px;
}

.filters label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: #536173;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.metric {
  background: #fff;
  border: 1px solid rgba(21, 101, 192, 0.1);
  border-left: 4px solid var(--brand);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 4px 14px rgba(21, 101, 192, 0.07);
}

.metric h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.metric p {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  color: var(--brand-dark);
}

.metric p.is-loading {
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  animation: metricPulse 1.1s ease-in-out infinite;
}

@keyframes metricPulse {
  0% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.45;
  }
}

#painelGastosSection .metric {
  min-height: 122px;
}

#gastosMaiorLancamento {
  font-size: 17px;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

.charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  min-width: 0;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-width: 0;
}

canvas {
  max-width: 100% !important;
  height: auto !important;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #ebeff5;
}

th {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: rgba(21, 101, 192, 0.05);
}

tbody tr:hover td {
  background: rgba(21, 101, 192, 0.035);
}

#aprovacoesBody .col-usuario {
  white-space: nowrap;
}

#aprovacoesBody .col-descricao {
  max-width: 320px;
  white-space: normal;
  line-height: 1.35;
}

#perguntasSemRespostaSection td[data-label="Pergunta"],
#perguntasSemRespostaSection td[data-label="Resposta / erro"] {
  max-width: 360px;
  white-space: normal;
  line-height: 1.35;
  vertical-align: top;
}

#perguntasSemRespostaStatus {
  margin-left: 8px;
  font-weight: 700;
}

.acao {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
}

.acao > * {
  flex: 0 0 auto;
}

.acao button {
  padding: 8px 12px;
  font-size: 12px;
  width: auto;
  min-width: 84px;
  min-height: 48px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #d9e2ef;
  border-radius: 999px;
  padding: 6px 10px;
  background: #f9fbff;
  font-size: 13px;
}

.catatreco-bairros-resumo {
  display: inline-block;
  margin-bottom: 8px;
  font-weight: 700;
  color: #14532d;
}

.catatreco-bairros-resumo.is-empty {
  color: #b91c1c;
}

.acao .acao-direcionamento {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  width: 130px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 7px 8px;
  font-size: 12px;
}

.acao .acao-info {
  width: 34px;
  min-height: 48px;
  border-radius: 10px;
  padding: 0;
  font-size: 18px;
  background: #eef2ff;
  color: #1e3a8a;
  border: 1px solid #c7d2fe;
}

.acao-direcionamento-logo {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.28);
}

.acao-direcionamento-texto {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.acao-direcionamento-texto strong {
  font-size: 12px;
}

.acao-direcionamento-texto small {
  opacity: 0.9;
  font-size: 10px;
}

.acao-direcionamento-cemig {
  background: linear-gradient(135deg, #046a38, #0f8d52);
  border-color: #045f33;
  color: #fff;
}

.acao-direcionamento-copasa {
  background: linear-gradient(135deg, #0b3a8f, #1f62d1);
  border-color: #0c347a;
  color: #fff;
}

.acao-direcionamento-mensagem {
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  border-color: #0d6b64;
  color: #fff;
}

.acao-direcionamento-cemig:hover,
.acao-direcionamento-copasa:hover,
.acao-direcionamento-mensagem:hover {
  filter: brightness(1.05);
}

.aprovacao-foto-thumb {
  width: 84px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #d0d7e2;
}

.foto-thumb-btn {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.acao .rejeitar {
  background: #b42318;
}

.direcionamento-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.direcionamento-preview .card {
  background: linear-gradient(180deg, #f8fbff, #f4f8ff);
}

.direcionamento-preview .card h4 {
  margin: 0 0 10px;
  color: #0b3a82;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.direcionamento-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #d9e2ef;
  background: #fff;
  object-fit: contain;
}

.direcionamento-preview-card {
  border-width: 1px;
  border-style: solid;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.direcionamento-preview-card.cemig {
  border-color: #b9e4cf;
}

.direcionamento-preview-card.copasa {
  border-color: #bfd4ff;
}

.direcionamento-preview-card .tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 8px;
}

.direcionamento-preview-card.cemig .tag {
  background: #e8f8ef;
  color: #065f46;
}

.direcionamento-preview-card.copasa .tag {
  background: #eaf1ff;
  color: #1d4ed8;
}

.direcionamento-preview-pre {
  margin: 0;
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.6;
  color: #1f2937;
  background: #ffffff;
  border: 1px solid #dbe7f6;
  border-radius: 10px;
  padding: 10px 12px;
}

.direcionamento-preview-pre p {
  margin: 0 0 6px;
}

.direcionamento-preview-pre p:last-child {
  margin-bottom: 0;
}

.direcionamento-preview-pre a {
  color: #0b5ed7;
  font-weight: 600;
  text-decoration: underline;
  word-break: break-all;
}

.filters-inline {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.card-head-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.field-group-wide {
  grid-column: 1 / -1;
}

.ponto-foto-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label,
#catalogoAtividadesSection > label[for="atividadeDescricaoInput"] {
  font-size: 12px;
  color: #536173;
  font-weight: 600;
}

.atividade-imagem-preview {
  display: block;
  width: 100%;
  max-width: 360px;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid #d9e2ef;
  margin-bottom: 10px;
}

.actions-line {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

#configuracoesGeraisStatus {
  font-size: 13px;
  color: #536173;
  align-self: center;
}

.status-inline {
  font-size: 13px;
  color: #536173;
  margin-bottom: 4px;
}

.gastos-subtitle {
  margin-top: -4px;
  margin-bottom: 4px;
  color: #536173;
  font-size: 14px;
}

.gastos-tabs {
  display: flex;
  gap: 8px;
  margin: 10px 0 12px;
  flex-wrap: wrap;
}

.gastos-tab-btn {
  background: #f3f6fb;
  color: #1f2a37;
  border: 1px solid #d9e2ef;
  font-weight: 600;
}

.gastos-tab-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.gastos-pane {
  display: grid;
  gap: 12px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.table-card-mode td.acao-cell .acao {
  width: 100%;
}

.gastos-charts {
  grid-template-columns: 2fr 1fr;
}

.gastos-grid table td:nth-child(3),
#gastosDetalheBody td:nth-last-child(-n + 3) {
  white-space: nowrap;
}

.mini .metric p {
  font-size: 18px;
}

.agenda-builder h4 {
  margin: 0 0 6px;
}

.agenda-builder p {
  margin: 0 0 12px;
  color: #536173;
  font-size: 13px;
}

.agenda-dia {
  border: 1px solid #e5ebf3;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  background: #fafcff;
}

.agenda-dia-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.agenda-dia-head label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.agenda-slots {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.agenda-slot {
  display: flex;
  align-items: center;
  gap: 6px;
}

.agenda-slot input[type='time'] {
  max-width: 130px;
}

.agenda-slot .remove-slot {
  background: #b42318;
  color: #fff;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

#appDialogModal {
  z-index: 1100;
}

.modal-card {
  width: min(1100px, 95vw);
  max-height: 90vh;
  overflow: hidden;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
}

.foto-modal-card {
  width: min(900px, 95vw);
}

.foto-modal-body {
  padding: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f8fafc;
}

.foto-modal-img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 78vh;
  border-radius: 10px;
  border: 1px solid #d0d7e2;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
}

.mapa-modal-card {
  width: min(1000px, 95vw);
}

.mapa-modal-body {
  padding: 14px;
  background: #f8fafc;
}

.mapa-modal-frame {
  width: 100%;
  height: 72vh;
  border: 1px solid #d0d7e2;
  border-radius: 10px;
  background: #fff;
}

.direcionamento-info-pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
}

.confirmacao-direcionamento-card {
  width: min(560px, 95vw);
}

.confirmacao-direcionamento-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #dbe7f6;
  border-radius: 10px;
  background: #f8fbff;
}

.confirmacao-direcionamento-head strong {
  font-size: 16px;
}

#mensagemChamadoHistorico {
  margin: 0;
  line-height: 1.5;
}

.mensagem-chamado-historico-wrap {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #dbe7f6;
  border-radius: 10px;
  background: #f8fbff;
  max-height: 180px;
  overflow-y: auto;
}

.mensagem-chamado-historico-titulo {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: #536173;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mensagem-chamado-historico {
  display: grid;
  gap: 8px;
}

.mensagem-chamado-item {
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e5ebf3;
}

.mensagem-chamado-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 4px;
  font-size: 11px;
  color: #64748b;
}

.mensagem-chamado-item-meta strong {
  color: var(--brand);
}

.mensagem-chamado-item p {
  margin: 0;
  font-size: 13px;
  color: #1f2937;
  white-space: pre-wrap;
}

#appDialogMensagem {
  margin: 0;
  line-height: 1.5;
}

#abrirRotaGpsLink {
  align-self: center;
  text-decoration: none;
  color: var(--brand);
  border: 1px solid #98c4bb;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5ebf3;
}

.modal-header h3 {
  margin: 0;
}

.modal-meta {
  padding: 10px 16px 0;
}

.modal-meta p {
  margin: 0;
  color: #536173;
}

.modal-body {
  padding: 12px 16px 16px;
  overflow: auto;
  display: grid;
  gap: 14px;
}

.modal-body h4 {
  margin: 0 0 8px;
}

@media (max-width: 980px) {
  .topbar {
    padding: 12px;
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
  }

  .container {
    padding: 12px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .sidebar h3 {
    grid-column: 1 / -1;
  }

  .charts,
  .grid2 {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 12px;
  }

  .filters,
  .filters-inline,
  .actions-line {
    flex-direction: column;
    align-items: stretch;
  }

  .filters > div,
  .filters-inline > *,
  .card-head-inline > * {
    min-width: 100%;
    width: 100%;
  }

  #painelGastosSection .filters-inline {
    flex-direction: column;
    align-items: stretch;
  }

  #painelGastosSection .filters-inline > * {
    width: 100%;
  }

  #painelGastosSection .gastos-tabs {
    flex-direction: column;
  }

  #painelGastosSection .gastos-tab-btn {
    width: 100%;
  }

  .acao button {
    width: 100%;
  }

  .table-scroll table {
    min-width: 680px;
  }

  .table-scroll table.table-card-mode {
    min-width: 100%;
  }

  .table-card-mode {
    width: 100%;
  }

  .table-card-mode thead {
    display: none;
  }

  .table-card-mode tbody tr {
    display: block;
    border: 1px solid #ebeff5;
    border-radius: 10px;
    background: #fafcff;
    padding: 10px 12px;
    margin-bottom: 10px;
  }

  .table-card-mode tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    border-bottom: 0;
    padding: 6px 0;
    white-space: normal;
  }

  .table-card-mode tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    color: #536173;
    text-transform: uppercase;
    font-weight: 600;
    flex-shrink: 0;
  }

  .table-card-mode tbody td.acao-cell {
    flex-direction: column;
    align-items: stretch;
  }

  .table-card-mode tbody td.acao-cell::before {
    margin-bottom: 4px;
  }

  #gestaoUsuariosSection .table-card-mode tbody td input,
  #gestaoUsuariosSection .table-card-mode tbody td select,
  #gestaoUsuariosSection .table-card-mode tbody td button,
  #categoriasChamadoSection .table-card-mode tbody td button {
    width: 100%;
  }

  #gestaoUsuariosSection .table-card-mode tbody td .acao,
  #categoriasChamadoSection .table-card-mode tbody td .acao {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  #aprovacoesBody .col-descricao {
    max-width: 220px;
  }
}
