:root {
  --primary: #1a56db;
  --primary-light: #e8effd;
  --price-color: #1a56db;
  --sac-color: #059669;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #475569;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.07), 0 10px 15px rgba(0,0,0,0.05);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 1rem 1rem;
  background: linear-gradient(135deg, #1e3a8a, #1a56db);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header__content {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header__brand { text-align: left; }

.header__brand h1 { font-size: 1.75rem; margin-bottom: 0.1rem; }
.header__brand p { font-size: 0.9rem; opacity: 0.9; }

main {
  flex: 1;
  max-width: 1500px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 992px) {
  main { grid-template-columns: 1fr 1fr; align-items: start; }
}

.card-comparativo {
  grid-column: 1 / -1;
}

.grafico-wrapper--comparativo {
  height: 300px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.card:hover { box-shadow: var(--shadow-lg); }

.card-header {
  padding: 0.75rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.card-header__inner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
}

.card-header h2 { font-size: 1.25rem; font-weight: 800; }

.card-body { padding: 1.25rem; }

.campo { min-width: 0; }

.campo label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.campo input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s;
  outline: none;
}

.campo input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

.rate-row {
  display: flex;
  gap: 0.75rem;
}

.rate-row .campo { flex: 1; }

.btn-calcular {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-calcular:hover { background: #1e40af; }
.btn-calcular:active { transform: scale(0.98); }

.btn-escrever {
  padding: 0.5rem 1.25rem;
  border: 1.5px solid var(--sac-color);
  border-radius: 8px;
  background: transparent;
  color: var(--sac-color);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.04em;
}
.btn-escrever:hover {
  background: var(--sac-color);
  color: #fff;
}
.btn-escrever:active { transform: scale(0.98); }
.btn-escrever:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.resultado { margin-top: 1rem; }
.resultado[hidden] { display: none; }

.sticky-summary {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card-bg);
  padding: 1rem 0 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.sticky-summary[hidden] { display: none; }

.resumo {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.resumo-item {
  background: var(--bg);
  padding: 0.6rem 0.5rem;
  border-radius: 6px;
  text-align: center;
}

.resumo-item .rotulo {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.resumo-item .valor {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.resumo-item .valor.destaque { color: var(--primary); }

.grafico-wrapper {
  position: relative;
  height: 220px;
  margin-bottom: 0.75rem;
}

.tabela-wrapper {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 420px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  white-space: nowrap;
}

th, td {
  padding: 0.4rem 0.5rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
}

td:first-child, th:first-child { text-align: center; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f1f5f9; }

.acoes {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.btn-pdf, .btn-copiar {
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-pdf:hover, .btn-copiar:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

footer {
  margin-top: auto;
}

.footer {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #cbd5e1;
  padding: 3rem 1rem 0;
}

.footer__content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 768px) {
  .footer__content { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

.footer__logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.75rem;
}

.footer__logo i { font-size: 1.3rem; color: var(--primary); }
.footer__logo span span { color: #60a5fa; }

.footer__desc {
  font-size: 0.85rem;
  line-height: 1.6;
  max-width: 360px;
}

.footer__email {
  margin-top: -1rem;
  font-size: 0.85rem;
}

.footer__email a {
  color: #60a5fa;
  text-decoration: none;
  transition: color 0.2s;
}

.footer__email a:hover {
  color: #93bbfc;
  text-decoration: underline;
}

.footer h4 {
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.footer__info li {
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.footer__dev {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  text-align: right;
}

.footer__dev-logo {
  height: 70px;
  width: auto;
  border-radius: 8px;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.footer__dev-logo:hover { opacity: 1; }

.footer__afiliado {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.footer__info { text-align: center; }

.footer__info ul { list-style: none; padding: 0; margin: 0; display: inline-block; text-align: left; }

.footer__info li i {
  width: 1.1rem;
  color: var(--primary);
  margin-right: 0.3rem;
}

.footer__bottom {
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 2rem;
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: #64748b;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

@media (min-width: 768px) {
  .footer__bottom { flex-direction: row; justify-content: center; gap: 1.5rem; }
}

.banner-afiliado {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.banner-afiliado__texto {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
}

.fale-conosco_bnt {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  background: #ff7a30;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.fale-conosco_bnt:hover {
  background: #ff6a14;
  transform: scale(1.03);
  color: #fff;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 10px 24px; border-radius: 8px;
  font-size: 0.9rem; font-weight: 600; z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: opacity 0.3s; opacity: 1;
}
.toast--fade { opacity: 0; }

@media (max-width: 767px) {
  header { padding: 0.75rem 0.75rem; }
  .header__content {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    text-align: center;
  }
  .header__brand h1 { font-size: 1.3rem; }
  .header__brand p { text-align: center; }
  .banner-afiliado {
    justify-content: center;
    width: 100%;
  }
  .fale-conosco_bnt {
    justify-content: center;
    min-width: 0;
    line-height: 1.2;
  }
  .header__brand { text-align: center; width: 100%; }
  .card[data-cenario="sac"] .card-header__inner { flex-wrap: wrap; }
  .card[data-cenario="sac"] .card-header__inner .btn-escrever { order: 3; }
  .footer__content {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 1.75rem;
  }
  .footer__content > div {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .footer__logo {
    justify-content: center;
    text-align: center;
  }
  .footer__desc {
    max-width: 24rem;
    text-align: center;
  }
  .footer__email {
    margin-top: 0;
    text-align: center;
    overflow-wrap: anywhere;
  }
  .footer__info ul {
    display: block;
    width: 100%;
    text-align: center !important;
  }
  .footer__info li {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    text-align: center;
  }
  .footer__info li i {
    margin-right: 0;
  }
  .footer__dev {
    align-items: center;
    text-align: center;
  }
  .footer h4 {
    width: 100%;
    text-align: center;
  }
  .grafico-wrapper { height: 180px; }
  .resumo { grid-template-columns: 1fr 1fr; }
  .sticky-summary { grid-template-columns: 1fr; }
  .resumo-item .valor { font-size: 0.9rem; }
  table { font-size: 0.72rem; }
  th, td { padding: 0.3rem 0.4rem; }
}

@media (max-width: 400px) {
  .rate-row { flex-direction: column; gap: 0.5rem; }
  .resumo { grid-template-columns: 1fr; }
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: #fff; border-radius: var(--radius);
  padding: 2rem; width: 100%; max-width: 440px;
  position: relative; max-height: 90vh; overflow-y: auto;
}

.modal__close {
  position: absolute; top: 0.75rem; right: 1rem;
  background: none; border: none; font-size: 1.5rem;
  cursor: pointer; color: var(--text-secondary); line-height: 1;
}

.modal h3 { font-size: 1.25rem; margin-bottom: 0.25rem; }
.modal__sub { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 1.25rem; }

.modal form label {
  display: block; margin-bottom: 0.75rem;
  font-size: 0.8rem; font-weight: 600; color: var(--text-secondary);
}
.modal form input,
.modal form select,
.modal form textarea {
  display: block; width: 100%; margin-top: 0.25rem;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 0.95rem; font-family: var(--font); color: var(--text);
  outline: none; transition: border-color 0.2s;
}
.modal form input:focus,
.modal form select:focus,
.modal form textarea:focus { border-color: var(--primary); }

.modal__submit {
  width: 100%; padding: 0.65rem; margin-top: 0.5rem;
  border: none; border-radius: 8px;
  background: var(--primary); color: #fff;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: background 0.2s;
}
.modal__submit:hover { background: #1e40af; }
.modal__submit:disabled { opacity: 0.6; cursor: not-allowed; }
