/* ConverteEase — azul cartório + branco (papel timbrado / sistema institucional).
   Tipografia: Source Sans 3. */

:root {
  --primary: #1a3f63;
  --primary-dark: #102a45;
  --primary-mid: #2a5680;
  --primary-light: #5a8fc4;
  --primary-soft: #e8eff8;
  --danger: #b01728;
  --bg: #ffffff;
  --bg-soft: #f2f6fb;
  --text: #121a24;
  --muted: #4a5a6e;
  --line: #d8e2ef;
  --ok: #0d5c2e;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(16, 42, 69, 0.07);
  --shadow-card: 0 1px 0 rgba(16, 42, 69, 0.04), 0 8px 28px rgba(16, 42, 69, 0.08);
  --font: "Source Sans 3", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b1018;
  --bg-soft: #111923;
  --text: #f2f6fc;
  --muted: #95a3bd;
  --line: #243249;
  --ok: #7ee787;
  --primary-soft: #152032;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  background: var(--bg-soft);
  color: var(--text);
  line-height: 1.45;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -80px;
  background: var(--primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  z-index: 10;
}
.skip-link:focus {
  top: 12px;
}

.app-header {
  background: var(--primary);
  color: #fff;
  padding: 16px max(20px, env(safe-area-inset-left)) 16px max(20px, env(safe-area-inset-right));
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
}

.app-header__inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  row-gap: 12px;
}

@media (max-width: 640px) {
  .app-header {
    padding: 14px max(16px, env(safe-area-inset-left)) 18px max(16px, env(safe-area-inset-right));
  }

  .app-header__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 12px;
  }

  .brand {
    min-width: 0;
    align-items: center;
    gap: 10px;
    flex: 1;
  }

  .brand__text {
    min-width: 0;
    flex: 1;
  }

  .brand__kicker {
    font-size: 0.58rem;
    letter-spacing: 0.08em;
    line-height: 1.35;
    white-space: normal;
  }

  .brand__title {
    font-size: clamp(1.05rem, 5vw, 1.28rem);
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand__mark {
    width: 40px;
    height: 40px;
    font-size: 1.05rem;
    flex-shrink: 0;
  }

  .app-header__tools {
    flex-shrink: 0;
  }

  .icon-btn {
    flex-shrink: 0;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #fff;
  color: var(--primary);
  font-weight: 900;
  font-size: 1.25rem;
  display: grid;
  place-items: center;
}

.brand__kicker {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.9;
}

.brand__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.app-header__tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.12);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
.icon-btn:hover {
  background: rgba(0, 0, 0, 0.2);
}

