:root {
  --krs-wine: #722F37;
  --krs-wine-dark: #521F25;
  --krs-wine-light: #94424B;
  --krs-wine-soft: rgba(114, 47, 55, 0.08);
  --krs-gold: #C59B27;
  --krs-gold-hover: #AF871F;
  --krs-gold-soft: rgba(197, 155, 39, 0.12);
  --primary: #722F37;
  --primary-hover: #521F25;
  --accent: #C59B27;
  --accent-light: rgba(197, 155, 39, 0.12);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1f2937;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --terminal-bg: #11141a;
  --radius: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 12px 24px -4px rgb(0 0 0 / 0.1), 0 4px 8px -4px rgb(0 0 0 / 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* NAVBAR */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.krs-navbar-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  display: block;
}

.portal-main-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f1f5f9;
  padding: 0.3rem 0.4rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.portal-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.portal-tab-btn:hover {
  color: var(--primary);
  background: rgba(114, 47, 55, 0.05);
}

.portal-tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(114, 47, 55, 0.15);
}

.tab-badge-gold {
  background: var(--krs-gold);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.logo-mark {
  background: linear-gradient(135deg, #0f2d59, #2563eb);
  color: #fff;
  font-weight: 800;
  font-size: 1.25rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  letter-spacing: 0.05em;
}

.brand-text h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--primary);
  line-height: 1.2;
}

.brand-text .subtitle {
  font-size: 0.775rem;
  color: var(--text-muted);
}

.domain-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 0.45rem 0.95rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e40af;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--success);
  display: inline-block;
  box-shadow: 0 0 8px var(--success);
}

/* CONTENT CONTAINER */
.content-container {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* CARDS */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.75rem;
}

/* HERO / CONTROLE DE EXTRAÇÃO */
.extraction-control-card {
  background: #ffffff;
  border-left: 5px solid var(--accent);
}

.extraction-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.extraction-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.01em;
}

.section-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.quick-dates {
  display: flex;
  gap: 0.4rem;
}

.btn-chip {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.btn-chip.small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.extract-inline-form {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding-top: 0.5rem;
}

.form-inputs-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.date-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  letter-spacing: 0.03em;
}

.date-field input[type="date"] {
  padding: 0.65rem 0.95rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 600;
  outline: none;
  background: #f8fafc;
  transition: all 0.15s ease;
}

