/* ═══════════════════════════════════════════════════════════════
   Crelider — Ficha Cadastral v2.0
   Design System · assets/css/app.css
═══════════════════════════════════════════════════════════════ */

/* ── 1. Design Tokens ───────────────────────────────────────── */
:root {
  --navy:      #2D2D2D;
  --navy-2:    #3D3D3D;
  --navy-3:    #505050;
  --navy-bg:   #F2F2F2;
  --navy-line: rgba(45,45,45,.15);

  --gold:      #E84020;
  --gold-lt:   #FEEAE6;
  --gold-xlt:  #FFF5F3;
  --gold-dk:   #C03015;

  --surface:   #ffffff;
  --surface-2: #f8f9fc;
  --bg:        #f1f3f8;
  --border:    #e2e8f0;

  --text:      #0d1117;
  --text-2:    #4a5568;
  --text-3:    #718096;
  --ghost:     #a0aec0;

  --red:       #e53e3e;
  --red-bg:    #fff5f5;
  --green:     #276749;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;

  --sh-xs: 0 1px 3px rgba(0,0,0,.06);
  --sh-sm: 0 4px 12px rgba(0,0,0,.07);
  --sh-md: 0 8px 24px rgba(0,0,0,.09);
  --sh-lg: 0 16px 40px rgba(0,0,0,.12);

  --ease: cubic-bezier(.4,0,.2,1);
  --dur:  180ms;

  --font:  'Inter', system-ui, -apple-system, sans-serif;
  --touch: 44px;
}

/* ── 2. Reset & Base ────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── 3. Brand Bar ───────────────────────────────────────────── */
.brand-bar {
  background: var(--navy);
  min-height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: stretch;
  position: relative;
}
.brand-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold) 40%, transparent 100%);
}
.brand-inner {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 1340px;
  margin: auto;
}
.brand-logo {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-right: 20px;
  border-right: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
.brand-logo img { height: 40px; width: auto; display: block; }
.brand-name {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: .3px;
  line-height: 1;
}
.brand-name em { color: var(--gold); font-style: normal; }
.brand-sub {
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.38);
  margin-top: 3px;
}
.brand-meta { flex: 1; padding-left: 20px; min-width: 0; }
.brand-doc {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-doc-sub { font-size: 11px; color: rgba(255,255,255,.38); margin-top: 1px; }
.brand-pill {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid rgba(232,64,32,.35);
  padding: 4px 12px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── 4. App Layout ──────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 1340px;
  margin: 24px auto 80px;
  padding: 0 20px;
  align-items: start;
}

/* ── 5. Alerts ──────────────────────────────────────────────── */
.alert-group { grid-column: 1/-1; display: flex; flex-direction: column; gap: 8px; }
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r);
  font-size: 13px;
  border: 1px solid;
}
.alert-warn { background: #fffbeb; color: #92400e; border-color: #fbbf24; }
.alert-err  { background: var(--red-bg); color: var(--red); border-color: rgba(229,62,62,.3); }
.alert-icon { font-size: 16px; flex-shrink: 0; }
.alert code {
  font-size: 11px;
  background: rgba(0,0,0,.07);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── 6. Form Card ───────────────────────────────────────────── */
.form-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  overflow: hidden;
}
.form-body { padding: 28px 28px 36px; }

/* ── 7. Section Header ──────────────────────────────────────── */
.section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 32px 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.section:first-child { margin-top: 0; }
.section-num {
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.section-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--navy-bg);
  border: 1px solid var(--navy-line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.section-info { flex: 1; min-width: 0; }
.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--navy);
}
.section-desc { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ── 8. Field Grid ──────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 10px 12px;
  align-items: start;
}
.g1  { grid-column: span 1;  } .g2  { grid-column: span 2;  }
.g3  { grid-column: span 3;  } .g4  { grid-column: span 4;  }
.g5  { grid-column: span 5;  } .g6  { grid-column: span 6;  }
.g7  { grid-column: span 7;  } .g8  { grid-column: span 8;  }
.g9  { grid-column: span 9;  } .g10 { grid-column: span 10; }
.g11 { grid-column: span 11; } .g12 { grid-column: span 12; }

