/* ===== ProjectFlow Design System ===== */
:root {
  --primary: #1a5cff;
  --primary-dark: #1248d0;
  --primary-light: #e8eeff;
  --secondary: #00c896;
  --secondary-dark: #00a07a;
  --accent: #ff6b35;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --info: #3b82f6;

  --sidebar-bg: #0f1729;
  --sidebar-hover: #1e2d4a;
  --sidebar-active: #1a5cff;
  --sidebar-text: #8ca0c4;
  --sidebar-text-active: #ffffff;
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;

  --bg: #f0f4fb;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --border: #e2e8f4;
  --border-light: #f1f5fc;

  --text-primary: #0f1729;
  --text-secondary: #4a5568;
  --text-muted: #8ca0c4;

  --shadow-sm: 0 1px 3px rgba(15,23,41,0.06);
  --shadow: 0 4px 16px rgba(15,23,41,0.08);
  --shadow-lg: 0 8px 32px rgba(15,23,41,0.12);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== LOGIN PAGE ===== */
#login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1729 0%, #1a2d50 50%, #0f1729 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
#login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(26,92,255,0.15) 0%, transparent 70%);
  top: -150px; right: -100px;
  border-radius: 50%;
}
#login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(0,200,150,0.1) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  border-radius: 50%;
}
.login-card {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xl);
  padding: 48px;
  width: 420px;
  position: relative;
  z-index: 1;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}
.login-logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: white;
}
.login-logo span { font-size: 22px; font-weight: 700; color: white; }
.login-title { font-size: 24px; font-weight: 700; color: white; margin-bottom: 6px; }
.login-subtitle { font-size: 14px; color: rgba(255,255,255,0.5); margin-bottom: 28px; }
.login-label { display: block; font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.6); margin-bottom: 6px; letter-spacing: 0.05em; text-transform: uppercase; }
.login-input {
  width: 100%;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: white;
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
  margin-bottom: 16px;
}
.login-input::placeholder { color: rgba(255,255,255,0.3); }
.login-input:focus { border-color: var(--primary); background: rgba(26,92,255,0.1); }
.login-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), #0040cc);
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  margin-top: 4px;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(26,92,255,0.4); }
.login-hint { text-align: center; margin-top: 20px; font-size: 12px; color: rgba(255,255,255,0.3); }
.login-hint span { color: rgba(255,255,255,0.6); }
.login-users { margin-top: 20px; }
.login-users-label { font-size: 11px; color: rgba(255,255,255,0.3); margin-bottom: 8px; }
.login-user-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm); padding: 8px 12px;
  color: rgba(255,255,255,0.7); font-size: 12px;
  font-family: var(--font); cursor: pointer;
  transition: all var(--transition); margin-bottom: 4px;
}
.login-user-btn:hover { background: rgba(26,92,255,0.2); border-color: var(--primary); color: white; }
.login-user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
}

/* ===== APP LAYOUT ===== */
#app { display: none; flex-direction: row; min-height: 100vh; }
#app.active { display: flex; }

/* ===== SIDEBAR ===== */
#sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100; transition: width var(--transition);
  overflow: hidden;
}
.sidebar-header {
  padding: 20px 20px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo-icon {
  width: 36px; height: 36px; min-width: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 8px; display: flex; align-items: center;
  justify-content: center; font-size: 16px; color: white;
}
.sidebar-brand { font-size: 16px; font-weight: 700; color: white; white-space: nowrap; }
.sidebar-brand span { color: var(--secondary); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section-title {
  padding: 8px 20px 4px;
  font-size: 10px; font-weight: 700;
  color: rgba(255,255,255,0.25);
  text-transform: uppercase; letter-spacing: 0.1em;
  white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; cursor: pointer;
  transition: all var(--transition);
  color: var(--sidebar-text); font-size: 13px;
  font-weight: 500; white-space: nowrap;
  border-left: 3px solid transparent;
  user-select: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active {
  background: rgba(26,92,255,0.15);
  color: white; border-left-color: var(--primary);
}
.nav-icon { width: 18px; font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--primary);
  color: white; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
}
.nav-badge.danger { background: var(--danger); }
.nav-badge.warning { background: var(--warning); }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.06); }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; padding: 8px;
  border-radius: var(--radius-sm); transition: background var(--transition);
}
.sidebar-user:hover { background: var(--sidebar-hover); }
.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--sidebar-text); }

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