.date-field input[type="date"]:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn-group {
  display: flex;
  gap: 0.75rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 0.75rem 1.4rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(15, 45, 89, 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.btn-primary.small {
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  padding: 0.75rem 1.15rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-secondary.small {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  text-decoration: none;
}

/* TERMINAL CONSOLE */
.console-wrapper {
  margin-top: 1.5rem;
  background: var(--terminal-bg);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #1e293b;
}

.console-top-bar {
  background: #111827;
  padding: 0.6rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1f2937;
}

.live-tag {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #e2e8f0;
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.3; }
  100% { opacity: 1; }
}

.console-body {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.825rem;
  color: #94a3b8;
  padding: 1rem;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.55;
}

.console-body .log-sucesso { color: #4ade80; font-weight: 600; }
.console-body .log-erro { color: #f87171; font-weight: 600; }
.console-body .log-info { color: #38bdf8; }

/* OVERVIEW BAR */
.overview-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.stats-pills {
  display: flex;
  gap: 0.75rem;
}

.stat-pill {
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.stat-num {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}

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

.global-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  min-width: 360px;
  box-shadow: var(--shadow-sm);
}

.global-search svg {
  color: var(--text-muted);
}

.global-search input {
  border: none;
  outline: none;
  font-size: 0.875rem;
  width: 100%;
  font-family: inherit;
}

/* SECTION SEGURADORAS */
.section-title-wrap {
  margin-bottom: 1.25rem;
}

.section-title-wrap h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.01em;
}

.section-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.insurers-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.insurer-block-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  position: relative;
}

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

.card-brand-bar {
  height: 5px;
  background-color: var(--brand-color, #2563eb);
}

.insurer-header {
  padding: 1.1rem 1.15rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.insurer-logo-box {
  width: 90px;
  height: 38px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.insurer-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.insurer-logo-fallback {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--brand-color, var(--primary));
  text-transform: uppercase;
}

.insurer-meta {
  overflow: hidden;
  flex: 1;
}

.insurer-card-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  margin-left: auto;
}

.btn-action-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.btn-action-icon:hover {
  background: #f8fafc;
  color: var(--text-main);
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.btn-test-conn:hover {
  color: #0284c7;
  border-color: #7dd3fc;
  background: #f0f9ff;
}

.btn-edit-config:hover {
  color: #4f46e5;
  border-color: #c7d2fe;
  background: #eef2ff;
}

.btn-action-icon.testing {
  animation: pulse 1s infinite alternate;
  color: #0284c7;
  border-color: #38bdf8;
  pointer-events: none;
}

.conn-status-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.5rem;
  transition: all 0.2s ease;
}

.conn-status-pill.online {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.conn-status-pill.offline {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.conn-status-pill.testing {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
}

.insurer-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insurer-user {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.insurer-stats {
  padding: 0.5rem 1.25rem;
}

.policy-badge {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: #334155;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
}

.policy-badge.has-policies {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #166534;
}

.insurer-card-actions {
  margin-top: auto;
  padding: 1rem 1.25rem;
  background: #fafbfc;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 0.5rem;
}

.btn-open-insurer {
  flex: 1;
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 0.55rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.btn-open-insurer:hover {
  background: var(--primary-hover);
}

.btn-quick-extract {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}

.btn-quick-extract:hover {
  background: #e2e8f0;
}

/* DRAWER (PAINEL LATERAL DE APÓLICES) */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.drawer-overlay.hidden {
  display: none;
  opacity: 0;
}

.insurer-drawer {
  background: #ffffff;
  width: 100%;
  max-width: 850px;
  height: 100%;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  animation: slideDrawer 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDrawer {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.drawer-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafbfc;
}

.drawer-title-group h3 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
}

.drawer-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-close-drawer, .btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
}

.btn-close-drawer:hover, .btn-close-modal:hover {
  color: var(--text-main);
}

.drawer-toolbar {
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  background: #ffffff;
}

.drawer-toolbar input {
  flex: 1;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  outline: none;
}

.drawer-toolbar input:focus {
  border-color: var(--accent);
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.75rem;
}

.drawer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.drawer-table th {
  background: #f8fafc;
  padding: 0.75rem 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.drawer-table td {
  padding: 0.85rem;
  border-bottom: 1px solid var(--border-light);
}

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

.empty-td {
  text-align: center;
  padding: 3rem 1rem !important;
  color: var(--text-muted);
}

/* BADGES DE TIPO */
.badge-tipo {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.725rem;
  font-weight: 700;
}

.badge-tipo.apolice { background: #dbeafe; color: #1e40af; }
.badge-tipo.endosso { background: #fef3c7; color: #92400e; }
.badge-tipo.cancelamento { background: #fee2e2; color: #991b1b; }

/* SITUAÇÃO DA APÓLICE (policy_status.py) */
.badge-situacao {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.725rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-situacao.vigente { background: #dcfce7; color: #166534; }
.badge-situacao.endossada { background: #fef3c7; color: #92400e; }
.badge-situacao.cancelada { background: #fee2e2; color: #991b1b; }
.badge-situacao.vencida { background: #e2e8f0; color: #475569; }

.table-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-action-view {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  font-size: 0.775rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-action-view:hover {
  background: #dbeafe;
}

.btn-action-download {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border);
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  font-size: 0.775rem;
  font-weight: 700;
  text-decoration: none;
}

.btn-action-download:hover {
  background: #e2e8f0;
}

/* MODAL DE VISUALIZAÇÃO DE PDF */
.pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdf-modal.hidden {
  display: none;
}

.pdf-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(3px);
}

.pdf-modal-container {
  position: relative;
  width: 90vw;
  max-width: 1100px;
  height: 90vh;
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  z-index: 10;
}

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

.pdf-modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 700px;
}

.pdf-modal-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pdf-modal-body {
  flex: 1;
  background: #525659;
}

.pdf-modal-body iframe {
  width: 100%;
  height: 100%;
}

/* FOOTER */
.footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.footer code {
  background: #f1f5f9;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: var(--primary);
  font-family: 'JetBrains Mono', monospace;
}

/* DRAWER LOGO */
.drawer-logo-container {
  width: 90px;
  height: 38px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  flex-shrink: 0;
}

.drawer-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.drawer-title-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* MODAL GERAL & CONFIGURAÇÃO */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
}

.modal-container {
  position: relative;
  width: 92vw;
  max-width: 520px;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.25);
  z-index: 10;
  overflow: hidden;
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-container.config-modal-dialog {
  max-width: 520px;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-logo-wrap {
  width: 80px;
  height: 36px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.modal-form {
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.form-group label {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-size: 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease;
  background: #ffffff;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.password-input-wrap, .url-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.btn-toggle-eye, .btn-icon-link {
  position: absolute;
  right: 0.6rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.btn-toggle-eye:hover, .btn-icon-link:hover {
  color: var(--text-main);
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.config-feedback {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 600;
  line-height: 1.4;
}

.config-feedback.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.config-feedback.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.config-feedback.info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  margin-top: 0.5rem;
  gap: 0.75rem;
}

.modal-footer-right {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* FLOATING TOAST NOTIFICATIONS */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  background: #0f172a;
  color: #ffffff;
  padding: 0.85rem 1.15rem;
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.3);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.toast-success { border-left: 4px solid #10b981; }
.toast.toast-error { border-left: 4px solid #ef4444; }
.toast.toast-info { border-left: 4px solid #38bdf8; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.hidden {
  display: none !important;
}

/* ==============================================================================
   NAVBAR USER CONTROLS & ADMIN BUTTONS
   ============================================================================== */
.navbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-pill-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-info-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.825rem;
  color: #e2e8f0;
}

.user-email-text {
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.user-role-badge.admin {
  background: #f59e0b;
  color: #78350f;
}

.btn-admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}

.btn-admin-badge:hover {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.5);
  color: #ffffff;
}

.btn-admin-badge:active {
  transform: translateY(0) scale(0.97);
}

.user-role-badge.operador {
  background: #3b82f6;
  color: #ffffff;
}

.btn-navbar-action, .btn-navbar-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-navbar-action {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-navbar-action:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.btn-navbar-logout {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-navbar-logout:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ffffff;
}

/* ==============================================================================
   VIEW MODE SWITCHER (POR SEGURADORA VS TODAS AS APÓLICES)
   ============================================================================== */
.view-switch-group {
  display: flex;
  background: #f1f5f9;
  padding: 0.25rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  gap: 0.25rem;
}

.btn-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-view-toggle:hover {
  color: var(--text-main);
}

.btn-view-toggle.active {
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ==============================================================================
   SEÇÃO: TODAS AS APÓLICES & FILTROS AVANÇADOS
   ============================================================================== */
.all-policies-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.filters-card {
  padding: 1.5rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

.filters-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-light);
}

.filters-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-main);
}

.filters-title-group h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.filter-count-badge {
  font-size: 0.825rem;
  font-weight: 700;
  background: #eff6ff;
  color: var(--accent);
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid #bfdbfe;
}

.filters-grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  align-items: flex-end;
}

.filter-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-col label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon svg {
  position: absolute;
  left: 0.75rem;
  color: #94a3b8;
  pointer-events: none;
}

.input-with-icon .form-control {
  padding-left: 2.2rem;
}

.form-control.uppercase {
  text-transform: uppercase;
}

.filter-actions-col {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.filter-actions-col .btn-secondary {
  flex: 1;
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
}

/* TABELA GERAL DE APÓLICES */
.table-card {
  padding: 0;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

.policies-master-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

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

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

.policies-master-table tr:hover td {
  background: #f8fafc;
}

.insurer-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.insurer-cell-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 4px;
}

.placa-badge {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  background: #0f172a;
  color: #ffffff;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
  border: 1px solid #334155;
}

.cpf-cell {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: #475569;
}

/* ==============================================================================
   DRAWER EXPANDIDO COM FILTROS DE PLACA, CPF E VIGÊNCIA
   ============================================================================== */
.drawer-toolbar-expanded {
  padding: 0.85rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.drawer-filters-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1.2fr;
  gap: 0.5rem;
}

.drawer-filters-row input {
  padding: 0.5rem 0.75rem;
  font-size: 0.825rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  background: #ffffff;
}

.drawer-filters-row input:focus {
  border-color: var(--accent);
}

.drawer-dates-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.drawer-date-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
}

.drawer-date-wrap input {
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
}

/* ==============================================================================
   MODAL ADMINISTRATIVO (GERENCIAMENTO DE UTILIZADORES)
   ============================================================================== */
.admin-modal-dialog {
  max-width: 680px;
}

.admin-modal-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.admin-card-section {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.admin-card-section h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 1rem 0;
}

.admin-inline-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

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

.form-group-admin label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
}

.admin-inline-form button {
  grid-column: span 2;
  margin-top: 0.5rem;
  justify-content: center;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.admin-table th {
  background: #f1f5f9;
  padding: 0.65rem 0.85rem;
  font-weight: 700;
  color: #475569;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.btn-edit-user, .btn-delete-user {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.775rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: 0.35rem;
  border: 1px solid transparent;
}

.btn-edit-user {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.btn-edit-user:hover {
  background: #dbeafe;
  color: #1e40af;
  border-color: #93c5fd;
  transform: translateY(-1px);
}

.btn-delete-user {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.btn-delete-user:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
  transform: translateY(-1px);
}

.btn-delete-user:disabled, .btn-edit-user:disabled {
  color: #cbd5e1;
  background: #f8fafc;
  border-color: #e2e8f0;
  cursor: not-allowed;
  transform: none;
}

.modal-icon-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #eff6ff;
  color: var(--accent);
  border: 1px solid #bfdbfe;
}

/* ==========================================================================
   DASHBOARD DE PRODUÇÃO & PRÊMIO LÍQUIDO (KRS SEGUROS)
   ========================================================================== */

.dash-hero-card {
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #ffffff 0%, #fffbf8 100%);
  border: 1px solid rgba(197, 155, 39, 0.25);
  border-left: 5px solid var(--krs-wine);
  box-shadow: var(--shadow-sm);
}

.dash-hero-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.dash-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--krs-wine);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--krs-wine-soft);
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  margin-bottom: 0.4rem;
}

.pulse-indicator-gold {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--krs-gold);
  box-shadow: 0 0 0 0 rgba(197, 155, 39, 0.7);
  animation: pulse-gold 2s infinite;
}

@keyframes pulse-gold {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(197, 155, 39, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(197, 155, 39, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(197, 155, 39, 0); }
}

.dash-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  max-width: 680px;
}

.dash-filters-bar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.dash-filter-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.dash-filter-item label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.dash-select {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text-main);
  font-size: 0.86rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dash-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(114, 47, 55, 0.15);
}

/* CARDS KPI DE PRODUÇÃO */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.kpi-card.highlight-card {
  border: 1px solid rgba(197, 155, 39, 0.4);
  background: linear-gradient(135deg, #ffffff 0%, #fffcf5 100%);
  box-shadow: 0 4px 14px rgba(197, 155, 39, 0.12);
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

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

.kpi-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon-wrap.wine {
  background: var(--krs-wine-soft);
  color: var(--krs-wine);
}

.kpi-icon-wrap.gold {
  background: var(--krs-gold-soft);
  color: var(--krs-gold);
}

.kpi-icon-wrap.green {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.kpi-icon-wrap.muted {
  background: #f1f5f9;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 0.6rem;
  font-family: 'JetBrains Mono', 'Inter', monospace;
}

.kpi-value.wine-text {
  color: var(--krs-wine);
}

.kpi-value.muted-text {
  color: #475569;
}

.kpi-value.green-text {
  color: var(--success);
}

.kpi-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-light);
}

.kpi-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.kpi-subtext strong {
  color: var(--text-main);
}

.kpi-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.kpi-pill.krs-badge {
  background: var(--krs-wine-soft);
  color: var(--krs-wine);
}

.kpi-pill.pill-wine {
  background: rgba(114, 47, 55, 0.12);
  color: var(--krs-wine);
}

.kpi-pill.pill-gold {
  background: var(--krs-gold-soft);
  color: var(--krs-gold);
}

.kpi-pill.pill-green {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}

.kpi-pill.pill-muted {
  background: #f1f5f9;
  color: var(--text-muted);
}

/* SEÇÃO 1: COMPARATIVO MENSAL */
.dash-chart-card {
  margin-bottom: 2rem;
  padding: 1.5rem;
}

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

.dash-card-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.chart-legend-custom {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.legend-badge {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.legend-sq {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.gold-sq {
  background: var(--krs-gold);
}

.wine-sq {
  background: var(--krs-wine);
}

.chart-wrapper {
  position: relative;
  width: 100%;
  min-height: 280px;
  margin-bottom: 1.5rem;
}

.monthly-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.dash-table th {
  background: #f8fafc;
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

.dash-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
}

.dash-table tbody tr:hover {
  background: #fcfdfe;
}

.td-val-pos {
  color: var(--success);
  font-weight: 600;
}

.td-val-neg {
  color: var(--danger);
  font-weight: 600;
}

.td-mono {
  font-family: 'JetBrains Mono', monospace;
}

/* SEÇÃO 2: PRODUÇÃO POR RAMO */
.dash-ramos-section {
  margin-bottom: 2rem;
}

.ramos-layout-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

@media (max-width: 992px) {
  .ramos-layout-grid {
    grid-template-columns: 1fr;
  }
}

.donut-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  text-align: center;
}

.card-subtitle-small {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 1rem;
}

.donut-chart-container {
  width: 240px;
  height: 240px;
  position: relative;
  margin: 0.5rem 0 1rem 0;
}

.donut-legend-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.donut-legend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  background: #f8fafc;
}

.donut-legend-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
}

.donut-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.donut-legend-val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

.ramos-cards-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.ramo-card {
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}

.ramo-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: rgba(114, 47, 55, 0.3);
}

.ramo-card-accent-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

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

.ramo-card-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.ramo-card-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
}

.ramo-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.ramo-card-pct {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: #f1f5f9;
}

.ramo-card-premio {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 0.6rem;
}

.ramo-card-metrics {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  padding-top: 0.6rem;
}

.ramo-card-metrics strong {
  color: var(--text-main);
}

/* SEÇÃO 3: PRODUÇÃO POR SEGURADORA */
.dash-insurers-card {
  margin-bottom: 2rem;
  padding: 1.5rem;
}

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

.dash-insurer-item {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  transition: all 0.2s ease;
}

.dash-insurer-item:hover {
  border-color: rgba(114, 47, 55, 0.3);
  box-shadow: var(--shadow);
}

.dash-insurer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-insurer-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.dash-insurer-logo-box {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
}

.dash-insurer-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.dash-insurer-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

.dash-insurer-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
}

.dash-insurer-premio {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
}

.dash-insurer-bar-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.dash-insurer-bar-track {
  width: 100%;
  height: 6px;
  background: #f1f5f9;
  border-radius: 9999px;
  overflow: hidden;
}

.dash-insurer-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--krs-wine) 0%, var(--krs-gold) 100%);
  border-radius: 9999px;
  transition: width 0.5s ease;
}

.dash-insurer-bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}


/* ==========================================================================
   MATRIZ COMPARATIVA MULTI-DIMENSIONAL (SEGURADORA x RAMO x MÊS A MÊS)
   ========================================================================== */
.dash-matriz-card {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

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

.matriz-ano-tabs {
  display: inline-flex;
  background: #f1f5f9;
  padding: 0.25rem;
  border-radius: var(--radius-md);
  gap: 0.25rem;
}

.btn-matriz-ano {
  border: none;
  background: transparent;
  padding: 0.35rem 0.9rem;
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-matriz-ano:hover {
  color: var(--krs-wine);
}

.btn-matriz-ano.active {
  background: var(--krs-wine);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(114, 47, 55, 0.25);
}

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

.matriz-views-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-matriz-view {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-matriz-view:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-matriz-view.active {
  background: var(--krs-wine);
  color: #ffffff;
  border-color: var(--krs-wine);
  box-shadow: 0 2px 5px rgba(114, 47, 55, 0.25);
}

.btn-matriz-view.active svg {
  stroke: #ffffff;
}

.matriz-actions-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Container do Gráfico da Matriz */
.matriz-chart-container {
  margin-top: 1.25rem;
  margin-bottom: 1.5rem;
  background: #fcfcfd;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1.2rem;
}

.matriz-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.matriz-chart-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--krs-wine);
}

.matriz-chart-legend {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.matriz-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.matriz-chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 240px;
}

/* Tabela Matriz */
.matriz-table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.matriz-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.815rem;
}

.matriz-table thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.725rem;
  letter-spacing: 0.03em;
  padding: 0.65rem 0.6rem;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  z-index: 10;
}

.matriz-table thead th.col-sticky-left {
  position: sticky;
  left: 0;
  z-index: 20;
  background: #f8fafc;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.04);
}

.matriz-table thead th.col-total {
  background: #faf5f5;
  color: var(--krs-wine);
}

.matriz-table tbody td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}

.matriz-table tbody td.col-sticky-left {
  position: sticky;
  left: 0;
  z-index: 5;
  background: #ffffff;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.04);
}

/* Linha Pai (Seguradora ou Ramo Principal) */
.matriz-row-parent {
  background: #ffffff;
  cursor: pointer;
  transition: background-color 0.15s ease;
  font-weight: 600;
}

.matriz-row-parent:hover {
  background: #fafafa;
}

.matriz-row-parent.expanded {
  background: #fbf8f8;
}

.matriz-row-parent td.col-sticky-left {
  background: inherit;
}

.matriz-parent-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.matriz-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: #94a3b8;
  transition: transform 0.2s ease;
}

.matriz-row-parent.expanded .matriz-chevron {
  transform: rotate(90deg);
  color: var(--krs-wine);
}

.matriz-logo-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  vertical-align: middle;
}

