/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold: #C9A84C;
  --gold-light: #E8C97A;
  --dark: #0E0E0E;
  --dark-2: #1A1A1A;
  --sidebar-w: 220px;
  --white: #fff;
  --bg: #F4F5F7;
  --border: #E5E7EB;
  --text: #1F2937;
  --text-light: #6B7280;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
}

html, body { height: 100%; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); display: flex; font-size: 14px; line-height: 1.6; overflow-x: hidden; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; border: none; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  flex-shrink: 0;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar__logo {
  width: 36px; height: 36px;
  background: var(--gold);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.sidebar__brand strong { display: block; color: white; font-size: 13px; }
.sidebar__brand span { font-size: 11px; color: rgba(255,255,255,0.4); }
.sidebar__nav { padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}
.sidebar__nav a:hover, .sidebar__nav a.active {
  background: rgba(255,255,255,0.08);
  color: white;
}
.sidebar__nav a.active { background: rgba(201,168,76,0.15); color: var(--gold-light); }

/* ===== MAIN ===== */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 32px;
  max-width: calc(100vw - var(--sidebar-w));
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-light); margin-top: 2px; }
.back-link { font-size: 13px; color: var(--text-light); margin-bottom: 4px; display: inline-block; }
.back-link:hover { color: var(--gold); }

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--gold);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  border: none;
  white-space: nowrap;
}
.btn-primary:hover { background: #a07830; transform: translateY(-1px); }
.btn-secondary {
  background: white;
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--border);
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }
.btn-mini {
  background: var(--bg);
  color: var(--text-light);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
}
.btn-mini:hover { background: var(--gold); color: white; border-color: var(--gold); }
.btn-mini--del:hover { background: #e74c3c; border-color: #e74c3c; color: white; }

/* ===== CARDS ===== */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card__title { font-size: 15px; font-weight: 600; margin-bottom: 20px; }
.card--full { grid-column: 1 / -1; }

/* ===== METRICS GRID ===== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.metric-card--gold { border-left: 3px solid var(--gold); }
.metric-card__icon { font-size: 28px; flex-shrink: 0; }
.metric-card__value { display: block; font-size: 24px; font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 4px; }
.metric-card__label { font-size: 12px; color: var(--text-light); }

/* ===== SECTION GRID ===== */
.section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ===== FUNIL ===== */
.funil { display: flex; flex-direction: column; gap: 10px; }
.funil-row { display: grid; grid-template-columns: 160px 1fr 40px; align-items: center; gap: 12px; }
.funil-row__label { font-size: 13px; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funil-row__bar-wrap { background: var(--bg); border-radius: 4px; height: 20px; overflow: hidden; }
.funil-row__bar { height: 100%; background: linear-gradient(90deg, var(--gold-light), var(--gold)); border-radius: 4px; transition: width 0.6s ease; }
.funil-row__count { font-size: 13px; font-weight: 600; color: var(--text); text-align: right; }

/* ===== BAR CHART ===== */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr; align-items: center; gap: 12px; }
.bar-row__label { font-size: 13px; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row__wrap { display: flex; align-items: center; gap: 8px; }
.bar-row__bar { height: 16px; background: var(--gold); border-radius: 4px; transition: width 0.5s ease; min-width: 4px; }
.bar-row__val { font-size: 12px; font-weight: 600; color: var(--text); }

/* ===== FOLLOW-UPS ===== */
.followups-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.followup-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  gap: 12px;
  border-left: 3px solid var(--gold);
}
.followup-item--late { border-left-color: #e74c3c; background: #fff5f5; }
.followup-item__info strong { display: block; font-size: 13px; font-weight: 600; }
.followup-item__info span { font-size: 12px; color: var(--text-light); }
.followup-item__date { font-size: 12px; font-weight: 600; color: var(--text-light); white-space: nowrap; }

/* ===== INVESTIMENTOS TABLE ===== */
.inv-header, .inv-row {
  display: grid;
  grid-template-columns: 120px 1fr 120px 40px;
  gap: 12px;
  padding: 10px 12px;
  align-items: center;
  font-size: 13px;
}
.inv-header { background: var(--bg); border-radius: var(--radius-sm); font-weight: 600; color: var(--text-light); font-size: 12px; }
.inv-row { border-bottom: 1px solid var(--border); }
.inv-row:last-child { border-bottom: none; }

/* ===== FILTERS ===== */
.filters { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-select {
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  background: white;
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--gold); }

/* ===== KANBAN ===== */
.kanban {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  min-height: calc(100vh - 200px);
}
.kanban-col {
  flex-shrink: 0;
  width: 240px;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.kanban-col__header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.kanban-col__emoji { font-size: 16px; }
.kanban-col__title { font-size: 13px; font-weight: 600; flex: 1; }
.kanban-col__count {
  font-size: 11px;
  font-weight: 700;
  color: white;
  padding: 2px 8px;
  border-radius: 50px;
}
.kanban-col__cards {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 60px;
  transition: background 0.2s;
}
.kanban-col__cards.drag-over { background: rgba(201,168,76,0.06); }
.kanban-col__empty { font-size: 12px; color: #ccc; text-align: center; padding: 16px 0; }
.kanban-col__empty.hidden { display: none; }

/* ===== KANBAN CARD ===== */
.kanban-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: grab;
  transition: box-shadow 0.2s, transform 0.2s;
}
.kanban-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); transform: translateY(-2px); }
.kanban-card.dragging { opacity: 0.5; cursor: grabbing; }
.kanban-card--followup { border-left: 3px solid #e74c3c; }
.kanban-card__top { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.kanban-card__avatar {
  width: 32px; height: 32px;
  background: var(--gold);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.kanban-card__info { flex: 1; min-width: 0; }
.kanban-card__info strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kanban-card__info span { font-size: 11px; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.kanban-card__edit { background: none; border: none; font-size: 14px; padding: 2px 4px; opacity: 0.5; transition: opacity 0.2s; flex-shrink: 0; }
.kanban-card__edit:hover { opacity: 1; }
.kanban-card__tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tag { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 50px; letter-spacing: 0.03em; }
.tag--origem { background: rgba(201,168,76,0.15); color: #a07830; }
.tag--valor { background: rgba(39,174,96,0.12); color: #1e8449; }
.kanban-card__followup { font-size: 11px; color: #e74c3c; background: #fff5f5; padding: 4px 8px; border-radius: 4px; margin-bottom: 8px; }
.kanban-card__footer { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-light); }
.kanban-card__link { color: var(--gold); font-weight: 600; font-size: 11px; }
.kanban-card__link:hover { text-decoration: underline; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
}
.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
.modal__header h2 { font-size: 16px; font-weight: 700; }
.modal__close { font-size: 24px; color: var(--text-light); background: none; border: none; line-height: 1; }
.modal__close:hover { color: var(--text); }
.modal__form { padding: 24px; display: flex; flex-direction: column; gap: 0; }
.modal__actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

/* ===== FORM ===== */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 0; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.04em; }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: white;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--gold); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* ===== PACIENTE PAGE ===== */
.paciente-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.whatsapp-action {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 14px 16px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--radius-sm);
  font-size: 24px;
}
.whatsapp-action strong { display: block; font-size: 13px; font-weight: 600; }
.whatsapp-action a { font-size: 13px; color: #16a34a; }

.followup-status {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}
.followup-status--late { background: #fff5f5; color: #e74c3c; }
.followup-status--today { background: #fffbeb; color: #d97706; }
.followup-status--ok { background: #f0fdf4; color: #16a34a; }

.nota-form { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 20px; }
.nota-form textarea { flex: 1; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; outline: none; resize: none; }
.nota-form textarea:focus { border-color: var(--gold); }

.notas-list { display: flex; flex-direction: column; gap: 12px; }
.notas-empty { color: var(--text-light); font-size: 13px; text-align: center; padding: 24px 0; }
.nota-item { background: var(--bg); border-radius: var(--radius-sm); padding: 14px 16px; }
.nota-item__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.nota-item__date { font-size: 11px; color: var(--text-light); }
.nota-item__del { background: none; border: none; font-size: 18px; color: var(--text-light); line-height: 1; padding: 0 4px; }
.nota-item__del:hover { color: #e74c3c; }
.nota-item p { font-size: 13px; line-height: 1.7; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--dark);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.3s;
  z-index: 9999;
}
.toast--show { opacity: 1; transform: translateY(0); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .section-grid { grid-template-columns: 1fr; }
  .paciente-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px 16px; max-width: 100vw; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}
