/* ═══════════════════════════════════════════════════════
   JLYN CRM DASHBOARD — Premium Luxury UI
   PHP 7.3 / Vanilla JS / No Build Step
   ═══════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────── */
:root {
  --azure:        #38bdf8;
  --azure-deep:   #0ea5e9;
  --sky:          #bae6fd;
  --violet:       #818cf8;
  --violet-deep:  #6366f1;
  --pink:         #f472b6;
  --pink-deep:    #ec4899;
  --gold:         #fbbf24;
  --gold-deep:    #f59e0b;
  --emerald:      #34d399;
  --emerald-deep: #10b981;
  --white:        #ffffff;
  --ink:          #0f172a;
  --ink-2:        #1e293b;
  --ink-3:        #334155;
  --muted:        #64748b;
  --muted-2:      #94a3b8;
  --border:       rgba(148,163,184,0.2);
  --glass-bg:     rgba(255,255,255,0.72);
  --glass-border: rgba(255,255,255,0.82);
  --sidebar-w:    264px;
  --sidebar-w-collapsed: 72px;
  --header-h:     72px;
  --radius-sm:    12px;
  --radius-md:    18px;
  --radius-lg:    24px;
  --radius-xl:    32px;
  --shadow-sm:    0 2px 8px rgba(15,23,42,0.06);
  --shadow-md:    0 8px 32px rgba(99,102,241,0.12);
  --shadow-lg:    0 20px 60px rgba(99,102,241,0.18);
  --shadow-glow:  0 0 40px rgba(56,189,248,0.25);
  --transition:   0.25s cubic-bezier(0.4,0,0.2,1);
  --font:         'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #e8f4ff;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
table { border-collapse: collapse; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.25); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.45); }

/* ── Aurora Background ──────────────────────────────────── */
#aurora-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background: linear-gradient(135deg, #f0f9ff 0%, #fdf4ff 35%, #fff7ed 65%, #f0fdf4 100%);
}
.aurora-orb {
  position: absolute; border-radius: 50%;
  filter: blur(60px); opacity: 0.55; pointer-events: none;
  animation: auroraFloat var(--dur, 20s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.aurora-orb:nth-child(1){
  width: 700px; height: 700px; left: -200px; top: -150px;
  background: radial-gradient(circle, rgba(56,189,248,0.4) 0%, rgba(99,102,241,0.2) 60%, transparent 80%);
  --dur: 18s;
}
.aurora-orb:nth-child(2){
  width: 600px; height: 600px; right: -150px; top: 10%;
  background: radial-gradient(circle, rgba(244,114,182,0.35) 0%, rgba(167,139,250,0.2) 60%, transparent 80%);
  --dur: 24s; --delay: -8s;
}
.aurora-orb:nth-child(3){
  width: 500px; height: 500px; left: 30%; bottom: -100px;
  background: radial-gradient(circle, rgba(251,191,36,0.3) 0%, rgba(52,211,153,0.2) 60%, transparent 80%);
  --dur: 21s; --delay: -5s;
}
.aurora-orb:nth-child(4){
  width: 400px; height: 400px; left: 60%; top: 40%;
  background: radial-gradient(circle, rgba(99,102,241,0.25) 0%, rgba(56,189,248,0.15) 60%, transparent 80%);
  --dur: 15s; --delay: -3s;
}
@keyframes auroraFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(30px, -40px) scale(1.05); }
  66%       { transform: translate(-20px, 30px) scale(0.95); }
}

/* ── Particles ──────────────────────────────────────────── */
#particles-canvas {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
}

/* ── Mouse Light ────────────────────────────────────────── */
#mouse-light {
  position: fixed; pointer-events: none; z-index: 2;
  width: 400px; height: 400px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(99,102,241,0.07) 0%, transparent 70%);
  transition: opacity 0.3s;
  mix-blend-mode: screen;
}

