/* ==========================================================================
   Ficha Cadastral Alianzo — design system moderno
   Identidade: ciano #00B0F0 + navy #002349 / #1D3E6B, tipografia Nunito Sans
   ========================================================================== */

:root {
  /* marca */
  --cyan: #00B0F0;
  --cyan-dark: #0090c8;
  --cyan-soft: rgba(0, 176, 240, 0.12);
  --cyan-soft-solid: #e2f6ff;
  --navy: #002349;
  --navy-2: #1D3E6B;
  --aqua: #00D28C;

  /* superfícies */
  --bg: #eef2f7;
  --card: #ffffff;
  --card-2: #f7f9fc;
  --border: #dce3ec;
  --border-strong: #c5d0de;

  /* texto */
  --text: #16233a;
  --text-dim: #5c6b83;
  --heading: #002349;

  /* estados */
  --error: #dc2626;
  --error-bg: #fdecec;
  --success: #16a34a;
  --success-bg: #e9f8ef;
  --success-deep: #146c3e;
  --warn: #f59e0b;

  /* forma */
  --radius-card: 16px;
  --radius: 11px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 32, 60, .04), 0 8px 24px rgba(16, 32, 60, .06);
  --shadow-lg: 0 12px 40px rgba(16, 32, 60, .12);
  --ring: 0 0 0 3px var(--cyan-soft);

  --font: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --maxw: 1040px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e151f;
    --card: #16202e;
    --card-2: #131c28;
    --border: #273545;
    --border-strong: #35485c;
    --text: #e6edf5;
    --text-dim: #9fb0c4;
    --heading: #dbe9fb;
    --cyan-soft: rgba(0, 176, 240, 0.18);
    --cyan-soft-solid: #103040;
    --error-bg: #3a1f22;
    --success-bg: #14301f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg: #0e151f; --card: #16202e; --card-2: #131c28; --border: #273545;
  --border-strong: #35485c; --text: #e6edf5; --text-dim: #9fb0c4; --heading: #dbe9fb;
  --cyan-soft: rgba(0,176,240,.18); --cyan-soft-solid: #103040; --error-bg: #3a1f22; --success-bg: #14301f;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(135deg, rgba(0,35,73,.94) 0%, rgba(29,62,107,.90) 100%), url('fachada.jpg') no-repeat center center fixed;
  background-size: cover;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ------- header (logo canto esquerdo, estilo portal) ------- */
.banner {
  background: rgba(0, 35, 73, .82);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--cyan);
  padding: 13px 28px;
  display: flex; align-items: center; gap: 16px;
  justify-content: flex-start; position: sticky; top: 0; z-index: 50;
}
.brand-group { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand { display: inline-flex; align-items: center; flex: none; }
.brand-logo { height: 32px; width: auto; display: block; }
.welcome {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: #eaf6fd; font-weight: 800; font-size: 19px; white-space: nowrap;
  display: flex; align-items: center; gap: 10px;
}
.welcome .wave { font-size: 22px; }
.theme-toggle {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; flex: none;
  border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.10);
  color: #fff; font-size: 17px; line-height: 1; display: grid; place-items: center;
  transition: background .15s, transform .15s;
}
.theme-toggle:hover { background: rgba(255,255,255,.2); }
.theme-toggle:active { transform: translateY(-50%) scale(.94); }
@media (max-width: 640px) { .welcome { display: none; } .banner { padding: 12px 16px; } }

/* ------- layout ------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 28px 20px 120px; }
@media (max-width: 600px) { .wrap { padding: 20px 16px 130px; } }

h1.title {
  font-size: clamp(24px, 4vw, 32px);
  color: #fff;
  text-align: center;
  margin: 8px 0 6px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.subtitle {
  text-align: center; color: rgba(255,255,255,.82);
  max-width: 60ch; margin: 0 auto 16px; font-size: 14.5px;
}
.trust-note {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  background: rgba(0,176,240,.16); color: #eaf6fd;
  border: 1px solid rgba(0,176,240,.4);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  width: fit-content; margin: 0 auto 22px; text-align: center;
}

/* ------- layout: formulário centralizado + rail flutuando no vão esquerdo ------- */
.intro { margin-bottom: 22px; }
.layout { display: block; }
.rail-col, .content-col { min-width: 0; }

