/* ── VARIÁVEIS ─────────────────────────────────────────── */
:root {
  --blue:     #2563eb;
  --blue-lt:  #eff6ff;
  --blue-mid: #bfdbfe;
  --green:    #16a34a;
  --green-lt: #f0fdf4;
  --orange:   #d97706;
  --orange-lt:#fffbeb;
  --red:      #dc2626;
  --red-lt:   #fef2f2;
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --sidebar-w: 220px;
  --radius:   10px;
  --shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:0 4px 12px rgba(0,0,0,.1);
}

/* ── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
       font-size: 14px; color: var(--gray-900); background: var(--gray-50); line-height: 1.5; }
a { cursor: pointer; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }
svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

/* ── LAYOUT ─────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.logo-icon {
  width: 36px; height: 36px;
  background: var(--blue);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  color: #fff; flex-shrink: 0;
}
.logo-text { display: flex; flex-direction: column; }
.logo-name { font-size: 13px; font-weight: 600; color: #fff; }
.logo-sub  { font-size: 11px; color: var(--gray-400); }

.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--gray-400);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-item svg { width: 16px; height: 16px; }

.sidebar-footer {
  padding: 14px 16px;
  font-size: 11px;
  color: var(--gray-500);
  border-top: 1px solid rgba(255,255,255,.06);
}

/* ── CONTENT ─────────────────────────────────────────────── */
.content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }
.view { display: none; padding: 28px 32px; }
.view.active { display: block; }

/* ── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.page-sub   { font-size: 13px; color: var(--gray-500); margin-top: 2px; }
.header-actions { display: flex; gap: 8px; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px; font-weight: 500;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn-primary  { background: var(--blue); color: #fff; }
.btn-primary:hover  { background: #1d4ed8; }
.btn-ghost    { background: transparent; color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-ghost:hover    { background: var(--gray-100); }
.btn-danger   { background: var(--red); color: #fff; }
.btn-danger:hover   { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: 6px; }

/* ── STATS ───────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}
.stat-card.stat-warn { border-left: 3px solid var(--orange); }
.stat-value { font-size: 32px; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 6px; }

/* ── SECTIONS GRID ───────────────────────────────────────── */
.sections-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.dash-section-full { grid-column: 1 / -1; }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.dash-section { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--gray-200); overflow: hidden; }
.section-header { padding: 14px 18px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: 13px; font-weight: 600; color: var(--gray-700); display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-orange { background: var(--orange); }
.dot-blue   { background: var(--blue); }
.dot-red    { background: var(--red); }

/* ── ALERT LIST ──────────────────────────────────────────── */
.alert-list { max-height: 280px; overflow-y: auto; }
.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--gray-100);
  gap: 12px;
}
.alert-item:last-child { border-bottom: none; }
.alert-item:hover { background: var(--gray-50); }
.alert-info { flex: 1; min-width: 0; }
.alert-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-meta { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.alert-date { font-size: 12px; font-weight: 500; white-space: nowrap; }
.alert-date.overdue { color: var(--red); }
.alert-date.soon    { color: var(--orange); }
.alert-date.ok      { color: var(--green); }
.alert-actions { display: flex; gap: 4px; }

/* ── SEARCH ──────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 9px 14px;
  margin-bottom: 16px;
  color: var(--gray-400);
}
.search-bar input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14px; color: var(--gray-900);
}
.search-bar input::placeholder { color: var(--gray-400); }

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-50); cursor: pointer; }
.data-table tbody tr:hover .row-actions { opacity: 1; }
.row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-green  { background: var(--green-lt);  color: var(--green); }
.badge-blue   { background: var(--blue-lt);   color: var(--blue); }
.badge-orange { background: var(--orange-lt); color: var(--orange); }
.badge-gray   { background: var(--gray-100);  color: var(--gray-500); }
.badge-red    { background: var(--red-lt);    color: var(--red); }

/* ── PROGRESS BAR ────────────────────────────────────────── */
.progress-wrap { display: flex; align-items: center; gap: 8px; }
.progress-bar  {
  flex: 1; height: 6px;
  background: var(--gray-100);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 99px;
  background: var(--blue);
  transition: width .3s;
}
.progress-text { font-size: 12px; color: var(--gray-500); white-space: nowrap; }

/* ── DETALHE ─────────────────────────────────────────────── */
.detalhe-grid { display: grid; grid-template-columns: 380px 1fr; gap: 18px; align-items: start; }
.detalhe-left  { display: flex; flex-direction: column; gap: 18px; }
.detalhe-right { display: flex; flex-direction: column; gap: 18px; }

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--gray-700); }
.card-body  { padding: 18px 20px; }

