/* ==========================================================================
   SISTEMA DE CONTROLE DE ENDEMIAS - ESTILOS PRINCIPAIS
   Interface moderna, mobile-first, com contraste para uso em campo
   ========================================================================== */

:root {
  --primary: #0d9488;          /* Verde azulado vigilância sanitária */
  --primary-dark: #0f766e;
  --primary-light: #ccfbf1;
  --primary-glow: rgba(13, 148, 136, 0.15);

  --secondary: #0284c7;        /* Azul SUS institucional */
  --secondary-dark: #0369a1;
  --secondary-light: #e0f2fe;

  --accent: #6366f1;

  /* Status Colors */
  --status-green: #10b981;      /* Em dia / Realizada */
  --status-green-bg: #ecfdf5;
  --status-green-border: #a7f3d0;
  
  --status-yellow: #f59e0b;     /* Próxima da visita / Atenção */
  --status-yellow-bg: #fffbeb;
  --status-yellow-border: #fde68a;

  --status-red: #ef4444;        /* Atrasada / Irregularidade / Foco */
  --status-red-bg: #fef2f2;
  --status-red-border: #fecaca;

  --status-blue: #3b82f6;       /* Programada */
  --status-blue-bg: #eff6ff;
  --status-blue-border: #bfdbfe;

  --status-gray: #64748b;       /* Neutro / Inativo */
  --status-gray-bg: #f8fafc;
  --status-gray-border: #e2e8f0;

  /* Neutrals */
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --border-focus: #0d9488;

  /* Metrics & Sizing */
  --sidebar-width: 260px;
  --bottom-nav-height: 64px;
  --header-height: 68px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --transition-fast: 0.18s ease;
  --transition-normal: 0.25s ease;
}

/* Reset básico */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Layout Estrutural */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

/* Sidebar Desktop */
.sidebar {
  width: var(--sidebar-width);
  background: #0f172a;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  transition: transform var(--transition-normal);
  box-shadow: var(--shadow-lg);
}

.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 10px rgba(13, 148, 136, 0.35);
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff;
}

.sidebar-subtitle {
  font-size: 0.72rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0.6rem 0.75rem 0.25rem;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
}

.nav-item-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-icon {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
}

.nav-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
}

.nav-badge.danger {
  background: #ef4444;
  color: #ffffff;
}

.nav-badge.warning {
  background: #f59e0b;
  color: #ffffff;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.nav-item.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
}

.nav-item.active .nav-badge {
  background: rgba(255, 255, 255, 0.25);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: #0284c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffffff;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.72rem;
  color: #38bdf8;
}

/* Área Principal de Conteúdo */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 2rem;
  transition: margin-left var(--transition-normal);
}

/* Header Superior */
.top-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-menu-mobile {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-main);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
}

.btn-menu-mobile:active {
  background-color: var(--border-color);
}

.page-title-box h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.page-title-box p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* Busca Global no Header */
.header-search {
  position: relative;
  width: 280px;
}

.header-search input {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.4rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  font-size: 0.85rem;
  color: var(--text-main);
  transition: all var(--transition-fast);
}

.header-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--primary-glow);
  width: 320px;
}

.header-search .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.95rem;
}

/* Indicador de Conexão */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
}

.status-pill.online {
  background: var(--status-green-bg);
  color: #065f46;
  border: 1px solid var(--status-green-border);
}

.status-pill.offline {
  background: var(--status-yellow-bg);
  color: #92400e;
  border: 1px solid var(--status-yellow-border);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.75; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.75; }
}

/* Botões do Header */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-header-icon {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  transition: all var(--transition-fast);
}

.btn-header-icon:hover {
  background: #f8fafc;
  color: var(--primary);
  border-color: var(--primary-light);
}

.btn-header-icon .badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #ffffff;
}

/* Botão de Registro Rápido */
.btn-primary-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #ffffff;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(13, 148, 136, 0.25);
  transition: all var(--transition-fast);
}

.btn-primary-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(13, 148, 136, 0.35);
}

.btn-primary-action:active {
  transform: translateY(0);
}