/* ------- stepper vertical (rail fixo à esquerda) ------- */
.stepper { margin: 0; }
.stepper-track {
  position: fixed; left: 28px; top: 50%; transform: translateY(-50%);
  width: 210px; z-index: 40;
  display: flex; flex-direction: column; gap: 0; align-items: stretch;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow); padding: 18px;
}
.step-item {
  display: flex; flex-direction: row; align-items: center; gap: 13px;
  width: 100%; text-align: left; padding: 9px 0;
  background: none; border: 0; cursor: pointer; color: var(--text-dim);
  font-family: inherit; position: relative;
}
.step-item::before {
  content: ""; position: absolute; left: 16px; top: -50%; width: 3px; height: 100%;
  background: var(--border); z-index: 0; border-radius: 3px;
}
.step-item:first-child::before { display: none; }
.step-item.done::before, .step-item.active::before { background: var(--cyan); }
.step-dot {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; z-index: 1;
  background: var(--card); border: 2px solid var(--border-strong);
  font-weight: 800; font-size: 14px; color: var(--text-dim);
  transition: transform .2s, background .2s, border-color .2s, color .2s;
}
.step-item.active .step-dot {
  background: var(--cyan); border-color: var(--cyan); color: #fff;
  transform: scale(1.1); box-shadow: 0 0 0 5px var(--cyan-soft);
}
.step-item.done .step-dot { background: var(--cyan); border-color: var(--cyan); color: #fff; }
.step-item.done .step-dot::after { content: "✓"; font-size: 16px; }
.step-item.done .step-dot span { display: none; }
.step-label { font-size: 12.5px; font-weight: 700; text-align: left; line-height: 1.2; }
.step-item.active .step-label { color: var(--heading); }

/* stepper compacto (telas estreitas, sem espaço para o rail lateral) */
.stepper-mobile { display: none; }
@media (max-width: 1560px) {
  .rail-col { display: none; }
  .stepper-mobile { display: block; margin-bottom: 18px; }
  .stepper-mobile .sm-label {
    font-family: var(--font-mono); font-size: 12px; color: var(--text-dim);
    display: flex; justify-content: space-between; margin-bottom: 7px; font-weight: 700;
  }
  .stepper-mobile .sm-track { height: 6px; background: var(--border); border-radius: 6px; overflow: hidden; }
  .stepper-mobile .sm-fill { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--aqua)); width: 0; transition: width .4s ease; }
}

/* ------- cards / steps ------- */
.step {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 26px;
  animation: card-in .35s ease both;
}
.step[hidden] { display: none; }
@keyframes card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) { .step { padding: 20px 16px; } }

.step-head { display: flex; align-items: center; gap: 12px; margin: 0 0 6px; }
.step-num {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--cyan); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 15px;
}
.step-head h2 { font-size: 19px; color: var(--heading); margin: 0; font-weight: 800; }
.step-desc { color: var(--text-dim); font-size: 13.5px; margin: 0 0 18px; }

/* ------- grid de campos ------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label { font-size: 13px; font-weight: 700; color: var(--text); display: flex; flex-wrap: wrap; align-items: baseline; align-content: flex-start; gap: 4px 6px; min-height: 44px; }
.req { color: var(--cyan); font-weight: 800; }
.hint { flex-basis: 100%; font-weight: 500; font-size: 12px; color: var(--text-dim); }

input, select, textarea {
  font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--card-2);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius); padding: 0 13px; height: 46px; width: 100%;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
select { appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235c6b83' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyan); box-shadow: var(--ring); background: var(--card); }
input::placeholder { color: var(--text-dim); opacity: .7; }
input[type="date"] { min-height: 46px; }

input.locked, input[readonly] { background: var(--card-2); color: var(--text-dim); cursor: not-allowed; }
.field.invalid input, .field.invalid select { border-color: var(--error); background: var(--error-bg); }
.field-error { display: none; font-size: 12px; color: var(--error); font-weight: 600; }
.field.invalid .field-error { display: block; }

/* ------- uploads ------- */
.file-input { display: none; }
.file-drop {
  border: 1.6px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--card-2); padding: 14px 16px; cursor: pointer;
  display: flex; align-items: center; gap: 12px; transition: border-color .15s, background .15s;
}
.file-drop:hover, .file-drop.drag { border-color: var(--cyan); background: var(--cyan-soft); }
.file-drop .fd-icon { width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--cyan-soft); color: var(--cyan-dark); display: grid; place-items: center; font-size: 18px; }
.file-drop .fd-text { font-size: 13px; color: var(--text-dim); }
.file-drop .fd-text strong { color: var(--text); display: block; font-size: 13.5px; }
.field.invalid .file-drop { border-color: var(--error); background: var(--error-bg); }