.info-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.info-row:last-child { margin-bottom: 0; }
.info-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-400); min-width: 120px; margin-top: 2px; }
.info-value { font-size: 14px; color: var(--gray-900); flex: 1; }

.pacote-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}
.pacote-stat { text-align: center; }
.pacote-stat-value { font-size: 24px; font-weight: 700; color: var(--gray-900); }
.pacote-stat-label { font-size: 11px; color: var(--gray-500); margin-top: 2px; }

.contato-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.contato-row:last-child { border-bottom: none; }
.contato-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.contato-info { flex: 1; min-width: 0; }
.contato-tipo { font-size: 12px; font-weight: 600; }
.contato-meta { font-size: 11px; color: var(--gray-400); }
.contato-data { font-size: 12px; color: var(--gray-500); white-space: nowrap; }

.consulta-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.consulta-row:last-child { border-bottom: none; }
.consulta-info { flex: 1; }
.consulta-data { font-weight: 600; font-size: 13px; }
.consulta-obs  { font-size: 12px; color: var(--gray-500); }

.empty-state { padding: 32px; text-align: center; color: var(--gray-400); font-size: 13px; }

/* ── FORM ────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group:last-of-type { margin-bottom: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--gray-700); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 7px;
  font-size: 13px;
  color: var(--gray-900);
  background: #fff;
  transition: border-color .15s;
  outline: none;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.form-group textarea { resize: vertical; }

/* ── MODAL ───────────────────────────────────────────────── */
.backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 40;
  backdrop-filter: blur(2px);
}
.backdrop.open { display: block; }

.modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  width: 460px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 50;
}
.modal.open { display: block; }
.modal-lg { width: 560px; }
.modal-sm { width: 360px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 20px; line-height: 1;
  color: var(--gray-400);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
form { padding: 20px; }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--gray-100);
  margin-top: 4px;
}

