/* IDV MI Analytics
   creme #F4F0E8 | escuro #221E41 | vinho #A81C4A | neutro #C2BEB2
   titulos Playfair Display | corpo Poppins */
:root {
  --creme: #F4F0E8;
  --escuro: #221E41;
  --vinho: #A81C4A;
  --neutro: #C2BEB2;
  --creme-card: #FFFFFF;
  --neutro-suave: #E7E3D9;
  --sombra: 0 1px 2px rgba(34, 30, 65, .05), 0 8px 24px rgba(34, 30, 65, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--creme);
  color: var(--escuro);
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--escuro);
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
}

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

/* ---------- loading ---------- */
#root.loading {
  display: grid;
  place-items: center;
  min-height: 100vh;
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--neutro-suave);
  border-top-color: var(--vinho);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons / inputs ---------- */
.btn {
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 16px;
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  cursor: pointer;
  transition: filter .15s ease, opacity .15s ease;
  width: 100%;
}
.btn-primary { background: var(--vinho); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--escuro);
  border: 1px solid var(--neutro);
  width: auto;
  padding: 9px 16px;
  font-size: 14px;
  border-radius: 10px;
}
.btn-ghost:hover { background: var(--neutro-suave); }
.btn-confirm {
  font: 600 12px/1 'Poppins', system-ui, sans-serif;
  color: #fff;
  background: var(--escuro);
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  margin-left: 8px;
  cursor: pointer;
  width: auto;
}
.btn-confirm:hover { filter: brightness(1.18); }
.btn-confirm:disabled { opacity: .5; cursor: not-allowed; }

