@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

:root {
  --ink: #0d1b3d;
  --muted: #475569;
  --line: #dbe3ef;
  --surface: #ffffff;
  --soft: #f4f7fb;
  --brand: #2563eb;
  --brand-2: #10b9b1;
  --earning: #0f766e;
  --earning-soft: #e6f5f2;
  --deduction: #b94b2c;
  --deduction-soft: #fff0eb;
  --base: #2563a6;
  --base-soft: #eaf2fb;
  --tax: #7a5010;
  --tax-soft: #fff6df;
  --net: #172554;
  --danger: #b42318;
  --focus: #83a2ff;
  font-family: "Poppins", "Segoe UI", "Source Sans 3", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f7f9fd 0%, #eef3f9 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--brand);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 48px;
  height: 48px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 4px;
  font-size: 17px;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

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

.rule-pill,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.primary-button,
.secondary-button,
.ghost-button,
.explain-button {
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 8px 13px;
  font-weight: 750;
  cursor: pointer;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
}

.secondary-button {
  background: var(--ink);
  color: white;
}

.ghost-button {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.explain-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.explain-button.active {
  background: #ecfdf5;
  border-color: #8ed8bf;
  color: #075e54;
}

.explain-button.inactive {
  background: #f8fafc;
  border-color: var(--line);
  color: var(--muted);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.16);
}

.explain-button.inactive .status-dot {
  background: #94a3b8;
  box-shadow: none;
}

.full {
  width: 100%;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 18px;
  padding: 18px;
}

.step-input .workspace {
  grid-template-columns: 1fr;
}

.step-input .result-panel,
.step-input .learning-panel {
  display: none;
}

.step-result .input-panel {
  display: none;
}

.input-panel,
.result-panel,
.learning-panel {
  min-width: 0;
}

.input-panel {
  display: grid;
  grid-column: 1;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 12px;
  align-items: start;
}

.input-panel .compact {
  grid-column: 1 / -1;
}

.result-panel {
  grid-column: 1;
}

.learning-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.panel-section,
.result-panel,
.learning-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(20, 39, 70, 0.05);
}

.panel-section,
.learning-card {
  padding: 16px;
  margin-bottom: 0;
}

.compact {
  padding-bottom: 18px;
}

.section-heading {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.section-heading p,
.learning-card p,
.hint-box,
.microcopy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.step {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #edf2ff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: #3d4b5f;
  font-size: 12px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: white;
  color: var(--ink);
}

.switch-row,
.incidence-grid {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.switch,
.incidence-grid label {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.switch input,
.incidence-grid input {
  width: auto;
  min-height: auto;
}

.picker-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: end;
}

.quantity-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 8px;
  height: 38px;
}

.quantity-input-group input {
  width: 60px;
  border: 0;
  padding: 0;
  height: 100%;
  text-align: center;
}

.quantity-input-group span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.hint-box {
  margin-top: 10px;
  padding: 10px;
  border-radius: 7px;
  background: var(--soft);
}

.event-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  margin-bottom: 12px;
}

.event-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
}

.event-item strong {
  display: block;
  font-size: 13px;
}

.event-item span {
  color: var(--muted);
  font-size: 12px;
}

.event-item button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--danger);
  cursor: pointer;
}

.validation-box {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #ffd2cc;
  border-radius: 7px;
  background: #fff4f2;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  white-space: pre-line;
}