/* ── TOAST ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 12px 18px;
  border-radius: 9px;
  background: var(--gray-900);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 100;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

/* ── MISC ────────────────────────────────────────────────── */
.phone-link { color: var(--blue); font-size: 13px; }
.phone-link:hover { text-decoration: underline; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  background: var(--gray-100); color: var(--gray-600);
}
.text-muted { color: var(--gray-400); font-size: 12px; }
.pacote-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ── CORES DE URGÊNCIA (texto) ───────────────────────────── */
.cor-verde    { color: var(--green); }
.cor-amarelo  { color: #ca8a04; }
.cor-laranja  { color: var(--orange); }
.cor-vermelho { color: var(--red); }

/* ── PILL colorida (presenciais) ─────────────────────────── */
.pill {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.cor-bg-verde    { background: var(--green-lt);  color: var(--green); }
.cor-bg-amarelo  { background: #fef9c3;          color: #a16207; }
.cor-bg-laranja  { background: var(--orange-lt); color: var(--orange); }
.cor-bg-vermelho { background: var(--red-lt);    color: var(--red); }

/* ── BADGES (cores PT) ───────────────────────────────────── */
.badge-verde    { background: var(--green-lt);  color: var(--green); }
.badge-amarelo  { background: #fef9c3;          color: #a16207; }
.badge-laranja  { background: var(--orange-lt); color: var(--orange); }
.badge-vermelho { background: var(--red-lt);    color: var(--red); }
.badge-azul     { background: var(--blue-lt);   color: var(--blue); }
.badge-roxo     { background: #f3e8ff;          color: #7c3aed; }

/* ── STAT CARDS coloridos ────────────────────────────────── */
.stat-card.stat-orange { border-left: 3px solid var(--orange); }
.stat-card.stat-yellow { border-left: 3px solid #ca8a04; }
.stat-card.stat-red    { border-left: 3px solid var(--red); }
.stat-card.stat-purple { border-left: 3px solid #7c3aed; }

/* ── DOTS extras ─────────────────────────────────────────── */
.dot-green  { background: var(--green); }
.dot-purple { background: #7c3aed; }
.dot-gray   { background: var(--gray-400); }

/* ── CHECKLIST ───────────────────────────────────────────── */
.check-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
}
.check-row:last-child { border-bottom: none; }
.check-row input { display: none; }
.check-box {
  width: 22px; height: 22px;
  border: 2px solid var(--gray-300);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0; transition: all .15s;
}
.check-row.checked .check-box { background: var(--green); border-color: var(--green); }
.check-label { font-size: 13px; color: var(--gray-700); }
.check-row.checked .check-label { color: var(--gray-400); text-decoration: line-through; }

.chip-ok { background: var(--green-lt); color: var(--green); }

/* ── GRUPOS DE CHECKLIST ─────────────────────────────────── */
.check-grupo { margin-bottom: 8px; }
.check-grupo + .check-grupo { margin-top: 8px; padding-top: 4px; border-top: 1px dashed var(--gray-200); }
.check-grupo-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--gray-500); padding: 8px 0 2px;
}
.check-row.check-pend .check-box { border-color: var(--red); }
.check-row.check-pend .check-label { color: var(--red); text-decoration: none; }
.btn-disabled { opacity: .45; cursor: not-allowed; }

/* ── ORDENAÇÃO DE TABELA ──────────────────────────────────── */
.data-table.sortable th { cursor: pointer; user-select: none; }
.data-table.sortable th:hover { color: var(--gray-700); }
.sort-ind { font-size: 10px; color: var(--blue); margin-left: 2px; }

/* ── ADENDOS (rotina) ─────────────────────────────────────── */
.adendos-row { display: flex; gap: 16px; flex-wrap: wrap; padding-top: 4px; }
.adendo-chk { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; cursor: pointer; }
.adendo-chk input { width: 16px; height: 16px; }

/* ── LINK "ver tudo" ──────────────────────────────────────── */
.link-ver { font-size: 12px; color: var(--blue); cursor: pointer; font-weight: 500; }
.link-ver:hover { text-decoration: underline; }

/* ── DIVIDER ─────────────────────────────────────────────── */
.divider { height: 1px; background: var(--gray-100); margin: 14px 0; }

/* ── STAT CARDS extras ───────────────────────────────────── */
.stat-card.stat-green { border-left: 3px solid var(--green); }
.stat-card.stat-blue  { border-left: 3px solid var(--blue); }

/* ── GRÁFICO DE BARRAS ───────────────────────────────────── */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 200px;
  padding-top: 10px;
  overflow-x: auto;
}
.chart-col {
  flex: 1; min-width: 42px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  height: 100%;
}
.chart-val { font-size: 10px; font-weight: 600; color: var(--gray-500); margin-bottom: 4px; height: 14px; }
.chart-bar {
  width: 100%;
  max-width: 46px;
  background: linear-gradient(180deg, var(--blue) 0%, #60a5fa 100%);
  border-radius: 6px 6px 0 0;
  transition: height .3s, opacity .15s;
}
.chart-col:hover .chart-bar { opacity: .8; }
.chart-lbl { font-size: 11px; color: var(--gray-600); text-align: center; margin-top: 6px; line-height: 1.2; }

/* ── HISTÓRICO FINANCEIRO ────────────────────────────────── */
.fin-mes { border-bottom: 1px solid var(--gray-100); }
.fin-mes:last-child { border-bottom: none; }
.fin-mes-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; cursor: pointer;
}
.fin-mes-head:hover { background: var(--gray-50); }
.fin-mes-nome { font-weight: 600; font-size: 14px; }
.fin-mes.open .fin-mes-nome::first-letter { } /* placeholder */
.fin-mes.open .fin-mes-nome { color: var(--blue); }
.fin-mes-resumo { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.fin-mes-itens { display: none; padding: 0 18px 12px; }
.fin-mes.open .fin-mes-itens { display: block; }
.fin-item {
  display: grid;
  grid-template-columns: 90px 1fr 1fr auto;
  gap: 12px; align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--gray-100);
  font-size: 13px;
}
.fin-item-data { color: var(--gray-500); font-size: 12px; }
.fin-item-nome { font-weight: 600; }
.fin-item-valor { font-weight: 600; color: var(--green); text-align: right; }

/* ── SIDEBAR: usuário / logout ───────────────────────────── */
.sidebar-user {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.sidebar-user-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-name { font-size: 12px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 10px; color: var(--gray-400); }
.btn-logout {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px;
  color: var(--gray-400); background: rgba(255,255,255,.06);
  transition: background .15s, color .15s; flex-shrink: 0;
}
.btn-logout:hover { background: var(--red); color: #fff; }
.btn-logout svg { width: 15px; height: 15px; }

/* ── LOGIN ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--gray-100); padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 32px 28px;
}
.login-logo {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 20px; margin-bottom: 20px;
  border-bottom: 1px solid var(--gray-200);
}
.login-logo .logo-name { color: var(--gray-900); }
.login-logo .logo-sub  { color: var(--gray-500); }
.login-title { font-size: 17px; font-weight: 600; margin-bottom: 18px; }
.login-erro {
  color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 6px;
}
