@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Acento admin (roxo) */
  --admin: #7C3AED;
  --admin-dark: #5B21B6;
  --admin-light: #EDE9FE;
  --admin-xlight: #F5F3FF;

  /* Marca azul */
  --brand-azul: #1B4FD8;
  --brand-azul-light: #EEF2FF;

  /* Status */
  --success: #16A34A;  --success-bg: #DCFCE7;
  --warn: #EF4444;     --warn-bg: #FEF2F2;
  --amber: #D97706;    --amber-bg: #FEF3C7;
  --cyan: #0891B2;     --cyan-bg: #ECFEFF;

  /* Escala cinza */
  --gray-50:  #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  /* Apelidos usados no app */
  --sidebar: #131929;
  --sidebar-muted: #94A3B8;
  --bg: var(--gray-50);
  --card: #ffffff;
  --border: var(--gray-200);
  --text: var(--gray-900);
  --muted: var(--gray-500);
  --red: var(--warn);
  --green: var(--success);

  --shadow: 0 4px 24px rgba(0,0,0,.10);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ════════════════════════════════════ Sidebar ════════════════════════════════════ */
.sidebar {
  width: 232px;
  background: var(--sidebar);
  color: #E2E8F0;
  display: flex;
  flex-direction: column;
  padding: 18px 0 14px;
  flex-shrink: 0;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 18px 18px;
  margin-bottom: 6px;
}
.sidebar .brand-logo { height: 30px; width: 30px; border-radius: 8px; flex-shrink: 0; }
.sidebar .brand-name { font-size: 17px; font-weight: 800; letter-spacing: -0.5px; color: #fff; }
.sidebar .brand-name span { color: var(--admin-light); }
.sidebar .brand-tag {
  margin-left: auto;
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: #A78BFA;
  background: rgba(124,58,237,.20);
  padding: 3px 8px; border-radius: 999px;
}

.sidebar nav { display: flex; flex-direction: column; gap: 14px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-group-label {
  font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--gray-600);
  padding: 0 18px 5px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px;
  color: var(--sidebar-muted);
  font-size: 12px; font-weight: 500;
  border-radius: 8px;
  margin: 0 8px;
}
.nav-link .nav-icon { width: 18px; font-size: 14px; text-align: center; flex-shrink: 0; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-link.active {
  background: rgba(124,58,237,.20);
  color: #C4B5FD;
  font-weight: 600;
}
.nav-badge-count {
  margin-left: auto;
  background: var(--warn); color: #fff;
  font-size: 8px; font-weight: 700;
  min-width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px; border-radius: 999px;
}
.nav-badge-count.purple { background: var(--admin); }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 14px 0;
  margin: auto 6px 0;
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 14px;
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--admin) 0%, var(--admin-dark) 100%);
  color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 10px; font-weight: 600; color: #E2E8F0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 8px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .05em; }
