:root {
  --bg: #f5f9fd;
  --surface: #ffffff;
  --surface-soft: #edf6ff;
  --line: #dbe6f1;
  --text: #1f2937;
  --muted: #51627a;
  --primary: #3f93ec;
  --primary-dark: #2f7bd0;
  --accent: #60a9eb;
  --success: #0f8a3b;
  --danger: #bf1d1d;
  --shadow: 0 18px 45px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.site-top {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: #fbfdff;
  border-bottom: 1px solid var(--line);
}

.site-top a {
  display: inline-flex;
  align-items: center;
  min-height: 45px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(63, 147, 236, 0.28);
  font-weight: 700;
  text-decoration: none;
}

.site-top a:hover {
  background: var(--primary-dark);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
  padding: 44px 48px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1;
  color: #fff;
}

.intro {
  max-width: 720px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.55;
}

.calculator-flow {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.panel,
.rate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
  min-width: 0;
}

.rate-card {
  padding: 18px;
}

.rate-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 1.28rem;
}

.panel-heading p,
.rate-card label {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.with-space {
  margin-top: 28px;
}

.field-grid {
  display: grid;
  gap: 16px;
}

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

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 8px;
}

.field > span:first-child,
.subpanel h3,
.details-grid h3 {
  color: #344258;
  font-size: 0.93rem;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input#dolar {
    height: 44px;
}

.money-field input,
.percent-field input {
  outline: none;
}

.field input:focus,
.money-field input:focus,
.percent-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96, 169, 235, 0.18);
}

.money-field,
.percent-field {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
}

.percent-field {
  grid-template-columns: minmax(0, 1fr) 42px;
}

