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

:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #ea580c;
  --warning-light: #fed7aa;
  --danger: #dc2626;
  --danger-light: #fecaca;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
}

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

.sidebar {
  width: 220px;
  background: var(--gray-900);
  color: #fff;
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 20px 20px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 12px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.sidebar-nav a .icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer a {
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 13px;
}

.main-content {
  margin-left: 220px;
  flex: 1;
  padding: 24px 32px;
  min-width: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h1 { font-size: 24px; font-weight: 700; }

/* Cards */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 20px;
  text-align: center;
}

.kpi-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.kpi-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* Agent KPI Table */
.agent-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.agent-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 20px;
}

.agent-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.agent-name { font-size: 18px; font-weight: 700; }
.agent-region { font-size: 13px; color: var(--gray-500); }

.agent-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.agent-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.agent-stat-label {
  font-size: 11px;
  color: var(--gray-500);
}

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}

.data-table tr:hover { background: var(--gray-50); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-prospecting { background: var(--primary-light); color: var(--primary); }
.badge-quoted { background: var(--warning-light); color: var(--warning); }
.badge-negotiating { background: var(--purple-light); color: var(--purple); }
.badge-won { background: var(--success-light); color: var(--success); }
.badge-lost { background: var(--danger-light); color: var(--danger); }

.badge-new_lead { background: var(--primary-light); color: var(--primary); }
.badge-follow_up { background: var(--warning-light); color: var(--warning); }
.badge-complaint { background: var(--danger-light); color: var(--danger); }
.badge-routine { background: var(--success-light); color: var(--success); }
.badge-quoting { background: var(--purple-light); color: var(--purple); }

/* Pipeline Kanban */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kanban-column {
  background: var(--gray-100);
  border-radius: 12px;
  padding: 16px;
  min-height: 200px;
}

.kanban-column-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kanban-count {
  background: var(--gray-300);
  color: var(--gray-700);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.kanban-card {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.kanban-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.kanban-card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.kanban-card-vendor { font-size: 12px; color: var(--gray-500); }
.kanban-card-value { font-size: 13px; color: var(--success); margin-top: 4px; }
.kanban-card-agent { font-size: 11px; color: var(--gray-500); margin-top: 4px; }

/* Filters */
.filters {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-select, .filter-input {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-100); }

/* Period Tabs */
.period-tabs {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  border-radius: 8px;
  padding: 4px;
}

.period-tab {
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--gray-500);
}

.period-tab.active {
  background: #fff;
  color: var(--gray-900);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* Login */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}

.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-title { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.login-subtitle { font-size: 14px; color: var(--gray-500); text-align: center; margin-bottom: 32px; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; }

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.15s;
}

.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  display: none;
}

.btn-login {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  margin-top: 8px;
}

/* Location */
.location-cell {
  font-size: 12px;
  color: var(--gray-500);
}

.location-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 12px;
}

.location-link:hover { text-decoration: underline; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--gray-500);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Responsive */
@media (max-width: 900px) {
  .kanban { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Loading */
.loading { text-align: center; padding: 40px; color: var(--gray-500); }
