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

:root {
  --primary: #1a6e44;
  --primary-hover: #155836;
  --primary-light: #e8f5ee;
  --primary-mid: #c6e8d5;
  --gold: #c9a96e;
  --gold-light: rgba(201,169,110,0.12);
  --bg: #f3f5f8;
  --card: #ffffff;
  --sidebar: #ffffff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --light: #9ca3af;
  --green: #059669;
  --green-bg: #ecfdf5;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --orange: #d97706;
  --orange-bg: #fffbeb;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 8px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 248px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 0; }

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #0f4d2e);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}
.logo-text { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.2; }
.logo-sub { font-size: 11px; color: var(--muted); font-weight: 400; }

.sidebar-nav { padding: 16px 12px; flex: 1; }
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--light);
  padding: 0 8px;
  margin-bottom: 6px;
  margin-top: 16px;
}
.nav-section-label:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  position: relative;
  user-select: none;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg); color: var(--text-2); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-item.active .nav-icon { color: var(--primary); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.8; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
}
.nav-item.demo-item {
  background: var(--gold-light);
  color: var(--gold);
  border: 1px solid rgba(201,169,110,0.2);
}
.nav-item.demo-item:hover { background: rgba(201,169,110,0.18); }
.nav-item.demo-item.active { background: rgba(201,169,110,0.22); }
.nav-item.demo-item .nav-icon { color: var(--gold); opacity: 1; }

.sidebar-bottom {
  padding: 16px 12px;
  border-top: 1px solid var(--border-light);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #0f4d2e);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--muted); }

/* ── MAIN LAYOUT ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── TOPBAR ── */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--muted); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.date-filter {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.date-filter-btn {
  padding: 5px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}
.date-filter-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  position: relative;
}
.icon-btn:hover { background: var(--bg); color: var(--text-2); }
.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 1.5px solid #fff;
}

.btn-primary {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,110,68,0.3); }
.btn-outline {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: var(--card);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}
.btn-outline:hover { background: var(--bg); }

/* ── PAGE CONTENT ── */
.page-content { padding: 24px 28px; flex: 1; }
.page { display: none; }
.page.active { display: block; }

/* ── CARDS ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 20px; }

/* ── METRIC CARDS ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.metric-card.accent {
  background: linear-gradient(135deg, var(--primary), #0f4d2e);
  border-color: transparent;
  color: #fff;
}
.metric-icon-wrap {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.metric-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.metric-card.accent .metric-label { color: rgba(255,255,255,0.75); }
.metric-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1.1; }
.metric-card.accent .metric-value { color: #fff; }
.metric-delta { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.metric-card.accent .metric-delta { color: rgba(255,255,255,0.65); }
.delta-up { color: var(--green); font-weight: 600; }
.delta-down { color: var(--red); font-weight: 600; }

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-2-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-3-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

/* ── CHARTS ── */
.chart-wrap { position: relative; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray   { background: #f3f4f6;          color: var(--muted); }
.badge-gold   { background: var(--gold-light);color: var(--gold); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border-light); }
th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-2);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }
.td-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.td-name { display: flex; align-items: center; gap: 10px; }
.td-name-text { font-size: 13px; font-weight: 500; color: var(--text); }
.td-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

/* ── FILTER BAR ── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-spacer { flex: 1; }
.filter-input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  background: var(--card);
  color: var(--text);
  outline: none;
  min-width: 200px;
}
.filter-input:focus { border-color: var(--primary); }
.filter-select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  background: var(--card);
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--primary); }

/* ── TODAY SCHEDULE ── */
.appt-list { display: flex; flex-direction: column; gap: 8px; }
.appt-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg);
  transition: background 0.15s;
}
.appt-item:hover { background: var(--primary-light); }
.appt-time { font-size: 12px; font-weight: 600; color: var(--muted); min-width: 60px; }
.appt-info { flex: 1; min-width: 0; }
.appt-name { font-size: 13px; font-weight: 500; color: var(--text); }
.appt-treatment { font-size: 11.5px; color: var(--muted); }

