:root {
  --brand: #1a56db;
  --brand-dark: #1240a0;
  --text: #111827;
  --muted: #6b7280;
  --border: #d1d5db;
  --bg: #f3f4f6;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  line-height: 1.6;
}

/* Auth pages */
.auth-page {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 1rem;
}

.auth-card {
  background: white;
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  padding: .625rem .875rem;
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: 1rem;
}

.message {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #15803d;
  padding: .625rem .875rem;
  border-radius: var(--radius);
  font-size: .9rem;
  margin-top: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: .375rem;
  font-size: .95rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

label input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .625rem .75rem;
  font-size: 1rem;
  width: 100%;
}

label input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}

.btn-primary {
  display: block;
  width: 100%;
  background: var(--brand);
  color: white;
  border: none;
  padding: .75rem 1.5rem;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: .5rem;
  transition: background .15s;
}

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

.link-sm {
  display: block;
  text-align: center;
  margin-top: 1rem;
  font-size: .875rem;
  color: var(--brand);
  text-decoration: none;
}

.link-sm:hover { text-decoration: underline; }

/* ============================================================
   Portal nav (top bar)
   ============================================================ */
.portal-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #1e293b;
  color: white;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 1.5rem;
  height: 56px;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  color: white;
  margin-right: 2rem;
  white-space: nowrap;
}

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

.nav-link {
  color: #94a3b8;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  transition: color .15s, background .15s;
  white-space: nowrap;
}

.nav-link:hover { color: white; background: rgba(255,255,255,.08); }
.nav-link.active { color: white; background: rgba(255,255,255,.14); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .8rem;
  color: #94a3b8;
  margin-left: auto;
  padding-left: 1rem;
  white-space: nowrap;
}

.nav-logout {
  color: #94a3b8;
  text-decoration: none;
  font-size: .8rem;
}
.nav-logout:hover { color: white; }

/* Stop the whole page from scrolling sideways (clip keeps sticky nav working). */
html, body { overflow-x: clip; max-width: 100%; }

/* Mobile: the nav had brand + 7 links + email + sign-out all nowrap in one row,
   overflowing the viewport. Let the LINKS scroll within their own strip, hide the
   email, and tighten spacing so the page itself never scrolls horizontally. */
@media (max-width: 820px) {
  .portal-nav { padding: 0 .6rem; gap: 6px; }
  .nav-brand { margin-right: .4rem; font-size: .9rem; }
  .nav-links {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    min-width: 0;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-link { padding: 6px 9px; font-size: .8rem; }
  .nav-user { padding-left: .4rem; }
  .nav-user span { display: none; }   /* hide the email address on small screens */
}

/* ============================================================
   Portal main content area
   ============================================================ */
.portal-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  background: var(--bg);
  min-height: calc(100vh - 56px);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-header h1 { font-size: 1.5rem; font-weight: 700; }

/* ============================================================
   Cards
   ============================================================ */
.info-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.info-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.info-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .5rem 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: .9rem;
}

.info-row:last-child { border-bottom: none; }

.info-label {
  color: var(--muted);
  min-width: 160px;
  flex-shrink: 0;
}

.info-value { color: var(--text); }

.dashboard-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .25rem;
}

.site-url {
  font-size: .875rem;
  color: var(--brand);
  text-decoration: none;
}

.site-url:hover { text-decoration: underline; }

/* ============================================================
   Quick actions grid
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.quick-action {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  transition: box-shadow .15s, transform .1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}

.quick-action:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  transform: translateY(-1px);
}

.qa-icon { font-size: 1.75rem; }
.qa-label { font-size: .875rem; font-weight: 500; }

/* ============================================================
   Badges & status
   ============================================================ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}

.badge-green  { background: #d1fae5; color: #065f46; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f3f4f6; color: #4b5563; }

/* ============================================================
   Stats grid (traffic page)
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.stat-num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: .25rem;
}

.stat-label {
  font-size: .8rem;
  color: var(--muted);
}

.setup-note {
  text-align: center;
  margin-bottom: 1.5rem;
}

/* ============================================================
   Keywords
   ============================================================ */
.kw-row { display: flex; flex-wrap: wrap; gap: 6px; }

.kw-tag {
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 99px;
  padding: 2px 10px;
  font-size: .78rem;
  font-weight: 500;
}