/* ── Loading Screen ─────────────────────────────────────── */
#loading-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #f0f9ff 0%, #fdf4ff 50%, #f0fdf4 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#loading-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.ls-logo {
  width: 80px; height: 80px; margin-bottom: 24px;
  animation: lsLogoPulse 2s ease-in-out infinite;
}
@keyframes lsLogoPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 8px 24px rgba(99,102,241,0.35)); }
  50%       { transform: scale(1.06); filter: drop-shadow(0 12px 40px rgba(99,102,241,0.55)); }
}
.ls-brand {
  font-size: 28px; font-weight: 900; letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--azure-deep), var(--violet), var(--pink));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.ls-tagline { font-size: 13px; color: var(--muted); letter-spacing: 0.15em; text-transform: uppercase; margin-bottom: 40px; font-weight: 600; }
.ls-bar-wrap { width: 220px; height: 4px; background: rgba(99,102,241,0.15); border-radius: 99px; overflow: hidden; }
.ls-bar {
  height: 100%; border-radius: 99px; width: 0%;
  background: linear-gradient(90deg, var(--azure), var(--violet), var(--pink));
  transition: width 0.4s ease;
  box-shadow: 0 0 16px rgba(99,102,241,0.5);
}
.ls-status { margin-top: 16px; font-size: 12px; color: var(--muted-2); font-weight: 500; }
.ls-dots span {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin: 0 3px;
  background: var(--violet); animation: dotBounce 1.2s ease-in-out infinite;
}
.ls-dots span:nth-child(2) { animation-delay: 0.2s; }
.ls-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50%       { transform: translateY(-8px); opacity: 1; }
}

/* ── App Shell ──────────────────────────────────────────── */
#app {
  position: relative; z-index: 10;
  display: flex; min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(24px) saturate(180%);
  border-right: 1px solid var(--glass-border);
  box-shadow: 4px 0 32px rgba(99,102,241,0.08);
  transition: width var(--transition), transform var(--transition);
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  z-index: 100;
}
#sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sb-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
  overflow: hidden;
}
.sb-logo-img { width: 40px; height: 40px; flex-shrink: 0; }
.sb-logo-text { overflow: hidden; white-space: nowrap; }
.sb-logo-name {
  font-size: 13px; font-weight: 900; letter-spacing: 0.12em;
  background: linear-gradient(135deg, var(--azure-deep), var(--violet), var(--pink));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.sb-logo-tagline { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; font-weight: 600; }
.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px; }
.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-section-label {
  font-size: 10px; font-weight: 800; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--muted-2); padding: 12px 10px 6px; white-space: nowrap; overflow: hidden;
}
#sidebar.collapsed .sb-section-label { opacity: 0; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 10px; border-radius: var(--radius-sm);
  cursor: pointer; position: relative; overflow: hidden;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap; margin-bottom: 2px; color: var(--ink-3);
  user-select: none;
}
.nav-item:hover { background: rgba(99,102,241,0.08); transform: translateX(2px); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(56,189,248,0.15), rgba(99,102,241,0.18));
  color: var(--violet-deep);
  box-shadow: inset 0 0 0 1px rgba(99,102,241,0.2);
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--azure), var(--violet));
}
.nav-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: transform var(--transition);
}
.nav-item.active .nav-icon { transform: scale(1.08); }
.nav-label { font-size: 13.5px; font-weight: 600; overflow: hidden; transition: opacity var(--transition), max-width var(--transition); }
.nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 800;
  background: linear-gradient(135deg, var(--azure), var(--violet));
  color: white; padding: 2px 7px; border-radius: 99px;
  flex-shrink: 0;
}
#sidebar.collapsed .nav-label,
#sidebar.collapsed .nav-badge,
#sidebar.collapsed .sb-logo-text { opacity: 0; max-width: 0; pointer-events: none; }
.sb-footer {
  padding: 16px; border-top: 1px solid var(--border);
  overflow: hidden;
}
.sb-sync-badge {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(99,102,241,0.06);
  font-size: 12px; font-weight: 600; color: var(--muted);
  overflow: hidden; white-space: nowrap;
}
.sync-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--emerald); box-shadow: 0 0 8px rgba(52,211,153,0.6);
  animation: syncPulse 2s ease-in-out infinite;
}
.sync-dot.error { background: #f87171; box-shadow: 0 0 8px rgba(248,113,113,0.6); }
.sync-dot.syncing { background: var(--gold); box-shadow: 0 0 8px rgba(251,191,36,0.6); animation: syncSpin 1s linear infinite; }
@keyframes syncPulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.6;transform:scale(0.85)} }
@keyframes syncSpin  { to{transform:rotate(360deg)} }