.matriz-ramo-icon-box {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.matriz-badge-share {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 9999px;
  background: #f1f5f9;
  color: var(--text-muted);
  font-weight: 600;
}

/* Sub-linhas (filhas) */
.matriz-row-child {
  background: #fafbfc;
  font-size: 0.775rem;
}

.matriz-row-child:hover {
  background: #f1f5f9;
}

.matriz-row-child.hidden {
  display: none;
}

.matriz-child-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding-left: 1.8rem;
  color: var(--text-main);
}

/* Valores monetários */
.matriz-val {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.785rem;
}

.matriz-val-zero {
  color: #cbd5e1;
  font-weight: 400;
}

.matriz-val-active {
  color: #1e293b;
  font-weight: 500;
}

.matriz-val-total {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--krs-wine);
  background: #faf5f5;
}

/* Linha de Totais no Rodapé */
.matriz-table tfoot tr {
  background: #722F37;
  color: #ffffff;
  font-weight: 700;
}

.matriz-table tfoot td {
  padding: 0.7rem 0.6rem;
  white-space: nowrap;
  border-top: 2px solid #571e25;
}

.matriz-table tfoot td.col-sticky-left {
  position: sticky;
  left: 0;
  z-index: 20;
  background: #722F37;
  color: #ffffff;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.15);
}

