/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f7f4;
  --bg-tertiary: #f1efe8;
  --bg-hover: #f0effe;
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-tertiary: #9b9b9b;
  --border: rgba(0,0,0,0.1);
  --border-strong: rgba(0,0,0,0.2);
  --accent: #4f46e5;
  --accent-light: #ede9fe;
  --accent-hover: #4338ca;
  --success: #10b981;
  --success-light: #dcfce7;
  --warn: #f59e0b;
  --warn-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --cyan: #06b6d4;
  --cyan-light: #cffafe;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  font-family: 'Segoe UI', Tahoma, 'Arabic UI Text', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
}

html, body { height: 100%; }
body { background: var(--bg-tertiary); overflow: hidden; }

/* ===== LOGIN ===== */
.login-screen {
  position: fixed; inset: 0; background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%);
  display: flex; align-items: center; justify-content: center; z-index: 999;
}
.login-card {
  background: var(--bg-primary); border-radius: 20px; padding: 40px;
  width: 380px; box-shadow: var(--shadow-md);
  animation: fadeUp 0.4s ease;
}
@keyframes fadeUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
.login-logo {
  width: 56px; height: 56px; border-radius: 16px; background: var(--accent);
  color: #fff; font-size: 20px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
}
.login-title { font-size: 22px; font-weight: 600; text-align: center; color: var(--text-primary); }
.login-sub { font-size: 13px; color: var(--text-secondary); text-align: center; margin-bottom: 28px; margin-top: 4px; }
.login-error { background: var(--danger-light); color: var(--danger); padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 10px; }
.login-hint { font-size: 11px; color: var(--text-tertiary); text-align: center; margin-top: 16px; line-height: 1.8; }

/* ===== LAYOUT ===== */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w); background: var(--bg-primary);
  border-left: 1px solid var(--border); display: flex; flex-direction: column;
  flex-shrink: 0; transition: transform 0.3s; overflow-y: auto; overflow-x: hidden;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 16px; border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px; background: var(--accent);
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.brand-sub { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-section { margin-bottom: 20px; }
.nav-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary); padding: 0 10px 8px; display: block;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  font-size: 13px; color: var(--text-secondary);
  transition: all 0.15s; margin-bottom: 2px; position: relative;
}
.nav-item:hover { background: var(--bg-secondary); color: var(--text-primary); }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 500; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-right: auto; background: var(--danger); color: #fff;
  font-size: 10px; padding: 2px 7px; border-radius: 10px; font-weight: 600;
}

.sidebar-bottom {
  padding: 12px; border-top: 1px solid var(--border);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; transition: background 0.15s;
}
.user-card:hover { background: var(--bg-secondary); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent-light);
  color: var(--accent); font-size: 13px; font-weight: 600; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.avatar.av-green { background: var(--success-light); color: var(--success); }