.result-panel {
  padding: 18px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.result-actions,
.next-action-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.calculation-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.calculation-flow article {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 9px;
  row-gap: 2px;
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.calculation-flow span {
  display: inline-grid;
  place-items: center;
  grid-row: 1 / 3;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #edf2ff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 850;
}

.calculation-flow strong {
  font-size: 14px;
}

.calculation-flow p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.kpi {
  display: grid;
  gap: 7px;
  min-height: 92px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kpi span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.kpi strong {
  font-size: clamp(17px, 1.6vw, 24px);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.earning {
  background: var(--earning-soft);
  color: var(--earning);
}

.deduction {
  background: var(--deduction-soft);
  color: var(--deduction);
}

.tax {
  background: var(--tax-soft);
  color: var(--tax);
}

.base {
  background: var(--base-soft);
  color: var(--base);
}

.net {
  background: #eaf0ff;
  color: var(--net);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.tab.active {
  border-color: var(--brand);
  color: var(--ink);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td.money {
  font-weight: 800;
  white-space: nowrap;
}

.why-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--brand);
  font-weight: 800;
  cursor: pointer;
}

.base-cards,
.comparison-grid,
.used-table-grid,
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.base-cards article,
.comparison-card,
.memory-block,
.used-tables,
.scenario-section,
.scenario-card,
.used-table-grid article,
.reduction-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.scenario-section {
  margin-top: 12px;
  background: white;
}

.scenario-grid {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
}

.scenario-card {
  display: grid;
  gap: 10px;
  width: 100%;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}

.scenario-card.selected {
  border-color: #d3a41c;
  background: #fffaf0;
  box-shadow: inset 4px 0 0 var(--tax);
}

.scenario-card strong {
  display: block;
  font-size: 20px;
}

.scenario-card span,
.scenario-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.scenario-card .scenario-badge {
  display: inline-flex;
  width: max-content;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--tax-soft);
  color: var(--tax);
  font-size: 12px;
  font-weight: 850;
}

.base-cards span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.base-cards strong {
  display: block;
  margin: 6px 0;
  font-size: 20px;
}

.base-cards p,
.memory-block p,
.comparison-card p,
.comparison-details,
.used-tables p,
.reduction-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.48;
}

.used-tables {
  margin-top: 12px;
  background: white;
}

.next-actions {
  margin-top: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.used-table-grid {
  grid-template-columns: 1fr 1fr;
}

.table-heading {
  margin-bottom: 12px;
}

.compact-table {
  max-width: 100%;
}

.compact-table table {
  min-width: 520px;
}

.used-row {
  background: #fff8df;
  box-shadow: inset 4px 0 0 var(--tax);
}

.used-row td:first-child {
  font-weight: 850;
  color: var(--tax);
}

.reduction-card {
  margin-top: 10px;
}

.reduction-card strong {
  color: var(--tax);
}

.memory-stack {
  display: grid;
  gap: 10px;
}

.memory-block h3 {
  margin-bottom: 8px;
}

.memory-block ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.learning-panel {
  position: sticky;
  top: 84px;
  align-self: start;
}

.learning-card ol,
.reference-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.reference-list li {
  margin-bottom: 7px;
}

.comparison-details {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--soft);
}

.hide-explanations .learning-panel,
.hide-explanations .why-button {
  display: none;
}

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

  .input-panel,
  .result-panel {
    grid-column: 1;
  }

  .input-panel {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }

  .learning-panel {
    grid-column: 1 / -1;
    grid-row: auto;
    position: static;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .learning-card {
    margin-bottom: 0;
  }

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

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

@media (max-width: 820px) {
  .topbar,
  .result-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace,
  .learning-panel {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .input-panel {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .base-cards,
  .comparison-grid,
  .used-table-grid,
  .scenario-grid,
  .kpi-grid,
  .calculation-flow {
    grid-template-columns: 1fr;
  }

  .picker-row {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #ffffff !important;
    color: #111827 !important;
  }
  .input-panel, 
  .learning-panel, 
  .topbar, 
  .next-actions, 
  .result-actions, 
  #explainToggle, 
  .ambient-glow, 
  .ambient-glow-right,
  .brand,
  .ghost-button,
  .primary-button {
    display: none !important;
  }
  .app-shell, 
  .workspace {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .result-panel {
    width: 100% !important;
    max-width: 100% !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .tab-panel {
    display: block !important;
    opacity: 1 !important;
  }
  .tabs {
    display: none !important;
  }
  /* Forçar a impressão limpa de tabelas e memórias */
  #tab-payslip, #tab-memory, #tab-details, #tab-compare {
    display: block !important;
    page-break-inside: avoid;
    margin-bottom: 30px;
  }
  .table-wrap {
    overflow: visible !important;
  }
  table {
    border-collapse: collapse !important;
    width: 100% !important;
  }
  th, td {
    border: 1px solid #dbe3ef !important;
    padding: 8px !important;
  }
}