.matriz-tfoot-val {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.825rem;
  color: #ffffff;
}

.matriz-tfoot-val-gold {
  color: #fbbf24 !important;
  font-weight: 800;
}


/* ==============================================================================
   PAINEL DE 4 GRÁFICOS (AUTOMÓVEL, VIDA, RESIDENCIAL, EMPRESARIAL) & GRUPO PRX
   ============================================================================== */
.btn-back-hub {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  background: #F1F5F9;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid #CBD5E1;
  transition: all 0.2s ease;
}
.btn-back-hub svg {
  color: #AE333F;
  stroke-width: 2.8;
  transition: color 0.2s ease;
}
.btn-back-hub:hover {
  background: #AE333F;
  color: #FFFFFF;
  border-color: #AE333F;
  transform: translateX(-2px);
  box-shadow: 0 2px 6px rgba(174, 51, 63, 0.25);
}
.btn-back-hub:hover svg {
  color: #FFFFFF;
}

.dashboard-panel-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 4px 25px -5px rgba(0,0,0,0.05);
  margin-bottom: 2rem;
}

.dash-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #E2E8F0;
}

.dash-filter-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dash-filter-group label {
  font-size: 0.875rem;
  font-weight: 700;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.select-insurer-control {
  padding: 0.65rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #0F172A;
  background: #F8FAFC;
  border: 1.5px solid #CBD5E1;
  border-radius: 10px;
  outline: none;
  min-width: 290px;
  cursor: pointer;
  transition: all 0.2s;
}

.select-insurer-control:focus {
  border-color: #AE333F;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(174, 51, 63, 0.15);
}

.charts-4-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.75rem;
}