.logout-form { margin: 0; }
.logout-form button {
  background: none; border: 1px solid #334155; color: var(--sidebar-muted);
  width: 26px; height: 26px; border-radius: 7px; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.logout-form button:hover { color: #fff; border-color: #475569; }

/* ════════════════════════════════════ Main ════════════════════════════════════ */
main { flex: 1; padding: 24px 32px; overflow-x: auto; }

/* Topbar reutilizável (título + subtítulo à esquerda, ação à direita) */
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.topbar .tb-left { min-width: 0; }
.page-title { font-size: 21px; font-weight: 800; margin: 0 0 3px; letter-spacing: -0.5px; }
.page-sub { color: var(--muted); margin: 0; font-size: 13px; }
.topbar .tb-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar .tb-stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.topbar .tb-stats b { color: var(--text); font-weight: 700; }

/* ════════════════════════════════════ Banners ════════════════════════════════════ */
.banner { padding: 11px 15px; border-radius: 9px; margin-bottom: 16px; font-size: 13px; border: 1px solid transparent; }
.banner.ok   { background: var(--success-bg); color: #166534; border-color: #BBF7D0; }
.banner.warn { background: var(--amber-bg);   color: #92400e; border-color: #FDE68A; }
.banner.err  { background: var(--warn-bg);    color: #991b1b; border-color: #FECACA; }

/* ════════════════════════════════════ Metric cards ════════════════════════════════════ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 15px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.metric-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent;
}
.metric-card.amber::before  { background: var(--amber); }
.metric-card.purple::before { background: var(--admin); }
.metric-card.green::before  { background: var(--success); }
.metric-card.blue::before   { background: var(--brand-azul); }
.metric-card.red::before    { background: var(--warn); }
.metric-card.cyan::before   { background: var(--cyan); }
.metric-icon { font-size: 18px; line-height: 1; margin-bottom: 8px; }
.metric-value { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.1; }
.metric-value.amber { color: var(--amber); }
.metric-value.purple { color: var(--admin); }
.metric-label { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--gray-400); margin-top: 5px; }
.metric-delta { font-size: 9px; font-weight: 600; margin-top: 4px; }
.metric-delta.up { color: var(--success); }
.metric-delta.down { color: var(--warn); }

/* Mantém compat com .card legado, se sobrar em algum lugar */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow-sm); }
.card .label { color: var(--gray-400); font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.card .value { font-size: 22px; font-weight: 800; margin-top: 6px; letter-spacing: -0.5px; }
.card .value.warn { color: var(--amber); }

/* ════════════════════════════════════ Panels & tabelas (densas) ════════════════════════════════════ */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm); }
.panel h2 { font-size: 13px; font-weight: 700; margin: 0; padding: 13px 16px; border-bottom: 1px solid var(--border); }

/* ════════════════════════════════════ Gráficos (Acompanhamento) ════════════════════════════════════ */
.section-title { font-size: 13px; font-weight: 700; margin: 4px 0 14px; color: var(--text); }
.charts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-bottom: 24px; align-items: start; }
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }
.chart-panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); padding: 14px 16px 16px; }
.chart-panel h3 { font-size: 12px; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.chart-panel .chart-sub { font-size: 10px; color: var(--muted); margin: 0 0 12px; }
.chart-wrap { position: relative; height: 240px; }
.chart-wrap canvas { max-width: 100%; }
.chart-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 11px; color: var(--muted); padding: 0 16px; }
.chart-fallback[hidden] { display: none; }