/* ── Sidebar Toggle ─────────────────────────────────────── */
#sb-toggle {
  position: absolute; right: -14px; top: 80px; z-index: 101;
  width: 28px; height: 28px; border-radius: 50%;
  background: white; border: 2px solid var(--border);
  box-shadow: var(--shadow-sm); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted);
  transition: transform var(--transition), box-shadow var(--transition);
}
#sb-toggle:hover { box-shadow: var(--shadow-md); transform: scale(1.1); }
#sidebar.collapsed #sb-toggle { transform: rotate(180deg); }

/* ── Main Content ───────────────────────────────────────── */
#main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  min-height: 100vh;
}

/* ── Top Header ─────────────────────────────────────────── */
#topbar {
  height: var(--header-h); display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 2px 20px rgba(99,102,241,0.08);
  position: sticky; top: 0; z-index: 50;
}
.tb-breadcrumb { flex: 1; overflow: hidden; }
.tb-section-name { font-size: 20px; font-weight: 800; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-section-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tb-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.tb-time {
  font-size: 13px; font-weight: 700; color: var(--ink-3);
  padding: 8px 14px; border-radius: 99px;
  background: rgba(99,102,241,0.07); white-space: nowrap;
  display: none;
}
@media(min-width:1100px) { .tb-time { display: block; } }
.tb-refresh-count { font-size: 11px; color: var(--muted-2); font-weight: 500; white-space: nowrap; display: none; }
@media(min-width:1200px) { .tb-refresh-count { display: block; } }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 700; border: none;
  transition: all var(--transition); white-space: nowrap;
  position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(rgba(255,255,255,0.25), transparent);
  opacity: 0; transition: opacity var(--transition);
}
.btn:hover::after { opacity: 1; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--azure-deep), var(--violet-deep), var(--pink-deep));
  color: white; box-shadow: 0 4px 20px rgba(99,102,241,0.3);
}
.btn-secondary {
  background: rgba(255,255,255,0.9); color: var(--ink-3);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.btn-ghost { background: transparent; color: var(--muted); padding: 9px 12px; }
.btn-ghost:hover { background: rgba(99,102,241,0.08); color: var(--violet-deep); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-danger { background: linear-gradient(135deg, #f87171, #ef4444); color: white; }
.btn-icon { padding: 9px; border-radius: 10px; }
.btn-icon svg { width: 18px; height: 18px; }

/* ── Content Area ───────────────────────────────────────── */
#content { flex: 1; padding: 24px 28px 40px; overflow-y: auto; }

/* ── Sections ───────────────────────────────────────────── */
.dash-section { display: none; }
.dash-section.active { display: block; animation: sectionIn 0.4s cubic-bezier(0.4,0,0.2,1) forwards; }
@keyframes sectionIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Section Header ─────────────────────────────────────── */
.section-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.section-title { font-size: 26px; font-weight: 900; color: var(--ink); line-height: 1.2; }
.section-sub { font-size: 14px; color: var(--muted); margin-top: 4px; }
.section-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Grid Layouts ───────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-kpi { grid-template-columns: repeat(4, 1fr); }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-1-1 { grid-template-columns: 1.2fr 1fr 1fr; }

/* ── KPI Cards ──────────────────────────────────────────── */
.kpi-card {
  border-radius: var(--radius-lg); padding: 22px;
  position: relative; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: default; transform-style: preserve-3d;
}
.kpi-card:hover { transform: translateY(-4px) scale(1.01); }
.kpi-card.c-azure  { background: linear-gradient(135deg, rgba(56,189,248,0.15) 0%, rgba(255,255,255,0.85) 100%); border: 1px solid rgba(56,189,248,0.25); }
.kpi-card.c-violet { background: linear-gradient(135deg, rgba(129,140,248,0.15) 0%, rgba(255,255,255,0.85) 100%); border: 1px solid rgba(129,140,248,0.25); }
.kpi-card.c-pink   { background: linear-gradient(135deg, rgba(244,114,182,0.15) 0%, rgba(255,255,255,0.85) 100%); border: 1px solid rgba(244,114,182,0.25); }
.kpi-card.c-gold   { background: linear-gradient(135deg, rgba(251,191,36,0.15) 0%, rgba(255,255,255,0.85) 100%); border: 1px solid rgba(251,191,36,0.25); }
.kpi-card.c-emerald{ background: linear-gradient(135deg, rgba(52,211,153,0.15) 0%, rgba(255,255,255,0.85) 100%); border: 1px solid rgba(52,211,153,0.25); }
.kpi-card.c-sky    { background: linear-gradient(135deg, rgba(186,230,253,0.35) 0%, rgba(255,255,255,0.85) 100%); border: 1px solid rgba(186,230,253,0.5); }
.kpi-card::before {
  content: ''; position: absolute; right: -30px; bottom: -40px;
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.6), transparent 70%);
  pointer-events: none;
}
.kpi-card-inner { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100%; }
.kpi-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-icon {
  width: 44px; height: 44px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; background: rgba(255,255,255,0.7);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  backdrop-filter: blur(8px);
}
.kpi-label { font-size: 12px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); margin-top: 16px; }
.kpi-value { font-size: clamp(28px,3.5vw,44px); font-weight: 900; color: var(--ink); margin-top: 6px; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-delta { display: flex; align-items: center; gap: 5px; margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.kpi-delta.up { color: var(--emerald-deep); }
.kpi-delta.down { color: #ef4444; }
.kpi-spark { margin-top: 14px; height: 42px; }
.kpi-spark canvas { width: 100% !important; height: 42px !important; }
.kpi-card-enter { animation: kpiEnter 0.6s cubic-bezier(0.34,1.56,0.64,1) both; }
@keyframes kpiEnter {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Panels / Cards ─────────────────────────────────────── */
.panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(160%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.panel:hover { box-shadow: var(--shadow-lg); }
.panel-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 20px 22px 0;
}
.panel-title { font-size: 16px; font-weight: 800; color: var(--ink); }
.panel-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.panel-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-body { padding: 16px 22px 20px; }
.panel-body.no-pad { padding: 0; }
.panel-separator { height: 1px; background: var(--border); margin: 0 22px; }
.panel-badge {
  display: inline-flex; align-items: center; padding: 5px 12px;
  border-radius: 99px; font-size: 11px; font-weight: 800;
  background: rgba(251,191,36,0.15); color: var(--gold-deep); border: 1px solid rgba(251,191,36,0.3);
  letter-spacing: 0.04em; text-transform: uppercase;
}

/* ── Chart Containers ───────────────────────────────────── */
.chart-wrap { position: relative; }
.chart-wrap canvas { max-width: 100%; }

/* ── Sales Funnel ───────────────────────────────────────── */
.funnel-list { display: flex; flex-direction: column; gap: 10px; }
.funnel-item {
  display: grid; grid-template-columns: 160px 1fr 100px 72px;
  gap: 10px; align-items: center;
}
.funnel-label { font-size: 13px; font-weight: 700; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funnel-track { height: 20px; border-radius: 99px; background: rgba(148,163,184,0.12); overflow: hidden; box-shadow: inset 0 1px 4px rgba(0,0,0,0.05); }
.funnel-fill {
  height: 100%; border-radius: 99px; transition: width 1.2s cubic-bezier(0.34,1.2,0.64,1);
  background: linear-gradient(90deg, var(--azure), var(--violet), var(--pink));
  box-shadow: 0 4px 14px rgba(99,102,241,0.3), 0 0 20px rgba(56,189,248,0.2);
  position: relative;
}
.funnel-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.3), transparent 60%);
  border-radius: inherit;
}
.funnel-count { font-size: 13px; font-weight: 800; color: var(--ink-3); text-align: right; }
.funnel-pct { font-size: 12px; font-weight: 700; color: var(--muted); text-align: right; }
.funnel-divider { display: flex; justify-content: center; margin: 2px 0; }
.funnel-divider::after {
  content: '▼'; font-size: 10px; color: rgba(99,102,241,0.3);
}

/* ── Data Tables ────────────────────────────────────────── */
.table-wrap { overflow: auto; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.data-table {
  width: 100%; min-width: 640px;
  background: transparent;
}
.data-table thead th {
  padding: 13px 16px; text-align: left;
  font-size: 11px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted);
  background: rgba(248,250,252,0.9); position: sticky; top: 0; z-index: 2;
  border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; cursor: pointer;
}
.data-table thead th:hover { color: var(--violet-deep); }
.data-table thead th.sort-asc::after  { content: ' ↑'; color: var(--violet); }
.data-table thead th.sort-desc::after { content: ' ↓'; color: var(--violet); }
.data-table tbody td { padding: 13px 16px; border-bottom: 1px solid rgba(241,245,249,0.8); font-size: 13.5px; color: var(--ink-3); vertical-align: middle; }
.data-table tbody tr { transition: background var(--transition), transform var(--transition), box-shadow var(--transition); }
.data-table tbody tr:hover { background: rgba(99,102,241,0.04); transform: translateX(2px); }
.data-table tbody tr:last-child td { border-bottom: none; }
.td-primary { font-weight: 700; color: var(--ink); }
.td-secondary { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Status Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 800; white-space: nowrap; letter-spacing: 0.03em;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-blue    { background: rgba(56,189,248,0.12);  color: var(--azure-deep);   border: 1px solid rgba(56,189,248,0.25); }
.badge-violet  { background: rgba(99,102,241,0.12);  color: var(--violet-deep);  border: 1px solid rgba(99,102,241,0.25); }
.badge-pink    { background: rgba(236,72,153,0.12);  color: var(--pink-deep);    border: 1px solid rgba(236,72,153,0.25); }
.badge-green   { background: rgba(16,185,129,0.12);  color: var(--emerald-deep); border: 1px solid rgba(16,185,129,0.25); }
.badge-gold    { background: rgba(245,158,11,0.12);  color: var(--gold-deep);    border: 1px solid rgba(245,158,11,0.25); }
.badge-red     { background: rgba(239,68,68,0.12);   color: #dc2626;             border: 1px solid rgba(239,68,68,0.25); }
.badge-gray    { background: rgba(100,116,139,0.1);  color: var(--muted);        border: 1px solid rgba(100,116,139,0.2); }
.badge-no-dot::before { display: none; }

/* ── Search & Filter ────────────────────────────────────── */
.search-wrap { display: flex; gap: 8px; flex-wrap: wrap; }
.search-input {
  padding: 9px 14px 9px 38px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: rgba(255,255,255,0.9);
  font-size: 13px; color: var(--ink); min-width: 220px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center; background-size: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.search-input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.filter-select {
  padding: 9px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: rgba(255,255,255,0.9);
  font-size: 13px; color: var(--ink); min-width: 160px;
  outline: none; cursor: pointer;
  transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--violet); }

/* ── Top Opportunities / Rank List ──────────────────────── */
.rank-list { display: flex; flex-direction: column; }
.rank-item {
  display: grid; grid-template-columns: 40px 1fr auto;
  gap: 12px; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(241,245,249,0.8);
  transition: background var(--transition), transform var(--transition);
}
.rank-item:last-child { border-bottom: none; }
.rank-item:hover { background: rgba(99,102,241,0.04); transform: translateX(4px); }
.rank-num {
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900; color: white;
  background: linear-gradient(135deg, var(--azure), var(--violet));
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.rank-num.top1 { background: linear-gradient(135deg, var(--gold), #f97316); box-shadow: 0 4px 12px rgba(251,191,36,0.4); }
.rank-num.top2 { background: linear-gradient(135deg, #94a3b8, #64748b); }
.rank-num.top3 { background: linear-gradient(135deg, var(--gold-deep), #a16207); }
.rank-info {}
.rank-name { font-size: 13.5px; font-weight: 700; color: var(--ink); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-sub  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.rank-amount { font-size: 15px; font-weight: 900; color: var(--ink); white-space: nowrap; }
.rank-prob { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; text-align: center; color: var(--muted);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--ink-3); margin-bottom: 8px; }
.empty-text { font-size: 13px; max-width: 300px; line-height: 1.6; }

/* ── Skeleton Loading ───────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, rgba(148,163,184,0.1) 0%, rgba(148,163,184,0.2) 50%, rgba(148,163,184,0.1) 100%);
  background-size: 200% 100%;
  border-radius: 8px;
  animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.skel-kpi { height: 120px; border-radius: var(--radius-lg); }
.skel-row  { height: 48px; border-radius: 8px; margin-bottom: 8px; }
.skel-text { height: 14px; border-radius: 4px; margin-bottom: 8px; }

/* ── Activity / Timeline ────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 14px; padding: 14px 0; position: relative; }
.timeline-item::before {
  content: ''; position: absolute; left: 14px; top: 36px; bottom: 0;
  width: 1px; background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; z-index: 1;
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-text { font-size: 13.5px; color: var(--ink-3); font-weight: 500; }
.timeline-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ── System Monitor ─────────────────────────────────────── */
.sys-stat {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.sys-stat:last-child { border-bottom: none; }
.sys-stat-row { display: flex; justify-content: space-between; align-items: center; }
.sys-stat-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.sys-stat-val { font-size: 14px; font-weight: 800; color: var(--ink); }
.sys-bar-wrap { height: 6px; background: rgba(148,163,184,0.15); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.sys-bar { height: 100%; border-radius: 99px; transition: width 1s ease; }
.sys-bar.ok  { background: linear-gradient(90deg, var(--emerald), #6ee7b7); }
.sys-bar.warn { background: linear-gradient(90deg, var(--gold), #fde68a); }
.sys-bar.err { background: linear-gradient(90deg, #f87171, #fca5a5); }
.sys-job-list { display: flex; flex-direction: column; gap: 8px; }
.sys-job {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: rgba(248,250,252,0.8); font-size: 13px;
}
.sys-job-label { font-weight: 700; color: var(--ink-3); }
.sys-job-meta  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sys-log-list  { max-height: 320px; overflow-y: auto; }
.sys-log-item  { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid rgba(241,245,249,0.6); font-size: 12px; }
.sys-log-item:last-child { border-bottom: none; }
.sys-log-level { font-weight: 800; padding: 2px 7px; border-radius: 4px; flex-shrink: 0; text-transform: uppercase; font-size: 10px; }
.sys-log-level.info  { background: rgba(56,189,248,0.1); color: var(--azure-deep); }
.sys-log-level.error { background: rgba(239,68,68,0.1); color: #dc2626; }
.sys-log-level.warn  { background: rgba(251,191,36,0.1); color: var(--gold-deep); }
.sys-log-text { flex: 1; color: var(--ink-3); line-height: 1.4; }
.sys-log-time { color: var(--muted-2); flex-shrink: 0; }

/* ── Toast Notifications ────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9990; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius-md);
  background: rgba(255,255,255,0.95); backdrop-filter: blur(20px);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  min-width: 280px; max-width: 380px;
  animation: toastIn 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
  font-size: 13.5px;
}
.toast.removing { animation: toastOut 0.3s ease forwards; }
.toast-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; }
.toast-title { font-weight: 800; color: var(--ink); margin-bottom: 2px; }
.toast-text  { color: var(--muted); font-size: 12.5px; }
.toast-close { cursor: pointer; color: var(--muted-2); padding: 2px; font-size: 16px; line-height: 1; flex-shrink: 0; }
.toast.success { border-left: 3px solid var(--emerald-deep); }
.toast.error   { border-left: 3px solid #ef4444; }
.toast.info    { border-left: 3px solid var(--violet-deep); }
.toast.warning { border-left: 3px solid var(--gold-deep); }
@keyframes toastIn  { from{opacity:0;transform:translateX(100%)} to{opacity:1;transform:translateX(0)} }
@keyframes toastOut { from{opacity:1;transform:translateX(0)} to{opacity:0;transform:translateX(100%)} }

/* ── Progress Bar ───────────────────────────────────────── */
#progress-bar {
  position: fixed; top: 0; left: 0; height: 3px; z-index: 9998;
  background: linear-gradient(90deg, var(--azure), var(--violet), var(--pink));
  transition: width 0.3s ease; width: 0%; border-radius: 0 3px 3px 0;
  box-shadow: 0 0 10px rgba(99,102,241,0.6);
}

/* ── Shimmer Refresh ────────────────────────────────────── */
.refreshing { position: relative; pointer-events: none; }
.refreshing::after {
  content: ''; position: absolute; inset: 0; z-index: 10;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.5) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1s ease-in-out;
  pointer-events: none;
}

/* ── Mobile Sidebar Overlay ─────────────────────────────── */
#sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 98;
  background: rgba(15,23,42,0.4); backdrop-filter: blur(4px);
  animation: overlayIn 0.25s ease;
}
@keyframes overlayIn { from{opacity:0} to{opacity:1} }

/* ── Win Rate Ring ──────────────────────────────────────── */
.win-ring { display: flex; align-items: center; gap: 20px; }
.win-ring-chart { flex-shrink: 0; }
.win-ring-stats { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.win-stat { display: flex; justify-content: space-between; align-items: center; }
.win-stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.win-stat-val { font-size: 18px; font-weight: 900; color: var(--ink); }

/* ── Mobile Menu Button ─────────────────────────────────── */
#mobile-menu-btn {
  display: none; padding: 9px; border-radius: 10px;
  background: rgba(99,102,241,0.08); border: none; color: var(--violet-deep);
  font-size: 22px; cursor: pointer; margin-right: 4px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1280px) {
  .grid-kpi { grid-template-columns: repeat(3, 1fr); }
  .grid-4   { grid-template-columns: repeat(2, 1fr); }
  .grid-1-1-1 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 72px; }
  #sidebar .nav-label,
  #sidebar .nav-badge,
  #sidebar .sb-logo-text,
  #sidebar .sb-section-label { opacity: 0; max-width: 0; overflow: hidden; pointer-events: none; }
  #sidebar.collapsed { width: 0; overflow: hidden; }
  .grid-kpi { grid-template-columns: repeat(2, 1fr); }
  .grid-3   { grid-template-columns: repeat(2, 1fr); }
  .grid-1-2, .grid-2-1 { grid-template-columns: 1fr; }
  #content { padding: 16px 20px 32px; }
}
@media (max-width: 768px) {
  #sidebar { position: fixed; left: 0; top: 0; height: 100vh; z-index: 99; width: var(--sidebar-w) !important; transform: translateX(-100%); }
  #sidebar.mobile-open { transform: translateX(0); }
  #sidebar .nav-label, #sidebar .nav-badge, #sidebar .sb-logo-text, #sidebar .sb-section-label { opacity: 1; max-width: 200px; pointer-events: auto; }
  #sidebar-overlay { display: block; }
  #mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
  :root { --sidebar-w: 264px; }
  #app { flex-direction: column; }
  #main { min-height: 0; }
  .grid-2, .grid-3, .grid-4, .grid-1-2, .grid-2-1, .grid-1-1-1 { grid-template-columns: 1fr; }
  .grid-kpi { grid-template-columns: repeat(2, 1fr); }
  #topbar { padding: 0 16px; }
  #content { padding: 12px 14px 28px; }
  .funnel-item { grid-template-columns: 1fr 1fr; }
  .funnel-count, .funnel-pct { display: none; }
  .section-title { font-size: 20px; }
}
@media (max-width: 480px) {
  .grid-kpi { grid-template-columns: 1fr; }
  .tb-actions .btn-secondary { display: none; }
}

/* ── Print ──────────────────────────────────────────────── */
@media print {
  #loading-screen, #particles-canvas, #aurora-bg,
  #sidebar, #topbar, #toast-container, #progress-bar { display: none !important; }
  #content { padding: 0; }
  .panel { box-shadow: none; border: 1px solid #eee; }
}

/* ── Reduced Motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
