:root {
  --bg-body: #090D16;
  --bg-card: #111726;
  --bg-card-hover: #161F33;
  --border-light: rgba(255, 255, 255, 0.08);
  --border-active: rgba(59, 130, 246, 0.4);

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  --color-pt: #EF4444;
  --color-psdb: #3B82F6;
  --color-missao: #8B5CF6;
  --color-outros: #64748B;

  --accent-blue: #3B82F6;
  --accent-green: #10B981;
  --accent-amber: #F59E0B;
  --accent-red: #EF4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-body);
  background-image: 
    radial-gradient(at 10% 0%, rgba(59, 130, 246, 0.1) 0px, transparent 40%),
    radial-gradient(at 90% 100%, rgba(16, 185, 129, 0.06) 0px, transparent 40%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.25rem 1.25rem 3.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Header */
.header-simple {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #34D399;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse 2s infinite;
}

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

.main-title {
  font-family: 'Outfit', sans-serif;
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.main-title span {
  background: linear-gradient(135deg, #60A5FA 0%, #38BDF8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.main-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.35rem;
  max-width: 600px;
}

/* Botão Atualizar */
.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93C5FD;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-refresh:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #60A5FA;
  color: #FFFFFF;
  transform: translateY(-1px);
}

.btn-refresh.loading .refresh-icon {
  display: inline-block;
  animation: spin 1s linear infinite;
}

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

/* Tabs */
.filter-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.75rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: rgba(59, 130, 246, 0.12);
  border-color: var(--border-active);
  color: #60A5FA;
  font-weight: 600;
}

/* Status Bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  gap: 1rem;
}

.status-left {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.status-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-green);
}

.status-bullet.loading {
  background-color: var(--accent-amber);
  animation: pulse 1s infinite;
}

.status-bullet.error {
  background-color: var(--accent-amber);
}

.status-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.auto-refresh-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #34D399;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 600;
  font-family: monospace;
}

/* Alert Box */
.alert-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: #FCD34D;
}

.alert-text {
  flex: 1;
}

.alert-close {
  background: transparent;
  border: none;
  color: #FCD34D;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.3rem;
}

/* Polls Grid */
.polls-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Poll Card */
.poll-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.5);
  transition: var(--transition);
}

.poll-card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.poll-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.85rem;
}

.poll-institute {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #FFFFFF;
}

.poll-tag {
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  margin-top: 0.25rem;
  display: inline-block;
}

.poll-meta {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.poll-badge-tse {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(59, 130, 246, 0.12);
  color: #93C5FD;
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
}

.poll-publish-highlight {
  margin-top: 0.4rem;
  font-size: 0.83rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  display: inline-block;
  font-weight: 500;
}

.poll-publish-highlight.today {
  color: #34D399;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.poll-publish-highlight.past {
  color: #FBBF24;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.poll-clarification-box {
  margin: 0.85rem 0 0.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.45;
}

.poll-clarification-box.today {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #6EE7B7;
}

.poll-clarification-box.warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: #FDE68A;
}

.poll-clarification-box.info {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: #BFDBFE;
}

.poll-source-box {
  margin-top: 0.85rem;
  padding: 0.55rem 0.8rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.poll-source-link {
  color: #60A5FA;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: var(--transition);
}

.poll-source-link:hover {
  color: #93C5FD;
}

.row-source-link td {
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: rgba(59, 130, 246, 0.05);
}

.row-publish-date {
  background: rgba(16, 185, 129, 0.08) !important;
  border-bottom: 2px solid rgba(16, 185, 129, 0.3);
}

.row-publish-date td {
  color: #F1F5F9;
  font-size: 0.88rem;
}

/* Candidate Progress Bar Rows */
.candidates-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.candidate-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.candidate-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
}