/* ── 9. Field ───────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .6px;
}
.field-err {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--red);
}

/* ── 10. Inputs ─────────────────────────────────────────────── */
input[type=text],
input[type=date],
input[type=tel],
input[type=email],
input[type=number],
select,
textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font: 14px/1.4 var(--font);
  color: var(--text);
  background: var(--surface-2);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    background var(--dur) var(--ease);
}
input::placeholder,
textarea::placeholder { color: var(--ghost); }
input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(232,64,32,.12);
}
input:not(:placeholder-shown):not(:focus):not([type=date]):not([type=number]) {
  border-color: rgba(232,64,32,.35);
  background: var(--surface);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%23718096' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}
textarea { resize: vertical; min-height: 76px; }

/* Validation state */
.field.has-err input,
.field.has-err select,
.field.has-err textarea {
  border-color: var(--red);
  background: var(--red-bg);
  box-shadow: 0 0 0 3px rgba(229,62,62,.08);
}

/* ── 11. Consortium Selector ────────────────────────────────── */
.co-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.co-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}
.co-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 8px 14px;
  border: 2px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  cursor: pointer;
  text-align: center;
  user-select: none;
  position: relative;
  transition:
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease),
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.co-card:hover {
  border-color: var(--gold);
  background: var(--gold-xlt);
  transform: translateY(-2px);
  box-shadow: var(--sh-sm);
}
.co-radio:checked + .co-card {
  border-color: var(--gold);
  background: var(--gold-lt);
  box-shadow: 0 0 0 1px var(--gold), var(--sh-sm);
}
.co-radio:checked + .co-card::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 7px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.co-icon  { font-size: 26px; line-height: 1; }
.co-label { font-size: 11px; font-weight: 700; color: var(--text-2); line-height: 1.3; }
.co-radio:checked + .co-card .co-label { color: var(--gold-dk); }

/* ── 12. LGPD ───────────────────────────────────────────────── */
.lgpd {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  margin-top: 20px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.65;
}

/* ── 13. Submit Button ──────────────────────────────────────── */
.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding: 14px 20px;
  min-height: var(--touch);
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dk) 100%);
  color: #fff;
  font: 700 15px/1 var(--font);
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  letter-spacing: .3px;
  box-shadow: 0 4px 14px rgba(232,64,32,.4);
  transition:
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}
.btn-submit::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,.07));
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.btn-submit:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(232,64,32,.5); }
.btn-submit:hover::after { opacity: 1; }
.btn-submit:active { transform: translateY(0); }

/* ── 14. Preview Column ─────────────────────────────────────── */
.preview-col { position: sticky; top: 20px; }

.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.live-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .6px;
  white-space: nowrap;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4; transform: scale(.6); }
}
.progress-track {
  flex: 1;
  height: 2px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-dk));
  border-radius: 99px;
  transition: width .4s var(--ease);
  width: 0%;
}
.btn-print {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  min-height: 34px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font: 600 11.5px/1 var(--font);
  letter-spacing: .2px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--sh-xs);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn-print:hover { background: var(--navy-2); transform: translateY(-1px); }

/* Mobile preview header */
.preview-mobile-hd {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: var(--navy);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.preview-mobile-left { display: flex; align-items: center; gap: 8px; }
.preview-mobile-title { font-size: 13px; font-weight: 700; color: #fff; }
.preview-chip {
  background: var(--gold);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  animation: pulse 1.8s ease-in-out infinite;
}
.preview-chevron {
  font-size: 18px;
  color: var(--gold);
  transition: transform .25s var(--ease);
}
.preview-col.is-collapsed .preview-chevron { transform: rotate(-90deg); }

/* ── 15. Ficha Document ─────────────────────────────────────── */
.ficha {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.ficha-hd {
  background: var(--navy);
  padding: 14px 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
}
.ficha-hd::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--navy-3));
}
.ficha-brand-name { font-size: 15px; font-weight: 800; color: #fff; line-height: 1; }
.ficha-brand-name em { color: var(--gold); font-style: normal; }
.ficha-brand-sub {
  font-size: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.32);
  margin-top: 3px;
}
.ficha-hd-right { text-align: right; flex-shrink: 0; }
.ficha-hd-label { font-size: 10px; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: .5px; }
.ficha-hd-meta { font-size: 9px; color: rgba(255,255,255,.38); margin-top: 2px; }
.ficha-hd-meta b { color: rgba(255,255,255,.7); font-weight: 500; }

