/* =============================================
   CRM Pro — Design System
   ============================================= */

:root {
  --bg: #0F1117;
  --bg-card: #1A1D27;
  --bg-sidebar: #13151F;
  --bg-hover: #22263A;
  --border: #2A2F45;
  --border-light: #353B55;
  --primary: #4F6EF7;
  --primary-dark: #3A55D4;
  --primary-glow: rgba(79,110,247,0.18);
  --accent: #7C5CFC;
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #06B6D4;
  --text: #E8EAF0;
  --text-muted: #6B7394;
  --text-dim: #9AA3BF;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.35);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
  --transition: 0.18s ease;
  --sidebar-w: 240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-card); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--primary-glow);
  color: var(--primary);
}
.nav-item .icon { width: 18px; text-align: center; font-size: 0.95rem; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 10px;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-name { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.user-role { font-size: 0.72rem; color: var(--text-muted); }
.logout-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-top: 4px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  transition: var(--transition);
}
.logout-btn:hover { background: rgba(239,68,68,0.12); color: var(--danger); }

/* ===== MAIN CONTENT ===== */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 58px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-content { padding: 28px; flex: 1; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.card-title { font-size: 0.95rem; font-weight: 600; color: var(--text); }

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-1px); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.blue::before { background: linear-gradient(90deg, var(--primary), var(--accent)); }
.stat-card.green::before { background: linear-gradient(90deg, var(--success), #16A34A); }
.stat-card.orange::before { background: linear-gradient(90deg, var(--warning), #D97706); }
.stat-card.purple::before { background: linear-gradient(90deg, var(--accent), #6D28D9); }

.stat-label { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.stat-icon {
  position: absolute; right: 18px; top: 18px;
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.stat-card.blue .stat-icon { background: rgba(79,110,247,0.15); color: var(--primary); }
.stat-card.green .stat-icon { background: rgba(34,197,94,0.15); color: var(--success); }
.stat-card.orange .stat-icon { background: rgba(245,158,11,0.15); color: var(--warning); }
.stat-card.purple .stat-icon { background: rgba(124,92,252,0.15); color: var(--accent); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: rgba(34,197,94,0.15); color: var(--success); border: 1px solid rgba(34,197,94,0.3); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 0.78rem; }
.btn-icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border); }
th { padding: 10px 14px; font-size: 0.72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; text-align: left; white-space: nowrap; }
td { padding: 12px 14px; font-size: 0.85rem; color: var(--text-dim); border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover td { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-blue { background: rgba(79,110,247,0.15); color: var(--primary); }
.badge-green { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-purple { background: rgba(124,92,252,0.15); color: var(--accent); }
.badge-gray { background: rgba(107,115,148,0.15); color: var(--text-muted); }
.badge-cyan { background: rgba(6,182,212,0.15); color: var(--info); }

/* Status badges */
.status-rascunho { background: rgba(107,115,148,0.15); color: var(--text-muted); }
.status-em_revisao { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-aprovada { background: rgba(6,182,212,0.15); color: var(--info); }
.status-enviada { background: rgba(79,110,247,0.15); color: var(--primary); }
.status-aceita { background: rgba(34,197,94,0.15); color: var(--success); }
.status-recusada { background: rgba(239,68,68,0.15); color: var(--danger); }
.status-vencida { background: rgba(239,68,68,0.12); color: #F87171; }
.status-cancelada { background: rgba(107,115,148,0.12); color: var(--text-muted); }

/* ===== FORMS ===== */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.8rem; font-weight: 600; color: var(--text-dim); }
.form-label span.req { color: var(--danger); margin-left: 2px; }

.form-control {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 13px;
  font-size: 0.87rem;
  font-family: inherit;
  transition: var(--transition);
  width: 100%;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: modalIn 0.2s ease;
}
.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1100px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.modal-close {
  background: var(--bg-hover);
  border: none; border-radius: 8px;
  color: var(--text-muted);
  width: 30px; height: 30px;
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--danger); color: #fff; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ===== KANBAN ===== */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 16px;
  min-height: calc(100vh - 180px);
}

.kanban-col {
  flex: 0 0 270px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.kanban-col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
}
.kanban-col-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; font-weight: 700; color: var(--text);
}
.kanban-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.kanban-count {
  background: var(--bg-hover); color: var(--text-muted);
  padding: 2px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 600;
}

.kanban-drop-zone {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 8px;
  min-height: 120px;
  transition: var(--transition);
}
.kanban-drop-zone.drag-over {
  background: var(--primary-glow);
  border-color: var(--primary);
}

.kanban-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  cursor: grab;
  transition: var(--transition);
  user-select: none;
}
.kanban-card:hover { border-color: var(--border-light); box-shadow: var(--shadow-sm); }
.kanban-card.dragging { opacity: 0.4; cursor: grabbing; }
.kanban-card-title { font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.kanban-card-sub { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 8px; }
.kanban-card-meta {
  display: flex; align-items: center; justify-content: space-between;
}
.kanban-card-value { font-size: 0.8rem; font-weight: 700; color: var(--success); }
.kanban-card-prob { font-size: 0.72rem; color: var(--text-muted); }
.kanban-card-actions { display: flex; gap: 4px; opacity: 0; transition: var(--transition); }
.kanban-card:hover .kanban-card-actions { opacity: 1; }

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 20% 50%, rgba(79,110,247,0.08) 0%, transparent 60%), radial-gradient(ellipse at 80% 20%, rgba(124,92,252,0.08) 0%, transparent 60%);
}
.login-box {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 14px;
  box-shadow: 0 8px 24px rgba(79,110,247,0.3);
}
.login-logo h1 { font-size: 1.4rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.login-logo p { font-size: 0.85rem; color: var(--text-muted); }
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
}
.login-card .form-group { margin-bottom: 16px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 0.95rem; }

/* ===== PROPOSAL ITEMS ===== */
.items-table { width: 100%; }
.items-table th, .items-table td { padding: 8px 10px; }
.items-table th { background: var(--bg); font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; border-bottom: 1px solid var(--border); }
.items-table td { border-bottom: 1px solid var(--border); vertical-align: middle; }
.items-table tbody tr:last-child td { border-bottom: none; }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #FCA5A5; }
.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: #86EFAC; }

/* ===== MISC ===== */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.fw-600 { font-weight: 600; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.w-100 { width: 100%; }

/* Pipeline mini chart */
.pipeline-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pipeline-bar-label { font-size: 0.78rem; color: var(--text-dim); width: 130px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipeline-bar-track { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.pipeline-bar-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.pipeline-bar-count { font-size: 0.78rem; color: var(--text-muted); width: 30px; text-align: right; }

/* Proposal view */
.proposal-section { margin-bottom: 20px; }
.proposal-section-title { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.info-item label { font-size: 0.73rem; color: var(--text-muted); display: block; margin-bottom: 2px; }
.info-item span { font-size: 0.88rem; color: var(--text); font-weight: 500; }

/* Responsive */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban-board { padding-bottom: 80px; }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; color: var(--text-dim); margin-bottom: 6px; }
.empty-state p { font-size: 0.85rem; }

/* ===== CURRENCY INPUT ===== */
.currency-input {
  text-align: right;
  font-weight: 600;
  font-family: 'Inter', monospace;
}
.currency-input::placeholder { font-weight: 400; text-align: right; }

/* ===== KANBAN COMPACTO (sobrescreve regras antigas) ===== */
.kanban-board { overflow-x: hidden !important; }