/* ===== HEADER ===== */
#topbar {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px; display: flex; align-items: center;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text-primary); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.search-wrap {
  display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 12px;
  gap: 8px; width: 220px; transition: all var(--transition);
}
.search-wrap:focus-within { border-color: var(--primary); background: white; }
.search-wrap input {
  border: none; background: transparent; outline: none;
  font-size: 13px; color: var(--text-primary); width: 100%;
  font-family: var(--font);
}
.search-wrap input::placeholder { color: var(--text-muted); }
.icon-btn {
  width: 36px; height: 36px; border: 1px solid var(--border);
  background: var(--bg); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; transition: all var(--transition);
  color: var(--text-secondary); position: relative;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.icon-btn .badge {
  position: absolute; top: -4px; right: -4px;
  width: 16px; height: 16px; background: var(--danger);
  border-radius: 50%; font-size: 10px; color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.topbar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; border: 2px solid var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: white;
}

/* ===== PAGE CONTENT ===== */
#page-content { flex: 1; padding: 28px; overflow-y: auto; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== KPI CARDS ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow-sm); transition: transform var(--transition), box-shadow var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-icon {
  width: 42px; height: 42px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 12px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.kpi-value { font-size: 26px; font-weight: 800; color: var(--text-primary); line-height: 1; margin-bottom: 8px; }
.kpi-trend { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }

/* ===== PROGRESS BAR ===== */
.progress-bar { height: 6px; background: var(--border); border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 10px; transition: width 0.6s ease; }
.progress-fill.green { background: linear-gradient(90deg, var(--success), var(--secondary)); }
.progress-fill.blue { background: linear-gradient(90deg, var(--primary), var(--info)); }
.progress-fill.orange { background: linear-gradient(90deg, var(--warning), var(--accent)); }
.progress-fill.red { background: linear-gradient(90deg, var(--danger), #ff6b6b); }

/* ===== BADGES / STATUS ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: all var(--transition); border: none;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(26,92,255,0.35); }
.btn-secondary { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* ===== GRID LAYOUTS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-3-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

/* ===== AVATAR ===== */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-lg { width: 42px; height: 42px; font-size: 16px; }
.avatar-sarah { background: linear-gradient(135deg, #667eea, #764ba2); }
.avatar-carlos { background: linear-gradient(135deg, #f093fb, #f5576c); }
.avatar-ana { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.avatar-client { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.avatar-admin { background: linear-gradient(135deg, #fa709a, #fee140); }

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

/* ===== KANBAN ===== */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col {
  min-width: 240px; flex: 1;
  background: var(--bg); border-radius: var(--radius-lg);
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.kanban-col-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.kanban-col-title { font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.08em; }
.kanban-count {
  background: white; border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 8px;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
}
.kanban-card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  cursor: grab; transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); }
.kanban-card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.kanban-card-meta { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-top: 8px; }

/* ===== GANTT ===== */
.gantt-wrap { overflow-x: auto; }
.gantt-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.gantt-table th { background: var(--bg); }
.gantt-bar-wrap { position: relative; height: 28px; }
.gantt-bar {
  position: absolute; top: 4px; height: 20px;
  border-radius: 10px; display: flex; align-items: center;
  padding: 0 10px; font-size: 11px; font-weight: 600; color: white;
  white-space: nowrap; overflow: hidden;
}
.gantt-bar.blue { background: linear-gradient(90deg, var(--primary), #5b8aff); }
.gantt-bar.green { background: linear-gradient(90deg, var(--success), var(--secondary)); }
.gantt-bar.orange { background: linear-gradient(90deg, var(--warning), var(--accent)); }
.gantt-bar.red { background: linear-gradient(90deg, var(--danger), #ff6b6b); }
.gantt-bar.purple { background: linear-gradient(90deg, #7c3aed, #a855f7); }

/* ===== CRM PIPELINE ===== */
.pipeline-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; min-height: 520px; }
.pipeline-col {
  min-width: 220px; flex: 1;
  display: flex; flex-direction: column;
}
.pipeline-col-header {
  padding: 12px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: 8px;
}
.pipeline-col-title { font-size: 12px; font-weight: 700; color: white; }
.pipeline-col-sum { font-size: 13px; font-weight: 800; color: rgba(255,255,255,0.8); margin-top: 2px; }
.pipeline-cards { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.deal-card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  cursor: pointer; transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.deal-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.deal-company { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.deal-contact { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.deal-value { font-size: 15px; font-weight: 800; color: var(--primary); margin: 8px 0; }
.deal-footer { display: flex; align-items: center; justify-content: space-between; }
.deal-prob { font-size: 11px; color: var(--text-muted); }
.deal-date { font-size: 11px; color: var(--text-muted); }

/* ===== COMPLIANCE ===== */
.compliance-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.cs-compliant { background: #d1fae5; color: #065f46; }
.cs-pending { background: #fef3c7; color: #92400e; }
.cs-non-compliant { background: #fee2e2; color: #991b1b; }

/* ===== PORTAL DO CLIENTE ===== */
.portal-header {
  background: linear-gradient(135deg, var(--sidebar-bg), #1a2d50);
  border-radius: var(--radius-lg); padding: 24px;
  margin-bottom: 20px; color: white;
  display: flex; align-items: center; justify-content: space-between;
}
.portal-badge {
  background: rgba(0,200,150,0.2); border: 1px solid rgba(0,200,150,0.4);
  color: var(--secondary); padding: 4px 12px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.comment-thread { display: flex; flex-direction: column; gap: 14px; }
.comment-item { display: flex; gap: 12px; }
.comment-bubble {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  padding: 12px 16px; flex: 1;
}
.comment-bubble.own { background: var(--primary-light); border-color: rgba(26,92,255,0.2); }
.comment-author { font-size: 12px; font-weight: 700; color: var(--text-primary); }
.comment-role { font-size: 11px; color: var(--text-muted); margin-left: 6px; }
.comment-time { font-size: 11px; color: var(--text-muted); float: right; }
.comment-text { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.comment-input-wrap {
  display: flex; gap: 10px; align-items: flex-end;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  margin-top: 16px;
}
.comment-input-wrap textarea {
  flex: 1; border: none; background: transparent; outline: none;
  font-family: var(--font); font-size: 13px; resize: none;
  color: var(--text-primary); min-height: 40px; max-height: 120px;
}

/* ===== REPORTING ===== */
.chart-container { position: relative; }
.metric-card {
  background: var(--bg); border-radius: var(--radius);
  padding: 16px; text-align: center;
}
.metric-value { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.metric-label { font-size: 12px; color: var(--text-muted); }

/* ===== SETTINGS ===== */
.settings-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.settings-tab {
  padding: 10px 18px; cursor: pointer; font-size: 13px;
  font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all var(--transition);
}
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.settings-tab:hover:not(.active) { color: var(--text-primary); }
.settings-section { margin-bottom: 28px; }
.settings-section-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--text-primary); }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; color: var(--text-primary);
  background: white; outline: none; transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); }
.form-textarea { resize: vertical; min-height: 80px; }
.toggle-wrap { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.toggle-info { }
.toggle-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.toggle-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.toggle {
  position: relative; width: 42px; height: 24px;
  background: var(--border); border-radius: 12px; cursor: pointer;
  transition: background var(--transition); flex-shrink: 0;
}
.toggle.on { background: var(--primary); }
.toggle::after {
  content: ''; position: absolute;
  width: 18px; height: 18px; background: white; border-radius: 50%;
  top: 3px; left: 3px; transition: left var(--transition);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle.on::after { left: 21px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: white; border-radius: var(--radius-xl);
  padding: 28px; width: 520px; max-width: 95vw;
  max-height: 85vh; overflow-y: auto;
  transform: scale(0.95); transition: transform var(--transition);
  box-shadow: var(--shadow-lg);
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { width: 30px; height: 30px; border: none; background: var(--bg); border-radius: var(--radius-sm); cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.modal-close:hover { background: var(--border); color: var(--text-primary); }

/* ===== TOAST ===== */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 500; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--text-primary); color: white;
  padding: 12px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: toastIn 0.3s ease;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes toastIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; color: var(--text-secondary); }
.empty-state-text { font-size: 13px; }

/* ===== DIVIDER ===== */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ===== SECTION HEADER ===== */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.section-actions { display: flex; gap: 8px; }

/* ===== DROPDOWN / SELECT ===== */
.filter-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-select {
  padding: 7px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px;
  background: white; color: var(--text-secondary);
  cursor: pointer; outline: none; font-family: var(--font);
  transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--primary); }

/* ===== LOADING ===== */
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap { display: flex; align-items: center; justify-content: center; padding: 48px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-3-1 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  #sidebar { display: none; }
  #main-content { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  #page-content { padding: 16px; }
  .kanban-board, .pipeline-board { flex-direction: column; }
  .kanban-col, .pipeline-col { min-width: unset; }
}

/* ===== UTILITIES ===== */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.w-100 { width: 100%; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.rounded { border-radius: var(--radius); }
.gap-6 { gap: 6px; }

/* ===== BORROWER PORTAL — EMPRESA TOMADORA ===== */

/* Banner do Tomador */
.borrower-banner {
  background: linear-gradient(135deg, #0f1729 0%, #1e3a5f 55%, #0f1729 100%);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 24px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  position: relative;
  overflow: hidden;
}
.borrower-banner::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(0,200,150,0.15) 0%, transparent 70%);
  pointer-events: none;
}
.borrower-banner::after {
  content: '';
  position: absolute;
  bottom: -40px; left: 20%;
  width: 300px; height: 200px;
  background: radial-gradient(circle, rgba(26,92,255,0.1) 0%, transparent 70%);
  pointer-events: none;
}
.borrower-banner-left { flex: 1; min-width: 280px; }
.borrower-banner-right {
  text-align: right;
  flex-shrink: 0;
}
.borrower-banner-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}
.borrower-banner-company {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}
.borrower-banner-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  margin-top: 6px;
}
.borrower-badge-status {
  background: rgba(26,92,255,0.25);
  border: 1px solid rgba(26,92,255,0.5);
  color: #a5c0ff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.borrower-badge-advisor {
  background: rgba(0,200,150,0.2);
  border: 1px solid rgba(0,200,150,0.4);
  color: #5dffd0;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.borrower-badge-date {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.borrower-banner-credit-label {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 4px;
}
.borrower-banner-credit {
  font-size: 32px;
  font-weight: 900;
  color: #5dffd0;
}
.borrower-banner-terms {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

/* KPI Card — Crescimento */
.kpi-card-growth {
  border-top: 3px solid var(--secondary);
}
.kpi-card-growth:first-child { border-top-color: var(--success); }
.kpi-card-growth:nth-child(2){ border-top-color: var(--primary); }
.kpi-card-growth:nth-child(3){ border-top-color: var(--secondary); }
.kpi-card-growth:nth-child(4){ border-top-color: var(--warning); }
.kpi-card-growth:nth-child(5){ border-top-color: var(--success); }
.kpi-card-growth:nth-child(6){ border-top-color: var(--info); }

/* Advisory Stages */
.advisory-stage-item {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
  position: relative;
}
.advisory-stage-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 15px;
  top: 34px;
  width: 2px;
  height: calc(100% - 14px);
  background: var(--border);
}
.advisory-stage-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.advisory-stage-body {
  flex: 1;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 1px solid var(--border);
}
.advisory-stage-title {
  font-size: 13px;
  font-weight: 700;
}

/* Chart buttons */
.borrower-chart-btn {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.borrower-chart-btn:hover {
  background: white;
  border-color: var(--primary);
  color: var(--primary);
}
.borrower-chart-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Risk Diagnosis — score ring */
.diagnosis-score-ring {
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.1));
}

/* Installments Progress bar segments */
.installs-bar-segment {
  flex: 1;
  height: 100%;
  transition: opacity 0.2s;
  cursor: help;
}
.installs-bar-segment:hover { opacity: 0.7; }

/* Responsive borrower */
@media (max-width: 900px) {
  .borrower-banner { flex-direction: column; }
  .borrower-banner-right { text-align: left; }
}

/* ===================================================================
   PAINEL MASTER — ERP DO FUNDO
   ISO 9001 | ISO 27001 | ISO 31000 | BACEN | CVM | LGPD
=================================================================== */

/* ── Header Master ── */
.master-header {
  background: linear-gradient(135deg, #0f1729 0%, #1e3a5f 60%, #0f2545 100%);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  color: white;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(93,255,208,0.15);
  box-shadow: 0 8px 32px rgba(15,23,41,0.18);
}
.master-header::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(93,255,208,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.master-header-left { flex: 1; }
.master-header-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  margin-bottom: 6px;
}
.master-header-title {
  font-size: 22px;
  font-weight: 900;
  color: #ffffff;
  line-height: 1.2;
  margin-bottom: 4px;
}
.master-header-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}
.master-header-right {
  text-align: right;
  min-width: 180px;
}

/* ── Master Chips ── */
.master-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.master-chip.green  { background: rgba(16,185,129,0.15); color: #5dffd0; border: 1px solid rgba(16,185,129,0.25); }
.master-chip.blue   { background: rgba(26,92,255,0.2);   color: #93c5fd; border: 1px solid rgba(26,92,255,0.3); }
.master-chip.yellow { background: rgba(245,158,11,0.15); color: #fde68a; border: 1px solid rgba(245,158,11,0.25); }
.master-chip.red    { background: rgba(239,68,68,0.15);  color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }
.master-chip.purple { background: rgba(139,92,246,0.15); color: #c4b5fd; border: 1px solid rgba(139,92,246,0.25); }

/* ── KPI Grid Master ── */
.master-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
}
.master-kpi-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: default;
  transition: transform 0.18s, box-shadow 0.18s;
}
.master-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ── Master Table ── */
.master-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.master-table thead tr {
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}
.master-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.master-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}
.master-table tbody tr:hover { background: #f8faff; }
.master-table tbody tr:last-child td { border-bottom: none; }

/* ── Quick Actions ── */
.master-quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
  background: var(--bg);
}
.master-quick-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}

/* ── Alerts Master ── */
.master-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  border-left: 3px solid;
}
.master-alert.danger  { background: #fef2f2; border-color: var(--danger); }
.master-alert.warning { background: #fffbeb; border-color: var(--warning); }
.master-alert.info    { background: #eff6ff; border-color: var(--info); }
.master-alert.success { background: #f0fdf4; border-color: var(--success); }
.master-alert-icon { font-size: 16px; margin-top: 1px; }

/* ── Match Card ── */
.master-match-card {
  transition: transform 0.18s, box-shadow 0.18s;
}
.master-match-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ── Badge de nível ── */
.master-badge-lv1 { background: #fee2e2; color: #991b1b; }
.master-badge-lv2 { background: #ede9fe; color: #5b21b6; }
.master-badge-lv3 { background: #dbeafe; color: #1e3a8a; }
.master-badge-lv4 { background: #d1fae5; color: #065f46; }
.master-badge-lv5 { background: #fef3c7; color: #92400e; }
.master-badge-lv6 { background: #f3f4f6; color: #374151; }

/* ── Badge purple ── */
.badge-purple { background: #ede9fe; color: #6d28d9; }

/* ── Form Labels e Inputs ── */
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
  color: var(--text-primary);
  background: #fff;
  transition: border-color 0.15s;
  outline: none;
  box-sizing: border-box;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,92,255,0.08); }
textarea.form-input { resize: vertical; min-height: 60px; }
select.form-input { cursor: pointer; }

/* ── Avatar sizes extra ── */
.avatar-md {
  width: 38px;
  height: 38px;
  font-size: 13px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

/* ── Sidebar Master section ── */
#sidebar .nav-section-title[style*="5dffd0"] {
  color: #5dffd0 !important;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 12px 16px 4px;
  text-transform: uppercase;
}

/* ── Responsive Master ── */
@media (max-width: 1200px) {
  .master-kpi-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}
@media (max-width: 900px) {
  .master-header { flex-direction: column; }
  .master-header-right { text-align: left; min-width: auto; }
  .master-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .master-kpi-grid { grid-template-columns: 1fr 1fr; }
  .master-header-title { font-size: 16px; }
}
