/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a1a2e;
  --primary-light: #16213e;
  --accent: #c9a84c;
  --accent-hover: #b8943f;
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --green: #22c55e;
  --blue: #3b82f6;
  --orange: #f59e0b;
  --red: #ef4444;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

#app {
  display: flex;
  min-height: 100vh;
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--primary);
}

.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.login-logo {
  width: 72px;
  height: 72px;
  background: var(--primary);
  color: var(--accent);
  font-size: 32px;
  font-weight: 700;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.login-card h1 {
  font-size: 24px;
  color: var(--text);
  margin-bottom: 8px;
}

.login-card p {
  color: var(--text-light);
  font-size: 14px;
}

.login-screen.hidden {
  display: none;
}

.sign-out-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s;
}

.sign-out-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

/* ===== SIDEBAR ===== */
#sidebar {
  width: 240px;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: width 0.3s;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.logo-text {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.5px;
}

.nav-links {
  list-style: none;
  padding: 16px 0;
  flex: 1;
}

.nav-links li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.nav-links li a:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}

.nav-links li a.active {
  color: #fff;
  background: rgba(255,255,255,0.08);
  border-left-color: var(--accent);
}

.nav-links li a .material-icons-outlined {
  font-size: 20px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

#userName {
  font-size: 14px;
  font-weight: 500;
}

/* ===== MAIN CONTENT ===== */
#mainContent {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
  max-width: 1200px;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

.subtitle {
  color: var(--text-light);
  font-size: 14px;
  margin-top: 4px;
}

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-header-row h2 {
  margin-bottom: 0;
}

.filter-row {
  display: flex;
  gap: 8px;
}

.filter-row select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}

/* ===== SCOREBOARD ===== */
.scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.score-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}

.score-card .material-icons-outlined {
  font-size: 32px;
  color: var(--accent);
}

.score-card.highlight {
  background: var(--primary);
  color: #fff;
}

.score-card.highlight .material-icons-outlined {
  color: var(--accent);
}

.score-info h3 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.score-info p {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}

.score-card.highlight .score-info p {
  color: rgba(255,255,255,0.65);
}

/* ===== GOAL BAR ===== */
.goal-bar-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.goal-bar {
  flex: 1;
  height: 24px;
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
}

.goal-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #d4af37);
  border-radius: 12px;
  transition: width 0.6s ease;
}

.goal-label {
  font-weight: 600;
  font-size: 14px;
  min-width: 45px;
}

/* ===== AGENT GRID ===== */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.agent-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.agent-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.agent-card-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.agent-card-name {
  font-weight: 600;
  font-size: 14px;
}

.agent-card-role {
  font-size: 12px;
  color: var(--text-light);
}

.agent-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.agent-stat {
  text-align: center;
}

.agent-stat-num {
  font-size: 18px;
  font-weight: 700;
}

.agent-stat-label {
  font-size: 11px;
  color: var(--text-light);
}

.agent-goal-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.agent-goal-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.6s ease;
}

.agent-goal-text {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
  text-align: right;
}

/* ===== TABLES ===== */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--text-light);
  border-bottom: 2px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: rgba(0,0,0,0.02);
}

.total-row td {
  font-weight: 600;
  border-top: 2px solid var(--border);
  background: var(--bg);
}

/* ===== STATUS DOTS / COLORS ===== */
.lead-row-green { border-left: 4px solid var(--green); }
.lead-row-blue { border-left: 4px solid var(--blue); }
.lead-row-orange { border-left: 4px solid var(--orange); }
.lead-row-red { border-left: 4px solid var(--red); }
.lead-row-neutral { border-left: 4px solid var(--border); }

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-closed { background: #dcfce7; color: #166534; }
.status-pending { background: #dbeafe; color: #1e40af; }
.status-active { background: #f3f4f6; color: #374151; }
.status-dead { background: #fee2e2; color: #991b1b; }
.status-needs-update { background: #fef3c7; color: #92400e; }

.legend {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-light);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.green { background: var(--green); }
.dot.blue { background: var(--blue); }
.dot.orange { background: var(--orange); }
.dot.red { background: var(--red); }
.dot.neutral { background: #d1d5db; }

/* ===== FORMS ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
}

input, select, textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.15);
}

textarea { resize: vertical; }

.num-input {
  width: 80px;
  text-align: center;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.form-actions.full-width {
  grid-column: 1 / -1;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: var(--primary);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-light);
  font-size: 18px;
  border-radius: 4px;
}

.btn-icon:hover {
  background: var(--bg);
  color: var(--text);
}

/* ===== ACTIVITY GRID ===== */
.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.activity-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.activity-item label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
}

.activity-detail {
  display: flex;
  gap: 8px;
}

.activity-detail input:first-child {
  flex: 1;
}

/* ===== AGENDA ===== */
.agenda-status {
  font-size: 14px;
}

.agenda-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.agenda-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.agenda-section p {
  font-size: 13px;
  color: var(--text-light);
  white-space: pre-wrap;
}

.agenda-submitted {
  border-left: 3px solid var(--green);
}

.agenda-pending {
  border-left: 3px solid var(--orange);
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  margin-bottom: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  padding: 4px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  z-index: 300;
}

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

/* ===== MOBILE BOTTOM NAV ===== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  z-index: 200;
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
}

.bottom-nav-links {
  display: flex;
  justify-content: space-around;
  list-style: none;
}

.bottom-nav-links a {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  padding: 6px 8px;
  gap: 2px;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-links a .material-icons-outlined {
  font-size: 22px;
}

.bottom-nav-links a.active {
  color: var(--accent);
}

/* ===== SYNC STATUS BAR ===== */
.sync-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-light);
  padding: 6px 0;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.sync-dot.syncing {
  background: var(--orange);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== GOAL HINTS ===== */
.goal-hint {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

/* ===== FULL WIDTH ACTIVITY ITEMS ===== */
.full-width-activity {
  grid-column: 1 / -1;
}

.full-width-activity input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

/* ===== BRIVITY CRM TOGGLE ===== */
.brivity-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-light);
  transition: all 0.2s;
}

.brivity-btn:hover {
  border-color: var(--accent);
}

.brivity-btn.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.brivity-btn .material-icons-outlined {
  font-size: 14px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #sidebar {
    display: none;
  }

  .bottom-nav {
    display: block;
  }

  #mainContent {
    margin-left: 0;
    padding: 16px 16px 80px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .scoreboard {
    grid-template-columns: 1fr 1fr;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .modal-content {
    margin: 16px;
    max-height: 90vh;
    overflow-y: auto;
  }

  .toast {
    bottom: 80px;
  }
}

@media (max-width: 480px) {
  .scoreboard {
    grid-template-columns: 1fr;
  }

  .agent-grid {
    grid-template-columns: 1fr;
  }
}
