/* ── Reset + Variables ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --border:      #dde3ec;
  --text:        #1a202c;
  --muted:       #64748b;
  --primary:     #2563eb;
  --primary-dk:  #1d4ed8;
  --primary-lt:  #eff6ff;
  --success:     #059669;
  --success-lt:  #d1fae5;
  --warning:     #d97706;
  --warning-lt:  #fef3c7;
  --error:       #dc2626;
  --error-lt:    #fee2e2;
  --header-bg:   #0f172a;
  --header-text: #f1f5f9;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 20px rgba(0,0,0,0.1);
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono:        'SF Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.brand { display: flex; align-items: center; gap: 0.5rem; }
.brand-icon { font-size: 1.3rem; }
.brand-name { font-size: 1.2rem; font-weight: 700; color: #fff; }
.brand-by   { font-size: 0.75rem; color: #94a3b8; margin-top: 2px; }
.header-nav { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.header-nav a { color: #94a3b8; font-size: 0.9rem; transition: color 0.15s; }
.header-nav a:hover { color: #fff; text-decoration: none; }

/* ── Auth area ─────────────────────────────────────────────────────────── */
.auth-area { display: flex; align-items: center; }
.key-form { display: flex; gap: 0.5rem; align-items: center; }
#api-key-input {
  width: 260px;
  padding: 0.4rem 0.75rem;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  background: #1e293b;
  color: #f1f5f9;
  font-size: 0.85rem;
}
#api-key-input::placeholder { color: #64748b; }
#api-key-input:focus { outline: none; border-color: var(--primary); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  padding: 0.65rem 1.5rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dk); text-decoration: none; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }

.btn-secondary {
  padding: 0.6rem 1.25rem;
  background: var(--surface);
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-secondary:hover { background: var(--primary-lt); text-decoration: none; }

.btn-sm {
  padding: 0.35rem 0.9rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-sm:hover { background: var(--primary-dk); }

.btn-link {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.btn-link:hover { color: #fff; }
.btn-full { width: 100%; justify-content: center; text-align: center; }
.btn-disabled, .btn-disabled:hover { background: var(--surface) !important; color: var(--muted) !important; border-color: var(--border) !important; cursor: not-allowed !important; }

/* ── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #0f172a 100%);
  padding: 5rem 2rem 4rem;
  text-align: center;
  color: #fff;
}
.hero-inner { max-width: 680px; margin: 0 auto; }
.hero h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
}
.hero p { font-size: 1.1rem; color: rgba(255,255,255,0.7); margin-bottom: 1.5rem; }
.hero-hint {
  display: inline-block;
  padding: 0.4rem 1rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 99px;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.75);
}

/* ── Crawl Section ──────────────────────────────────────────────────────── */
.crawl-section { max-width: 860px; margin: 0 auto; padding: 2.5rem 1.5rem; }

.crawl-form-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}
.form-row { margin-bottom: 1rem; }
.mode-select {
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.mode-select:focus { outline: none; border-color: var(--primary); }

/* SPA options panel */
.spa-options {
  background: #f0f9ff;
  border: 1.5px solid #bae6fd;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem 0.9rem;
  margin-top: -0.25rem;
}
.spa-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.spa-option-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #0369a1;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.spa-option-group .mode-select {
  width: 100%;
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  border-color: #7dd3fc;
  background: #fff;
}
.spa-note {
  font-size: 0.8rem;
  color: #0369a1;
  line-height: 1.5;
  padding-top: 0.5rem;
  border-top: 1px solid #bae6fd;
}

/* Render mode badge */
.render-mode-badge {
  display: inline-block;
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #7dd3fc;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.url-input-group { display: flex; gap: 0.75rem; }
#url-input {
  flex: 1;
  padding: 0.75rem 1.2rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 1rem;
  transition: border-color 0.2s;
  min-width: 0;
}
#url-input:focus { outline: none; border-color: var(--primary); }

#start-btn { flex-shrink: 0; }

.form-error {
  margin-top: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--error-lt);
  color: var(--error);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

/* ── Progress ────────────────────────────────────────────────────────────── */
.progress-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.btn-stop-crawl {
  margin-left: auto;
  padding: 0.3rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  background: #fff1f2;
  color: #be123c;
  border: 1.5px solid #fda4af;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-stop-crawl:hover  { background: #be123c; color: #fff; border-color: #be123c; }
.btn-stop-crawl:disabled { opacity: 0.6; cursor: not-allowed; }
.progress-status-text { font-weight: 600; }
.progress-count {
  background: var(--primary-lt);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.2rem 0.7rem;
  border-radius: 99px;
}
.progress-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 99px;
  transition: width 0.4s ease;
}
.live-feed {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  background: #f8fafc;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.8;
}
.feed-item { color: var(--muted); word-break: break-all; }
.feed-item.ok    { color: var(--success); }
.feed-item.error { color: var(--error); }

/* ── Results ─────────────────────────────────────────────────────────────── */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.results-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.25rem; }
.results-summary { font-size: 0.9rem; color: var(--muted); }
.results-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

.upgrade-prompt {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--warning-lt);
  border: 1px solid #fcd34d;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.results-table {
  width: 100%;
  border-collapse: collapse;
}
.results-table th {
  background: #f1f5f9;
  text-align: left;
  padding: 0.7rem 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.results-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  vertical-align: top;
}
.results-table tr:hover td { background: #f8fafc; }
.results-table tr.clickable { cursor: pointer; }
.td-url { max-width: 300px; word-break: break-all; }
.td-title { max-width: 250px; }
.status-ok  { color: var(--success); font-weight: 700; }
.status-err { color: var(--error);   font-weight: 700; }
.status-rdr { color: var(--warning); font-weight: 700; }

/* ── Pricing ─────────────────────────────────────────────────────────────── */
.pricing-section {
  background: var(--surface);
  padding: 5rem 2rem;
  border-top: 1px solid var(--border);
}
.section-inner { max-width: 1100px; margin: 0 auto; }
.section-title { font-size: 2rem; font-weight: 800; text-align: center; margin-bottom: 0.5rem; }
.section-sub   { text-align: center; color: var(--muted); margin-bottom: 3rem; font-size: 1.05rem; }

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}
.pricing-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.pricing-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.pricing-card.featured { border-color: var(--primary); background: var(--primary-lt); }
.pricing-card.featured::before {
  content: 'POPULAR';
  position: absolute;
  top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.75rem;
  border-radius: 99px;
}
.plan-name  { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; }
.plan-price { font-size: 2.2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.plan-price span { font-size: 1rem; font-weight: 400; color: var(--muted); }
.plan-pages { font-size: 0.9rem; color: var(--muted); margin: 0.5rem 0 1.25rem; }
.plan-features { list-style: none; font-size: 0.88rem; display: flex; flex-direction: column; gap: 0.5rem; }
.plan-features li::before { content: '✓ '; color: var(--success); font-weight: 700; }
.plan-features li.no::before { content: '✗ '; color: #94a3b8; }
.pricing-loading { text-align: center; color: var(--muted); padding: 2rem; }

/* ── Tier Badge ──────────────────────────────────────────────────────────── */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tier-badge.free       { background: #e2e8f0; color: #475569; }
.tier-badge.starter    { background: #dbeafe; color: #1d4ed8; }
.tier-badge.pro        { background: var(--success-lt); color: #065f46; }
.tier-badge.enterprise { background: var(--warning-lt); color: #92400e; }

/* ── Dashboard ───────────────────────────────────────────────────────────── */
.dashboard-page body { background: var(--bg); }
.auth-guard {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 2rem;
}
.auth-guard-inner { text-align: center; max-width: 400px; }
.auth-guard-inner h2 { font-size: 2rem; margin-bottom: 1rem; }
.auth-guard-inner p  { color: var(--muted); margin-bottom: 2rem; }

.dashboard-main {
  display: flex;
  min-height: calc(100vh - 60px);
}
.dashboard-sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  overflow-y: auto;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
}
.sidebar-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.75rem; margin-top: 0.25rem; }
.sidebar-divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.summary-dl dt { font-size: 0.78rem; color: var(--muted); margin-top: 0.5rem; }
.summary-dl dd { font-size: 0.95rem; font-weight: 600; word-break: break-all; }
.filter-group { margin-bottom: 0.85rem; }
.filter-group label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.3rem; }
.filter-input {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--bg);
}
.filter-input:focus { outline: none; border-color: var(--primary); }

.dashboard-content { flex: 1; padding: 1.75rem; overflow: auto; min-width: 0; }
.content-toolbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.25rem; }
.dash-heading { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.15rem; }
.row-count { font-size: 0.85rem; color: var(--muted); }

.full-table td { font-size: 0.85rem; }
.full-table .num { color: var(--muted); font-size: 0.82rem; }

/* Detail panel */
.detail-panel {
  width: 360px;
  min-width: 360px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 1.5rem;
  overflow-y: auto;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
}
.detail-header { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 1rem; }
.detail-header .detail-title { flex: 1; margin: 0; }
.detail-title { font-size: 1rem; font-weight: 700; }
.close-btn { font-size: 1.1rem; color: var(--muted); }
.detail-body dl { font-size: 0.85rem; }
.detail-body dt { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 1rem; }
.detail-body dd { margin-top: 0.2rem; word-break: break-all; }
.detail-body .body-preview {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 0.3rem;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--header-bg);
  color: #64748b;
  padding: 1.5rem 2rem;
  font-size: 0.85rem;
  border-top: 1px solid #1e293b;
}
.footer-inner { max-width: 1100px; margin: 0 auto; display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.footer-inner a { color: #94a3b8; }

/* ── Auth Pages (register / login) ───────────────────────────────────────── */
.auth-page-wrap {
  min-height: calc(100vh - 60px - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
}
.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 440px;
}
.auth-card-header { margin-bottom: 1.75rem; }
.auth-card-header h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: 0.35rem; }
.auth-card-header p  { color: var(--muted); font-size: 0.95rem; }

.field-group { margin-bottom: 1rem; }
.field-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}
.field-group input {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}
.field-group input:focus { outline: none; border-color: var(--primary); }
.field-group input:invalid:not(:placeholder-shown) { border-color: var(--error); }

.input-password-wrap { position: relative; }
.input-password-wrap input { padding-right: 2.75rem; }
.toggle-pw {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
  padding: 0;
  line-height: 1;
}

.field-error {
  padding: 0.65rem 1rem;
  background: var(--error-lt);
  color: var(--error);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-top: 0.5rem;
}

.auth-switch {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ── Checkout Page ────────────────────────────────────────────────────────── */
.checkout-page-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}
.checkout-header { text-align: center; margin-bottom: 2rem; }
.checkout-header h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.5rem; }
.checkout-header p  { color: var(--muted); font-size: 1rem; }