/* ============================================================
   Steps list (traffic page)
   ============================================================ */
.steps-list {
  padding-left: 0;
  list-style: none;
  counter-reset: step;
}

.steps-list li {
  counter-increment: step;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: .875rem 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: .9rem;
  line-height: 1.5;
}

.steps-list li:last-child { border-bottom: none; }

.steps-list li::before {
  content: counter(step);
  background: var(--brand);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ============================================================
   Chat (site manager)
   ============================================================ */
.chat-container {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  margin-bottom: 1.5rem;
  overflow: hidden;
  height: 400px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.msg {
  max-width: 80%;
  padding: .625rem .875rem;
  border-radius: 12px;
  font-size: .9rem;
  line-height: 1.5;
}

.msg-bot {
  background: #f3f4f6;
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.msg-user {
  background: var(--brand);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-input-row {
  display: flex;
  gap: .5rem;
  padding: .875rem;
  border-top: 1px solid #e5e7eb;
}

.chat-input-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .875rem;
  font-size: .9rem;
  outline: none;
}

.chat-input-row input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.chat-input-row .btn-primary {
  width: auto;
  padding: .5rem 1.25rem;
  font-size: .9rem;
}

.change-history {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.change-history h3 { font-size: .95rem; font-weight: 600; margin-bottom: .75rem; }

/* ============================================================
   Email setup steps
   ============================================================ */
.setup-steps { margin: 1rem 0; }

.setup-step {
  display: flex;
  gap: .875rem;
  padding: .75rem 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: .9rem;
  align-items: flex-start;
  line-height: 1.5;
}

.setup-step:last-child { border-bottom: none; }

.step-num {
  background: var(--brand);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ============================================================
   Billing
   ============================================================ */
.addon-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .625rem 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: .9rem;
}

.addon-row:last-child { border-bottom: none; }
.addon-row > span:first-child { flex: 1; }
.addon-price { color: var(--muted); font-size: .85rem; }

.danger-zone { border: 1px solid #fca5a5; }

.btn-row {
  display: flex;
  gap: .75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.btn-secondary {
  display: inline-block;
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  padding: .5rem 1.25rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}

.btn-secondary:hover { border-color: #9ca3af; background: #f9fafb; }

.btn-secondary.btn-sm { padding: .25rem .75rem; font-size: .8rem; }

.btn-danger {
  background: #ef4444;
  color: white;
  border: none;
  padding: .5rem 1.25rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}

.btn-danger:hover { background: #dc2626; }

/* ============================================================
   Upsell card
   ============================================================ */
.upsell-card {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.upsell-card h3 { font-size: 1.25rem; margin-bottom: .75rem; }
.upsell-card p { color: var(--muted); margin-bottom: 1.5rem; line-height: 1.6; }
.upsell-card .btn-primary { width: auto; display: inline-block; }

/* ============================================================
   Banner
   ============================================================ */
.banner-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
  border-radius: var(--radius);
  padding: .75rem 1.25rem;
  margin-bottom: 1.25rem;
  font-size: .9rem;
}

/* ============================================================
   Misc
   ============================================================ */
.text-muted { color: var(--muted); font-size: .9rem; line-height: 1.6; }

/* Sidebar layout kept for reference — not used in top-nav version */
.portal-layout { display: flex; min-height: 100vh; }
.portal-sidebar { width: 220px; background: #1e293b; color: white; padding: 1.5rem 1rem; flex-shrink: 0; }
.portal-sidebar h2 { font-size: 1rem; margin-bottom: 1.5rem; opacity: .7; }
.portal-sidebar nav a { display: block; color: #94a3b8; text-decoration: none; padding: .5rem .75rem; border-radius: 6px; margin-bottom: .25rem; font-size: .9rem; }
.portal-sidebar nav a:hover, .portal-sidebar nav a.active { background: rgba(255,255,255,.1); color: white; }

/* ============================================================
   Leads table
   ============================================================ */
.leads-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.leads-table th { text-align: left; padding: .5rem .75rem; border-bottom: 2px solid var(--border); color: var(--muted); font-weight: 600; white-space: nowrap; }
.leads-table td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.leads-table tbody tr:hover { background: #f8fafc; }
.leads-table tbody tr:last-child td { border-bottom: none; }