.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.file-item {
  display: flex; align-items: center; gap: 10px; background: var(--card-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px;
}
.file-item .fi-ico { color: var(--cyan-dark); flex: none; }
.file-item-name { flex: 1; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; flex: none; }
.file-item-remove { background: none; border: 0; color: var(--text-dim); cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 6px; line-height: 1; }
.file-item-remove:hover { background: var(--error-bg); color: var(--error); }

/* ------- dependentes ------- */
.dep-empty { color: var(--text-dim); font-size: 14px; background: var(--card-2); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 16px; text-align: center; margin-bottom: 14px; }
.dependente-card {
  border: 1.6px dashed var(--border-strong); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--card-2), var(--card));
  padding: 18px; margin-bottom: 16px; position: relative; animation: card-in .3s ease both;
}
.dependente-card h3 { margin: 0 0 14px; font-size: 16px; color: var(--heading); font-weight: 800; }
.remove-dependente {
  position: absolute; top: 12px; right: 12px; background: var(--error-bg); color: var(--error);
  border: 1px solid transparent; border-radius: 8px; padding: 5px 10px; font-size: 12.5px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.remove-dependente:hover { border-color: var(--error); }
.add-dependente-btn {
  width: 100%; border: 1.6px dashed var(--cyan); background: var(--cyan-soft);
  color: var(--cyan-dark); border-radius: var(--radius); padding: 14px; font-size: 14.5px;
  font-weight: 800; cursor: pointer; font-family: inherit; transition: background .15s;
}
.add-dependente-btn:hover { background: var(--cyan-soft-solid); }

/* ------- navegação do wizard ------- */
.wizard-nav {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  margin-top: 22px;
}
.btn {
  font-family: inherit; font-weight: 800; font-size: 15px; border-radius: var(--radius);
  padding: 0 24px; height: 50px; cursor: pointer; border: 1.5px solid transparent;
  transition: transform .12s, box-shadow .15s, background .15s; display: inline-flex; align-items: center; gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(120deg, var(--cyan), var(--cyan-dark)); color: #fff; box-shadow: 0 6px 18px rgba(0,176,240,.32); }
.btn-primary:hover { box-shadow: 0 8px 24px rgba(0,176,240,.42); }
.btn-primary:disabled { opacity: .6; cursor: default; box-shadow: none; }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--cyan); color: var(--cyan-dark); }
.btn[hidden] { display: none; }
.spacer { flex: 1; }

@media (max-width: 600px) {
  .wizard-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--card); border-top: 1px solid var(--border);
    padding: 12px 16px; margin: 0; box-shadow: 0 -6px 20px rgba(16,32,60,.08);
  }
  .btn { flex: 1; justify-content: center; padding: 0 14px; }
}

/* ------- resumo de erros ------- */
.summary-errors {
  display: none; background: var(--error-bg); border: 1px solid var(--error);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; color: var(--error);
}
.summary-errors.show { display: block; animation: card-in .25s ease both; }
.summary-errors strong { display: block; margin-bottom: 6px; }
.summary-errors ul { margin: 0; padding-left: 20px; font-size: 13.5px; }

/* ------- sucesso ------- */
.success-box { display: none; text-align: center; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 44px 26px; }
.success-box.show { display: block; animation: card-in .35s ease both; }
.check-circle { width: 84px; height: 84px; margin: 0 auto 18px; }
.check-circle circle, .check-circle path { fill: none; stroke: var(--success); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.check-circle circle { stroke-dasharray: 289; stroke-dashoffset: 289; animation: draw-c .6s ease forwards; }
.check-circle path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw-k .35s .5s ease forwards; }
@keyframes draw-c { to { stroke-dashoffset: 0; } }
@keyframes draw-k { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .check-circle circle, .check-circle path { animation: none; stroke-dashoffset: 0; } }
.success-box h2 { color: var(--success-deep); margin: 0 0 8px; font-size: 22px; }
.success-box p { color: var(--text-dim); margin: 0 auto; max-width: 44ch; }
.success-box .protocolo { display: inline-block; margin-top: 16px; font-family: var(--font-mono); font-size: 15px; font-weight: 800; color: var(--heading); background: var(--cyan-soft); border: 1px solid var(--cyan-soft-solid); border-radius: 10px; padding: 8px 16px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