table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); }
th {
  color: var(--gray-400); font-weight: 700; font-size: 9px;
  text-transform: uppercase; letter-spacing: .07em;
  background: var(--gray-50);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
tbody tr.row-pending { background: var(--amber-bg); }
tbody tr.row-pending:hover { background: #FDEFD0; }
/* Linha clicável (abre o detalhe). Os botões de ação param a propagação. */
tbody tr.row-link { cursor: pointer; }
tbody tr.row-link:hover { background: var(--admin-bg, #F4F0FF); }
.empty { padding: 36px; text-align: center; color: var(--muted); font-size: 12px; }

/* ── Página de detalhe ── */
.detalhe-back { display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--muted); text-decoration: none; margin-bottom: 12px; }
.detalhe-back:hover { color: var(--admin, #7C3AED); }
.detalhe-grid { display: grid; grid-template-columns: 180px 1fr; gap: 10px 18px; font-size: 13px; }
.detalhe-grid dt { color: var(--muted); font-weight: 600; }
.detalhe-grid dd { margin: 0; color: var(--gray-700, #334155); }
.detalhe-galeria { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.detalhe-galeria img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--gray-100, #E2E8F0); }

/* Avatar em célula de tabela */
.table-cell-name { display: flex; align-items: center; gap: 9px; }
.table-avatar {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--admin) 0%, var(--admin-dark) 100%);
  color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; text-transform: uppercase;
}
.table-avatar.blue { background: linear-gradient(135deg, var(--brand-azul) 0%, #1E40AF 100%); }
.cell-name-main { font-weight: 600; font-size: 11px; }
.cell-name-sub { font-size: 9px; color: var(--muted); }

/* ════════════════════════════════════ Badges por status ════════════════════════════════════ */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  background: var(--gray-100); color: var(--gray-500);
}
/* verde — ativo/sucesso/confirmado */
.badge.ativo, .badge.ativa, .badge.pago, .badge.confirmado, .badge.aprovado { background: var(--success-bg); color: var(--success); }
/* âmbar — pendente / aguardando / rascunho / em andamento */
.badge.pendente, .badge.aguardando, .badge.rascunho, .badge.em_andamento { background: var(--amber-bg); color: var(--amber); }
/* vermelho — bloqueado / cancelado / inativo / ignorada / rejeitado */
.badge.inativo, .badge.bloqueado, .badge.cancelada, .badge.cancelado, .badge.ignorada, .badge.rejeitado { background: var(--warn-bg); color: var(--warn); }
/* roxo — categoria / em negociação / notificada */
.badge.notificada, .badge.em_negociacao, .badge.purple { background: var(--admin-light); color: var(--admin); }
/* azul — nova / campanha criada */
.badge.nova, .badge.campanha_criada, .badge.blue { background: var(--brand-azul-light); color: var(--brand-azul); }
/* cyan */
.badge.cyan { background: var(--cyan-bg); color: var(--cyan); }
/* neutro */
.badge.neutro, .badge.encerrada { background: var(--gray-100); color: var(--gray-500); }

/* ════════════════════════════════════ Tags / categorias ════════════════════════════════════ */
.tag {
  display: inline-block; background: var(--admin-light); color: var(--admin);
  border-radius: 999px; padding: 2px 8px; font-size: 9px; font-weight: 600;
  margin: 0 4px 3px 0; text-transform: capitalize;
}

/* ════════════════════════════════════ Botões ════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  background: var(--admin); color: #fff; border: none; border-radius: 7px;
  padding: 7px 13px; font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--admin-dark); }
.btn.ghost { background: none; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn.danger { background: var(--warn); }
.btn.danger:hover { background: #DC2626; }
.btn.success { background: var(--success); }
.btn.success:hover { background: #15803d; }
.btn.sm { padding: 5px 10px; font-size: 11px; }

.actions { display: inline-flex; gap: 6px; align-items: center; }

/* Botão-ícone para ações por linha */
.action-btn {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--gray-600); cursor: pointer; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
  font-family: inherit; text-decoration: none;
}
.action-btn:hover { background: var(--gray-50); }
.action-btn.approve { color: var(--success); border-color: #BBF7D0; }
.action-btn.approve:hover { background: var(--success-bg); }
.action-btn.reject { color: var(--warn); border-color: #FECACA; }
.action-btn.reject:hover { background: var(--warn-bg); }

/* ════════════════════════════════════ Tabs (pílula) ════════════════════════════════════ */
.tabs {
  display: inline-flex; gap: 3px; background: var(--gray-200);
  padding: 3px; border-radius: 9px; margin-bottom: 16px; flex-wrap: wrap;
}
.tabs a {
  padding: 6px 12px; border-radius: 7px; font-size: 11px; font-weight: 600;
  color: var(--gray-600);
}
.tabs a:hover { color: var(--text); }
.tabs a.active { background: #fff; color: var(--admin); box-shadow: var(--shadow-sm); }
.tabs a .count { color: var(--gray-400); font-weight: 600; }
.tabs a.active .count { color: var(--admin); }

/* ════════════════════════════════════ Filter chips ════════════════════════════════════ */
.filter-chips { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: var(--gray-600); font-size: 11px; font-weight: 600;
}
.filter-chip:hover { border-color: var(--gray-300); }
.filter-chip.active { background: var(--admin); color: #fff; border-color: var(--admin); }
.filter-chip .count {
  background: var(--gray-100); color: var(--gray-500);
  border-radius: 999px; padding: 1px 6px; font-size: 9px;
}
.filter-chip.active .count { background: rgba(255,255,255,.25); color: #fff; }

/* ════════════════════════════════════ Progress bar ════════════════════════════════════ */
.progress-wrap { height: 5px; border-radius: 999px; background: var(--gray-200); overflow: hidden; min-width: 70px; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--admin) 0%, var(--admin-dark) 100%); }
.progress-fill.green { background: linear-gradient(90deg, var(--success) 0%, #15803d 100%); }
.progress-fill.amber { background: linear-gradient(90deg, var(--amber) 0%, #B45309 100%); }

/* ════════════════════════════════════ Timeline (atividades) ════════════════════════════════════ */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 11px; align-items: flex-start; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--admin); }
.timeline .dot.condominio { background: var(--success); }
.timeline .dot.vendedor { background: var(--brand-azul); }
.timeline .dot.representante { background: var(--amber); }
.timeline .tl-body { flex: 1; }
.timeline .tl-desc { font-size: 12px; color: var(--text); }
.timeline .tl-meta { font-size: 10px; color: var(--muted); margin-top: 2px; }
.timeline .tl-tipo { display: inline-block; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--admin); margin-right: 8px; }

/* ════════════════════════════════════ Grid do dashboard ════════════════════════════════════ */
.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* ════════════════════════════════════ Modal (rejeição/notificação) ════════════════════════════════════ */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal:target { display: flex; }
.modal-card { background: var(--card); border-radius: 16px; width: 100%; max-width: 440px; padding: 24px; box-shadow: 0 20px 50px rgba(0,0,0,.25); margin: 16px; }
.modal-card h3 { margin: 0 0 6px; font-size: 17px; }
.modal-card p { margin: 0 0 16px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.modal-card label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.modal-card textarea { width: 100%; min-height: 92px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; resize: vertical; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ════════════════════════════════════ Filterbar (select nativo legado) ════════════════════════════════════ */
.filterbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filterbar label { font-size: 12px; font-weight: 600; color: var(--muted); }
.filterbar select, .filterbar input { padding: 7px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; background: var(--card); color: var(--text); }

/* ════════════════════════════════════ Login ════════════════════════════════════ */
body.login-body {
  background: linear-gradient(135deg, #0F0A1E 0%, #1A0E3A 55%, #0D1628 100%);
}
.login-wrap { margin: auto; width: 100%; max-width: 380px; padding: 24px; }
.login-card { background: var(--card); border-radius: 18px; padding: 36px 32px; box-shadow: 0 24px 60px rgba(0,0,0,.45); }
.login-card .login-logo { height: 40px; width: 40px; border-radius: 10px; margin-bottom: 14px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; font-weight: 800; letter-spacing: -0.5px; }
.login-card h1 span { color: var(--admin); }
.login-card p { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; margin: 14px 0 6px; }
.login-card input { width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; font-family: inherit; }
.login-card input:focus { outline: none; border-color: var(--admin); box-shadow: 0 0 0 3px rgba(124,58,237,.15); }
.login-btn {
  width: 100%; margin-top: 24px; padding: 12px;
  background: linear-gradient(135deg, var(--admin) 0%, var(--admin-dark) 100%);
  color: #fff; border: none; border-radius: 9px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.login-btn:hover { filter: brightness(1.07); }

/* ════════════════════════════════════ Formulários (criar/editar) ════════════════════════════════════ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; max-width: 720px; }
.form-field { display: flex; flex-direction: column; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: var(--card); color: var(--text);
}
.form-field textarea { min-height: 80px; resize: vertical; }
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { outline: none; border-color: var(--admin); box-shadow: 0 0 0 3px rgba(124,58,237,.15); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.detalhe-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ════════════════════════════════════ Paginação ════════════════════════════════════ */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 12px 16px; border-top: 1px solid var(--border);
}
.pagination .page-info { font-size: 12px; color: var(--muted); }
.pagination .page-info b { color: var(--text); font-weight: 700; }
.btn.disabled {
  opacity: .45; pointer-events: none; cursor: default;
}

/* ════════════════════════════════════ Responsivo ════════════════════════════════════ */
@media (max-width: 720px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 12px; align-items: center; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 6px; width: 100%; }
  .nav-group { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; }
  .nav-group-label { display: none; }
  .sidebar-footer { margin: 0 0 0 auto; border-top: none; padding-top: 0; }
  main { padding: 18px 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
