/* === New UI — DM Sans / DM Mono === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: rgba(0,0,0,0.08);
  --border-med: rgba(0,0,0,0.15);
  --text-1: #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --accent: #4578EC;
  --accent-dark: #2d5fd4;
  --sidebar-w: 228px;
  --sidebar-cw: 60px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
}

body {
  font-family:'DM Sans',system-ui,sans-serif;
  background:var(--bg); color:var(--text-1);
  font-size:14px; line-height:1.5;
  min-height:100vh; display:flex;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); min-height:100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display:flex; flex-direction:column;
  position:fixed; top:0; left:0; z-index:200;
  overflow:hidden;
  transition: width 0.22s cubic-bezier(0.4,0,0.2,1);
}
.sidebar.collapsed { width: var(--sidebar-cw); }

.sb-logo {
  height:64px; padding:0 14px;
  border-bottom:1px solid var(--border);
  display:flex; align-items:center; gap:10px; flex-shrink:0;
}
.logo-icon {
  width:36px; height:36px; flex-shrink:0;
  background:var(--accent); border-radius:var(--r-sm);
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 2px 8px rgba(69,120,236,0.28);
}
.logo-icon svg { width:18px; height:18px; }
.logo-text { overflow:hidden; white-space:nowrap; flex:1; transition:opacity 0.15s; }
.sidebar.collapsed .logo-text { opacity:0; pointer-events:none; }
.logo-name { font-size:14px; font-weight:600; letter-spacing:-0.3px; }
.logo-sub  { font-size:11px; color:var(--text-3); font-family:'DM Mono',monospace; margin-top:1px; }

.sb-toggle {
  flex-shrink:0; width:28px; height:28px;
  display:flex; align-items:center; justify-content:center;
  border-radius:var(--r-sm); border:1px solid var(--border);
  background:var(--surface-2); cursor:pointer; transition:all 0.12s; color:var(--text-3);
}
.sb-toggle:hover { background:var(--surface); border-color:var(--border-med); color:var(--text-1); }

.nav { padding:12px 8px; flex:1; overflow:hidden; }
.nav-group-lbl {
  font-size:10px; font-weight:500; letter-spacing:0.9px; text-transform:uppercase;
  color:var(--text-3); padding:0 8px; margin:14px 0 5px;
  white-space:nowrap; transition:opacity 0.15s;
}
.nav-group-lbl:first-child { margin-top:0; }
.sidebar.collapsed .nav-group-lbl { opacity:0; }

.nav-item {
  display:flex; align-items:center; gap:10px;
  padding:8px 10px; border-radius:var(--r-sm);
  font-size:13px; color:var(--text-2); cursor:pointer;
  transition:all 0.12s; margin-bottom:2px;
  border:none; background:none; width:100%; text-align:left; font-family:inherit;
  white-space:nowrap; overflow:hidden; position:relative;
  text-decoration:none;
}
.nav-item:hover { background:var(--surface-2); color:var(--text-1); }
.nav-item.active { background:var(--accent); color:#fff; }
.nav-icon { width:16px; height:16px; opacity:0.65; flex-shrink:0; }
.nav-item.active .nav-icon { opacity:1; }
.nav-lbl { overflow:hidden; transition:opacity 0.15s; }
.sidebar.collapsed .nav-lbl { opacity:0; }
.nav-badge {
  margin-left:auto; font-size:11px; font-family:'DM Mono',monospace;
  background:var(--surface-2); border:1px solid var(--border);
  padding:1px 7px; border-radius:20px; color:var(--text-3); flex-shrink:0;
  transition:opacity 0.15s;
}
.nav-item.active .nav-badge { background:rgba(255,255,255,0.2); border-color:transparent; color:rgba(255,255,255,0.85); }
.sidebar.collapsed .nav-badge { opacity:0; }

/* tooltip on collapsed */
.sidebar.collapsed .nav-item:hover::after {
  content:attr(data-label);
  position:absolute; left:52px; top:50%; transform:translateY(-50%);
  background:var(--text-1); color:#fff; font-size:12px;
  padding:4px 10px; border-radius:var(--r-sm); white-space:nowrap;
  pointer-events:none; z-index:300;
}

