/* Portal Empresa NIPON */
:root {
  --navy-deep: #061122;
  --navy: #0b1d36;
  --navy-mid: #132d52;
  --red: #d62833;
  --red-dark: #a31524;
  --red-light: #f0585c;
  --gold: #e2b35c;
  --green: #209c68;
  --amber: #d9921a;
  --ink: #0d192b;
  --body: #5e6d84;
  --muted: #8795aa;
  --line: #dfe6f0;
  --bg: #f4f7fb;
  --card: #fff;
  --radius: 18px;
  --shadow: 0 14px 40px rgba(12, 26, 48, .1);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.02em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }

.container { width: min(100% - 40px, 1180px); margin-inline: auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* Logo */
.logo { display: inline-flex; align-items: center; gap: 12px; }
.logo__mark { width: 42px; height: 42px; }
.logo__text { display: flex; flex-direction: column; line-height: 1; color: #fff; }
.logo__text strong { font-size: 22px; font-weight: 900; }
.logo__text em {
  margin-top: 3px; font-style: normal; font-size: 9px; font-weight: 600;
  letter-spacing: .32em; color: #a9bdd8;
}
.logo--dark .logo__text { color: var(--ink); }
.logo--dark .logo__text em { color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border: 1.5px solid transparent; border-radius: 999px;
  font-weight: 600; cursor: pointer; transition: .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--red); color: #fff; box-shadow: 0 10px 24px rgba(214,40,51,.28); }
.btn--primary:hover { background: #c31f2b; }
.btn--ghost { background: transparent; border-color: rgba(255,255,255,.35); color: #fff; }
.btn--ghost-dark { background: #fff; border-color: var(--line); color: var(--ink); }
.btn--ghost-dark:hover { border-color: var(--red); color: var(--red); }
.btn--sm { padding: 8px 14px; font-size: 14px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
}
.badge--done { background: #e4f7ee; color: var(--green); }
.badge--in_progress { background: #e8eefc; color: #2f5fd0; }
.badge--waiting_client { background: #fff3df; color: #b87400; }
.badge--pending { background: #eef1f5; color: var(--muted); }
.badge--solicitado { background: #fff3df; color: #b87400; }
.badge--enviado { background: #e8eefc; color: #2f5fd0; }
.badge--aprovado { background: #e4f7ee; color: var(--green); }
.badge--rejeitado { background: #fde7e9; color: var(--red); }

/* Toast */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  max-width: 360px; padding: 14px 18px; border-radius: 14px;
  background: var(--navy); color: #fff; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: .25s ease;
}
.toast.is-visible { opacity: 1; transform: none; }

/* ========== LOGIN ========== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background: linear-gradient(150deg, var(--navy-deep), var(--navy-mid));
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: "";
  position: absolute; top: -280px; right: -200px;
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(214,40,51,.38), transparent 65%);
  pointer-events: none;
}
.login-card {
  position: relative; z-index: 1;
  width: min(100%, 440px);
  padding: 36px 34px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 30px 70px rgba(6,17,34,.35);
}
.login-card__brand { margin-bottom: 28px; }
.login-card h1 { font-size: 26px; margin-bottom: 8px; }
.login-card .lead { color: var(--body); font-size: 15px; margin-bottom: 26px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: #43526a; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: #fbfcfe; color: var(--ink);
  transition: border-color .18s, box-shadow .18s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--red); background: #fff;
  box-shadow: 0 0 0 4px rgba(214,40,51,.12);
}
.field textarea { resize: vertical; min-height: 80px; }
.form-error {
  min-height: 20px; margin: 4px 0 12px;
  font-size: 14px; font-weight: 600; color: var(--red);
}
.demo-hint {
  margin-top: 22px; padding: 14px 16px;
  border-radius: 14px; background: var(--bg); border: 1px solid var(--line);
  font-size: 13px; color: var(--body);
}
.demo-hint strong { color: var(--ink); }
.demo-hint code {
  display: inline-block; margin: 2px 0;
  padding: 1px 6px; border-radius: 6px;
  background: #fff; border: 1px solid var(--line);
  font-size: 12px;
}
.login-footer {
  margin-top: 18px; text-align: center; font-size: 13px; color: #9bb0cb;
}
.login-footer a { color: #c9d8ee; text-decoration: underline; }

/* ========== APP SHELL ========== */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 29, 54, .96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.app-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 0;
}
.app-header__meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.app-header__user { color: #c3d3ea; font-size: 14px; text-align: right; }
.app-header__user strong { display: block; color: #fff; font-size: 15px; }
.app-main { padding: 32px 0 64px; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  justify-content: space-between; gap: 16px; margin-bottom: 28px;
}
.page-head h1 { font-size: clamp(24px, 3vw, 34px); }
.page-head p { margin-top: 6px; color: var(--body); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.stack { display: grid; gap: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}
.card h2, .card h3 { margin-bottom: 6px; }
.card__lead { color: var(--body); font-size: 14.5px; margin-bottom: 16px; }

.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px;
}
.kpi {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 18px; box-shadow: 0 6px 18px rgba(12,26,48,.05);
}
.kpi__icon {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
}
.kpi__icon svg { width: 22px; height: 22px; }
.kpi__body { min-width: 0; }
.kpi strong { display: block; font-size: 22px; font-weight: 900; letter-spacing: -.02em; line-height: 1.15; }
.kpi span { font-size: 13px; color: var(--body); }
.kpi--green .kpi__icon { background: #e4f7ee; color: var(--green); }
.kpi--blue .kpi__icon { background: #e8eefc; color: #2f5fd0; }
.kpi--amber .kpi__icon { background: #fff3df; color: #b87400; }
.kpi--red .kpi__icon { background: #fde7e9; color: var(--red); }
.kpi--navy .kpi__icon { background: #e8eef5; color: var(--navy); }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.dash-chart {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px 12px;
  box-shadow: 0 6px 18px rgba(12,26,48,.05);
}
.dash-chart h3 { font-size: 15px; margin-bottom: 4px; }
.dash-chart__lead { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.dash-chart svg { width: 100%; height: auto; display: block; }
.dash-chart .bar { fill: #16365f; }
.dash-chart .bar:hover { fill: var(--red); }
.dash-chart .area { fill: rgba(214,40,51,.12); }
.dash-chart .line { fill: none; stroke: var(--red); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.dash-chart .dot { fill: var(--red); }
.dash-chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.dash-chart .grid-line { stroke: var(--line); stroke-width: 1; }

.dash-insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.dash-insight {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 4px 14px rgba(12,26,48,.04);
}
.dash-insight__label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.dash-insight__value {
  display: block;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.dash-insight__meta {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--body);
}
.dash-insight--risk .dash-insight__value { color: var(--red); font-size: 14px; font-weight: 700; }

/* Journey timeline */
.journey {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.journey__step {
  position: relative;
  text-align: center;
  padding: 16px 10px 14px;
  border-radius: 16px;
  background: #fff;
  border: 1.5px solid var(--line);
  cursor: default;
  transition: .2s ease;
}
.journey__step::after {
  content: "";
  position: absolute; top: 28px; left: calc(50% + 22px); right: calc(-50% + 22px);
  height: 2px; background: var(--line); z-index: 0;
}
.journey__step:last-child::after { display: none; }
.journey__num {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  width: 36px; height: 36px; margin: 0 auto 10px;
  border-radius: 50%;
  background: #eef1f5; color: var(--muted);
  font-size: 13px; font-weight: 800;
}
.journey__title { font-size: 12.5px; font-weight: 700; color: var(--body); line-height: 1.3; }
.journey__step.is-done {
  border-color: #b6e5cb;
  background: linear-gradient(180deg, #f4fcf8, #fff);
}
.journey__step.is-done .journey__num { background: var(--green); color: #fff; }
.journey__step.is-done::after { background: #b6e5cb; }
.journey__step.is-active {
  border-color: var(--red-light);
  box-shadow: 0 10px 28px rgba(214,40,51,.15);
  transform: translateY(-3px);
}
.journey__step.is-active .journey__num { background: var(--red); color: #fff; }
.journey__step.is-active .journey__title { color: var(--ink); }
.journey__step.is-waiting .journey__num { background: var(--amber); color: #fff; }

.etapa-card__top {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 10px; margin-bottom: 12px;
}
.etapa-card h2 { font-size: 22px; }
.etapa-card .resumo { color: var(--body); font-size: 15px; }

/* Docs list */
.doc-list { display: grid; gap: 10px; }
.doc-item {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 14px 16px; border-radius: 14px;
  background: var(--bg); border: 1px solid var(--line);
}
.doc-item__name { font-weight: 700; font-size: 14.5px; }
.doc-item__meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
.doc-item__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.aviso-list { display: grid; gap: 10px; }
.aviso {
  padding: 14px 16px; border-radius: 14px;
  background: #fff8eb; border: 1px solid #f0dfb8;
}
.aviso time { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.aviso p { font-size: 14.5px; }

.empty {
  padding: 22px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 14px; background: #fafbfd;
}

/* Admin client cards */
.client-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.client-card {
  text-align: left; cursor: pointer;
  padding: 20px; border-radius: 18px;
  background: #fff; border: 1.5px solid var(--line);
  box-shadow: 0 8px 22px rgba(12,26,48,.06);
  transition: .2s ease;
}
.client-card:hover, .client-card.is-selected {
  border-color: var(--red-light);
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(214,40,51,.12);
}
.client-card h3 { font-size: 18px; margin-bottom: 4px; }
.client-card .cnpj { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.progress {
  height: 8px; border-radius: 999px; background: #e8edf4; overflow: hidden; margin: 10px 0 6px;
}
.progress > span {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--red-light));
}
.client-card .etapa-atual { font-size: 13px; color: var(--body); }

.admin-panel { display: none; }
.admin-panel.is-open { display: block; }

.etapa-admin {
  display: grid; gap: 12px;
}
.etapa-admin__row {
  display: grid; grid-template-columns: 1.2fr .9fr 1fr auto; gap: 10px; align-items: end;
  padding: 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line);
}
.etapa-admin__row .field { margin: 0; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 18px;
}

/* ---------- tabs CRM ---------- */
.tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 22px; padding: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
}
.tab {
  border: 0; background: transparent; color: var(--body);
  padding: 10px 16px; border-radius: 12px;
  font-weight: 700; font-size: 14px; cursor: pointer;
  transition: .18s ease;
}
.tab:hover { background: var(--bg); color: var(--ink); }
.tab.is-active { background: var(--navy); color: #fff; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.muted { color: var(--muted); font-size: 13px; }

.kpi-row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.badge--apto { background: #e4f7ee; color: var(--green); }
.badge--pendente { background: #fff3df; color: #b87400; }
.badge--inelegivel { background: #fde7e9; color: var(--red); }
.badge--atrasado { background: #fde7e9; color: var(--red); }
.badge--recebido { background: #e8eefc; color: #2f5fd0; }
.badge--arquivado { background: #eef1f5; color: var(--muted); }
.badge--agendada { background: #e8eefc; color: #2f5fd0; }
.badge--realizada { background: #e4f7ee; color: var(--green); }
.badge--cancelada { background: #eef1f5; color: var(--muted); }

.semaforo {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  vertical-align: middle; margin-right: 6px;
}
.semaforo--apto { background: var(--green); box-shadow: 0 0 0 3px rgba(32,156,104,.18); }
.semaforo--pendente { background: var(--amber); box-shadow: 0 0 0 3px rgba(217,146,26,.18); }
.semaforo--atrasado { background: var(--red); box-shadow: 0 0 0 3px rgba(214,40,51,.18); }

.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 14.5px;
}
.data-table th, .data-table td {
  text-align: left; padding: 14px 12px;
  border-bottom: 1px solid var(--line); vertical-align: top;
}
.data-table th {
  font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}
.data-table td.cell-ellipsis {
  white-space: nowrap;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header__meta { flex-wrap: wrap; justify-content: flex-end; }

.comp-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px 24px;
  margin: 0 0 22px;
  padding: 18px 22px;
  border-radius: 16px;
  background: linear-gradient(135deg, #0b1d36 0%, #16365f 55%, #1a4a7a 100%);
  color: #fff;
  box-shadow: 0 12px 28px rgba(11, 29, 54, .22);
}
.comp-banner__eyebrow {
  display: block;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .75;
  font-weight: 700;
}
.comp-banner__value {
  display: block;
  margin-top: 4px;
  font-size: clamp(1.6rem, 3vw, 2rem);
  letter-spacing: .04em;
  line-height: 1.1;
}
.comp-banner__hint {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  opacity: .8;
  max-width: 36ch;
}
.comp-banner__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: end;
}
.comp-banner__controls .field label {
  color: rgba(255,255,255,.8);
}
.comp-banner__controls select {
  background: #fff;
  color: var(--ink);
  min-width: 150px;
}
.comp-banner .btn--ghost-dark {
  background: transparent;
  color: #fff;
  border-color: rgba(255,255,255,.35);
}
.comp-banner .btn--ghost-dark:hover {
  background: rgba(255,255,255,.1);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
}
.form-grid .field-row,
.form-grid > .btn {
  grid-column: 1 / -1;
}

.followup-thread {
  display: grid;
  gap: 12px;
  max-height: 420px;
  overflow-y: auto;
  margin-top: 12px;
}
.followup {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
}
.followup header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}
.followup header strong { color: var(--ink); }
.followup p { margin: 0; font-size: 14.5px; line-height: 1.45; color: var(--body); }
.followup--interno {
  background: #fff8f0;
  border-color: #f0d9b8;
}
.followup--cliente {
  background: #f3f7ff;
  border-color: #d5e0f7;
}

.cadastro-view {
  display: grid;
  gap: 12px;
  margin: 0;
}
.cadastro-view > div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.cadastro-view dt {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.cadastro-view dd {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink);
}

@media (max-width: 980px) {
  .grid-2, .grid-3, .client-cards, .kpi-row, .dash-grid { grid-template-columns: 1fr 1fr; }
  .journey { grid-template-columns: repeat(3, 1fr); }
  .journey__step::after { display: none; }
  .etapa-admin__row { grid-template-columns: 1fr 1fr; }
  .tabs { gap: 4px; }
  .tab { padding: 9px 12px; font-size: 13px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .grid-2, .grid-3, .client-cards, .kpi-row, .dash-grid { grid-template-columns: 1fr; }
  .journey { grid-template-columns: 1fr 1fr; }
  .doc-item { grid-template-columns: 1fr; }
  .app-header__user { display: none; }
  .etapa-admin__row { grid-template-columns: 1fr; }
  .cadastro-view > div { grid-template-columns: 1fr; gap: 4px; }
  .field-row { grid-template-columns: 1fr; }
}