@media (max-width: 1024px) {
  .charts-4-grid {
    grid-template-columns: 1fr;
  }
}

.chart-box-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.2s;
}

.chart-box-card:hover {
  border-color: #CBD5E1;
  box-shadow: 0 6px 20px rgba(0,0,0,0.06);
}

.chart-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #F1F5F9;
  padding-bottom: 0.85rem;
}

.chart-box-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.chart-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-icon-badge.auto { background: #FDF2F3; color: #AE333F; }
.chart-icon-badge.vida { background: #F0F9FF; color: #0284C7; }
.chart-icon-badge.res { background: #ECFDF5; color: #16A34A; }
.chart-icon-badge.emp { background: #FFFBEB; color: #D97706; }

.chart-box-title-wrap h4 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #0F172A;
}

.chart-box-kpis {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chart-kpi-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
}

.chart-kpi-pill.ano-2026 {
  background: #F1F5F9;
  color: #0F172A;
}

.chart-kpi-pill.yoy-pos {
  background: #ECFDF5;
  color: #059669;
}

.chart-kpi-pill.yoy-neg {
  background: #FEF2F2;
  color: #DC2626;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 240px;
}

.chart-footer-totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #F8FAFC;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.8rem;
  border: 1px solid #F1F5F9;
}

.chart-footer-totals span strong {
  color: #0F172A;
}

/* TOOLBAR GLOBAL: GRÁFICOS / TABELAS */
.charts-view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  padding: 0 0.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.charts-toolbar-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1E293B;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.charts-global-switch {
  display: inline-flex;
  align-items: center;
  background: #FFFFFF;
  border-radius: 8px;
  padding: 3px;
  gap: 4px;
  border: 1px solid #E2E8F0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.btn-global-view {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748B;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-global-view:hover {
  color: #0F172A;
}

.btn-global-view.active {
  background: #0F172A;
  color: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  font-weight: 700;
}

/* CARD-LEVEL VIEW SWITCHER */
.card-view-switcher {
  display: inline-flex;
  align-items: center;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  margin-left: auto;
}

.btn-card-view {
  border: none;
  background: transparent;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748B;
  transition: all 0.15s ease;
  font-family: inherit;
  line-height: 1.2;
}

.btn-card-view:hover {
  color: #0F172A;
}

.btn-card-view.active {
  background: #FFFFFF;
  color: #0F172A;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  font-weight: 700;
}

/* TABLE WRAPPER & STYLES */
.chart-table-wrap {
  width: 100%;
  height: 240px;
  overflow-y: auto;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #E2E8F0;
  background: #FFFFFF;
  scrollbar-width: thin;
  scrollbar-color: #CBD5E1 #F8FAFC;
}

.chart-table-wrap::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.chart-table-wrap::-webkit-scrollbar-track {
  background: #F8FAFC;
}
.chart-table-wrap::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 3px;
}

.chart-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.775rem;
  font-family: inherit;
}

