:root {
  --navy: #061027;
  --navy2: #0c234f;
  --green: #16a34a;
  --blue: #2563eb;
  --bg: #f5f7fb;
  --text: #172033;
  --muted: #64748b;
  --line: #e5eaf3;
  --shadow: 0 24px 70px rgba(7, 19, 48, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.sidebar {
  background: linear-gradient(180deg, var(--navy), var(--navy2));
  color: white;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-logo {
  width: 210px;
  max-width: 100%;
  height: auto;
  display: block;
}

.brand-sub {
  color: #b8c5db;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-nav a,
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  text-decoration: none;
  font-weight: 800;
  color: #dbe8ff;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 15px;
  width: 100%;
  text-align: left;
}

.sidebar-nav a.active,
.sidebar-nav a:hover,
.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.logout-btn {
  color: #fca5a5;
}

.main {
  padding: 30px;
}

.login-card {
  max-width: 460px;
  margin: 8vh auto;
  background: white;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 28px;
  padding: 34px;
}

.login-card h1,
.topbar h1 {
  margin: 0 0 8px;
  font-size: 34px;
  letter-spacing: -0.04em;
}

.login-card p,
.topbar p {
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

input,
select,
textarea {
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 13px 14px;
  background: white;
  width: 100%;
}

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

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 900;
  cursor: pointer;
}

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

.btn-outline {
  background: white;
  color: var(--navy);
  border: 1px solid #cbd5e1;
}

.status {
  font-weight: 800;
  margin-top: 4px;
}

.error {
  color: #dc2626;
}

.success {
  color: #16a34a;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 22px;
}

.user-chip {
  background: white;
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 800;
  color: #334155;
}

.stats-grid,
.grid-3 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.stat,
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

.stat strong {
  display: block;
  font-size: 32px;
  margin-top: 8px;
  color: var(--green);
}

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.toolbar input {
  flex: 1;
}

.toolbar select {
  width: 220px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
}

.table-card,
.detail-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: auto;
}

.detail-card {
  padding: 22px;
  min-height: 520px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 15px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 30px;
}

.empty-panel {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
  background: #eef2ff;
  color: #3730a3;
}

.badge.new {
  background: #ecfdf5;
  color: #047857;
}

.badge.contacted {
  background: #fef3c7;
  color: #92400e;
}

.badge.demo_scheduled {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge.pilot_started {
  background: #f0fdf4;
  color: #166534;
}

.badge.proposal_sent {
  background: #fff7ed;
  color: #9a3412;
}

.badge.won {
  background: #dcfce7;
  color: #166534;
}

.badge.lost {
  background: #fee2e2;
  color: #991b1b;
}

.email-ok {
  color: #16a34a;
  font-weight: 900;
}

.email-bad {
  color: #dc2626;
  font-weight: 900;
}

.message-box {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 16px;
  padding: 14px;
  white-space: pre-wrap;
  line-height: 1.55;
  color: #334155;
}

.detail-meta {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.meta-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  font-size: 14px;
}

.meta-row span:first-child {
  color: var(--muted);
  font-weight: 800;
}

.panel-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.small-btn {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: white;
  font-weight: 800;
  cursor: pointer;
}

.funnel {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.funnel-step {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  text-align: center;
}

.funnel-step strong {
  display: block;
  font-size: 24px;
  color: var(--blue);
}

.funnel-step span {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 900;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fbfdff;
}

.list-item strong {
  display: block;
}

.list-item span {
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  body {
    grid-template-columns: 1fr;
  }

  .content-grid,
  .stats-grid,
  .grid-3,
  .funnel {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
  }

  .toolbar select {
    width: 100%;
  }
}

/* Prevent split-second login flash while Firebase auth state loads */
body.auth-loading #loginView,
body.auth-loading #dashboardView {
  visibility: hidden;
}

/* Mobile hamburger / slide-out admin sidebar - applied to every admin page */
.mobile-menu-btn,
.mobile-close-btn,
.sidebar-overlay {
  display: none;
}

@media (max-width: 768px) {
  body {
    display: block;
    min-height: 100vh;
  }

  .mobile-menu-btn {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1200;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 14px;
    background: var(--navy);
    box-shadow: 0 14px 35px rgba(7, 19, 48, 0.25);
    display: grid;
    place-items: center;
    gap: 4px;
    padding: 12px;
    cursor: pointer;
  }

  .mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 3px;
    border-radius: 999px;
    background: #ffffff;
  }

  .mobile-close-btn {
    display: grid;
    place-items: center;
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 12px;
    background: rgba(255,255,255,.08);
    color: #ffffff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 84vw;
    max-width: 330px;
    min-height: 100vh;
    z-index: 1300;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: 28px 0 80px rgba(0,0,0,.28);
    overflow-y: auto;
    padding-top: 64px;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1250;
    background: rgba(2, 8, 23, 0.58);
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }

  .main {
    padding: 76px 16px 24px;
  }

  .brand-logo {
    width: 215px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar h1 {
    font-size: 30px;
  }

  .user-chip {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .stats-grid,
  .grid-3,
  .content-grid,
  .funnel {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
  }

  .toolbar select {
    width: 100%;
  }

  .table-card {
    overflow-x: auto;
  }

  table {
    min-width: 760px;
  }
}


/* Horizontal scrolling tables for mobile */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 16px;
}

.table-scroll table {
  min-width: 760px;
}

@media (max-width: 768px) {
  .card .table-scroll {
    margin-top: 8px;
  }

  .card h2 {
    margin-top: 0;
  }

  .table-scroll {
    border: 1px solid var(--line);
    background: #fff;
  }

  .table-scroll table {
    min-width: 760px;
  }
}


/* Demo Schedule + Pilot Schools CRUD layout */
.admin-page-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-form {
  display: grid;
  gap: 14px;
}

.admin-form label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-weight: 800;
  font-size: 13px;
}

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

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.muted-text {
  color: var(--muted);
  line-height: 1.55;
  margin-top: -6px;
}

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

.action-danger {
  color: #991b1b;
  border-color: #fecaca;
  background: #fff5f5;
}

.badge.prospect {
  background: #f8fafc;
  color: #334155;
}

.badge.scheduled {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge.completed {
  background: #dcfce7;
  color: #166534;
}

.badge.rescheduled {
  background: #fef3c7;
  color: #92400e;
}

.badge.cancelled {
  background: #fee2e2;
  color: #991b1b;
}

@media (max-width: 980px) {
  .admin-page-grid {
    grid-template-columns: 1fr;
  }

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


/* New lead picker cards for Demo Schedule and Pilot Schools */
.lead-picker-toolbar {
  margin-bottom: 12px;
}

.lead-picker-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.lead-picker-item {
  border: 1px solid var(--line);
  background: #fbfdff;
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.lead-picker-item strong {
  color: #0f172a;
  font-size: 15px;
}

.lead-picker-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.lead-picker-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lead-picker-meta small {
  background: #eef2ff;
  color: #3730a3;
  border-radius: 999px;
  padding: 5px 8px;
  font-weight: 800;
}

.lead-picker-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}


/* Dashboard / Leads CRM summary sections */
.crm-sections-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.crm-list {
  display: grid;
  gap: 10px;
}

.crm-item {
  border: 1px solid var(--line);
  background: #fbfdff;
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.crm-item strong {
  color: #0f172a;
}

.crm-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.crm-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.crm-total-list {
  display: grid;
  gap: 12px;
}

.crm-total-list div {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fbfdff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.crm-total-list span {
  color: var(--muted);
  font-weight: 800;
}

.crm-total-list strong {
  color: var(--green);
  font-size: 26px;
}

@media (max-width: 980px) {
  .crm-sections-grid {
    grid-template-columns: 1fr;
  }
}
