:root {
  --brand-dark: #4c1d95;
  --brand-primary: #7c3aed;
  --brand-accent: #f57d0b;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --green: #16a34a;
  --green-hover: #15803d;
  --amber: #d97706;
  --red: #dc2626;
  --blue: #2563eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #2e1065 0%, #6d28d9 55%, #ea580c 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #f57d0b);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.login-title { margin: 0; font-size: 20px; font-weight: 800; color: var(--text); }
.login-sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

/* ---- Top Header ---- */
.topbar {
  background: linear-gradient(90deg, #4c1d95 0%, #7c3aed 55%, #ea580c 100%);
  color: #fff;
  padding: 14px 20px;
  box-shadow: 0 4px 14px rgba(76, 29, 149, 0.22);
}

.topbar-inner {
  max-width: 1340px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand h1 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.topbar-brand p { margin: 2px 0 0; font-size: 12.5px; opacity: 0.92; }

.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.user-pill {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
}

/* ---- Layout Container ---- */
.container {
  max-width: 1340px;
  margin: 0 auto;
  padding: 18px 20px 48px;
}

/* ---- Banners ---- */
.alert-banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 600;
}

.alert-warning { background: #fef3c7; border: 1px solid #f59e0b; color: #92400e; }
.alert-danger { background: #fee2e2; border: 1px solid #ef4444; color: #991b1b; }
.alert-success { background: #dcfce7; border: 1px solid #22c55e; color: #166534; }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.tab-btn {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover { color: var(--text); border-color: #cbd5e1; }
.tab-btn.active {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.28);
}

/* ---- KPI Grid ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.kpi-label { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-value { font-size: 24px; font-weight: 800; margin-top: 4px; color: var(--text); }
.kpi-green { border-top: 3px solid var(--green); }
.kpi-amber { border-top: 3px solid var(--amber); }
.kpi-purple { border-top: 3px solid var(--brand-primary); }
.kpi-blue { border-top: 3px solid var(--blue); }

/* ---- Filter Bar & Cards ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
}

.field-group { margin-bottom: 14px; }
.field-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-primary { background: var(--brand-primary); color: #fff; }
.btn-primary:hover { background: #6d28d9; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-hover); }
.btn-amber { background: #facc15; color: #1e293b; }
.btn-amber:hover { background: #eab308; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: #fff; color: #334155; border-color: #cbd5e1; }
.btn-outline:hover { background: #f8fafc; border-color: #94a3b8; }
.btn-ghost { background: rgba(255,255,255,0.16); color: #fff; border-color: rgba(255,255,255,0.28); }
.btn-ghost:hover { background: rgba(255,255,255,0.25); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.badge-count {
  background: #0f172a;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
}

/* ---- Lead Cards ---- */
.lead-list { display: flex; flex-direction: column; gap: 10px; }

.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.lead-card.is-due { border-left: 4px solid var(--red); background: #fffbfb; }
.lead-card.is-won { border-left: 4px solid var(--green); }
.lead-card.is-interested { border-left: 4px solid var(--blue); }

.lead-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.lead-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  background: #f1f5f9;
  color: #334155;
}
.tag-cat { background: #ede9fe; color: #5b21b6; }
.tag-area { background: #ffedd5; color: #9a3412; }
.tag-user { background: #e0f2fe; color: #075985; }
.tag-due { background: #fee2e2; color: #b91c1c; }

.lead-name { margin: 4px 0 0; font-size: 16px; font-weight: 800; color: var(--text); }
.lead-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.lead-controls {
  display: grid;
  grid-template-columns: 180px 235px 1fr auto;
  gap: 8px;
  align-items: center;
}

.reminder-wrap { display: flex; align-items: center; gap: 4px; }

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; font-weight: 700; color: #334155; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: #fafbff; }

/* ---- Admin Grid ---- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- Modals ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-backdrop.open { display: flex; }

.modal {
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin: 0; font-size: 17px; font-weight: 800; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0f172a;
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 2000;
}

.toast.show { opacity: 1; transform: translateY(0); }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12.5px; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .lead-controls { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: 1fr; }
  .lead-controls { grid-template-columns: 1fr; }
  .topbar-brand h1 { font-size: 16px; }
}