.chart-data-table thead th {
  position: sticky;
  top: 0;
  background: #F8FAFC;
  color: #475569;
  font-weight: 700;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid #E2E8F0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  z-index: 2;
  white-space: nowrap;
}

.chart-data-table tbody tr {
  border-bottom: 1px solid #F1F5F9;
  transition: background 0.1s ease;
}

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

.chart-data-table tbody td {
  padding: 0.35rem 0.65rem;
  color: #334155;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
}

.chart-data-table tbody td.mes-col {
  font-weight: 700;
  color: #0F172A;
}

.chart-data-table tfoot th,
.chart-data-table tfoot td {
  position: sticky;
  bottom: 0;
  background: #F1F5F9;
  font-weight: 800;
  color: #0F172A;
  padding: 0.45rem 0.65rem;
  border-top: 2px solid #CBD5E1;
  font-size: 0.76rem;
  z-index: 2;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.badge-var-pos {
  display: inline-block;
  background: #DCFCE7;
  color: #15803D;
  padding: 0.12rem 0.38rem;
  border-radius: 4px;
  font-size: 0.69rem;
  font-weight: 700;
}

.badge-var-neg {
  display: inline-block;
  background: #FEE2E2;
  color: #B91C1C;
  padding: 0.12rem 0.38rem;
  border-radius: 4px;
  font-size: 0.69rem;
  font-weight: 700;
}

.badge-var-zero {
  display: inline-block;
  background: #F1F5F9;
  color: #64748B;
  padding: 0.12rem 0.38rem;
  border-radius: 4px;
  font-size: 0.69rem;
  font-weight: 600;
}

.qtd-pill {
  color: #64748B;
  font-size: 0.72rem;
  font-weight: 500;
}

.table-loading-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #94A3B8;
  font-size: 0.8rem;
}