.sb-user {
  padding:12px 14px; border-top:1px solid var(--border);
  display:flex; align-items:center; gap:10px; flex-shrink:0; overflow:hidden;
}
.user-avatar {
  width:32px; height:32px; border-radius:50%; flex-shrink:0;
  background:var(--accent); display:flex; align-items:center; justify-content:center;
  font-size:12px; font-weight:500; color:#fff;
}
.user-info { overflow:hidden; white-space:nowrap; transition:opacity 0.15s; }
.sidebar.collapsed .sb-logo { justify-content:center; padding:0 12px; }
.sidebar.collapsed .logo-icon { display:none; }
.sidebar.collapsed .sb-toggle { margin:0; }
.sidebar.collapsed .user-info { opacity:0; }
.user-name { font-size:13px; font-weight:500; }
.user-role { font-size:11px; color:var(--text-3); }

/* ── MAIN ── */
.main {
  margin-left:var(--sidebar-w); flex:1;
  display:flex; flex-direction:column; min-height:100vh;
  transition:margin-left 0.22s cubic-bezier(0.4,0,0.2,1);
}
.main.collapsed { margin-left:var(--sidebar-cw); }

/* TOPBAR */
.topbar {
  background:var(--surface); border-bottom:1px solid var(--border);
  height:64px; padding:0 28px;
  display:flex; align-items:center; gap:16px;
  position:sticky; top:0; z-index:100;
}
.topbar-title { font-size:15px; font-weight:500; letter-spacing:-0.2px; flex:1; }
.search-wrap {
  display:flex; align-items:center; gap:8px;
  background:var(--surface-2); border:1px solid var(--border);
  border-radius:30px; padding:7px 14px; width:240px; transition:all 0.15s;
}
.search-wrap:focus-within { border-color:var(--border-med); background:var(--surface); }
.search-wrap input { background:none; border:none; outline:none; font-size:13px; color:var(--text-1); font-family:inherit; width:100%; }
.search-wrap input::placeholder { color:var(--text-3); }
.topbar-btn {
  display:flex; align-items:center; gap:6px; padding:7px 14px; border-radius:30px;
  border:1px solid var(--border); background:var(--surface);
  font-size:12px; color:var(--text-2); cursor:pointer; font-family:inherit; transition:all 0.12s;
}
.topbar-btn:hover { background:var(--surface-2); color:var(--text-1); }
.topbar-btn.primary { background:var(--accent); color:#fff; border-color:transparent; }
.topbar-btn.primary:hover { background:var(--accent-dark); }

/* STATS */
.stats-grid { padding:22px 28px 16px; display:grid; grid-template-columns:repeat(4,1fr); gap:12px; }
.stat-card {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--r-lg);
  padding:18px 20px; cursor:pointer; transition:all 0.15s;
  position:relative; overflow:hidden; user-select:none;
}
.stat-card::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; background:transparent; transition:background 0.15s; }
.stat-card:hover { border-color:var(--border-med); }
.stat-card.active::before { background:var(--accent); }
.stat-card.active { border-color:var(--accent); box-shadow:0 0 0 3px rgba(69,120,236,0.1); }
.stat-label { font-size:11px; font-weight:500; letter-spacing:0.4px; text-transform:uppercase; color:var(--text-3); margin-bottom:10px; }
.stat-num { font-size:32px; font-weight:300; font-family:'DM Mono',monospace; letter-spacing:-2px; color:var(--text-1); line-height:1; }
.stat-pill { display:inline-flex; align-items:center; margin-top:8px; font-size:11px; padding:2px 8px; border-radius:20px; }
.stat-pill.new       { background:#dce8fd; color:#2d5fd4; }
.stat-pill.followup  { background:#d6f0e8; color:#0f6e56; }
.stat-pill.resolved  { background:#d9f0ce; color:#3b6d11; }
.stat-pill.all       { background:var(--surface-2); color:var(--text-2); }

/* FILTER BAR */
.filter-bar { padding:0 28px 16px; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.pill-group { display:flex; gap:4px; }
.pill {
  font-size:12px; padding:5px 13px; border-radius:30px;
  border:1px solid var(--border); background:var(--surface);
  color:var(--text-2); cursor:pointer; font-family:inherit; transition:all 0.12s;
  display:flex; align-items:center; gap:5px;
}
.pill:hover { background:var(--surface-2); color:var(--text-1); border-color:var(--border-med); }
.pill.active { background:var(--accent); color:#fff; border-color:transparent; }
.filter-div { width:1px; height:24px; background:var(--border); margin:0 4px; }
.sort-sel {
  font-size:12px; padding:5px 12px; border-radius:30px;
  border:1px solid var(--border); background:var(--surface);
  color:var(--text-2); font-family:inherit; cursor:pointer; outline:none;
}
.sort-sel:hover { border-color:var(--border-med); }
.result-count { margin-left:auto; font-size:12px; color:var(--text-3); font-family:'DM Mono',monospace; }

/* SECTION HEADER */
.section-hdr {
  padding:6px 28px 10px; font-size:11px; font-weight:500;
  letter-spacing:0.5px; text-transform:uppercase; color:var(--text-3);
  display:flex; align-items:center; gap:12px;
}
.section-hdr::after { content:''; flex:1; height:1px; background:var(--border); }

/* ── CALL CARDS ── */
.call-list { padding:0 28px 8px; display:flex; flex-direction:column; gap:6px; }

.call-card {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--r-lg);
  display:flex; transition:all 0.12s; cursor:pointer; overflow:hidden;
}
.call-card:hover { border-color:var(--border-med); box-shadow:0 2px 12px rgba(0,0,0,0.05); }
.call-card.resolved { opacity:0.5; }

.pri-bar { width:4px; flex-shrink:0; }
.pri-bar.high   { background:#d85a30; }
.pri-bar.medium { background:#ba7517; }
.pri-bar.low    { background:var(--accent); }

/* 6-column grid */
.call-inner {
  flex:1; padding:13px 18px;
  display:grid;
  grid-template-columns: 100px 1fr 155px 110px 130px 100px;
  align-items:center; gap:14px;
}

.badge {
  display:inline-flex; align-items:center; gap:5px;
  font-size:10px; font-weight:500; padding:3px 9px; border-radius:20px;
  white-space:nowrap; letter-spacing:0.3px; font-family:'DM Mono',monospace;
  border:1px solid transparent;
}
.bdot { width:5px; height:5px; border-radius:50%; background:currentColor; flex-shrink:0; }
.badge.high   { background:#faece7; color:#993c1d; border-color:#f0997b; }
.badge.medium { background:#faeeda; color:#854f0b; border-color:#fac775; }
.badge.low    { background:#dce8fd; color:#2d5fd4; border-color:#9ab8f5; }
.type-lbl { font-size:10px; color:var(--text-3); font-family:'DM Mono',monospace; margin-top:6px; }

.call-title { font-size:13px; font-weight:500; color:var(--text-1); margin-bottom:4px; line-height:1.35; }
.call-meta  { font-size:11px; color:var(--text-3); display:flex; gap:12px; flex-wrap:wrap; }
.call-meta span { display:flex; align-items:center; gap:4px; }

.cust-name  { font-size:13px; font-weight:500; margin-bottom:3px; }
.cust-phone { font-size:11px; color:var(--text-3); font-family:'DM Mono',monospace; }

.price-val   { font-size:15px; font-weight:500; font-family:'DM Mono',monospace; letter-spacing:-0.5px; }
.price-lbl   { font-size:10px; color:var(--text-3); letter-spacing:0.3px; text-transform:uppercase; margin-top:3px; }
.time-txt    { font-size:12px; color:var(--text-2); font-family:'DM Mono',monospace; line-height:1.6; }

/* vertical button stack */
.btn-col { display:flex; flex-direction:column; gap:5px; }
.btn {
  font-size:11px; padding:6px 10px; border-radius:var(--r-sm);
  border:1px solid var(--border); background:var(--surface);
  color:var(--text-2); cursor:pointer; font-family:inherit;
  transition:all 0.12s; white-space:nowrap; text-align:center;
}
.btn:hover { background:var(--surface-2); color:var(--text-1); border-color:var(--border-med); }
.btn.primary { background:var(--accent); color:#fff; border-color:transparent; }
.btn.primary:hover { background:var(--accent-dark); }
.btn.done { background:#eaf3de; color:#3b6d11; border-color:#97c459; }

/* EMPTY */
.empty-state { padding:60px 28px; text-align:center; color:var(--text-3); }
.empty-icon  { font-size:36px; margin-bottom:12px; }
.empty-txt   { font-size:15px; font-weight:500; margin-bottom:6px; color:var(--text-2); }
.empty-sub   { font-size:13px; }

/* ── PAGINATION ── */
.pgbar {
  padding:16px 28px 28px;
  display:flex; align-items:center; gap:8px; flex-wrap:wrap;
}
.pg-size-wrap { display:flex; align-items:center; gap:8px; }
.pg-size-lbl { font-size:12px; color:var(--text-3); }
.pg-size-sel {
  font-size:12px; padding:5px 10px; border-radius:var(--r-sm);
  border:1px solid var(--border); background:var(--surface);
  color:var(--text-2); font-family:inherit; cursor:pointer; outline:none;
}
.pg-size-sel:hover { border-color:var(--border-med); }
.pg-info { font-size:12px; color:var(--text-3); font-family:'DM Mono',monospace; margin-left:auto; }
.pg-btns { display:flex; gap:4px; }
.pg-btn {
  min-width:32px; height:32px; padding:0 8px;
  display:flex; align-items:center; justify-content:center;
  border-radius:var(--r-sm); border:1px solid var(--border);
  background:var(--surface); color:var(--text-2);
  font-size:12px; font-family:'DM Mono',monospace;
  cursor:pointer; transition:all 0.12s; user-select:none;
}
.pg-btn:hover:not(:disabled) { background:var(--surface-2); border-color:var(--border-med); }
.pg-btn.active { background:var(--accent); color:#fff; border-color:transparent; }
.pg-btn:disabled { opacity:0.35; cursor:not-allowed; }

/* ── DETAIL PANEL ── */
.detail-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,0.28); z-index:300;
  display:none; align-items:center; justify-content:flex-end;
}
.detail-overlay.open { display:flex; }
.detail-panel {
  width:420px; height:100vh; background:var(--surface);
  border-left:1px solid var(--border);
  display:flex; flex-direction:column; overflow-y:auto;
  animation:slideIn 0.2s ease;
}
@keyframes slideIn { from{transform:translateX(24px);opacity:0} to{transform:translateX(0);opacity:1} }
.dp-hdr { padding:20px 24px; border-bottom:1px solid var(--border); display:flex; align-items:flex-start; gap:12px; }
.dp-close {
  margin-left:auto; width:28px; height:28px; border-radius:50%;
  border:1px solid var(--border); background:var(--surface-2);
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; flex-shrink:0; font-size:13px; color:var(--text-2); transition:all 0.12s;
}
.dp-close:hover { background:var(--surface); border-color:var(--border-med); }
.dp-body { padding:20px 24px; flex:1; }
.dp-section { margin-bottom:22px; }
.dp-sec-lbl { font-size:11px; font-weight:500; text-transform:uppercase; letter-spacing:0.5px; color:var(--text-3); margin-bottom:10px; }
.dp-row { display:flex; justify-content:space-between; align-items:center; padding:8px 0; border-bottom:1px solid var(--border); font-size:13px; }
.dp-row:last-child { border-bottom:none; }
.dp-row-lbl { color:var(--text-2); }
.dp-row-val { font-weight:500; text-align:right; }
.dp-footer { padding:16px 24px; border-top:1px solid var(--border); display:flex; gap:8px; }
.dp-btn { flex:1; padding:10px; border-radius:var(--r-sm); border:1px solid var(--border); background:var(--surface-2); color:var(--text-2); font-family:inherit; font-size:13px; cursor:pointer; text-align:center; transition:all 0.12s; }
.dp-btn:hover { background:var(--surface); border-color:var(--border-med); }
.dp-btn.primary { background:var(--accent); color:#fff; border-color:transparent; }
.dp-btn.primary:hover { background:var(--accent-dark); }

/* TOAST */
.toast {
  position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(70px);
  background:var(--text-1); color:#fff; padding:9px 20px; border-radius:30px;
  font-size:13px; font-weight:500; z-index:500; pointer-events:none;
  transition:transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s; opacity:0;
}
.toast.show { transform:translateX(-50%) translateY(0); opacity:1; }

/* ── REVENUE / ANALYTICS PAGE ── */
.page-pad { padding:22px 28px; }
.page-title { font-size:18px; font-weight:600; letter-spacing:-0.3px; margin-bottom:18px; }

.date-range-bar {
  display:flex; align-items:center; gap:10px; margin-bottom:20px; flex-wrap:wrap;
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--r-lg); padding:12px 18px;
}
.date-input {
  padding:6px 12px; border:1px solid var(--border); border-radius:var(--r-sm);
  font-size:13px; font-weight:500; color:var(--text-1); background:var(--surface-2); font-family:inherit;
}
.date-to-label { font-size:13px; color:var(--text-3); }
.date-presets { display:flex; gap:5px; margin-left:auto; }

.revenue-hero { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin-bottom:24px; }
.hero-card {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--r-lg);
  padding:20px;
}
.hero-label { font-size:12px; color:var(--text-3); font-weight:500; text-transform:uppercase; letter-spacing:0.3px; margin-bottom:6px; }
.hero-number { font-size:32px; font-weight:300; font-family:'DM Mono',monospace; letter-spacing:-2px; margin-bottom:4px; }
.hero-calls { color:#E65100; }
.hero-green { color:#2E7D32; }
.hero-blue  { color:var(--accent); }
.hero-sub   { font-size:12px; color:var(--text-3); }

.analytics-section { margin-bottom:24px; }
.charts-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:12px; }
.chart-card {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--r-lg);
  padding:20px;
}
.chart-card h3 { font-size:14px; font-weight:600; margin-bottom:14px; color:var(--text-1); }
.chart-card canvas { display:block; max-width:100%; }

.donut-with-legend { display:flex; align-items:center; gap:20px; }
.donut-legend { display:flex; flex-direction:column; gap:6px; flex:1; }
.legend-item { display:flex; align-items:center; gap:8px; font-size:12px; }
.legend-dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.legend-name { color:var(--text-1); font-weight:500; flex:1; }
.legend-count { color:var(--text-3); font-weight:500; font-size:11px; }

.breakdown-bars { display:flex; flex-direction:column; gap:10px; }
.bar-row { display:flex; flex-direction:column; gap:4px; }
.bar-label { display:flex; justify-content:space-between; font-size:12px; }
.bar-label-name { color:var(--text-2); font-weight:500; }
.bar-label-value { color:var(--text-1); font-weight:600; font-family:'DM Mono',monospace; }
.bar-track { width:100%; height:8px; background:var(--surface-2); border-radius:4px; overflow:hidden; }
.bar-fill { height:100%; border-radius:4px; transition:width 0.6s ease; background:var(--accent); }

.section-insight {
  padding:14px 18px; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--r-lg); margin-top:8px; font-size:13px; color:var(--text-1); line-height:1.6;
}
.section-insight::before {
  content:'AI Insights'; display:block;
  font-size:14px; font-weight:600; color:var(--text-1); margin-bottom:8px;
}
.section-insight:empty { display:none; }

/* Detail table (single-day) */
.opp-table { width:100%; border-collapse:collapse; font-size:13px; }
.opp-table th {
  text-align:left; font-size:10px; font-weight:500; text-transform:uppercase;
  letter-spacing:0.5px; color:var(--text-3); padding:8px 12px; border-bottom:1px solid var(--border);
}
.opp-table td { padding:10px 12px; border-bottom:1px solid var(--border); color:var(--text-2); }
.opp-table tr:hover td { background:var(--surface-2); }
.opp-name { font-weight:500; color:var(--text-1); }
.opp-value { text-align:right; font-weight:600; color:#2E7D32; font-family:'DM Mono',monospace; }
.opp-status { display:inline-block; padding:2px 10px; border-radius:20px; font-size:10px; font-weight:500; }
.opp-status-new { background:#dce8fd; color:#2d5fd4; }
.opp-status-following_up { background:#faeeda; color:#854f0b; }
.opp-status-resolved { background:#eaf3de; color:#3b6d11; }

/* ── RESPONSIVE ── */
@media(max-width:1200px){ .call-inner{ grid-template-columns:100px 1fr 140px 100px 110px 96px; gap:10px; } }
@media(max-width:900px){
  .sidebar{ width:var(--sidebar-cw) !important; }
  .main{ margin-left:var(--sidebar-cw) !important; }
  .stats-grid{ grid-template-columns:repeat(2,1fr); }
  .call-inner{ grid-template-columns:1fr; padding:12px 14px; }
  .detail-panel{ width:100%; }
  .revenue-hero{ grid-template-columns:1fr; }
  .charts-row{ grid-template-columns:1fr; }
}
