@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --charcoal: #1F1F1F;
  --orange: #F97316;
  --orange-dark: #C2570B;
  --white: #FFFFFF;
  --bg: #F7F7F6;
  --border: #E5E4E2;
  --muted: #6B6B6B;
  --red: #B3261E;
  --green: #1E7A3D;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--charcoal);
  background: var(--bg);
}
h1, h2, h3 { font-family: 'Montserrat', sans-serif; font-weight: 700; margin: 0 0 12px; }
h1 { font-size: 20px; }
h2 { font-size: 15px; margin-top: 0; }
a { color: var(--orange-dark); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.block { display: block; }

/* --- Auth --- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--charcoal); }
.auth-card { background: var(--white); padding: 40px; border-radius: 10px; width: 340px; box-shadow: 0 10px 40px rgba(0,0,0,0.35); }
.auth-card h1 { font-size: 18px; }

/* --- Shell layout --- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex-shrink: 0; background: var(--charcoal); display: flex; flex-direction: column; }
.sidebar-brand { color: var(--white); font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 14px; padding: 18px 16px 10px; }
.sidebar-nav { display: flex; flex-direction: column; padding: 8px; gap: 1px; overflow-y: auto; }
.sidebar-nav a { color: rgba(255,255,255,0.6); font-size: 13px; font-weight: 500; padding: 9px 10px; border-radius: 6px; }
.sidebar-nav a:hover { color: var(--white); background: rgba(255,255,255,0.08); }
.sidebar-nav a.active { color: var(--orange); background: rgba(249,115,22,0.12); }
.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: var(--white); border-bottom: 0.5px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; flex-shrink: 0; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.avatar-circle { width: 28px; height: 28px; border-radius: 50%; background: var(--orange); color: var(--white); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.page { padding: 22px 24px; max-width: 1300px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* --- Buttons --- */
.btn { display: inline-block; padding: 9px 16px; border-radius: 6px; font-weight: 600; font-size: 13.5px; border: 1px solid transparent; cursor: pointer; }
.btn-primary { background: var(--orange); color: var(--white); }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { background: var(--white); color: var(--charcoal); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--charcoal); border-color: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,0.05); }
.btn-danger { background: var(--white); color: var(--red); border-color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; text-align: center; }

/* --- Forms --- */
form label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 12px; color: var(--charcoal); }
input, select, textarea {
  width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13.5px; font-family: inherit; background: var(--white);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: 1px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.alert { padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: #FBEAE9; color: var(--red); border: 1px solid #F3C6C3; }
.alert-success { background: #E9F5EC; color: var(--green); border: 1px solid #C3E4CC; }

/* --- Cards --- */
.card { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.card + .card { margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }

/* --- KPI / metric cards --- */
.metric-card { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.metric-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.metric-value { font-family: 'Montserrat', sans-serif; font-size: 24px; font-weight: 700; }
.metric-delta { font-size: 12px; margin-top: 4px; }
.metric-delta.up { color: var(--green); }
.metric-delta.down { color: var(--red); }

/* --- Tables --- */
.simple-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.simple-table th, .simple-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.simple-table th { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.row-actions { display: flex; gap: 6px; align-items: center; }

/* --- Badges --- */
.badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px; display: inline-block; }
.badge-gray { background: var(--bg); color: var(--muted); }
.badge-orange { background: rgba(249,115,22,0.12); color: var(--orange-dark); }
.badge-green { background: #E9F5EC; color: var(--green); }
.badge-red { background: #FBEAE9; color: var(--red); }

/* --- Leaderboards --- */
.leaderboard-list { list-style: none; margin: 0; padding: 0; }
.leaderboard-list li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.leaderboard-list li:last-child { border-bottom: none; }
.leaderboard-rank { color: var(--muted); width: 18px; display: inline-block; }

/* --- Sales Pipeline (President/VP only) --- */
.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select { width: auto; min-width: 160px; margin-top: 0; }

.stage-columns { display: grid; grid-template-columns: repeat(7, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; }
.stage-col { background: var(--white); border: 1px solid var(--border); border-radius: 8px; min-height: 200px; }
.stage-col-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; }
.count-badge { background: var(--bg); border-radius: 10px; padding: 1px 8px; font-size: 11px; color: var(--muted); }
.stage-col-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.lead-card { display: block; background: var(--bg); border: 1px solid var(--border); border-left: 3px solid var(--muted); border-radius: 6px; padding: 8px 10px; color: var(--charcoal); }
.lead-card:hover { border-color: var(--orange); }
.lead-card.tier-hot { border-left-color: var(--red); }
.lead-card.tier-warm { border-left-color: var(--orange); }
.lead-card.tier-cold { border-left-color: #5B7DA6; }
.lead-card-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.tier-badge { font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 4px; color: var(--white); }
.tier-badge.tier-hot { background: var(--red); }
.tier-badge.tier-warm { background: var(--orange); }
.tier-badge.tier-cold { background: #5B7DA6; }

.lead-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.touch-form { border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 16px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }

@media (max-width: 1000px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  .shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .lead-grid { grid-template-columns: 1fr; }
}
