* { box-sizing: border-box; }
body {
  margin: 0;
  background: #F7F8FA;
  color: #111827;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea, table { font-family: inherit; }
button { cursor: pointer; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
input::placeholder, textarea::placeholder { color: #ADB1B8; }

.app-shell {
  display: flex;
  min-height: 100vh;
  background: #F7F8FA;
}
.crm-sidebar {
  width: 234px;
  background: #1E1B4B;
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-brand {
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #F59E0B;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1E1B4B;
  font-weight: 900;
}
.brand-title { font-size: 16.5px; font-weight: 800; letter-spacing: -0.01em; }
.brand-subtitle { font-size: 10.5px; color: #A5A6D9; font-weight: 500; }
.sidebar-nav {
  padding: 4px 12px;
  flex: 1;
  overflow-y: auto;
}
.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  border: none;
  margin-bottom: 2px;
  background: transparent;
  color: #C7C8E8;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background .12s;
}
.nav-btn:hover { background: rgba(255,255,255,0.06); }
.nav-btn.active {
  background: rgba(255,255,255,0.13);
  color: white;
  font-weight: 600;
}
.nav-icon { width: 16.5px; text-align: center; opacity: .95; }
.nav-count {
  margin-left: auto;
  background: rgba(255,255,255,0.12);
  color: #C7C8E8;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}
.nav-btn.active .nav-count {
  background: #F59E0B;
  color: #1E1B4B;
}
.sidebar-user {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #F59E0B;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-name {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: 10.5px; color: #A5A6D9; }

.main-area { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px;
  border-bottom: 1px solid #EEF0F2;
  background: white;
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.mobile-menu-btn {
  display: none;
  background: #F3F4F6;
  border: none;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
}
.topbar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.01em;
}
.topbar-subtitle { font-size: 12.5px; color: #9CA3AF; margin-top: 2px; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-pad { padding: 18px 26px; }
.btn {
  border-radius: 8px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: filter .12s, transform .05s;
  white-space: nowrap;
  padding: 9px 15px;
  font-size: 13.5px;
  border: 1px solid transparent;
}
.btn:hover { filter: brightness(.96); }
.btn.primary { background: #1E1B4B; color: white; border-color: #1E1B4B; }
.btn.accent { background: #F59E0B; color: #1E1B4B; border-color: #F59E0B; }
.btn.secondary { background: white; color: #374151; border-color: #D1D5DB; }
.btn.ghost { background: transparent; color: #4B5563; border-color: transparent; }
.btn.danger { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }
.btn.success { background: #F0FDF4; color: #15803D; border-color: #BBF7D0; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid #E5E7EB;
  background: white;
  color: #4B5563;
}
.icon-btn.danger { color: #DC2626; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid #D1D5DB;
  font-size: 13.5px;
  color: #111827;
  outline: none;
  background: white;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: #6366F1;
  box-shadow: 0 0 0 3px #6366F11A;
}
.textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}
.required { color: #DC2626; }

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-box {
  position: relative;
  flex: 1 1 280px;
  min-width: 220px;
}
.search-box .input { padding-left: 36px; }
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9CA3AF;
}
.filters-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  background: #F9FAFB;
  border: 1px solid #EEF0F2;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}
.filter-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #6B7280;
  margin-bottom: 5px;
}

.panel {
  background: white;
  border: 1px solid #EEF0F2;
  border-radius: 14px;
  overflow: hidden;
}
.panel-pad { padding: 18px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2, .panel-head h3 { margin: 0; font-size: 16px; }
.leads-table-scroll { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 980px;
}
thead tr {
  background: #FAFAFB;
  border-bottom: 1px solid #EEF0F2;
}
th {
  text-align: left;
  padding: 11px 16px;
  font-weight: 600;
  color: #6B7280;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
td {
  padding: 13px 16px;
  border-bottom: 1px solid #F3F4F6;
  color: #374151;
  vertical-align: middle;
}
tbody tr:hover { background: #FAFAFB; }
.lead-code { font-size: 11.5px; color: #9CA3AF; margin-top: 2px; }
.muted { color: #9CA3AF; }
.soft { color: #6B7280; }
.stage-badge {
  border: 1px solid;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.stage-dot { width: 6px; height: 6px; border-radius: 50%; }
.stage-New-Lead { background:#EEF2FF; color:#4338CA; border-color:#C7D2FE; }
.stage-Contacted { background:#F5F3FF; color:#6D28D9; border-color:#DDD6FE; }
.stage-Qualified { background:#ECFEFF; color:#0E7490; border-color:#A5F3FC; }
.stage-Proposal { background:#FFFBEB; color:#B45309; border-color:#FDE68A; }
.stage-Won { background:#F0FDF4; color:#15803D; border-color:#BBF7D0; }
.stage-Lost { background:#FEF2F2; color:#B91C1C; border-color:#FECACA; }
.status-badge {
  border: 1px solid;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.status-Pending { background: #FFFBEB; color: #B45309; border-color: #FDE68A; }
.status-Completed { background: #F0FDF4; color: #15803D; border-color: #BBF7D0; }
.status-Missed { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.stat-card {
  background: white;
  border: 1px solid #EEF0F2;
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-label { font-size: 12.5px; font-weight: 600; color: #6B7280; }
.stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #6366F117;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -0.03em; }
.stat-sub { font-size: 12px; color: #9CA3AF; }

.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.pipeline-col {
  min-height: 430px;
  background: #F9FAFB;
  border: 1px solid #EEF0F2;
  border-radius: 14px;
  padding: 12px;
}
.pipeline-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
}
.lead-card {
  background: white;
  border: 1px solid #EEF0F2;
  border-radius: 12px;
  padding: 13px;
  margin-bottom: 10px;
}
.lead-card h4 { margin: 0 0 6px; font-size: 13.5px; }
.lead-card p { margin: 4px 0; font-size: 12.5px; color: #6B7280; }
.lead-card-actions {
  display: flex;
  gap: 7px;
  margin-top: 10px;
}

.settings-grid, .reports-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.reports-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 44px;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
  font-size: 13px;
}
.bar-track {
  height: 8px;
  border-radius: 999px;
  background: #EEF0F2;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #6366F1;
}
.timeline {
  position: relative;
  padding-left: 22px;
}
.timeline-item {
  position: relative;
  padding: 0 0 18px 18px;
  border-left: 1px solid #E5E7EB;
}
.timeline-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -7px;
  top: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #6366F1;
  border: 3px solid white;
  box-shadow: 0 0 0 1px #E5E7EB;
}
.activity-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.team-row {
  display: grid;
  grid-template-columns: 1.2fr repeat(5, minmax(90px, 1fr));
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #F3F4F6;
  font-size: 13px;
}
.team-row.head {
  background: #FAFAFB;
  color: #6B7280;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.source-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #F3F4F6;
  padding: 10px 0;
  font-size: 13px;
}
.role-card {
  border: 1px solid #EEF0F2;
  border-radius: 12px;
  padding: 13px;
  background: #FAFAFB;
  margin-bottom: 10px;
}
.role-card strong { display: block; margin-bottom: 5px; }
.role-card span { color: #6B7280; font-size: 12px; line-height: 1.5; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 130px 90px 90px auto;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border: 1px solid #EEF0F2;
  border-radius: 12px;
  background: #FAFAFB;
  margin-bottom: 10px;
}
.field-options { grid-column: 1 / -1; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: white;
  border-radius: 14px;
  width: 100%;
  max-width: 760px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px -12px rgba(0,0,0,.35);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #F1F2F4;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid #F1F2F4;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.span-2 { grid-column: span 2; }
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #6B7280;
  text-align: center;
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1100;
  background: #111827;
  color: white;
  padding: 11px 14px;
  border-radius: 9px;
  box-shadow: 0 12px 34px rgba(0,0,0,.24);
  font-size: 13px;
}
.sidebar-overlay { display: none; }

.mobile-preview.app-shell {
  max-width: 420px;
  min-height: 760px;
  margin: 18px auto;
  border: 10px solid #111827;
  border-radius: 34px;
  overflow: hidden;
  box-shadow: 0 25px 60px -12px rgba(0,0,0,.35);
}
.mobile-preview .crm-sidebar { display: none; }
.mobile-preview .topbar { position: static; padding: 14px; }
.mobile-preview .mobile-menu-btn { display: flex; }
.mobile-preview .page-pad { padding: 14px; }
.mobile-preview .form-grid,
.mobile-preview .settings-grid,
.mobile-preview .reports-grid-2 { grid-template-columns: 1fr; }
.mobile-preview .span-2 { grid-column: span 1; }
.mobile-preview table { min-width: 760px; }

@media (max-width: 880px) {
  .crm-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .crm-sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 90;
  }
  .mobile-menu-btn { display: flex; }
  .settings-grid, .reports-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { padding: 14px; align-items: flex-start; }
  .page-pad { padding: 14px; }
  .form-grid, .field-row { grid-template-columns: 1fr; }
  .span-2, .field-options { grid-column: span 1; }
  .reports-grid-3, .team-row { grid-template-columns: 1fr; }
}
