/* ============================================================
   SalesPipeline Pro — Main Stylesheet
   B2B Industrial CRM
   ============================================================ */

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --primary-bg: #eff6ff;
  --secondary: #7c3aed;
  --accent: #0891b2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #0284c7;
  --info-bg: #f0f9ff;

  /* Layout */
  --sidebar-w: 260px;
  --sidebar-collapsed-w: 68px;
  --header-h: 64px;

  /* Light Theme */
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card2: #f8fafc;
  --bg-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #2563eb;
  --sidebar-active-bg: rgba(37, 99, 235, 0.12);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.05);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --transition: .18s cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card2: #162032;
  --bg-hover: #2d3748;
  --border: #334155;
  --border-light: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --sidebar-bg: #0b1120;
  --sidebar-text: #6b7280;
  --primary-bg: rgba(37,99,235,.15);
  --success-bg: rgba(22,163,74,.12);
  --warning-bg: rgba(217,119,6,.12);
  --danger-bg: rgba(220,38,38,.12);
  --info-bg: rgba(2,132,199,.12);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.5);
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; transition: background var(--transition), color var(--transition); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
.hidden { display: none !important; }

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

/* ─── Login Screen ──────────────────────────────────────────── */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 40%, #1e293b 100%);
}
.login-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.login-bg::before {
  content: ''; position: absolute; width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(37,99,235,.25) 0%, transparent 70%);
  top: -200px; right: -200px; border-radius: 50%;
}
.login-bg::after {
  content: ''; position: absolute; width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(124,58,237,.2) 0%, transparent 70%);
  bottom: -100px; left: -100px; border-radius: 50%;
}
.login-card {
  position: relative; z-index: 10; background: rgba(30,41,59,.85);
  backdrop-filter: blur(24px); border: 1px solid rgba(255,255,255,.08);
  border-radius: 24px; padding: 48px 40px; width: 440px; max-width: 95vw;
  box-shadow: 0 25px 50px rgba(0,0,0,.5);
}
.login-logo { display: flex; align-items: center; gap: 16px; margin-bottom: 36px; }
.login-logo .logo-icon {
  width: 52px; height: 52px; background: var(--primary);
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: white;
  box-shadow: 0 0 30px rgba(37,99,235,.5);
}
.login-logo h1 { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.login-logo h1 span { color: var(--primary-light); }
.login-logo p { font-size: 12px; color: #64748b; margin-top: 2px; }

.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; font-size: 12px; font-weight: 600; color: #94a3b8; margin-bottom: 8px; letter-spacing: .5px; text-transform: uppercase; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #475569; font-size: 14px; }
.input-icon input {
  width: 100%; padding: 12px 14px 12px 42px; background: rgba(15,23,42,.6);
  border: 1px solid rgba(255,255,255,.1); border-radius: 10px; color: #fff;
  outline: none; transition: all var(--transition);
}
.input-icon input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.2); }
.toggle-pass { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #475569; padding: 4px; }
.login-options { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; color: #94a3b8; font-size: 13px; cursor: pointer; }
.forgot-link { color: var(--primary-light); font-size: 13px; }
.btn-login {
  width: 100%; padding: 13px; background: var(--primary);
  color: white; border-radius: 10px; font-weight: 600; font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: all var(--transition); letter-spacing: .3px;
}
.btn-login:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 8px 25px rgba(37,99,235,.4); }
.demo-accounts { margin-top: 28px; padding-top: 24px; border-top: 1px solid rgba(255,255,255,.08); text-align: center; }
.demo-accounts p { color: #64748b; font-size: 12px; margin-bottom: 12px; }
.demo-btns { display: flex; gap: 8px; justify-content: center; }
.demo-btns button {
  padding: 7px 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,.1);
  color: #94a3b8; font-size: 12px; transition: all var(--transition);
  display: flex; align-items: center; gap: 6px;
}
.demo-btns button:hover { border-color: var(--primary); color: var(--primary-light); background: rgba(37,99,235,.1); }

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

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 100; transition: width var(--transition);
  box-shadow: 2px 0 20px rgba(0,0,0,.15);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-w); }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-item span:not(.nav-indicator),
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .user-info { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0 18px; }
.sidebar.collapsed .sidebar-footer { padding: 16px 10px; }
.sidebar.collapsed .user-card { justify-content: center; }
.sidebar.collapsed .user-card .btn-icon { display: none; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.06);
  min-height: 64px;
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; }
.sidebar-logo .logo-icon {
  width: 36px; height: 36px; background: var(--primary); border-radius: 9px;
  display: flex; align-items: center; justify-content: center; color: white; font-size: 16px;
  flex-shrink: 0;
}
.logo-text { font-size: 15px; color: #f1f5f9; font-weight: 600; white-space: nowrap; }
.logo-text b { color: var(--primary-light); }
.sidebar-toggle { color: #475569; padding: 6px; border-radius: 6px; transition: all var(--transition); }
.sidebar-toggle:hover { color: #94a3b8; background: rgba(255,255,255,.05); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section { margin-bottom: 8px; }
.nav-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px; color: #374151;
  padding: 8px 20px 4px; display: block; white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  margin: 2px 8px; border-radius: 8px; color: var(--sidebar-text);
  transition: all var(--transition); position: relative; cursor: pointer;
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
}
.nav-item i { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item:hover { color: #e2e8f0; background: rgba(255,255,255,.06); }
.nav-item.active { color: var(--primary-light); background: var(--sidebar-active-bg); }
.nav-item.active .nav-indicator {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--primary); border-radius: 3px 0 0 3px;
}
.nav-badge {
  margin-left: auto; background: var(--primary); color: white;
  border-radius: 12px; padding: 2px 7px; font-size: 11px; font-weight: 600;
}

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.06); }
.user-card { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.user-avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.user-role { font-size: 11px; color: #475569; }
.user-card .btn-icon { margin-left: auto; color: #475569; }

/* ─── Main Content ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w); flex: 1; min-height: 100vh;
  display: flex; flex-direction: column; transition: margin-left var(--transition);
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed-w); }

/* ─── Top Header ────────────────────────────────────────────── */
.top-header {
  height: var(--header-h); background: var(--bg-card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-sm);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.sidebar-toggle-mobile { display: none; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.bc-separator { color: var(--text-muted); }
.bc-current { color: var(--text); font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-search {
  display: flex; align-items: center; gap: 10px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; width: 280px;
  transition: all var(--transition);
}
.header-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.header-search i { color: var(--text-muted); font-size: 13px; }
.header-search input { border: none; background: none; outline: none; color: var(--text); width: 100%; }
.header-search input::placeholder { color: var(--text-muted); }
.btn-icon {
  width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; color: var(--text-secondary); transition: all var(--transition);
  font-size: 15px; position: relative;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }
.btn-notif .notif-badge {
  position: absolute; top: 4px; right: 4px; width: 16px; height: 16px;
  background: var(--danger); color: white; border-radius: 50%;
  font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.header-user {
  display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 10px;
  border-radius: 8px; transition: all var(--transition);
}
.header-user:hover { background: var(--bg-hover); }
.header-user span { font-size: 13px; font-weight: 600; }
.header-user i { color: var(--text-muted); font-size: 10px; }

/* ─── Notifications Panel ───────────────────────────────────── */
.notif-panel {
  position: absolute; top: 64px; right: 16px; width: 360px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  z-index: 200; overflow: hidden;
}
.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.notif-header h3 { font-size: 15px; font-weight: 700; }
.notif-header button { font-size: 12px; color: var(--primary); }
.notif-item {
  display: flex; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border-light);
  transition: background var(--transition); cursor: pointer;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: var(--primary-bg); }
.notif-icon {
  width: 36px; height: 36px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0;
}
.notif-body .notif-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.notif-body .notif-desc { font-size: 12px; color: var(--text-secondary); }
.notif-body .notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ─── Page Container ────────────────────────────────────────── */
.page-container { flex: 1; padding: 24px; overflow-y: auto; }

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--primary); }
.card-body { padding: 20px; }

/* ─── Stat Cards ─────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; align-items: flex-start; gap: 16px;
  transition: all var(--transition); box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--stat-color, var(--primary));
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-size: 20px;
  background: var(--stat-bg, var(--primary-bg)); color: var(--stat-color, var(--primary));
  flex-shrink: 0;
}
.stat-info { flex: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; letter-spacing: .3px; }
.stat-value { font-size: 26px; font-weight: 800; margin: 4px 0; letter-spacing: -.5px; color: var(--text); }
.stat-change { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ─── Stage Colors & Badges ──────────────────────────────────── */
.stage-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.stage-lead { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }
.stage-so { background: #ede9fe; color: #7c3aed; border: 1px solid #ddd6fe; }
.stage-proposal { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.stage-bid { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.stage-negotiation { background: #fed7aa; color: #9a3412; border: 1px solid #fdba74; }
.stage-approval { background: #e0e7ff; color: #3730a3; border: 1px solid #c7d2fe; }
.stage-won { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.stage-lost { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.stage-paused { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }

.priority-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 700; }
.priority-cao { background: #fee2e2; color: #dc2626; }
.priority-trung { background: #fef9c3; color: #d97706; }
.priority-thap { background: #f0fdf4; color: #16a34a; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  transition: all var(--transition); cursor: pointer; 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(37,99,235,.35); }
.btn-secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-icon-text { padding: 8px 14px; }

/* ─── Form Elements ──────────────────────────────────────────── */
.form-control {
  width: 100%; padding: 9px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); outline: none;
  transition: all var(--transition); font-size: 13px;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); background: var(--bg-card); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; letter-spacing: .3px; }
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ─── Tables ─────────────────────────────────────────────────── */
.table-wrapper { overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead { position: sticky; top: 0; z-index: 10; background: var(--bg-card2); }
.data-table th {
  padding: 12px 14px; text-align: left; font-weight: 600; color: var(--text-secondary);
  font-size: 11px; letter-spacing: .5px; text-transform: uppercase; border-bottom: 2px solid var(--border);
  white-space: nowrap; user-select: none; cursor: pointer;
}
.data-table th:hover { color: var(--primary); }
.data-table th .sort-icon { margin-left: 4px; opacity: .4; }
.data-table th.sorted .sort-icon { opacity: 1; color: var(--primary); }
.data-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border-light);
  vertical-align: middle; color: var(--text);
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .col-sticky { position: sticky; left: 0; background: var(--bg-card); z-index: 5; }
.data-table tbody tr:hover .col-sticky { background: var(--bg-hover); }

.table-actions { display: flex; gap: 6px; }
.action-btn {
  width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center;
  justify-content: center; font-size: 12px; color: var(--text-secondary);
  transition: all var(--transition); border: 1px solid transparent;
}
.action-btn:hover { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.action-btn.danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

/* ─── Health Score ───────────────────────────────────────────── */
.health-bar {
  height: 6px; border-radius: 3px; background: var(--border);
  overflow: hidden; width: 80px; display: inline-block; vertical-align: middle;
}
.health-fill { height: 100%; border-radius: 3px; transition: width .5s ease; }
.health-high { background: var(--success); }
.health-mid { background: var(--warning); }
.health-low { background: var(--danger); }
.health-score-text { font-size: 12px; font-weight: 700; margin-left: 6px; }

/* ─── Probability Bar ────────────────────────────────────────── */
.prob-bar { display: flex; align-items: center; gap: 8px; }
.prob-track { flex: 1; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; min-width: 60px; }
.prob-fill { height: 100%; border-radius: 3px; background: var(--primary); }
.prob-text { font-size: 12px; font-weight: 700; width: 32px; text-align: right; }

/* ─── Dashboard Grids ─────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dashboard-grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

/* ─── Kanban Board ───────────────────────────────────────────── */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; min-height: calc(100vh - 180px); }
.kanban-column {
  min-width: 260px; max-width: 260px; background: var(--bg-card2);
  border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 200px);
}
.kanban-header {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; position: sticky; top: 0;
  background: var(--bg-card2); border-radius: var(--radius) var(--radius) 0 0;
}
.kanban-stage-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.kanban-stage-name { font-size: 13px; font-weight: 700; flex: 1; }
.kanban-count {
  background: var(--bg-hover); border-radius: 12px; padding: 2px 8px;
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
}
.kanban-value { font-size: 11px; color: var(--text-muted); padding: 4px 14px 8px; }
.kanban-cards { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.kanban-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; cursor: pointer; transition: all var(--transition);
  border-left: 3px solid var(--stage-color, var(--border));
  position: relative;
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-left-color: var(--primary); }
.kanban-card.dragging { opacity: .5; transform: rotate(2deg); }
.card-priority-line { position: absolute; top: 0; right: 0; width: 4px; height: 100%; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.kanban-card-customer { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kanban-card-desc { font-size: 11px; color: var(--text-secondary); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kanban-card-value { font-size: 13px; font-weight: 700; color: var(--primary); }
.kanban-card-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.kanban-card-prob { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-secondary); }
.kanban-card-owner {
  width: 22px; height: 22px; border-radius: 50%; background: var(--secondary);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700;
}
.aging-warning { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--danger); margin-top: 6px; }

/* ─── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-container {
  background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  width: 100%; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
  animation: modalIn .2s ease;
}
.modal-xl { max-width: 1100px; }
.modal-lg { max-width: 700px; }
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(10px); } to { opacity: 1; transform: none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); transition: all var(--transition); }
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-body { flex: 1; overflow-y: auto; padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Filter Drawer ──────────────────────────────────────────── */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 300; }
.filter-drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: 380px; background: var(--bg-card);
  z-index: 310; box-shadow: var(--shadow-xl); display: flex; flex-direction: column;
  animation: drawerIn .25s ease;
}
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* ─── Opportunity Detail ─────────────────────────────────────── */
.opp-detail-header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  padding: 24px; color: white; position: relative; overflow: hidden;
}
.opp-detail-header::before {
  content: ''; position: absolute; top: -50px; right: -50px;
  width: 200px; height: 200px; background: radial-gradient(circle, rgba(37,99,235,.3) 0%, transparent 70%);
  border-radius: 50%;
}
.opp-code { font-size: 11px; color: #64748b; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.opp-title { font-size: 20px; font-weight: 800; margin: 6px 0; }
.opp-subtitle { font-size: 13px; color: #94a3b8; }
.opp-header-meta { display: flex; gap: 20px; margin-top: 16px; flex-wrap: wrap; }
.opp-meta-item { display: flex; flex-direction: column; gap: 2px; }
.opp-meta-label { font-size: 10px; color: #475569; text-transform: uppercase; letter-spacing: .5px; }
.opp-meta-value { font-size: 14px; font-weight: 700; }
.opp-meta-value.big { font-size: 22px; color: #60a5fa; }

.opp-detail-body { display: grid; grid-template-columns: 1fr 340px; gap: 0; }
.opp-detail-main { padding: 24px; border-right: 1px solid var(--border); overflow-y: auto; }
.opp-detail-sidebar { padding: 24px; overflow-y: auto; }

.health-score-circle {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 4px solid; position: relative; margin: 0 auto 12px;
}
.health-score-circle .score-num { font-size: 22px; font-weight: 800; }
.health-score-circle .score-label { font-size: 9px; text-transform: uppercase; letter-spacing: .5px; }

.bant-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bant-item {
  padding: 12px; border-radius: 8px; border: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.bant-check { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.bant-item.confirmed { background: var(--success-bg); border-color: #bbf7d0; }
.bant-item.confirmed .bant-check { background: var(--success); color: white; }
.bant-item.pending { background: var(--warning-bg); border-color: #fde68a; }
.bant-item.pending .bant-check { background: var(--warning); color: white; }
.bant-item.unknown { background: var(--bg-hover); }
.bant-item.unknown .bant-check { background: var(--border); color: var(--text-muted); }
.bant-label { font-size: 12px; font-weight: 700; }
.bant-status { font-size: 11px; color: var(--text-secondary); }

.activity-timeline { display: flex; flex-direction: column; gap: 0; }
.activity-item { display: flex; gap: 14px; position: relative; padding-bottom: 20px; }
.activity-item:last-child { padding-bottom: 0; }
.activity-item::before { content: ''; position: absolute; left: 18px; top: 36px; bottom: 0; width: 1px; background: var(--border); }
.activity-item:last-child::before { display: none; }
.activity-icon {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 13px; flex-shrink: 0; border: 2px solid var(--bg-card);
}
.activity-content { flex: 1; }
.activity-header { display: flex; justify-content: space-between; align-items: baseline; }
.activity-user { font-size: 13px; font-weight: 600; }
.activity-time { font-size: 11px; color: var(--text-muted); }
.activity-text { font-size: 13px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }
.activity-tag {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600;
  background: var(--primary-bg); color: var(--primary); margin-top: 6px;
}

/* ─── Charts ─────────────────────────────────────────────────── */
.chart-container { width: 100%; }

/* ─── Progress Ring ──────────────────────────────────────────── */
.progress-ring { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.progress-ring-item { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.progress-ring-label { font-size: 11px; color: var(--text-secondary); text-align: center; }

/* ─── Tags ───────────────────────────────────────────────────── */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600;
  background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border);
  margin: 2px;
}

/* ─── Tooltip ────────────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); background: #1e293b; color: white; padding: 5px 10px;
  border-radius: 6px; font-size: 11px; white-space: nowrap; z-index: 1000; pointer-events: none;
}

/* ─── Toast ──────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: 10px;
  box-shadow: var(--shadow-lg); min-width: 280px; animation: toastIn .3s ease;
  border-left: 4px solid;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.toast-success { background: var(--bg-card); border-color: var(--success); }
.toast-error { background: var(--bg-card); border-color: var(--danger); }
.toast-warning { background: var(--bg-card); border-color: var(--warning); }
.toast-info { background: var(--bg-card); border-color: var(--primary); }
.toast-icon { font-size: 16px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--primary); }
.toast-text { font-size: 13px; font-weight: 500; flex: 1; }

/* ─── Page Headers ───────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.page-actions { display: flex; gap: 10px; align-items: center; }

/* ─── Tabs ───────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 18px; font-size: 13px; font-weight: 600; color: var(--text-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all var(--transition);
  display: flex; align-items: center; gap: 7px;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Empty State ────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; color: var(--text-muted); text-align: center;
}
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.empty-state p { font-size: 13px; }

/* ─── Loading ────────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-muted); gap: 10px; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Inline Edit ────────────────────────────────────────────── */
.inline-edit { display: flex; align-items: center; gap: 6px; }
.inline-edit .editable { cursor: pointer; border-bottom: 1px dashed transparent; transition: all var(--transition); }
.inline-edit .editable:hover { border-bottom-color: var(--primary); color: var(--primary); }

/* ─── KPI Indicators ─────────────────────────────────────────── */
.kpi-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.kpi-card {
  flex: 1; min-width: 160px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.kpi-value { font-size: 28px; font-weight: 800; color: var(--primary); }
.kpi-label { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

/* ─── Forecast Table ─────────────────────────────────────────── */
.forecast-bar {
  height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; min-width: 120px;
}
.forecast-fill { height: 100%; border-radius: 4px; }

/* ─── Risk Indicator ─────────────────────────────────────────── */
.risk-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px;
  border-radius: 10px; font-size: 11px; font-weight: 700;
}
.risk-high { background: var(--danger-bg); color: var(--danger); }
.risk-mid { background: var(--warning-bg); color: var(--warning); }
.risk-low { background: var(--success-bg); color: var(--success); }

/* ─── Calendar ───────────────────────────────────────────────── */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-header-cell { background: var(--bg-card2); padding: 10px; text-align: center; font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; }
.cal-cell { background: var(--bg-card); padding: 8px; min-height: 90px; vertical-align: top; }
.cal-cell.other-month { background: var(--bg); }
.cal-date { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.cal-cell.today .cal-date { background: var(--primary); color: white; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.cal-event { font-size: 10px; padding: 2px 5px; border-radius: 4px; margin-bottom: 2px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .sidebar-toggle-mobile { display: flex; }
  .header-search { width: 180px; }
  .opp-detail-body { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr; }
  .page-container { padding: 16px; }
  .header-search { display: none; }
  .kanban-board { padding-bottom: 80px; }
}

/* ─── Toggle Switch ──────────────────────────────────────────── */
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 22px; transition: .3s;
}
.toggle-slider::before {
  content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: .3s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-switch input:disabled + .toggle-slider { opacity: .5; cursor: not-allowed; }

/* ─── Kanban Quick Edit ───────────────────────────────────────── */
.kanban-card-actions {
  display: none; position: absolute; top: 6px; right: 6px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 2px; gap: 2px; z-index: 10;
}
.kanban-card:hover .kanban-card-actions { display: flex; }
.kc-action-btn {
  width: 24px; height: 24px; border-radius: 5px; display: flex;
  align-items: center; justify-content: center; font-size: 11px;
  color: var(--text-secondary); transition: all var(--transition);
}
.kc-action-btn:hover { background: var(--primary-bg); color: var(--primary); }
.kc-action-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ─── Quick Edit Popup ───────────────────────────────────────── */
.quick-edit-popup {
  position: fixed; z-index: 600; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl); width: 340px; padding: 0;
  animation: modalIn .15s ease;
}
.qe-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.qe-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; }
.qe-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ─── User Mgmt ──────────────────────────────────────────────── */
.cfg-value-row:hover { background: var(--bg-hover) !important; }
.cfg-value-input:focus { color: var(--primary); }

/* ─── Utility ────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 700; }
.fw-600 { font-weight: 600; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.separator { height: 1px; background: var(--border); margin: 16px 0; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