label { font-size: 14px; font-weight: 500; display: block; margin-bottom: 7px; }
.req { color: var(--vinho); }
.field { margin-bottom: 18px; text-align: left; }
input[type=email], input[type=password], input[type=text], input[type=tel],
input[type=date], select, textarea {
  width: 100%;
  font-family: 'Poppins', sans-serif;
  font-size: 16px;
  padding: 13px 15px;
  border: 1px solid var(--neutro);
  border-radius: 12px;
  background: #fff;
  color: var(--escuro);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; line-height: 1.5; }
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='%23A81C4A' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 15px center; padding-right: 38px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--vinho);
  box-shadow: 0 0 0 3px rgba(168, 28, 74, .12);
}
.static-field { padding: 12px 15px; border: 1px dashed var(--neutro); border-radius: 12px;
  color: #6b6780; font-size: 15px; background: var(--creme); }
.static-field small { color: #9a96a8; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }

.error {
  background: rgba(168, 28, 74, .08);
  color: var(--vinho);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  text-align: left;
}

/* ---------- login ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--creme-card);
  border-radius: 22px;
  padding: 38px 32px 34px;
  box-shadow: var(--sombra);
  text-align: center;
}
.brand {
  font-family: 'Playfair Display', serif;
  font-size: 13px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--vinho);
  margin-bottom: 6px;
}
.auth-card h1 { font-size: 27px; margin-bottom: 6px; }
.auth-sub { color: #6b6780; font-size: 14.5px; margin: 0 0 28px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  background: var(--escuro);
  color: var(--creme);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .tb-brand {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .02em;
}
.topbar .tb-brand small {
  display: block;
  font-family: 'Poppins', sans-serif;
  font-weight: 300;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--neutro);
}
.topbar .btn-ghost { color: var(--creme); border-color: rgba(255,255,255,.28); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.1); }

/* ---------- page shell (desktop-first, confortavel para edicao) ---------- */
.page { max-width: 1040px; margin: 0 auto; padding: 30px 28px 64px; }
.page-head { margin-bottom: 24px; }
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-head h1 { font-size: 30px; margin-bottom: 4px; }
.page-head p { color: #6b6780; font-size: 15px; margin: 0; }
.btn-inline { width: auto; flex: none; padding: 12px 20px; font-size: 15px; white-space: nowrap; }
.count-pill {
  display: inline-block;
  background: var(--neutro-suave);
  color: var(--escuro);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 999px;
  margin-top: 10px;
}

/* ---------- patient cards ---------- */
.list { display: flex; flex-direction: column; gap: 13px; }
/* No desktop, cartoes em 2 colunas para aproveitar a largura e dar respiro. */
.list.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.card {
  background: var(--creme-card);
  border-radius: 16px;
  padding: 18px 18px 14px;
  box-shadow: var(--sombra);
  display: flex;
  flex-direction: column;
}
.card-actions { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--neutro-suave); text-align: right; display: flex; gap: 4px; justify-content: flex-end; }
.btn-link {
  background: none; border: none; cursor: pointer;
  color: var(--vinho); font-family: 'Poppins', sans-serif; font-size: 13.5px; font-weight: 500;
  padding: 4px 6px; border-radius: 8px;
}
.btn-link:hover { background: rgba(168,28,74,.08); }
/* acao destrutiva discreta (excluir): cinza por padrao, vermelho no hover */
.btn-link-danger { color: var(--neutro); }
.btn-link-danger:hover { color: #b3261e; background: rgba(179,38,30,.08); }
.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.card-name {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--escuro);
}
.card-phone {
  font-size: 13.5px;
  color: #6b6780;
  margin-top: 2px;
}
.card-phone a { color: #6b6780; text-decoration: none; }
.card-note {
  margin-top: 12px;
  font-size: 14.5px;
  color: #3b3756;
  background: var(--creme);
  border-radius: 11px;
  padding: 11px 13px;
  border-left: 3px solid var(--neutro);
}
.card-note .note-label {
  display: block;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #9a96a8;
  margin-bottom: 3px;
}
.card-note.empty { color: #9a96a8; font-style: italic; }

/* ---------- status badge ---------- */
.badge {
  flex: none;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-ativo  { background: rgba(168,28,74,.10);  color: var(--vinho);  border-color: rgba(168,28,74,.22); }
.badge-novo   { background: rgba(34,30,65,.07);   color: var(--escuro); border-color: rgba(34,30,65,.16); }
.badge-andamento { background: #EDE7D9; color: #8a6d1f; border-color: #ddd0ac; }
.badge-neutro { background: var(--neutro-suave); color: #5b5872; border-color: var(--neutro); }

/* ---------- empty ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #6b6780;
}
.empty-state h2 { font-size: 21px; margin-bottom: 8px; }

/* ---------- termo ---------- */
.terms-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 18px 30px;
}
.terms-card {
  width: 100%;
  max-width: 680px;
  background: var(--creme-card);
  border-radius: 22px;
  box-shadow: var(--sombra);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 56px);
}
.terms-header { padding: 26px 28px 16px; border-bottom: 1px solid var(--neutro-suave); }
.terms-header h1 { font-size: 23px; }
.terms-header p { color: #6b6780; font-size: 14px; margin: 6px 0 0; }
.terms-body {
  padding: 20px 28px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 15px;
  color: #3b3756;
}
.terms-body h2 {
  font-size: 19px;
  margin: 4px 0 14px;
}
.terms-body p { margin: 0 0 14px; }
.terms-body strong { color: var(--escuro); }
.terms-body hr { border: none; border-top: 1px solid var(--neutro-suave); margin: 18px 0; }
.terms-body em { color: #6b6780; }
.terms-footer {
  padding: 18px 28px 24px;
  border-top: 1px solid var(--neutro-suave);
  background: var(--creme);
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 16px;
  font-size: 14.5px;
  text-align: left;
  cursor: pointer;
  user-select: none;
}
.check-row input { width: 20px; height: 20px; accent-color: var(--vinho); margin-top: 1px; flex: none; }

/* ---------- abas no topbar ---------- */
.tabs { display: flex; gap: 6px; flex: 1; justify-content: center; }
.tab {
  background: transparent; border: none; cursor: pointer;
  font-family: 'Poppins', sans-serif; font-size: 14.5px; font-weight: 500;
  color: var(--neutro); padding: 8px 16px; border-radius: 999px;
  transition: background .15s ease, color .15s ease;
}
.tab:hover { color: var(--creme); background: rgba(255,255,255,.08); }
.tab-active { color: var(--escuro); background: var(--creme); }
.tab-active:hover { color: var(--escuro); background: var(--creme); }

/* ---------- financeiro: totais ---------- */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 26px; }
.total-card {
  background: var(--creme-card); border-radius: 16px; padding: 18px 20px;
  box-shadow: var(--sombra); border-left: 4px solid var(--neutro);
}
.total-card.recebido { border-left-color: var(--vinho); }
.total-card.pendente { border-left-color: #c89a2a; }
.total-card.total { border-left-color: var(--escuro); }
.total-label { display: block; font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: #9a96a8; margin-bottom: 8px; }
.total-value { font-family: 'Playfair Display', serif; font-size: 26px; font-weight: 600; color: var(--escuro); }

/* ---------- financeiro: tabela ---------- */
.table-wrap { background: var(--creme-card); border-radius: 16px; box-shadow: var(--sombra); overflow: hidden; }
.fin-table { width: 100%; border-collapse: collapse; }
.fin-table thead th {
  text-align: left; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: #9a96a8; font-weight: 500; padding: 14px 20px; background: var(--creme);
  border-bottom: 1px solid var(--neutro-suave);
}
.fin-table tbody td { padding: 15px 20px; font-size: 14.5px; color: var(--escuro);
  border-bottom: 1px solid var(--neutro-suave); }
.fin-table tbody tr:last-child td { border-bottom: none; }
.fin-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(34,30,65,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 18px; z-index: 50; overflow-y: auto;
}
.modal-card {
  background: var(--creme-card); border-radius: 20px; width: 100%; max-width: 520px;
  box-shadow: 0 12px 40px rgba(34,30,65,.25); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 26px 16px; border-bottom: 1px solid var(--neutro-suave);
}
.modal-head h2 { font-size: 22px; }
.modal-close {
  background: none; border: none; cursor: pointer; font-size: 26px; line-height: 1;
  color: #9a96a8; padding: 0 4px;
}
.modal-close:hover { color: var(--vinho); }
.modal-body { padding: 22px 26px 26px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }
.modal-actions .btn-ghost { width: auto; }
.modal-actions .btn { width: auto; flex: none; }
/* edicao: excluir a esquerda, cancelar/salvar a direita */
.modal-actions-split { justify-content: space-between; align-items: center; }
.modal-actions-right { display: flex; gap: 12px; }
/* botao destrutivo principal (confirmacao de exclusao) */
.btn-danger { background: #b3261e; color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }
.btn-danger:disabled { opacity: .5; cursor: not-allowed; }
/* texto do modal de confirmacao */
.confirm-text { font-size: 15.5px; color: var(--escuro); margin: 4px 0 8px; }
.confirm-sub { font-size: 13.5px; color: var(--neutro); margin: 0 0 20px; }
.edit-name { font-family: 'Playfair Display', serif; font-size: 20px; color: var(--escuro); margin-bottom: 18px; }
.form-msg {
  display: none; background: rgba(168,28,74,.08); color: var(--vinho);
  border-radius: 10px; padding: 11px 14px; font-size: 14px; margin-bottom: 16px;
}

/* ---------- responsive (desktop-first; mobile = consulta rapida) ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 14px 18px; }
  .tabs { order: 3; width: 100%; justify-content: flex-start; flex: none; }
  .page { padding: 22px 16px 56px; }
  .page-head h1 { font-size: 25px; }
  .page-head-row { flex-direction: column; gap: 14px; }
  .btn-inline { width: 100%; }
  .totals { grid-template-columns: 1fr; gap: 12px; }
  .field-row { flex-direction: column; gap: 0; }
  .total-value { font-size: 23px; }
}
@media (max-width: 380px) {
  .auth-card { padding: 30px 22px 28px; }
  .terms-body, .terms-header, .terms-footer { padding-left: 20px; padding-right: 20px; }
}
.footnote {
  text-align: center;
  color: #9a96a8;
  font-size: 12px;
  margin-top: 26px;
}

.btn-edit-pay {
  font: 600 12px/1 'Poppins', system-ui, sans-serif;
  color: var(--vinho);
  background: transparent;
  border: 1px solid var(--vinho);
  border-radius: 6px;
  padding: 4px 9px;
  margin-left: 6px;
  cursor: pointer;
  width: auto;
}
.btn-edit-pay:hover { background: rgba(168,28,74,.06); }

/* ============================================================
   SHELL com sidebar — fiel ao modelo aprovado (MI Comercial)
   ============================================================ */
.shell { width: min(1220px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 56px; }

.app-header {
  display: grid; grid-template-columns: 1fr auto; gap: 20px;
  align-items: end; margin-bottom: 22px;
}
.app-header-main .eyebrow {
  color: var(--vinho); font-size: 12px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; margin: 0 0 6px;
}
.app-header-main h1 {
  font-family: 'Playfair Display', serif; color: var(--escuro);
  font-size: clamp(28px, 3.6vw, 42px); line-height: 1.05; margin: 0;
}
.app-header-main .subtitle { color: #6b6780; max-width: 640px; margin-top: 8px; font-size: 14.5px; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.top-actions .btn {
  border: 1px solid var(--neutro); background: var(--creme-card); color: var(--escuro);
  border-radius: 10px; min-height: 42px; padding: 0 16px; font-weight: 500; font-size: 14.5px;
  width: auto; cursor: pointer; transition: filter .15s ease, background .15s ease;
}
.top-actions .btn:hover { background: var(--neutro-suave); }
.top-actions .btn.primary { background: var(--escuro); color: #fff; border-color: var(--escuro); }
.top-actions .btn.primary:hover { filter: brightness(1.12); background: var(--escuro); }
.top-actions .btn:disabled { opacity: .55; cursor: not-allowed; }
.top-actions .btn-logout { color: #6b6780; }

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

aside {
  background: var(--creme-card); border: 1px solid var(--neutro-suave);
  border-radius: 16px; box-shadow: var(--sombra); padding: 14px; position: sticky; top: 16px;
}
.brandbox { border-bottom: 1px solid var(--neutro-suave); padding: 6px 6px 14px; margin-bottom: 10px; }
.brandbox strong { color: var(--escuro); display: block; font-family: 'Playfair Display', serif; font-size: 17px; }
.brandbox span { color: #9a96a8; font-size: 13px; }
nav#sidenav { display: flex; flex-direction: column; gap: 3px; }
.navlink {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  color: var(--escuro); text-decoration: none; padding: 11px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 500; transition: background .15s ease, color .15s ease;
}
.navlink:hover { background: var(--creme); }
.navlink.active { background: var(--escuro); color: #fff; }
.nav-hint { font-size: 11px; font-weight: 600; opacity: .6; }
.navlink.active .nav-hint { opacity: .75; }

.main { display: grid; gap: 16px; }
.loading-block { display: grid; place-items: center; min-height: 240px; }

/* ---- metricas (cards de topo) ---- */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric {
  background: var(--creme-card); border: 1px solid var(--neutro-suave);
  border-radius: 14px; padding: 16px 18px; box-shadow: var(--sombra);
}
.metric span { color: #9a96a8; font-size: 12.5px; }
.metric strong { color: var(--escuro); display: block; font-family: 'Playfair Display', serif;
  font-size: 28px; line-height: 1.1; margin-top: 6px; }
.metric small { color: var(--vinho); display: block; margin-top: 8px; font-weight: 500; font-size: 12.5px; }

/* ---- secoes (mesma linguagem do modelo) ---- */
.main section {
  background: var(--creme-card); border: 1px solid var(--neutro-suave);
  border-radius: 16px; box-shadow: var(--sombra); padding: 20px 22px; overflow: hidden;
}
.main section h2 { font-family: 'Playfair Display', serif; color: var(--escuro); font-size: 23px; margin-bottom: 4px; }
.section-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.section-head .muted, .muted { color: #6b6780; font-size: 14px; }
.section-head .btn-inline { flex: none; }

.split { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }

/* ---- chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; min-height: 28px;
  border: 1px solid var(--neutro-suave); border-radius: 999px; background: var(--creme);
  color: var(--escuro); padding: 4px 12px; font-size: 12px; font-weight: 500; white-space: nowrap;
}

/* ---- count row (leads) ---- */
.count-row { margin: -4px 0 14px; }

/* ---- timeline (prioridades / proximas) ---- */
.timeline { display: grid; gap: 12px; }
.timeline-card { }
.task { display: grid; grid-template-columns: 10px 1fr; gap: 12px; border-bottom: 1px solid var(--neutro-suave); padding-bottom: 12px; }
.task:last-child { border-bottom: 0; padding-bottom: 0; }
.task.done strong { color: #9a96a8; text-decoration: line-through; }
.dot { width: 10px; height: 10px; border-radius: 999px; background: var(--vinho); margin-top: 6px; }
.dot-done { background: var(--neutro); }
.task strong { color: var(--escuro); display: block; font-size: 14.5px; }
.task p { color: #6b6780; font-size: 13px; margin: 3px 0 0; }

/* ---- tabela operacional (agenda) ---- */
.ops-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.ops-table thead th {
  text-align: left; font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  color: #9a96a8; font-weight: 500; padding: 12px 14px; border-bottom: 1px solid var(--neutro-suave); background: var(--creme);
}
.ops-table tbody td { padding: 13px 14px; font-size: 14px; color: var(--escuro); border-bottom: 1px solid var(--neutro-suave); }
.ops-table tbody tr:last-child td { border-bottom: none; }
.ops-table .row-past td { color: #9a96a8; }
.status {
  display: inline-flex; border-radius: 999px; padding: 4px 10px; background: var(--creme);
  font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid var(--neutro-suave);
}
.status.ok { color: #247756; }
.status.warn { color: #9a6412; }
.status.danger { color: #b42318; }

/* ---- cards planos (rotina) ---- */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.card-flat { background: var(--creme); border: 1px solid var(--neutro-suave); border-radius: 12px; padding: 16px; }
.card-flat strong { color: var(--escuro); display: block; margin-bottom: 6px; font-family: 'Playfair Display', serif; font-size: 16px; }
.card-flat p { color: #6b6780; font-size: 13.5px; margin: 0; }
.placeholder-note {
  margin-top: 16px; font-size: 13px; color: #6b6780; background: var(--creme);
  border: 1px dashed var(--neutro); border-radius: 12px; padding: 13px 15px;
}

/* ---- responsive do shell ---- */
@media (max-width: 980px) {
  .app-header, .layout, .split { grid-template-columns: 1fr; }
  aside { position: static; }
  .top-actions { justify-content: flex-start; }
  .metrics, .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  nav#sidenav { flex-direction: row; flex-wrap: wrap; }
  .navlink { flex: 1 1 auto; }
}
@media (max-width: 620px) {
  .shell { width: calc(100% - 20px); padding-top: 18px; }
  .metrics, .cards { grid-template-columns: 1fr; }
  .main section { padding: 16px; }
  .section-head { flex-direction: column; }
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1 1 auto; }
}