.billing-toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}
.billing-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s;
}
.billing-label.billing-active { color: var(--text); }
.lifetime-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: var(--success-lt);
  color: var(--success);
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 0.3rem;
}
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--primary); }
.toggle-track::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-track::after { transform: translateX(20px); }

.checkout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  align-items: start;
}
.checkout-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.checkout-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.checkout-card.featured {
  border-color: var(--primary);
  background: var(--primary-lt);
}
.checkout-card.featured::before {
  content: 'MOST POPULAR';
  position: absolute;
  top: -13px; left: 50%; transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.85rem;
  border-radius: 99px;
}
.checkout-note {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2rem;
}

/* ── Payment Success ─────────────────────────────────────────────────────── */
.success-card { text-align: center; }
.success-icon { font-size: 3rem; margin-bottom: 1rem; }
.success-card h1 { font-size: 1.75rem; font-weight: 800; margin-bottom: 0.5rem; }
.success-card p  { color: var(--muted); margin-bottom: 0.5rem; }

.api-key-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  text-align: left;
}
.api-key-box code {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
  color: var(--text);
}
.warn-box {
  background: var(--warning-lt);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  color: #92400e;
  text-align: left;
}

/* ── Account Page ────────────────────────────────────────────────────────── */
.account-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  gap: 1rem;
  color: var(--muted);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.account-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.account-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.account-section-inner { padding: 1.75rem 2rem; }
