/* ============================================================
   DIFAL Não Contribuinte — Documental Editorial
   3C Empresarial · v2.0
   ============================================================ */

:root {
  --bg:           #f8f7f4;
  --surface:      #ffffff;
  --surface-2:    #f2f1ec;
  --border:       #e0dfd8;
  --border-2:     #c8c7c0;
  --text:         #1c1c1a;
  --text-2:       #6b6b67;
  --text-3:       #a0a09a;
  --blue:         #181b46;
  --blue-2:       #252963;
  --blue-light:   #eef0f8;
  --blue-mid:     #c5cae9;
  --warm:         #7a5c1a;
  --warm-light:   #fdf6e8;
  --red:          #b53030;
  --red-light:    #fdf0f0;
  --radius:       6px;
  --radius-sm:    4px;
  --font:         'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* CONTAINER */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 32px;
}

@media (max-width: 640px) { .container { padding: 0 20px; } }

/* ============================================================
   NAV
   ============================================================ */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@media (max-width: 640px) { .nav-inner { padding: 12px 20px; } }

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

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.brand-text { display: flex; flex-direction: column; }

.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1;
  margin-top: 2px;
}

.version-tag {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  padding: 56px 0 40px;
  background: var(--surface);
}

.header-meta {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 14px;
}

.page-title {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
  color: var(--text);
  margin-bottom: 14px;
}

.page-desc {
  font-size: 15px;
  color: var(--text-2);
  max-width: 560px;
  line-height: 1.7;
}

/* ============================================================
   DIVIDERS
   ============================================================ */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 56px 0;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main { padding: 48px 0 80px; }

.calc-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
}

@media (max-width: 768px) { .calc-layout { grid-template-columns: 1fr; } }

/* ============================================================
   FORM SECTION
   ============================================================ */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 24px;
}

.form-row { margin-bottom: 18px; }

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 7px;
}

/* Locked field */
.field--locked {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: not-allowed;
  opacity: 0.7;
}

.field-value {
  font-size: 14px;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 13px;
}

.field-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-light);
  border: 1px solid var(--blue-mid);
  padding: 2px 7px;
  border-radius: 100px;
  letter-spacing: 0.04em;
}

/* Select */
.select-field {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s;
  overflow: hidden;
}

.select-field:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24, 27, 70, 0.12);
}

.select-field.error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(181, 48, 48, 0.08);
}

.select {
  width: 100%;
  padding: 10px 36px 10px 12px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.select option { background: #fff; color: var(--text); }

.select-arrow {
  position: absolute;
  right: 12px;
  color: var(--text-3);
  font-size: 11px;
  pointer-events: none;
  font-style: normal;
}

/* Input */
.input-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s;
  overflow: hidden;
}

.input-field:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24, 27, 70, 0.12);
}

.input-field.error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(181, 48, 48, 0.08);
  animation: shake 0.32s ease;
}

.input-currency {
  padding: 10px 0 10px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-3);
  font-weight: 500;
  flex-shrink: 0;
  user-select: none;
}

.input {
  flex: 1;
  padding: 10px 12px 10px 6px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
}

.input::placeholder { color: var(--text-3); font-weight: 400; }

/* Error message */
.form-error {
  font-size: 12px;
  color: var(--red);
  min-height: 16px;
  margin-bottom: 4px;
}

/* Button */
.btn-calc {
  width: 100%;
  padding: 12px 24px;
  background: var(--blue);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.01em;
  margin-top: 4px;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.btn-calc:hover {
  background: var(--blue-2);
  box-shadow: 0 4px 16px rgba(24, 27, 70, 0.3);
  transform: translateY(-1px);
}

.btn-calc:active { transform: translateY(0); box-shadow: none; }

.form-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.6;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   RESULT SECTION
   ============================================================ */
.result-section {
  animation: fadeUp 0.35s cubic-bezier(0.165, 0.84, 0.44, 1) both;
}

.result-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}

.result-state {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-light);
  border: 1px solid var(--blue-mid);
  padding: 3px 9px;
  border-radius: 100px;
  letter-spacing: 0.02em;
}

/* Hero total */
.result-hero {
  padding: 24px;
  background: var(--blue);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.result-hero-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 8px;
}

.result-hero-value {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* Result rows */
.result-table {
  display: flex;
  flex-direction: column;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.result-row:last-child { border-bottom: none; }

.result-row--highlight {
  background: var(--blue-light);
  margin: 0 -12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--blue-mid);
}

.result-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.result-row-label {
  font-size: 13px;
  color: var(--text-2);
}

.result-row-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}

.result-row-value--accent  { color: var(--blue); }
.result-row-value--green   { color: var(--blue); font-size: 15px; font-weight: 600; }
.result-row-value--muted   { color: var(--text-3); font-weight: 400; }
.result-row-value--warm    { color: var(--warm); }

/* ============================================================
   FULL SECTIONS (table + law)
   ============================================================ */
.full-section { margin-bottom: 0; }

.full-section-header { margin-bottom: 24px; }

.full-section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 4px;
}

.full-section-desc {
  font-size: 13px;
  color: var(--text-2);
}

/* ============================================================
   DATA TABLE
   ============================================================ */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  background: var(--surface-2);
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.data-table thead th.th-num { text-align: right; }

.data-table tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  color: var(--text);
  white-space: nowrap;
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.015);
}

.data-table tbody tr:hover td {
  background: var(--blue-light);
}

.td-state-name { font-weight: 500; }
.td-state-abbr {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  margin-left: 6px;
}

.td-num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}

.td-aliq    { color: var(--blue); }
.td-inter   { color: var(--text-3); }
.td-difal   { color: var(--text); }
.td-total   { color: var(--blue); font-weight: 600; }

.fecp-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--warm);
  background: var(--warm-light);
  border: 1px solid rgba(122, 92, 26, 0.2);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.td-no-fecp {
  color: var(--text-3);
  font-size: 11px;
  text-align: right;
  display: block;
}

/* ============================================================
   LAW GRID
   ============================================================ */
.law-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.law-item {
  display: flex;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--surface);
  transition: background 0.15s;
}

.law-item:hover { background: var(--blue-light); }

.law-item:nth-child(2n) { border-right: none; }

@media (max-width: 640px) {
  .law-grid { grid-template-columns: 1fr; }
  .law-item { border-right: none; }
}

.law-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--blue);
  flex-shrink: 0;
  padding-top: 2px;
  opacity: 0.6;
}

.law-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  color: var(--text);
}

.law-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.65;
}

.formula-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
}

.formula-block code {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--blue);
  background: var(--blue-light);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--blue-mid);
  white-space: nowrap;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  color: var(--text-3);
  flex-wrap: wrap;
}

.footer-note { font-size: 11px; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-4px); }
  40%       { transform: translateX(4px); }
  60%       { transform: translateX(-3px); }
  80%       { transform: translateX(3px); }
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
