/* ===== APP SHELL ===== */
.app-body {
  background: var(--bg-primary);
  min-height: 100vh;
  color: var(--fg-primary);
}

/* ===== NAV ===== */
.app-nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg-primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-link {
  font-size: 0.9rem;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: var(--fg-primary);
  background: rgba(255,255,255,0.05);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-subtle);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn:hover { opacity: 0.85; }

.btn-primary {
  background: var(--accent);
  color: #0c0a09;
  padding: 10px 20px;
}

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: var(--fg-primary);
  padding: 10px 20px;
}

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  padding: 8px 14px;
}

.btn-ghost:hover {
  color: var(--fg-primary);
  background: rgba(255,255,255,0.06);
  opacity: 1;
}

.btn-sm {
  font-size: 0.82rem;
  padding: 6px 12px;
}

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: #f87171;
  padding: 8px 16px;
}

/* ===== PAGE LAYOUT ===== */
.page-wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px 24px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.page-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--fg-primary);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 0.95rem;
  color: var(--fg-muted);
  margin-top: 6px;
}

/* ===== STAT CARDS ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 24px 20px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--fg-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: 'Space Grotesk', sans-serif;
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--fg-primary);
  line-height: 1;
}

.stat-value.accent { color: var(--accent); }

/* ===== PIPELINE STAGES ===== */
.pipeline {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 40px;
}

.stage-col {
  background: var(--bg-secondary);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius);
  overflow: hidden;
}

.stage-header {
  padding: 12px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.stage-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-secondary);
}

.stage-count {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-subtle);
  border-radius: 100px;
  padding: 1px 8px;
}

.stage-leads {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
}

.lead-card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition: border-color 0.15s;
}

.lead-card:hover {
  border-color: rgba(245,158,11,0.25);
}

.lead-card-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-primary);
  margin-bottom: 4px;
}

.lead-card-meta {
  font-size: 0.78rem;
  color: var(--fg-muted);
  line-height: 1.4;
}

.lead-card-revenue {
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
}

/* ===== STAGE BADGES ===== */
.stage-badge {
  display: inline-block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 100px;
}

.stage-new { background: rgba(100,116,139,0.2); color: #94a3b8; }
.stage-qualified { background: rgba(59,130,246,0.15); color: #60a5fa; }
.stage-permitted { background: rgba(234,179,8,0.15); color: #facc15; }
.stage-scheduled { background: rgba(168,85,247,0.15); color: #c084fc; }
.stage-installed { background: rgba(245,158,11,0.15); color: var(--accent); }
.stage-closed { background: rgba(34,197,94,0.15); color: #4ade80; }

/* ===== TABLE ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--fg-secondary);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

.data-table td a {
  color: var(--fg-primary);
  text-decoration: none;
  font-weight: 500;
}

.data-table td a:hover { color: var(--accent); }

.table-wrap {
  background: var(--bg-secondary);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ===== FORMS ===== */
.form-card {
  background: var(--bg-secondary);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 680px;
}

.form-section {
  margin-bottom: 32px;
}

.form-section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

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

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

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

label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--fg-secondary);
  font-family: 'Space Grotesk', sans-serif;
}

input, select, textarea {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--fg-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  width: 100%;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

select option {
  background: var(--bg-card);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.error-msg {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 8px;
  padding: 12px 16px;
  color: #f87171;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* ===== LEAD DETAIL ===== */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

.detail-card {
  background: var(--bg-secondary);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.detail-card-body {
  padding: 20px 24px;
}

.detail-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.detail-label {
  font-size: 0.82rem;
  color: var(--fg-muted);
  min-width: 130px;
  font-family: 'Space Grotesk', sans-serif;
}

.detail-value {
  font-size: 0.9rem;
  color: var(--fg-primary);
}

/* ===== TIMELINE ===== */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 14px;
  padding-bottom: 20px;
  position: relative;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-secondary);
  flex-shrink: 0;
  margin-top: 4px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 14px;
  bottom: 0;
  width: 2px;
  background: rgba(255,255,255,0.06);
}

.timeline-item:last-child::before { display: none; }

.timeline-content { flex: 1; }

.timeline-stage {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-primary);
  margin-bottom: 3px;
}

.timeline-date {
  font-size: 0.78rem;
  color: var(--fg-muted);
}

.timeline-note {
  font-size: 0.83rem;
  color: var(--fg-secondary);
  margin-top: 4px;
}

/* ===== PERMITS CHECKLIST ===== */
.permits-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.permit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 8px;
}

.permit-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.permit-pending { background: var(--fg-muted); }
.permit-submitted { background: #60a5fa; }
.permit-approved { background: #4ade80; }
.permit-rejected { background: #f87171; }

.permit-type {
  font-size: 0.88rem;
  color: var(--fg-primary);
  flex: 1;
}

.permit-status-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.permit-actions form {
  display: inline;
}

/* ===== STAGE MOVER ===== */
.stage-mover {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stage-btn {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: all 0.15s;
}

.stage-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.stage-btn.current {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
  cursor: default;
}

/* ===== AUTH PAGE ===== */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: linear-gradient(175deg, var(--bg-primary) 0%, #1a1208 50%, var(--bg-primary) 100%);
}

.auth-card {
  background: var(--bg-secondary);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--fg-primary);
  margin-bottom: 8px;
  text-align: center;
}

.auth-tagline {
  font-size: 0.88rem;
  color: var(--fg-muted);
  text-align: center;
  margin-bottom: 32px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 32px;
  color: var(--fg-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state-text {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ===== SECTION DIVIDERS ===== */
.section-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .pipeline {
    grid-template-columns: repeat(3, 1fr);
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .detail-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .pipeline {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .page-wrap {
    padding: 24px 16px;
  }
}