/* ── PIPELINE / LEADS ── */
.pipeline-stages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.pipeline-col { display: flex; flex-direction: column; gap: 8px; }
.pipeline-col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
}
.pipeline-count {
  background: rgba(0,0,0,0.08);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
}
.lead-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.lead-card:hover { box-shadow: var(--shadow); }
.lead-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.lead-treatment { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.lead-meta { display: flex; justify-content: space-between; align-items: center; }
.lead-source {
  font-size: 11px; font-weight: 600;
  padding: 2px 6px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 5px;
}
.lead-time { font-size: 11px; color: var(--light); }

/* ── ACTIVITY STATS ── */
.activity-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.activity-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.activity-stat-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.activity-stat-value { font-size: 24px; font-weight: 800; color: var(--text); }

/* ── DEMO MODE ── */
.demo-banner {
  background: linear-gradient(135deg, var(--primary), #0f4d2e);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  color: #fff;
}
.demo-banner-icon { font-size: 28px; }
.demo-banner-title { font-size: 16px; font-weight: 700; }
.demo-banner-sub { font-size: 12.5px; opacity: 0.75; margin-top: 2px; }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.agent-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
}
.agent-block-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-light);
}
.agent-block-title { font-size: 14px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.agent-block-body { padding: 16px 20px; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.agent-block-footer { padding: 0 20px 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 11.5px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field-input-demo, .field-select-demo {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.field-input-demo:focus, .field-select-demo:focus { border-color: var(--primary); background: #fff; }
.trigger-btn-demo {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.trigger-btn-demo:hover { transform: translateY(-1px); }
.trigger-btn-demo:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-speed-demo   { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.btn-confirm-demo { background: var(--blue-bg); color: #1e40af; border: 1px solid #bfdbfe; }
.btn-followup-demo { background: var(--purple-bg); color: #5b21b6; border: 1px solid #ddd6fe; }
.btn-review-demo  { background: var(--green-bg); color: #065f46; border: 1px solid #a7f3d0; }

.inbound-card {
  background: var(--card);
  border: 1px solid var(--primary-mid);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.inbound-num-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.inbound-num { font-size: 22px; font-weight: 800; color: var(--primary); letter-spacing: 0.01em; }
.inbound-number-display {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--primary-light);
  border: 1px solid var(--primary-mid);
  border-radius: var(--radius-sm);
}
.copy-btn-demo {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  margin-bottom: 4px;
}
.copy-btn-demo:hover { background: var(--primary-hover); }

/* ── AGENT PERFORMANCE ── */
.agent-perf-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}
.agent-perf-row:last-child { border-bottom: none; }
.agent-perf-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.agent-perf-name { font-size: 13px; font-weight: 500; color: var(--text); flex: 1; }
.agent-perf-calls { font-size: 12px; color: var(--muted); min-width: 60px; text-align: right; }
.agent-perf-rate { font-size: 12px; font-weight: 600; min-width: 50px; text-align: right; }
.progress-bar-wrap { width: 60px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 3px; background: var(--primary); }

/* ── DONUT STAT ── */
.donut-stat-wrap { display: flex; flex-direction: row; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-label { color: var(--muted); flex: 1; }
.legend-value { font-weight: 600; color: var(--text); }

/* ── LOADING STATE ── */
.loading-row td {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 13px;
}
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
  height: 14px;
  display: inline-block;
}
@keyframes shimmer { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }

/* ── TOAST ── */
.toast-wrap {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 100;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.25s ease;
  max-width: 360px;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast-success { background: #fff; border: 1px solid #a7f3d0; color: #065f46; }
.toast-error   { background: #fff; border: 1px solid #fca5a5; color: #991b1b; }
.toast-info    { background: #fff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ── SPINNER ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes ringPulse { 0%,100%{box-shadow:0 0 0 0 rgba(26,110,68,0.4)} 50%{box-shadow:0 0 0 8px rgba(26,110,68,0)} }
.ringing { animation: ringPulse 1s ease infinite; }
@keyframes fadeSlideIn { from { opacity: 0.4 } to { opacity: 1 } }

/* ── RESPONSIVE ── */
@media (max-width: 1280px) {
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1100px) {
  .grid-3-2 { grid-template-columns: 1fr; }
  .grid-2-3 { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 60px; }
  .logo-text, .logo-sub, .nav-item span, .user-name, .user-role, .nav-badge, .nav-section-label { display: none; }
  .logo-icon { margin: 0 auto; }
  .sidebar-logo { justify-content: center; }
  .nav-item { justify-content: center; padding: 10px; }
  .sidebar-user { justify-content: center; }
  .user-avatar { margin: 0; }
  .pipeline-stages { grid-template-columns: 1fr 1fr; }
  .activity-stats { grid-template-columns: 1fr 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-2-3, .grid-3-2 { grid-template-columns: 1fr; }
  .demo-grid { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .activity-stats { grid-template-columns: 1fr 1fr; }
}