/* Conteúdo das Views */
.view-container {
  padding: 1.5rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.view-section {
  display: none;
  animation: fadeIn 0.2s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Alertas de Notificação */
.alert-banner {
  background: #ffffff;
  border-radius: var(--radius-md);
  border-left: 5px solid;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  gap: 1rem;
}

.alert-banner.danger {
  border-left-color: var(--status-red);
  background: linear-gradient(90deg, #fef2f2 0%, #ffffff 100%);
}

.alert-banner.warning {
  border-left-color: var(--status-yellow);
  background: linear-gradient(90deg, #fffbeb 0%, #ffffff 100%);
}

.alert-banner.info {
  border-left-color: var(--status-blue);
  background: linear-gradient(90deg, #eff6ff 0%, #ffffff 100%);
}

.alert-banner.success {
  border-left-color: var(--status-green);
  background: linear-gradient(90deg, #ecfdf5 0%, #ffffff 100%);
}

.alert-content {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.alert-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.alert-text h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.alert-text p {
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* Grid de Indicadores Principais (KPIs) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-icon-box {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.kpi-icon-box.green { background: var(--status-green-bg); color: var(--status-green); }
.kpi-icon-box.blue { background: var(--status-blue-bg); color: var(--status-blue); }
.kpi-icon-box.yellow { background: var(--status-yellow-bg); color: var(--status-yellow); }
.kpi-icon-box.red { background: var(--status-red-bg); color: var(--status-red); }
.kpi-icon-box.purple { background: #f3e8ff; color: #9333ea; }
.kpi-icon-box.teal { background: var(--primary-light); color: var(--primary); }

.kpi-info {
  flex: 1;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-main);
  margin-top: 0.2rem;
}

.kpi-subtext {
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 0.2rem;
}

/* ==========================================================================
   CARDS DE CATEGORIAS (MÓDULO 1 E 14)
   Cards separados, ricos e visualmente únicos para cada tipo de local
   ========================================================================== */

.category-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.category-section-title h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.category-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.category-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  position: relative;
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: #cbd5e1;
}

/* Identidades Visuais Únicas de cada categoria */
.category-card[data-cat="posto"] { border-top: 5px solid #0284c7; }
.category-card[data-cat="escola"] { border-top: 5px solid #10b981; }
.category-card[data-cat="acumulador"] { border-top: 5px solid #ef4444; background: linear-gradient(180deg, #fffafa 0%, #ffffff 60px); }
.category-card[data-cat="construcao"] { border-top: 5px solid #f59e0b; }
.category-card[data-cat="igreja"] { border-top: 5px solid #8b5cf6; }
.category-card[data-cat="comercio"] { border-top: 5px solid #0d9488; }

.category-card-header {
  padding: 1.15rem 1.25rem 0.85rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
}

.category-header-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.category-icon-bubble {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: #f8fafc;
  border: 1px solid var(--border-color);
}

.category-card[data-cat="posto"] .category-icon-bubble { background: #e0f2fe; }
.category-card[data-cat="escola"] .category-icon-bubble { background: #d1fae5; }
.category-card[data-cat="acumulador"] .category-icon-bubble { background: #fee2e2; }
.category-card[data-cat="construcao"] .category-icon-bubble { background: #fef3c7; }
.category-card[data-cat="igreja"] .category-icon-bubble { background: #ede9fe; }
.category-card[data-cat="comercio"] .category-icon-bubble { background: #ccfbf1; }

.category-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.category-code-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  display: inline-block;
  margin-top: 0.25rem;
}

.category-status-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

/* Métricas do Card */
.category-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 0.85rem 1.25rem;
  background: #fafafa;
  border-bottom: 1px solid #f1f5f9;
  text-align: center;
}

.cat-stat-item {
  display: flex;
  flex-direction: column;
}

.cat-stat-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.cat-stat-val.green { color: var(--status-green); }
.cat-stat-val.yellow { color: var(--status-yellow); }
.cat-stat-val.red { color: var(--status-red); }

.cat-stat-lbl {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.15rem;
}

/* Datas do Card e Controle Quinzenal */
.category-dates-box {
  padding: 0.85rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
}

.date-label {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.date-value {
  font-weight: 600;
  color: var(--text-main);
}

.countdown-box {
  background: #f8fafc;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.35rem;
}

.countdown-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.countdown-value {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.countdown-value.green {
  background: var(--status-green-bg);
  color: #065f46;
}

.countdown-value.yellow {
  background: var(--status-yellow-bg);
  color: #92400e;
}

.countdown-value.red {
  background: var(--status-red-bg);
  color: #991b1b;
}

.category-card-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.category-action-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
}

.category-action-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   TABELAS E LISTAGENS
   ========================================================================== */

.table-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.table-header-bar {
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
}

.table-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.filter-select, .filter-input {
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  font-size: 0.85rem;
  color: var(--text-main);
  min-width: 150px;
}

.filter-select:focus, .filter-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.86rem;
}

.data-table th {
  background: #f8fafc;
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table tbody tr.row-danger {
  background: #fef2f2;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-icon-sm {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.btn-icon-sm:hover {
  background: #f1f5f9;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-icon-sm.btn-danger:hover {
  background: var(--status-red-bg);
  color: var(--status-red);
  border-color: var(--status-red);
}

/* Badges de Status */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-tag.em-dia {
  background: var(--status-green-bg);
  color: #065f46;
  border: 1px solid var(--status-green-border);
}

.status-tag.proximo {
  background: var(--status-yellow-bg);
  color: #92400e;
  border: 1px solid var(--status-yellow-border);
}

.status-tag.atrasada {
  background: var(--status-red-bg);
  color: #991b1b;
  border: 1px solid var(--status-red-border);
}

.status-tag.realizada {
  background: var(--status-blue-bg);
  color: #1e40af;
  border: 1px solid var(--status-blue-border);
}

.status-tag.sem-visita {
  background: var(--status-gray-bg);
  color: var(--status-gray);
  border: 1px solid var(--status-gray-border);
}

/* ==========================================================================
   FORMULÁRIOS & CHECKLISTS DE CAMPO (MÓDULO 7, 8, 9, 10)
   Botões grandes, touch targets ergonômicos
   ========================================================================== */

.form-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 2rem;
}

.form-card-header {
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-card-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.form-card-body {
  padding: 1.5rem;
}

.form-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--primary-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group.col-span-full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.form-label.required::after {
  content: "*";
  color: var(--status-red);
  font-weight: bold;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #ffffff;
  font-size: 0.92rem;
  color: var(--text-main);
  font-family: inherit;
  transition: all var(--transition-fast);
  min-height: 46px; /* Touch target ergonômico */
}

.form-textarea {
  min-height: 90px;
  resize: vertical;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Checklist Cards de Dengue e Escorpiões */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.checklist-card {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: background var(--transition-fast);
}

.checklist-card:hover {
  background: #ffffff;
  border-color: #cbd5e1;
}

.checklist-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checklist-switch {
  display: flex;
  align-items: center;
  background: #e2e8f0;
  padding: 3px;
  border-radius: var(--radius-full);
  gap: 2px;
}

.checklist-switch label {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  color: var(--text-muted);
}

.checklist-switch input[type="radio"] {
  display: none;
}

.checklist-switch input[type="radio"]:checked + label.opt-nao {
  background: #ffffff;
  color: #475569;
  box-shadow: var(--shadow-sm);
}

.checklist-switch input[type="radio"]:checked + label.opt-sim {
  background: var(--status-red);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.checklist-switch input[type="radio"]:checked + label.opt-sim-green {
  background: var(--status-green);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

/* Área de Fotos com Câmera e Galeria */
.photo-uploader-box {
  background: #f8fafc;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
  transition: border-color var(--transition-fast);
}

.photo-uploader-box:hover {
  border-color: var(--primary);
}

.photo-uploader-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin-top: 0.75rem;
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 48px;
}

.btn-camera {
  background: var(--secondary);
  color: #ffffff;
  border: none;
}

.btn-camera:hover {
  background: var(--secondary-dark);
}

.btn-gallery {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-gallery:hover {
  background: #f1f5f9;
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.photo-preview-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.photo-preview-img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  display: block;
}

.photo-watermark-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  font-size: 0.65rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.photo-preview-info {
  padding: 0.5rem;
}

.photo-preview-desc {
  width: 100%;
  font-size: 0.75rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.btn-remove-photo {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ef4444;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
}

/* Assinatura Digital com Canvas */
.signature-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.signature-canvas-wrapper {
  background: #fafafa;
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  touch-action: none; /* Crucial para desenhar em touch sem rolar a tela */
}

.signature-canvas {
  width: 100%;
  height: 180px;
  display: block;
  cursor: crosshair;
}

.signature-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--text-light);
  pointer-events: none;
}

.signature-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
}

/* Botões do Rodapé de Formulários */
.form-card-footer {
  padding: 1.25rem 1.5rem;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.85rem;
}

.btn-secondary {
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 46px;
}

.btn-secondary:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.btn-primary {
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #ffffff;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(13, 148, 136, 0.3);
  min-height: 46px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(13, 148, 136, 0.4);
}

/* ==========================================================================
   CRONOGRAMA (MÓDULO 5 E 6)
   Visualizações Diário, Semanal, Quinzenal, Mensal e Anual
   ========================================================================== */

.calendar-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.calendar-tabs-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
}

.calendar-tabs {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 4px;
}

.cal-tab-btn {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cal-tab-btn.active {
  background: #ffffff;
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.calendar-nav-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.calendar-month-title {
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 170px;
  text-align: center;
}

/* Grade do Calendário Mensal */
.calendar-grid-month {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-weekday {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.cal-day-cell {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  min-height: 95px;
  padding: 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.cal-day-cell:hover {
  background: #f8fafc;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.cal-day-cell.other-month {
  background: #f8fafc;
  opacity: 0.45;
}

.cal-day-cell.today {
  border: 2px solid var(--primary);
  background: #f0fdfa;
}

.cal-day-number {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.cal-day-events {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow: hidden;
}

.cal-event-pill {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.cal-event-pill.green { background: var(--status-green-bg); color: #065f46; border-left: 2px solid var(--status-green); }
.cal-event-pill.yellow { background: var(--status-yellow-bg); color: #92400e; border-left: 2px solid var(--status-yellow); }
.cal-event-pill.red { background: var(--status-red-bg); color: #991b1b; border-left: 2px solid var(--status-red); }
.cal-event-pill.blue { background: var(--status-blue-bg); color: #1e40af; border-left: 2px solid var(--status-blue); }

/* Calendário Anual com 12 Meses */
.calendar-annual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.annual-month-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.annual-month-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.annual-month-card.current-month {
  border: 2px solid var(--primary);
  background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 60px);
}

.annual-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #f1f5f9;
}

.annual-month-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.annual-month-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.annual-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.annual-stat-box {
  background: #f8fafc;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
}

.annual-stat-val {
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.1;
}

.annual-stat-lbl {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* ==========================================================================
   TIMELINE DO HISTÓRICO DO ESTABELECIMENTO
   ========================================================================== */

.timeline {
  position: relative;
  padding-left: 2rem;
  margin: 1.5rem 0;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 11px;
  width: 2px;
  background: #cbd5e1;
}

.timeline-item {
  position: relative;
  margin-bottom: 1.75rem;
}

.timeline-bullet {
  position: absolute;
  left: -2rem;
  top: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  z-index: 2;
}

.timeline-bullet.green { border-color: var(--status-green); color: var(--status-green); }
.timeline-bullet.red { border-color: var(--status-red); color: var(--status-red); }
.timeline-bullet.yellow { border-color: var(--status-yellow); color: var(--status-yellow); }
.timeline-bullet.blue { border-color: var(--status-blue); color: var(--status-blue); }

.timeline-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.timeline-date {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

/* ==========================================================================
   MODAIS E DRAWERS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-container {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 780px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.2s ease;
}

.modal-container.modal-lg {
  max-width: 1000px;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-modal:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ==========================================================================
   NAVEGAÇÃO INFERIOR PARA DISPOSITIVOS MÓVEIS (MOBILE BOTTOM NAV)
   ========================================================================== */

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
  justify-content: space-around;
  align-items: center;
  padding: 0 0.5rem;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  gap: 3px;
  flex: 1;
  height: 100%;
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast);
}

.mobile-nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.mobile-nav-item.active {
  color: var(--primary);
}

.mobile-nav-badge {
  position: absolute;
  top: 6px;
  right: 22%;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 800;
  border-radius: var(--radius-full);
  padding: 1px 5px;
}

/* Gaveta Lateral Mobile */
.mobile-drawer-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 90;
}

/* ==========================================================================
   GRÁFICOS E ESTATÍSTICAS
   ========================================================================== */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.chart-card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-container {
  width: 100%;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Barra de Progresso e Gráfico de Barras SVG/CSS */
.bar-chart-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.bar-label {
  width: 130px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  flex: 1;
  height: 22px;
  background: #f1f5f9;
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.5rem;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
}

.bar-fill.red { background: linear-gradient(90deg, #f87171 0%, #ef4444 100%); }
.bar-fill.yellow { background: linear-gradient(90deg, #fcd34d 0%, #f59e0b 100%); color: #78350f; }
.bar-fill.green { background: linear-gradient(90deg, #34d399 0%, #10b981 100%); }

/* ==========================================================================
   RESPONSIVIDADE E ADAPTAÇÃO PARA CAMPO (CELULAR E TABLET)
   ========================================================================== */

@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-drawer-overlay.open {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding-bottom: calc(var(--bottom-nav-height) + 1.5rem);
  }

  .btn-menu-mobile {
    display: flex;
  }

  .header-search {
    width: 200px;
  }

  .header-search input:focus {
    width: 220px;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .top-header {
    padding: 0 1rem;
  }

  .header-search {
    display: none; /* No mobile abrimos via modal ou usamos na aba de locais */
  }

  .btn-primary-action span.action-label {
    display: none;
  }

  .view-container {
    padding: 1rem;
  }

  .category-cards-grid {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .checklist-grid {
    grid-template-columns: 1fr;
  }

  .calendar-grid-month {
    gap: 3px;
  }

  .cal-day-cell {
    min-height: 70px;
    padding: 0.25rem;
  }

  .cal-event-pill {
    font-size: 0.6rem;
    padding: 1px 2px;
  }
}