.money-field > span,
.percent-field > span {
  display: grid;
  place-items: center;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

.money-field > span {
  border-radius: 5px 0 0 5px;
  border-right: 0;
}

.percent-field > span {
  border-radius: 0 5px 5px 0;
  border-left: 0;
}

.money-field input {
  border-radius: 0 5px 5px 0;
  border-left: 0;
}

.percent-field input {
  border-radius: 5px 0 0 5px;
  text-align: right;
  border-right: 0;
}

.compact {
  margin-top: 10px;
}

.rate-card .money-field > span {
  background: #f0f7ff;
  border-color: #cfe0f2;
}

.rate-card .money-field input {
  border-color: #cfe0f2;
}

.subpanel {
  margin-top: 20px;
  padding: 18px;
  background: #f2f7fc;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.subpanel h3 {
  margin-bottom: 16px;
}

.featured-field {
  margin-top: 18px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.tax-options {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.tax-option {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}

.tax-option input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--primary);
}

.tax-option strong,
.tax-option small {
  display: block;
}

.tax-option small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

.actions button {
  min-width: 110px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.actions .primary-action {
  min-width: 190px;
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.actions .primary-action:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.actions button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.result-panel {
  scroll-margin-top: 18px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

.summary-card.highlight {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.summary-card span,
.summary-card small,
.summary-card strong {
  display: block;
}

.summary-card span {
  font-size: 0.88rem;
  font-weight: 700;
}

.summary-card strong {
  margin: 8px 0 4px;
  font-size: 1.35rem;
}

.summary-card small {
  color: var(--muted);
}

.summary-card.highlight small {
  color: rgba(255, 255, 255, 0.82);
}

.comparison-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}

.table-hint {
  display: none;
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
  color: var(--muted);
  font-size: 0.86rem;
}

.comparison-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  background: #fff;
}

.comparison-table th,
.comparison-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.comparison-table th:first-child,
.comparison-table td:first-child {
  text-align: left;
}

.comparison-table th {
  background: var(--surface-soft);
  color: #344258;
  font-size: 0.86rem;
}

.comparison-table tr:last-child td {
  border-bottom: 0;
}

.comparison-table .total-row td {
  background: #dceeff;
  color: var(--text);
  font-weight: 700;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.details-grid article,
.note {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 16px;
}

.details-grid h3 {
  margin-bottom: 14px;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
}

.detail-row dt,
.detail-row dd {
  margin: 0;
}

.detail-row dd {
  color: var(--text);
  font-weight: 700;
  text-align: right;
}

.note {
  margin-top: 18px;
  background: #f8fbff;
  color: var(--muted);
  line-height: 1.45;
}

.note strong {
  color: var(--text);
}

.note p {
  margin: 8px 0 0;
}

.note p + p {
  margin-top: 12px;
}

.tax-reference {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.tax-reference h2 {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 1.55rem;
}

.tax-reference p {
  max-width: 820px;
  color: var(--muted);
  line-height: 1.5;
}

.reference-table-wrap {
  margin-top: 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.reference-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.reference-table th,
.reference-table td {
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.reference-table th {
  background: #fff;
  color: var(--text);
  font-size: 1rem;
}

.reference-table tr:last-child td {
  border-bottom: 0;
}

.positive {
  color: var(--success);
}

.negative {
  color: var(--danger);
}

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

  .table-hint {
    display: block;
  }
}

@media (max-width: 720px) {
  .site-top {
    padding: 10px;
  }

  .site-top a {
    justify-content: center;
    width: 100%;
    max-width: 360px;
    min-height: 42px;
    padding: 0 14px;
    text-align: center;
    font-size: 0.92rem;
  }

  .app-shell {
    width: min(100% - 16px, 1180px);
    padding-top: 12px;
    padding-bottom: 28px;
  }

  .hero {
    gap: 18px;
    padding: 28px 18px;
    border-radius: 14px;
  }

  .intro {
    font-size: 0.95rem;
  }

  .rate-card {
    padding: 14px;
  }

  .panel {
    padding: 16px;
    border-radius: 14px;
  }

  .panel-heading h2 {
    font-size: 1.12rem;
  }

  .panel-heading p,
  .rate-card label {
    font-size: 0.9rem;
  }

  .subpanel {
    padding: 14px;
  }

  .featured-field {
    padding: 14px;
  }

  .actions {
    flex-direction: column;
  }

  .actions button,
  .actions .primary-action {
    width: 100%;
  }

  .field-grid.two,
  .field-grid.three,
  .summary-cards,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .summary-card {
    padding: 14px;
    text-align: left;
  }

  .summary-card strong {
    font-size: 1.22rem;
  }

  .table-hint {
    display: none;
  }

  .comparison-table-wrap {
    overflow-x: visible;
    border: 0;
    border-radius: 0;
  }

  .comparison-table {
    display: block;
    width: 100%;
    min-width: 0;
    background: transparent;
  }

  .comparison-table thead {
    display: none;
  }

  .comparison-table tbody {
    display: grid;
    gap: 12px;
    width: 100%;
  }

  .comparison-table tr {
    display: grid;
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
  }

  .comparison-table th,
  .comparison-table td {
    white-space: normal;
  }

  .comparison-table td {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    min-width: 0;
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }

  .comparison-table td:first-child {
    display: block;
    padding: 13px 12px;
    background: var(--surface-soft);
    color: var(--text);
    font-weight: 700;
    text-align: left;
  }

  .comparison-table td:not(:first-child)::before {
    content: attr(data-label);
    flex: 1;
    color: var(--muted);
    font-weight: 700;
    text-align: left;
  }

  .comparison-table .total-row td {
    background: #fff;
    color: var(--text);
  }

  .comparison-table .total-row td:first-child {
    background: #dceeff;
  }

  .comparison-table tr:last-child td {
    border-bottom: 1px solid var(--line);
  }

  .comparison-table tr td:last-child {
    border-bottom: 0;
  }

  .reference-table-wrap {
    overflow-x: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .reference-table {
    display: block;
    min-width: 0;
    background: transparent;
  }

  .reference-table thead {
    display: none;
  }

  .reference-table tbody {
    display: grid;
    gap: 12px;
  }

  .reference-table tr {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
  }

  .reference-table td {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }

  .reference-table td::before {
    flex: 1;
    color: var(--muted);
    font-weight: 700;
  }

  .reference-table td:nth-child(1)::before {
    content: "Faixa";
  }

  .reference-table td:nth-child(2)::before {
    content: "Alíquota";
  }

  .reference-table td:nth-child(3)::before {
    content: "Dedução";
  }

  .reference-table td:last-child {
    border-bottom: 0;
  }

  .detail-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .detail-row dd {
    max-width: 100%;
    text-align: left;
  }

  h1 {
    font-size: 2.1rem;
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: 100%;
    padding-left: 8px;
    padding-right: 8px;
  }

  .hero {
    border-radius: 0;
    margin-left: -8px;
    margin-right: -8px;
  }

  h1 {
    font-size: 1.85rem;
  }

  .field input,
  .money-field > span,
  .percent-field > span {
    height: 42px;
  }

  .money-field {
    grid-template-columns: 46px minmax(0, 1fr);
  }
}
