:root {
  --bg-0: #f2efe8;
  --bg-1: #fcfaf6;
  --ink: #1b2620;
  --ink-soft: #4e5f55;
  --line: #d1d8d1;
  --accent: #0b6e4f;
  --accent-2: #f29545;
  --danger: #ba3c3c;
  --warn: #c7871a;
  --ok: #2e7d32;
  --card: rgba(255, 255, 255, 0.86);
  --shadow: 0 10px 40px rgba(18, 38, 28, 0.15);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: radial-gradient(circle at 10% -5%, #f7d8bb, transparent 45%),
    radial-gradient(circle at 90% 10%, #bde4d5, transparent 40%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
  font-family: "IBM Plex Sans", sans-serif;
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  background-image: radial-gradient(#000 0.6px, transparent 0.6px);
  background-size: 4px 4px;
}

.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 24px;
}

h1,
h2,
h3 {
  font-family: "Sora", sans-serif;
  letter-spacing: -0.02em;
  margin: 0;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

.subcopy {
  margin: 12px 0;
  color: var(--ink-soft);
  max-width: 560px;
}

.hidden {
  display: none !important;
}

.card,
.glass {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
}

.auth-wrap {
  display: grid;
  gap: 24px;
}

.brand-card {
  padding: 24px;
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.chip {
  background: #edf6f2;
  color: #0d5c45;
  border: 1px solid #cde2da;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.form-block {
  padding: 18px;
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
}

input,
select,
textarea,
button {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font: inherit;
}

input,
select,
textarea {
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

button {
  background: linear-gradient(120deg, var(--accent), #18995c);
  color: #fff;
  border: none;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.68;
  cursor: not-allowed;
  transform: none;
}

.is-busy {
  position: relative;
  padding-left: 34px;
}

.is-busy::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  animation: spin 0.75s linear infinite;
}

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  background: #1f2823;
  color: #e8ffe8;
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  max-height: 280px;
}

.app-wrap {
  display: grid;
  gap: 16px;
}

.topbar {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill {
  background: #edf6f2;
  border: 1px solid #cce6db;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
}

.sidebar {
  padding: 10px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.nav-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  text-align: left;
}

.nav-btn.active {
  background: #eff7f2;
  border-color: #c6e1d4;
  color: #0d5c45;
}

.content {
  padding: 16px;
  overflow: hidden;
}

.status {
  min-height: 24px;
  margin-bottom: 8px;
  font-size: 13px;
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: var(--warn);
}

.status.err {
  color: var(--danger);
}

.tab {
  display: none;
}

.tab.active {
  display: block;
  animation: fadeIn 0.24s ease;
}

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

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar input {
  flex: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.form-grid textarea {
  grid-column: span 2;
}

.form-grid select[multiple] {
  min-height: 140px;
}

.filters-grid {
  background: #f8fbf9;
  border: 1px solid #dde9e2;
  border-radius: 12px;
  padding: 10px;
}

.filters-grid label {
  margin: 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.checkbox-label input {
  margin: 0;
}

.map-wrap {
  margin-bottom: 12px;
  border: 1px solid #dbe7df;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.map-toolbar {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid #ecf2ee;
  background: #f8fbf9;
}

.map-toolbar label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

#voter-map-wrap .map-toolbar select,
#influencer-map-wrap .map-toolbar select {
  min-width: 150px;
}

#influencer-map-wrap .map-toolbar input {
  width: 120px;
}

#voter-map {
  position: relative;
  width: 100%;
  height: 520px;
}

#regions-map {
  position: relative;
  width: 100%;
  height: 540px;
}

#influencer-map,
#dashboard-map {
  position: relative;
  width: 100%;
  height: 460px;
}

#voter-map-meta {
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid #ecf2ee;
}

#influencer-map-meta,
#dashboard-map-meta {
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid #ecf2ee;
}

#regions-map-meta {
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid #ecf2ee;
}

