/* =========================================================
   PLAZMARE SYSTEM — Identidade visual
   Dark, minimalista, premium. Preto / quase-preto / branco / cinza.
   Cores de destaque só quando necessário (vermelho / amarelo / verde).
   ========================================================= */

:root {
  --bg-0: #0a0a0b;
  --bg-1: #111113;
  --bg-2: #17171a;
  --bg-3: #1e1e22;
  --border: #2a2a2f;
  --border-soft: #202024;
  --text-0: #f5f5f7;
  --text-1: #b8b8c0;
  --text-2: #7d7d87;
  --accent: #6e6ef6;
  --accent-soft: rgba(110, 110, 246, 0.15);
  --red: #f24545;
  --red-soft: rgba(242, 69, 69, 0.14);
  --yellow: #f2c94c;
  --yellow-soft: rgba(242, 201, 76, 0.14);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 8px 24px rgba(0,0,0,0.35);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; }

/* ---------- Layout shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-1);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 22px;
}
.logo-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #3f3fbf);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 15px;
}
.logo-text { font-size: 12.5px; letter-spacing: 0.06em; color: var(--text-1); font-weight: 600; }
.logo-text strong { color: var(--text-0); }

.sidebar-nav { flex: 1; overflow-y: auto; }
.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  padding: 16px 10px 6px;
}
.nav-group-label.muted { color: #4b4b52; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-1);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .12s ease, color .12s ease;
}
.nav-link .nav-ico { font-size: 8px; color: var(--text-2); }
.nav-link:hover { background: var(--bg-2); color: var(--text-0); }
.nav-link.active { background: var(--accent-soft); color: var(--text-0); }
.nav-link.active .nav-ico { color: var(--accent); }
.nav-link.disabled { color: #4b4b52; cursor: default; }
.nav-link.disabled:hover { background: none; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-top: 1px solid var(--border-soft);
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg-3); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.user-name { font-size: 12.5px; font-weight: 600; }
.user-logout { font-size: 11.5px; color: var(--text-2); }
.user-logout:hover { color: var(--red); }

.mobile-menu-btn {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 50;
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-0); width: 38px; height: 38px; border-radius: 8px;
  font-size: 16px; cursor: pointer;
}

.main-content {
  flex: 1;
  padding: 26px 32px 60px;
  max-width: 1400px;
  min-width: 0;
}

/* ---------- Page header ---------- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 22px;
}
.page-header h1 { font-size: 20px; font-weight: 700; margin: 0; }
.page-header .subtitle { color: var(--text-2); font-size: 13px; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-0);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .12s ease;
}
.btn:hover { background: var(--bg-3); border-color: #3a3a42; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #5c5cf0; }
.btn-danger { background: var(--red-soft); border-color: transparent; color: var(--red); }
.btn-danger:hover { background: rgba(242,69,69,0.25); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-1); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text-0); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 14px; }
.grid-metrics { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.card-title { font-size: 13px; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }

.metric-card { position: relative; overflow: hidden; }
.metric-value { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.metric-label { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.metric-accent-red { border-color: rgba(242,69,69,0.35); }
.metric-accent-yellow { border-color: rgba(242,201,76,0.35); }
.metric-accent-green { border-color: rgba(52,211,153,0.35); }

/* ---------- Today actions ---------- */
.today-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; margin-bottom: 26px; }
.action-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px; border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  background: var(--bg-1);
}
.action-card.link { cursor: pointer; transition: transform .12s ease, border-color .12s ease; }
.action-card.link:hover { transform: translateY(-1px); border-color: #3a3a42; }
.action-card .count { font-size: 26px; font-weight: 700; }
.action-card .label { font-size: 12.5px; color: var(--text-1); margin-top: 2px; }
.action-card.overdue { border-color: rgba(242,69,69,0.4); background: linear-gradient(180deg, var(--red-soft), transparent); }
.action-card.today { border-color: rgba(242,201,76,0.4); background: linear-gradient(180deg, var(--yellow-soft), transparent); }
.action-card.waiting { border-color: rgba(52,211,153,0.4); background: linear-gradient(180deg, var(--green-soft), transparent); }
.action-dot { font-size: 18px; }

/* ---------- Funnel ---------- */
.funnel { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.funnel-step {
  flex: 1; min-width: 100px;
  background: var(--bg-1); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 12px; text-align: center;
}
.funnel-step .fs-value { font-size: 18px; font-weight: 700; }
.funnel-step .fs-label { font-size: 11px; color: var(--text-2); margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; }
.funnel-rates { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-1); margin-top: 4px; }
.funnel-rates b { color: var(--text-0); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border-soft); }
table { width: 100%; border-collapse: collapse; background: var(--bg-1); }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-2); padding: 11px 14px; border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-2); }
.row-link { cursor: pointer; }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  background: var(--bg-3); color: var(--text-1);
}
.badge-novo { background: #26262b; color: #cfcfd6; }
.badge-abordado { background: #23233a; color: #a9a9f5; }
.badge-respondeu { background: #1e2f3a; color: #7fd3f2; }
.badge-interessado { background: #233a2e; color: #7fe3ae; }
.badge-proposta { background: var(--yellow-soft); color: var(--yellow); }
.badge-negociacao { background: #3a2c1e; color: #f2a44c; }
.badge-fechado { background: var(--green-soft); color: var(--green); }
.badge-perdido { background: var(--red-soft); color: var(--red); }

.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-green { color: var(--green); }
.text-muted { color: var(--text-2); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 600; color: var(--text-1); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=datetime-local], input[type=date], select, textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .12s ease;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
.form-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 22px 0 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }

.filters-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.filters-bar select, .filters-bar input[type=search] { width: auto; min-width: 140px; }

/* ---------- Kanban ---------- */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle a { padding: 7px 14px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.view-toggle a.active { background: var(--bg-3); color: var(--text-0); }

.kanban-wrap { overflow-x: auto; padding-bottom: 14px; }
.kanban { display: flex; gap: 12px; min-width: max-content; }
.kanban-col { width: 260px; flex-shrink: 0; background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); padding: 10px; }
.kanban-col-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 6px 10px; }
.kanban-col-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kanban-col-count { font-size: 11px; color: var(--text-2); background: var(--bg-3); border-radius: 20px; padding: 1px 8px; }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kanban-col.drag-over { background: var(--bg-2); border-color: var(--accent); }

.kcard {
  background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 9px;
  padding: 11px; cursor: grab; transition: border-color .12s ease, transform .12s ease;
}
.kcard:hover { border-color: #3a3a42; }
.kcard.dragging { opacity: .4; }
.kcard .kc-name { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.kcard .kc-meta { font-size: 11.5px; color: var(--text-2); margin-bottom: 6px; }
.kcard .kc-offer { font-size: 12px; color: var(--text-1); margin-bottom: 4px; }
.kcard .kc-value { font-size: 13px; font-weight: 700; color: var(--text-0); }
.kcard .kc-followup { font-size: 11px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }

/* ---------- Lead detail page ---------- */
.lead-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.lead-header h1 { font-size: 22px; margin: 0 0 4px; }
.lead-sub { color: var(--text-2); font-size: 13.5px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 1px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before {
  content: ''; position: absolute; left: -22px; top: 3px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--bg-0);
}
.timeline-date { font-size: 11px; color: var(--text-2); margin-bottom: 2px; }
.timeline-type { font-size: 12.5px; font-weight: 700; }
.timeline-desc { font-size: 13px; color: var(--text-1); margin-top: 2px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 100%; max-width: 440px; padding: 22px; box-shadow: var(--shadow);
}
.modal h3 { margin-top: 0; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Auth pages ---------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-0); padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); padding: 32px 28px; }
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo .logo-mark { margin: 0 auto 10px; }
.auth-logo .app-name { font-size: 14px; font-weight: 700; letter-spacing: .06em; }
.auth-error { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 14px; }
.auth-note { text-align: center; font-size: 12px; color: var(--text-2); margin-top: 16px; }

/* ---------- Flash ---------- */
.flash-stack { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 11px 14px; border-radius: 8px; font-size: 13px; }
.flash-success { background: var(--green-soft); color: var(--green); }
.flash-error { background: var(--red-soft); color: var(--red); }
.flash-info { background: var(--accent-soft); color: #b8b8f5; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-2); }
.empty-state .es-icon { font-size: 28px; margin-bottom: 10px; }

.pagination { display: flex; gap: 6px; margin-top: 16px; justify-content: flex-end; }
.pagination a, .pagination span {
  padding: 7px 12px; border-radius: 7px; font-size: 12.5px; border: 1px solid var(--border); color: var(--text-1);
}
.pagination a:hover { background: var(--bg-2); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: -260px; top: 0; z-index: 60; transition: left .18s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { left: 0; }
  .mobile-menu-btn { display: block; }
  .main-content { padding: 70px 16px 40px; }
  .lead-header { flex-direction: column; }
}
@media (max-width: 560px) {
  .grid-metrics { grid-template-columns: repeat(2, 1fr); }
  .kanban-col { width: 78vw; }
}