.candidate-name {
  font-weight: 600;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.candidate-party {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: normal;
}

/* Badges de Evolução / Comparativo */
.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

.trend-up {
  color: #34D399;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.trend-down {
  color: #F87171;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.trend-equal {
  color: #94A3B8;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.prev-val {
  font-weight: normal;
  opacity: 0.85;
  font-size: 0.7rem;
}

/* Caixa comparativa com a rodada anterior */
.prev-poll-comparison {
  margin-top: 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.09);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.prev-poll-header {
  color: #93C5FD;
  font-size: 0.82rem;
  margin-bottom: 0.2rem;
}

.prev-poll-text {
  color: var(--text-muted);
  line-height: 1.4;
  font-weight: normal;
}

.candidate-pct {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #60A5FA;
}

.bar-track {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-pt {
  background: linear-gradient(90deg, #DC2626, #EF4444);
}

.bar-psdb {
  background: linear-gradient(90deg, #2563EB, #38BDF8);
}

.bar-missao {
  background: linear-gradient(90deg, #7C3AED, #A855F7);
}

.bar-outros {
  background: linear-gradient(90deg, #475569, #64748B);
}

.poll-footer-info {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-light);
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Tabela Comparativa */
.comparativo-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.comparativo-table th, .comparativo-table td {
  border: 1px solid var(--border-light);
  padding: 0.75rem 1rem;
  text-align: left;
}

.comparativo-table th {
  background: rgba(255, 255, 255, 0.04);
  color: #FFFFFF;
  font-weight: 600;
}

.comparativo-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* AI Summary Card */
.ai-summary-card {
  background: rgba(17, 24, 38, 0.95);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 8px 30px -4px rgba(37, 99, 235, 0.25);
  margin-bottom: 1.75rem;
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
}

.ai-summary-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #3B82F6, #10B981, #60A5FA);
}

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

.ai-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  color: #93C5FD;
}

.ai-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.ai-content {
  font-size: 0.94rem;
  color: #CBD5E1;
  line-height: 1.7;
}

/* Fontes */
.sources-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}

.sources-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sources-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.sources-list li a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #60A5FA;
  text-decoration: none;
  font-size: 0.85rem;
  background: rgba(59, 130, 246, 0.08);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.sources-list li a:hover {
  background: rgba(59, 130, 246, 0.18);
  text-decoration: underline;
}

/* Footer Simples & Configuração */
.footer-simple {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.link-discrete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  transition: var(--transition);
}

.link-discrete:hover {
  color: var(--text-secondary);
}

.key-config-box {
  display: flex;
  gap: 0.5rem;
  max-width: 400px;
  width: 100%;
}

.key-config-box input {
  flex: 1;
  background: #0B0F19;
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  outline: none;
}

/* Painel de Redes Sociais */
.socials-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}

.social-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}

.social-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.social-card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #FFFFFF;
}

.social-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  flex: 1;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #93C5FD;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
}

.social-links a:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #FFFFFF;
}

.btn-reset-key {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-reset-key:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
}

/* Animação e Badges de Atualização da Tela Inicial */
@keyframes updatedPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(59, 130, 246, 0); }
  50% { transform: scale(1.015); box-shadow: 0 0 25px rgba(59, 130, 246, 0.45); border-color: #3b82f6; }
  100% { transform: scale(1); box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.5); }
}

.updated-pulse {
  animation: updatedPulse 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.badge-just-updated {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  margin-left: 0.35rem;
  animation: pulse 2s infinite;
}

/* Card de Apoio via PIX */
.pix-card {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(59, 130, 246, 0.08) 100%);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.4);
}

.pix-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 260px;
}

.pix-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.pix-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #FFFFFF;
}

.pix-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  line-height: 1.4;
}

.pix-action {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.pix-key-badge {
  background: #090D16;
  border: 1px solid var(--border-light);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
}

.pix-key-badge:hover {
  border-color: rgba(16, 185, 129, 0.4);
  background: #0D1322;
}

.pix-type {
  color: var(--text-muted);
}

.pix-val {
  color: #34D399;
  letter-spacing: 0.04em;
  font-family: monospace;
  font-size: 0.95rem;
}

.btn-copy-pix {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  color: #FFFFFF;
  border: none;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
  font-family: inherit;
}

.btn-copy-pix:hover {
  background: linear-gradient(135deg, #34D399 0%, #10B981 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-copy-pix.copied {
  background: #2563EB;
}

@media (max-width: 600px) {
  .app-container {
    padding: 1.5rem 1rem;
  }
  .main-title {
    font-size: 1.65rem;
  }
  .header-simple {
    flex-direction: column;
  }
  .btn-refresh {
    width: 100%;
    justify-content: center;
  }
  .poll-card {
    padding: 1.25rem;
  }
  .pix-card {
    flex-direction: column;
    align-items: stretch;
  }
  .pix-action {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-copy-pix {
    justify-content: center;
  }
}