.account-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.account-profile-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.account-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.account-name  { font-size: 1.1rem; font-weight: 700; }
.account-email { font-size: 0.88rem; color: var(--muted); }
.account-since { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }

.sub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1.25rem;
}
.sub-stat-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.25rem; }
.sub-stat-value { font-size: 1rem; font-weight: 600; }

.key-display-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
}
.masked-key {
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--text);
  flex: 1;
  word-break: break-all;
}
.key-status-badge {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
}
.key-status-badge.active   { background: var(--success-lt); color: #065f46; }
.key-status-badge.inactive { background: var(--error-lt);   color: var(--error); }

.regen-msg {
  margin-top: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}
.regen-msg.success { background: var(--success-lt); color: #065f46; }
.regen-msg.error   { background: var(--error-lt);   color: var(--error); }

.code-block {
  position: relative;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.8;
  overflow-x: auto;
}
.copy-code-btn {
  position: absolute;
  top: 0.6rem; right: 0.75rem;
  background: #334155;
  color: #94a3b8;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.copy-code-btn:hover { background: #475569; color: #fff; }

/* ── Crawl History Table ─────────────────────────────────────────────────── */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.history-table th {
  text-align: left;
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.history-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: var(--surface); }
.history-table a { color: var(--primary); text-decoration: none; }
.history-table a:hover { text-decoration: underline; }

.history-actions { display: flex; gap: 0.5rem; align-items: center; }
.history-no-export { color: var(--muted); }

.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.btn-view {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #86efac;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-view:hover { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-export {
  background: #eff6ff;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-export:hover { background: var(--primary); color: #fff; }

/* Per-row page download button (results table) */
.btn-dl-page {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.btn-dl-page:hover { color: var(--primary); background: var(--primary-lt, #eff6ff); }
.btn-delete {
  background: var(--error-lt);
  color: var(--error);
  border-color: var(--error);
}
.btn-delete:hover { background: var(--error); color: #fff; }
.btn-delete:disabled, .btn-export:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── Tech Stack — Dashboard Sidebar ─────────────────────────────────────── */
.tech-sidebar-group {
  margin-bottom: 0.9rem;
}
.tech-sidebar-cat {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.tech-sidebar-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0;
  font-size: 0.82rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.tech-sidebar-row:last-child { border-bottom: none; }
.tech-icon { font-size: 0.9rem; flex-shrink: 0; }
.tech-name { flex: 1; font-weight: 500; }
.tech-pages-count {
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface);
  border-radius: 99px;
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
}

/* Tech count badge in table */
.tech-count-badge {
  display: inline-block;
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #86efac;
  border-radius: 99px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: default;
}

/* Tech tags in detail panel */
.tech-detail-wrap { margin-top: 0.35rem; }
.tech-cat-group { margin-bottom: 0.6rem; }
.tech-cat-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.tech-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tech-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

/* ── Utilities ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .hero h1 { font-size: 1.8rem; }
  .url-input-group { flex-direction: column; }
  /* Keep auth buttons visible on mobile but reduce size */
  .key-form { gap: 0.3rem; }
  .key-form .btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
  #api-key-input { display: none; } /* hide manual key input on mobile */
  .dashboard-main { flex-direction: column; }
  .dashboard-sidebar { width: 100%; position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .detail-panel { width: 100%; min-width: unset; position: static; height: auto; border-left: none; border-top: 1px solid var(--border); }

  /* Auth pages */
  .auth-card { padding: 1.75rem 1.25rem; }
  .checkout-grid { grid-template-columns: 1fr; }
  .checkout-page-wrap { padding: 2rem 1rem 3rem; }

  /* Account page */
  .account-profile-row { gap: 0.75rem; }
  .account-section-inner { padding: 1.25rem; }
  .sub-grid { grid-template-columns: repeat(2, 1fr); }
}