.wrap {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.lede {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-wrap: pretty;
}

/* Justificação estável no mobile (Safari/WebKit costumam ignorar justify sem ajuda). */
@media (max-width: 640px) {
  .lede {
    text-align: justify;
    text-align-last: left;
    text-justify: inter-word;
    text-wrap: unset;
    hyphenate-limit-chars: auto 8 3;
  }

  .lede::after {
    content: "";
    display: inline-block;
    width: 100%;
    height: 0;
    line-height: 0;
    vertical-align: top;
  }
}

.boot-error {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #e8f0fa;
  color: var(--danger);
  border: 1px solid #b8cce8;
  font-weight: 600;
}

[data-theme="dark"] .boot-error {
  background: #1a2535;
  color: #f0b4b8;
  border-color: #4a6a8f;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.tabs__btn {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-weight: 700;
  padding: 12px 14px;
  border-radius: var(--radius);
  cursor: pointer;
}

.tabs__btn[aria-selected="true"] {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.grid2 {
  display: grid;
  gap: 16px;
}

@media (min-width: 860px) {
  .grid2 {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.card__title {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form__row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form__row--2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lbl {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.inp {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

.inp:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.inp--money {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.inp--num {
  font-variant-numeric: tabular-nums;
}

.inp--invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 1px rgba(176, 23, 40, 0.28);
}

.chk {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  font-size: 0.9rem;
  cursor: pointer;
}

.chk.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.chk input {
  margin-top: 3px;
  accent-color: var(--primary);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
}

.btn--primary {
  background: var(--primary);
  color: #fff;
}
.btn--primary:hover {
  background: var(--primary-dark);
}

.btn--outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn--outline:hover {
  background: rgba(26, 63, 99, 0.08);
}

.btn--sm {
  padding: 10px 12px;
  font-size: 0.88rem;
  border-radius: 9px;
}

.btn--ghost {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn--ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.btn--panel {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
}
.btn--panel:hover {
  opacity: 0.92;
}

[data-theme="dark"] .btn--panel {
  background: #e8eff8;
  color: #0b1018;
}

.export-bar {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.fine {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.out {
  min-height: 120px;
}

.kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

@media (max-width: 520px) {
  .kpi-row {
    grid-template-columns: 1fr;
  }
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--bg-soft);
}

.kpi--liquido {
  border-color: rgba(13, 92, 46, 0.25);
}

.kpi__eyebrow {
  margin: 0 0 4px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi__label {
  margin: 0 0 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.kpi__value {
  margin: 0;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  font-weight: 800;
}

.kpi--liquido .kpi__value {
  color: var(--ok);
}

.kpi--bruto .kpi__value {
  color: var(--primary);
}

.kpi__meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.35;
}

.breakdown {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.breakdown__head {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-soft);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.breakdown__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

.breakdown__row--strong {
  font-weight: 800;
  background: rgba(26, 63, 99, 0.07);
}

.breakdown__desc {
  color: var(--text);
}

.breakdown__sub {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 4px;
}

.breakdown__amt {
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.breakdown__amt--neg {
  color: var(--primary);
}

.breakdown__amt--note {
  color: var(--muted);
  font-weight: 600;
}

.callout {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  font-size: 0.82rem;
  color: var(--muted);
}

.callout--alert {
  border-color: #c5d6eb;
  background: #f0f5fc;
  color: var(--primary-dark);
  font-weight: 700;
}

[data-theme="dark"] .callout--alert {
  background: #1a2535;
  color: #dbe7fa;
  border-color: #334b6d;
}

.callout--list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ——— Bloco de gráficos / exportação (no fluxo da página, sem overlay) ——— */
.dash-inline {
  margin-top: 20px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: dashFade 0.2s ease-out;
}

/* [hidden] precisa ganhar do display:flex (senão “Recolher” não esconde o bloco). */
.dash-inline[hidden] {
  display: none !important;
}

@keyframes dashFade {
  from {
    opacity: 0.75;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dash-inline__top {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  background: linear-gradient(180deg, var(--primary-soft) 0%, transparent 100%);
  border-bottom: 1px solid var(--line);
}

.dash-inline__kicker {
  margin: 0 0 4px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
}

.dash-inline__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.dash-inline__close {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.dash-inline__close:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.dash-inline__body {
  flex-shrink: 0;
  padding: 16px 20px 20px;
}

.dash-inline__actions {
  flex-shrink: 0;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}

.dash-inline__actions-label {
  margin: 0 0 10px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.dash-export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (min-width: 380px) {
  .dash-export-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.dash-hero {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-soft) 100%);
}

@media (min-width: 400px) {
  .dash-hero {
    grid-template-columns: 1.4fr 1fr;
    align-items: start;
  }
}

.dash-hero--alert {
  border-color: #c5d6eb;
  background: #f0f5fc;
}

[data-theme="dark"] .dash-hero--alert {
  background: #1a2535;
  border-color: #334b6d;
}

.dash-hero__eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.dash-hero__value {
  margin: 0;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--ok);
  line-height: 1.15;
}

.dash-hero__value--sm {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.dash-hero--alert .dash-hero__value {
  color: var(--primary-dark);
}

.dash-hero__sub {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.35;
}

.dash-hero__side {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-hero__mini {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
}
.dash-hero__mini span {
  display: block;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.62rem;
  margin-bottom: 4px;
}
.dash-hero__mini strong {
  display: block;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  color: var(--text);
}

.dash-chart {
  margin: 0 0 18px;
}

.dash-chart__cap {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.stack-bar {
  display: flex;
  width: 100%;
  height: 20px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.stack-bar__seg {
  display: block;
  min-width: 3px;
  transition: width 0.35s ease;
}

.stack-bar__seg--base {
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
}
.stack-bar__seg--he50 {
  background: linear-gradient(90deg, var(--primary), var(--primary-mid));
}
.stack-bar__seg--he100 {
  background: linear-gradient(90deg, var(--primary-mid), var(--primary-light));
}
.stack-bar__seg--adic {
  background: linear-gradient(90deg, #4a5568, #6b7280);
}
.stack-bar__seg--inss {
  background: linear-gradient(90deg, #b45309, #d97706);
}
.stack-bar__seg--ir {
  background: linear-gradient(90deg, #0d2844, #1a4a7a);
}

.dash-legend {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.dash-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-legend__sw {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.dash-legend__sw.stack-bar__seg--base {
  background: var(--primary);
}
.dash-legend__sw.stack-bar__seg--he50 {
  background: var(--primary-mid);
}
.dash-legend__sw.stack-bar__seg--he100 {
  background: var(--primary-light);
}
.dash-legend__sw.stack-bar__seg--adic {
  background: #6b7280;
}
.dash-legend__sw.stack-bar__seg--inss {
  background: #d97706;
}
.dash-legend__sw.stack-bar__seg--ir {
  background: #1a4a7a;
}

.dash-muted {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.dash-table {
  margin-top: 4px;
}

.dash-footnote {
  margin: 12px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.dash-notes {
  margin: 14px 0 0;
  padding-left: 18px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.dash-inline .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ——— Rodapé ——— */
.app-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding: 0 16px 32px;
  background: var(--bg-soft);
}

.app-footer__inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 4px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-top: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

[data-theme="dark"] .app-footer__inner {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.app-footer__accent {
  height: 4px;
  background: linear-gradient(90deg, var(--primary-dark) 0%, var(--primary) 40%, var(--primary-light) 100%);
}

.app-footer__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding: 20px 22px 14px;
}

.app-footer__identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.app-footer__mark {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  line-height: 1;
}

.app-footer__text {
  min-width: 0;
}

.app-footer__name {
  margin: 0 0 2px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.app-footer__tagline {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.app-footer__copy {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.app-footer__legal {
  margin: 0;
  padding: 0 22px 18px;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}

[data-theme="dark"] .app-footer__legal {
  background: rgba(0, 0, 0, 0.2);
}

@media (max-width: 560px) {
  .app-footer {
    padding: 0 12px 24px;
  }

  .app-footer__row {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 16px 12px;
  }

  .app-footer__copy {
    white-space: normal;
    width: 100%;
  }

  .app-footer__legal {
    padding: 12px 16px 16px;
  }
}