.avatar.av-pink { background: #fce7f3; color: #db2777; }
.avatar.av-orange { background: var(--warn-light); color: #d97706; }
.avatar.av-purple { background: #f3e8ff; color: #9333ea; }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-secondary); }
.logout-btn {
  margin-right: auto; background: none; border: none; cursor: pointer;
  color: var(--text-tertiary); font-size: 16px; padding: 4px; border-radius: 6px;
  transition: all 0.15s;
}
.logout-btn:hover { background: var(--danger-light); color: var(--danger); }

/* ===== TOPBAR ===== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar {
  height: var(--topbar-h); background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 24px;
  flex-shrink: 0;
}
.menu-btn {
  display: none; background: none; border: none; cursor: pointer;
  font-size: 20px; padding: 4px 8px; color: var(--text-secondary);
}
.page-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.topbar-right { margin-right: auto; display: flex; align-items: center; gap: 12px; }
.date-badge {
  font-size: 12px; color: var(--text-secondary);
  background: var(--bg-secondary); padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border);
}

/* ===== CONTENT ===== */
.content { flex: 1; overflow-y: auto; padding: 24px; }
.content::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  padding: 9px 18px; border-radius: 9px; font-size: 13px; font-weight: 500;
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  transition: all 0.15s; font-family: inherit;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-outline {
  background: transparent; color: var(--text-primary);
  border: 1px solid var(--border-strong);
  padding: 8px 16px; border-radius: 9px; font-size: 13px;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.btn-outline:hover { background: var(--bg-secondary); }
.btn-success { background: var(--success); color: #fff; border: none; padding: 7px 14px; border-radius: 8px; font-size: 12px; cursor: pointer; font-family: inherit; }
.btn-danger { background: var(--danger); color: #fff; border: none; padding: 7px 14px; border-radius: 8px; font-size: 12px; cursor: pointer; font-family: inherit; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

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

/* ===== KPI GRID ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.kpi-card {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; right: 0;
  width: 4px; height: 100%; background: var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
}
.kpi-card.green::before { background: var(--success); }
.kpi-card.warn::before { background: var(--warn); }
.kpi-card.danger::before { background: var(--danger); }
.kpi-card.cyan::before { background: var(--cyan); }
.kpi-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.kpi-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.kpi-icon { font-size: 24px; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); opacity: 0.15; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: right; padding: 10px 12px;
  color: var(--text-secondary); font-weight: 500; font-size: 12px;
  border-bottom: 1px solid var(--border); background: var(--bg-secondary);
  white-space: nowrap;
}
thead th:first-child { border-radius: 0 8px 0 0; }
thead th:last-child { border-radius: 8px 0 0 0; }
tbody td { padding: 12px 12px; border-bottom: 1px solid var(--border); color: var(--text-primary); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; }
tbody tr:hover td { background: var(--bg-hover); }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge-success { background: var(--success-light); color: #15803d; }
.badge-warn { background: var(--warn-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-info { background: var(--info-light); color: #1e40af; }
.badge-gray { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge-accent { background: var(--accent-light); color: var(--accent); }
.badge-cyan { background: var(--cyan-light); color: #0e7490; }

/* ===== PROGRESS ===== */
.progress-row { margin-bottom: 14px; }
.progress-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; margin-bottom: 6px; }
.progress-track { height: 7px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 1s cubic-bezier(.4,0,.2,1); }
.progress-hint { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }

/* ===== BAR CHART ===== */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 80px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.bar-col .bar { width: 100%; border-radius: 5px 5px 0 0; min-height: 4px; }
.bar-col .bar-val { font-size: 10px; color: var(--text-secondary); }
.bar-col .bar-lbl { font-size: 10px; color: var(--text-tertiary); }

/* ===== PIPELINE ===== */
.pipeline-board { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.pipeline-col { background: var(--bg-secondary); border-radius: 12px; padding: 14px; min-height: 350px; }
.pipeline-col-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.pipeline-col-title { font-size: 13px; font-weight: 600; }
.pipeline-col-count {
  font-size: 11px; background: var(--bg-primary);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 2px 9px; color: var(--text-secondary);
}
.deal-card {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; margin-bottom: 8px; cursor: pointer;
  transition: all 0.15s;
}
.deal-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); transform: translateY(-1px); }
.deal-name { font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.deal-service { font-size: 11px; color: var(--text-secondary); margin-bottom: 8px; }
.deal-footer { display: flex; justify-content: space-between; align-items: center; }
.deal-value { font-size: 12px; font-weight: 600; color: var(--success); }
.deal-rep { font-size: 10px; color: var(--text-tertiary); }

/* ===== FUNNEL ===== */
.funnel { padding: 8px 0; }
.funnel-step { margin-bottom: 12px; }
.funnel-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; }
.funnel-bar { height: 32px; border-radius: 6px; display: flex; align-items: center; padding: 0 12px; font-size: 12px; font-weight: 600; color: #fff; transition: width 1s; }

/* ===== EMPLOYEE CARD ===== */
.emp-profile { display: flex; align-items: center; gap: 10px; }
.emp-info .emp-name { font-size: 13px; font-weight: 500; }
.emp-info .emp-meta { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }

/* ===== LEADERBOARD ===== */
.leaderboard-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.leaderboard-item:last-child { border-bottom: none; }
.rank-badge { width: 32px; text-align: center; font-size: 20px; flex-shrink: 0; }
.leaderboard-stats { margin-right: auto; text-align: left; }
.leaderboard-revenue { font-size: 15px; font-weight: 700; color: var(--success); }
.leaderboard-calls { font-size: 11px; color: var(--text-secondary); }

/* ===== ACTIVITY ===== */
.activity-feed { }
.activity-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.activity-body { flex: 1; }
.activity-text { font-size: 13px; color: var(--text-primary); line-height: 1.4; }
.activity-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 3px; }
.activity-badge { flex-shrink: 0; }

/* ===== FORM ===== */
.form-group { margin-bottom: 14px; }
.form-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; display: block; font-weight: 500; }
.form-input {
  width: 100%; padding: 10px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: 13px; font-family: inherit; transition: border-color 0.15s;
  outline: none;
}
.form-input:focus { border-color: var(--accent); background: var(--bg-primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.form-select {
  width: 100%; padding: 10px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: 13px; font-family: inherit; outline: none; cursor: pointer;
  transition: border-color 0.15s;
}
.form-select:focus { border-color: var(--accent); }
textarea.form-input { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-primary); border-radius: 16px;
  padding: 26px; width: 540px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-md); animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal::-webkit-scrollbar { width: 4px; }
.modal::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer; font-size: 18px;
  color: var(--text-secondary); padding: 6px; border-radius: 8px; transition: all 0.15s;
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1a1a1a; color: #fff; padding: 12px 24px;
  border-radius: 20px; font-size: 13px; opacity: 0;
  transition: opacity 0.3s; z-index: 9999; pointer-events: none;
  white-space: nowrap; box-shadow: var(--shadow-md);
}
.toast.show { opacity: 1; }

/* ===== MY STATS (SALES VIEW) ===== */
.stat-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 16px; }
.stat-box { background: var(--bg-secondary); border-radius: 10px; padding: 16px; text-align: center; }
.stat-num { font-size: 28px; font-weight: 700; }
.stat-lbl { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

/* ===== SEARCH ===== */
.search-wrap { position: relative; }
.search-wrap .search-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); font-size: 14px; }
.search-input { padding-right: 36px !important; }

/* ===== ALERT ===== */
.alert {
  padding: 12px 16px; border-radius: 10px; font-size: 13px;
  margin-bottom: 16px; display: flex; align-items: center; gap: 10px;
}
.alert-info { background: var(--info-light); color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: var(--success-light); color: #15803d; border: 1px solid #bbf7d0; }
.alert-warn { background: var(--warn-light); color: #92400e; border: 1px solid #fde68a; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg-secondary); border-radius: 12px; margin-bottom: 18px; border: 1px solid var(--border); }
.tab { flex: 1; padding: 8px 12px; text-align: center; font-size: 12px; font-weight: 500; border-radius: 9px; cursor: pointer; color: var(--text-secondary); transition: all 0.15s; }
.tab:hover { color: var(--text-primary); }
.tab.active { background: var(--bg-primary); color: var(--accent); box-shadow: var(--shadow); }

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

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

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-tertiary); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 14px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 50; height: 100vh; transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .menu-btn { display: block; }
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .pipeline-board { grid-template-columns: repeat(2,1fr); }
  .grid-2, .grid-3-1, .grid-1-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
}
@media (max-width: 540px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .pipeline-board { grid-template-columns: 1fr; }
  .topbar-right .date-badge { display: none; }
}