#show-voter-list.active-view,
#show-voter-map.active-view {
  background: #ecf7f1;
  border-color: #c7e3d6;
  color: #0c5a44;
}

#show-influencer-list.active-view,
#show-influencer-map.active-view {
  background: #ecf7f1;
  border-color: #c7e3d6;
  color: #0c5a44;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.metric {
  background: #f7faf8;
  border: 1px solid #d7e5de;
  border-radius: 12px;
  padding: 10px;
}

.metric p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.metric strong {
  display: block;
  font-size: 24px;
  margin-top: 4px;
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #dae4df;
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid #ebf0ec;
  text-align: left;
}

th {
  background: #f4f8f5;
  font-weight: 700;
}

tr:hover td {
  background: #f9fcfa;
}

.row-clickable {
  cursor: pointer;
}

.table-link-btn {
  border: 0;
  background: transparent;
  color: #0c5a44;
  text-decoration: underline;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

.bulk-voter-check {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.detail-panel {
  margin-top: 12px;
  border: 1px solid #d7e5de;
  border-radius: 12px;
  background: #fdfefd;
  padding: 12px;
}

.ai-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 2px;
}

.ai-loading-title {
  margin: 0 0 4px;
  font-weight: 700;
  color: #0d5c45;
}

.ai-spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #bfd7ca;
  border-top-color: #0d5c45;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.ai-answer-shell {
  display: grid;
  gap: 10px;
}

.ai-answer-head h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.ai-answer {
  display: grid;
  gap: 10px;
}

.ai-keyfacts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-keyfact {
  background: #e8f4ee;
  border: 1px solid #c8dfd3;
  color: #0c5a44;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
}

.ai-answer-section {
  border: 1px solid #d8e7df;
  background: #f7fcf9;
  border-radius: 10px;
  padding: 10px 12px;
}

.ai-section-title {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #2d6c54;
}

.ai-para {
  margin: 0 0 8px;
  color: var(--ink);
  line-height: 1.45;
}

.ai-para:last-child {
  margin-bottom: 0;
}

.ai-bullets {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  line-height: 1.45;
}

.ai-bullets li {
  margin: 6px 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.detail-head h3 {
  margin: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.detail-item {
  background: #f5f9f6;
  border: 1px solid #dce8e1;
  border-radius: 10px;
  padding: 8px;
}

.detail-item p {
  margin: 0 0 4px;
  font-size: 12px;
  color: #4f665b;
}

.detail-item strong {
  font-size: 13px;
}

.regions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.ra-card {
  border: 1px solid #d7e4dc;
  background: #fdfefd;
  border-radius: 12px;
  padding: 12px;
}

.progress {
  margin-top: 8px;
  height: 8px;
  background: #e8efeb;
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  height: 100%;
  display: block;
  background: linear-gradient(90deg, #1d8f62, #74c169);
}

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

  .sidebar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(0, auto);
  }

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

@media (max-width: 620px) {
  .shell {
    padding: 14px;
  }

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

  .form-grid,
  .form-grid textarea {
    grid-template-columns: 1fr;
    grid-column: span 1;
  }

  #voter-map {
    height: 380px;
  }

  #regions-map {
    height: 380px;
  }

  #influencer-map,
  #dashboard-map {
    height: 340px;
  }
}

/* Help / Ajuda */
.help-content {
  max-width: 980px;
}

.help-content h4 {
  margin-top: 14px;
  margin-bottom: 8px;
}

.help-content p {
  line-height: 1.45;
}

.help-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}

.help-toc a {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d7e5de;
  background: #f5f9f6;
  color: #0c5a44;
  font-weight: 700;
  text-decoration: none;
  font-size: 12px;
}

.help-toc a:hover {
  background: #eef6f1;
}

.help-content details {
  border: 1px solid #d7e5de;
  border-radius: 12px;
  background: #ffffff;
  padding: 10px 12px;
  margin: 10px 0;
}

.help-content summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
}

.help-content details > *:not(summary) {
  margin-top: 10px;
}