.ficha-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 18px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-dk) 100%);
}
.ficha-strip-tipo { font-size: 11px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 5px; }
.ficha-strip-tipo .empty { color: rgba(255,255,255,.32); font-style: italic; font-weight: 400; font-size: 10px; }
.ficha-strip-val { font-size: 13px; font-weight: 800; color: #fff; }
.ficha-strip-val.empty { font-size: 10px; color: rgba(255,255,255,.32); font-weight: 400; }

.fs-hd {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  background: var(--navy-bg);
  border-top: 1px solid var(--navy-line);
  border-bottom: 1px solid var(--navy-line);
}
.fs-hd:first-child { border-top: none; }
.fs-hd-label { font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--navy); }

.frow { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.frow:last-child { border-bottom: none; }
.ff { padding: 5px 14px; flex: 1; min-width: 80px; border-right: 1px solid #f0f2f5; }
.ff:last-child { border-right: none; }
.ff.full { flex-basis: 100%; min-width: 100%; }
.ff-lbl {
  display: block;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ghost);
  margin-bottom: 1px;
}
.ff-val {
  display: block;
  font-size: 11px;
  color: var(--text);
  font-weight: 500;
  min-height: 16px;
  word-break: break-word;
  line-height: 1.4;
}
.ff-val.empty { color: var(--ghost); font-style: italic; font-size: 10px; font-weight: 400; }
.ff-val.bold  { font-weight: 700; color: var(--navy); font-size: 12px; }

.tipo-pill {
  display: inline-flex;
  align-items: center;
  background: var(--navy-bg);
  border: 1px solid var(--navy-line);
  color: var(--navy);
  font-weight: 700;
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 99px;
}

.ficha-sig { display: flex; border-top: 2px solid var(--navy-bg); background: var(--surface-2); }
.ficha-sig-box { flex: 1; padding: 18px 14px 12px; text-align: center; border-right: 1px solid var(--border); }
.ficha-sig-box:last-child { border-right: none; }
.sig-line { border-top: 1px solid #aaa; padding-top: 5px; font-size: 8.5px; color: var(--text-3); margin-top: 8px; }

.ficha-ft {
  background: var(--navy);
  padding: 7px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ficha-ft-text  { font-size: 8px; color: rgba(255,255,255,.28); }
.ficha-ft-brand { font-size: 9px; font-weight: 700; color: rgba(255,255,255,.48); }
.ficha-ft-brand em { color: var(--gold); font-style: normal; }

/* ── 16. FAB ────────────────────────────────────────────────── */
.fab {
  display: none;
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: 20px;
  z-index: 50;
}
.fab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 99px;
  font: 700 13px/1 var(--font);
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur) var(--ease);
}
.fab-btn:active { transform: scale(.96); }

/* Page footer */
.pg-foot { text-align: center; padding: 20px; font-size: 11px; color: var(--ghost); }

/* ── 17. Responsive — ≤1020px ───────────────────────────────── */
@media (max-width: 1020px) {
  .app { grid-template-columns: 1fr; gap: 16px; }
  .form-col    { order: 1; }
  .preview-col { order: 2; position: static; }
  .preview-mobile-hd { display: flex; }
  .preview-toolbar { display: none; }
  .fab { display: block; }
  .ficha { border-radius: 0 0 var(--r-lg) var(--r-lg); }
  .preview-col.is-collapsed .preview-body { display: none; }
}

/* ── 18. Responsive — ≤768px ────────────────────────────────── */
@media (max-width: 768px) {
  .app { padding: 0 14px; margin-top: 16px; margin-bottom: 88px; }
  .form-body { padding: 20px 18px 28px; }
  .brand-bar { min-height: 54px; padding: 0 16px; }
  .brand-pill,.brand-doc-sub { display: none; }
  .brand-meta { padding-left: 14px; }
  .brand-logo { padding-right: 14px; }
  .grid { grid-template-columns: repeat(6, 1fr); gap: 8px 10px; }
  .g1,.g2         { grid-column: span 2; }
  .g3,.g4         { grid-column: span 3; }
  .g5,.g6         { grid-column: span 3; }
  .g7,.g8         { grid-column: span 4; }
  .g9,.g10,.g11,.g12 { grid-column: span 6; }
  .section { margin: 24px 0 14px; }
  .section-desc { display: none; }
  .co-grid { grid-template-columns: repeat(2, 1fr); }
  .ficha-sig { flex-direction: column; }
  .ficha-sig-box { border-right: none; border-bottom: 1px solid var(--border); }
  .ficha-sig-box:last-child { border-bottom: none; }
}

/* ── 19. Responsive — ≤480px ────────────────────────────────── */
@media (max-width: 480px) {
  .app { padding: 0 10px; margin-top: 12px; gap: 12px; }
  .form-body { padding: 16px 14px 24px; }
  .brand-bar { min-height: 50px; padding: 0 12px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .g1,.g2,.g3,.g4,.g5,.g6,
  .g7,.g8,.g9,.g10,.g11,.g12 { grid-column: span 2; }
  .g-half { grid-column: span 1 !important; }
  input[type=text],input[type=date],input[type=tel],
  input[type=email],input[type=number],select { font-size: 16px; }
  .section { margin: 20px 0 12px; padding-bottom: 10px; }
  .section-num { min-width: 22px; height: 22px; font-size: 10px; }
  .btn-submit { padding: 15px; font-size: 15px; }
  .fab { right: 0; bottom: 0; width: 100%; }
  .fab-btn {
    width: 100%;
    border-radius: 0;
    justify-content: center;
    box-shadow: 0 -2px 12px rgba(0,0,0,.15);
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .ff { flex-basis: 100%; min-width: 100%; border-right: none; border-bottom: 1px solid #f0f2f5; }
  .ff:last-child { border-bottom: none; }
  .ficha-hd { padding: 10px 14px; }
  .ficha-hd-meta { display: none; }
}

/* ── 20. Premium UX — Field States ─────────────────────────── */

/* Valid field */
.field.is-valid > input,
.field.is-valid > select {
  border-color: #10b981;
  background: #f0fdf4;
  padding-right: 36px;
}
/* Invalid field — enhanced */
.field.is-invalid > input,
.field.is-invalid > select {
  border-color: var(--red);
  background: var(--red-bg);
  box-shadow: 0 0 0 3px rgba(229,62,62,.08);
}
/* Icon wrapper inside field */
.field-icon-wrap { position: relative; display: block; }
.field-icon-wrap input,
.field-icon-wrap select { display: block; width: 100%; }
.field-icon {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
}
/* JS injeta um único .field-icon; estado controlado por .is-valid/.is-invalid */
.field.is-valid   .field-icon { display: flex; background: #10b981; color: #fff; }
.field.is-invalid .field-icon { display: flex; background: var(--red);   color: #fff; }

/* ── 21. Section completion badge ───────────────────────────── */
.section-num {
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.section-num.is-done {
  background: #10b981;
  transform: scale(1.05);
}
.section-num.is-done::after { content: ' ✓'; }

/* ── 22. Submit loading state ───────────────────────────────── */
.btn-submit.is-loading {
  opacity: .85;
  cursor: not-allowed;
  pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-spinner {
  width: 17px;
  height: 17px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}

/* ── 23. CEP loading ────────────────────────────────────────── */
@keyframes input-pulse {
  0%,100% { box-shadow: 0 0 0 2px rgba(232,64,32,.2); }
  50%      { box-shadow: 0 0 0 4px rgba(232,64,32,.35); }
}
input.cep-fetching {
  border-color: var(--gold) !important;
  animation: input-pulse .9s ease-in-out infinite;
}

/* ── 24. Toast Notifications ────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  width: min(360px, calc(100vw - 40px));
}
.toast {
  background: var(--navy);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.28), 0 2px 8px rgba(0,0,0,.14);
  overflow: hidden;
  pointer-events: all;
  transform: translateX(calc(100% + 24px));
  transition: transform .36s cubic-bezier(.34,1.26,.64,1);
  will-change: transform;
}
.toast.is-show { transform: translateX(0); }
.toast.is-hide {
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  transition: transform .25s var(--ease), opacity .25s var(--ease);
}
.toast-body {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}
.toast-ico  { font-size: 15px; flex-shrink: 0; line-height: 1; }
.toast-msg  { flex: 1; font-size: 13px; font-weight: 500; color: #fff; line-height: 1.4; }
.toast-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.45);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: color var(--dur) var(--ease);
}
.toast-close:hover { color: #fff; }
.toast-prog { height: 3px; background: rgba(255,255,255,.15); }
.toast-bar  { height: 100%; width: 100%; transition: none; }

/* Toast variants */
.toast-success { border-left: 3px solid #10b981; }
.toast-success .toast-bar { background: #10b981; }
.toast-err     { border-left: 3px solid #ef4444; }
.toast-err .toast-bar { background: #ef4444; }
.toast-warn    { border-left: 3px solid #f59e0b; }
.toast-warn .toast-bar { background: #f59e0b; }
.toast-info    { border-left: 3px solid var(--gold); }
.toast-info .toast-bar { background: var(--gold); }

/* Inline action inside toast */
.toast-action {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 4px;
  transition: background var(--dur) var(--ease);
}
.toast-action:hover { background: rgba(255,255,255,.25); }

/* ── 25. Draft Status ───────────────────────────────────────── */
.draft-status {
  font-size: 10px;
  font-weight: 600;
  color: var(--ghost);
  letter-spacing: .3px;
  white-space: nowrap;
  transition: color .3s var(--ease);
  min-width: 70px;
}
@keyframes draft-flash {
  0%,100% { color: var(--ghost); }
  40%     { color: #10b981; }
}
.draft-status.is-pulse { animation: draft-flash .7s ease-in-out; }

/* ── 26. Progress % label ───────────────────────────────────── */
.progress-pct {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  white-space: nowrap;
  min-width: 30px;
  transition: color .4s var(--ease);
}
.progress-pct.is-done { color: #10b981; }

/* ── 27. Mobile toast — bottom position ─────────────────────── */
@media (max-width: 480px) {
  .toast-container {
    top: auto;
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 12px;
    left: 12px;
    width: auto;
  }
  .toast { transform: translateY(120%); }
  .toast.is-show { transform: translateY(0); }
  .toast.is-hide { transform: translateY(120%); opacity: 0; }
}

/* ── 28. Input transition polish ────────────────────────────── */
input[type=text]:focus,
input[type=tel]:focus,
input[type=email]:focus,
select:focus,
textarea:focus {
  transform: translateY(-1px);
}
input[type=text],
input[type=tel],
input[type=email],
select,
textarea { transform: translateY(0); }

/* ── 29. Performance — Rendering Hints ─────────────────────── */

/* Isolamento de layout para containers grandes */
.form-card   { contain: layout style; }
.preview-body { contain: layout; }
.ficha        { contain: layout style; }

/* Elementos com animação: promove camada GPU */
.progress-fill { will-change: width; }
.section-num   { will-change: background, transform; }
.toast         { will-change: transform, opacity; }
.btn-submit    { will-change: opacity; }

/* Input focus: evita reflow no document inteiro */
input[type=text]:focus,
input[type=tel]:focus,
input[type=email]:focus,
input[type=number]:focus,
select:focus,
textarea:focus { isolation: isolate; }

/* Fieldset sem borda (substitui inline style) */
.fieldset-reset { border: none; padding: 0; margin: 0; }
.legend-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 4px;
}

/* Grid com margem superior para o bloco de consórcio */
.grid-consortium { margin-top: 12px; }

/* ── 30. Print ──────────────────────────────────────────────── */
@media print {

  @page { size: A4 portrait; margin: 12mm; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { background: #fff; font-size: 11px; }
  .brand-bar,.form-col,.preview-toolbar,.preview-mobile-hd,
  .btn-print,.lgpd,.alert-group,.pg-foot,.fab { display: none !important; }
  .app { display: block !important; margin: 0 !important; padding: 0 !important; }
  .preview-col { position: static !important; }
  .preview-body { display: block !important; }
  .ficha { box-shadow: none !important; border: 1px solid #ddd !important; border-radius: 0 !important; }
  .frow { page-break-inside: avoid; }
  .ff { flex-basis: auto !important; min-width: 80px !important; border-right: 1px solid #f0f2f5 !important; border-bottom: none !important; }
  .ff:last-child { border-right: none !important; }
  .ficha-sig { background: #f8f9fb !important; }
}
