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

:root {
  --primary: #007AFF;
  --primary-dark: #0056CC;
  --success: #198754;
  --danger: #DC3545;
  --bg: #F5F7FA;
  --card: #ffffff;
  --border: #E2E8F0;
  --text: #1A202C;
  --muted: #718096;
  --radius: 12px;
}

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

/* ── Auth pages ── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.auth-logo .logo-mark {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 18px;
}
.auth-logo span { font-size: 22px; font-weight: 700; }
.auth-logo .ai-tag { color: var(--primary); }

h2 { font-size: 22px; margin-bottom: 6px; }
.auth-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #444; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=tel] {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
input:focus { border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, background 0.2s;
  text-decoration: none;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-full { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }

.auth-switch { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }
.auth-switch a { color: var(--primary); text-decoration: none; font-weight: 600; }

.error-msg {
  background: #FFF5F5; border: 1px solid #FED7D7;
  color: var(--danger); border-radius: 8px;
  padding: 10px 14px; font-size: 13px; margin-bottom: 16px;
  display: none;
}
.error-msg.show { display: block; }

/* ── Dashboard layout ── */
.dash-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar .logo {
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.sidebar .logo .logo-mark {
  width: 32px; height: 32px;
  background: var(--primary); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 14px;
}
.sidebar .logo span { font-size: 17px; font-weight: 700; }
.sidebar .logo .ai-tag { color: var(--primary); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: var(--muted); font-size: 14px; font-weight: 500;
  cursor: pointer; border-radius: 8px; margin: 0 8px;
  transition: all 0.15s;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: #EBF4FF; color: var(--primary); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-bottom {
  margin-top: auto;
  padding: 16px 8px 0;
  border-top: 1px solid var(--border);
}

.main { flex: 1; padding: 32px; overflow-y: auto; }

.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header p { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-card .stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat-card .stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Status badge ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-pending { background: #FFF3CD; color: #856404; }
.badge-crawling { background: #CCE5FF; color: #004085; }
.badge-ready { background: #D4EDDA; color: #155724; }
.badge-error { background: #F8D7DA; color: #721C24; }

/* ── Embed code box ── */
.embed-box {
  background: #1E1E2E;
  color: #A6E3A1;
  border-radius: 10px;
  padding: 16px 18px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  position: relative;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.6;
}
.copy-btn {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(255,255,255,0.1);
  border: none; color: #fff;
  padding: 5px 10px; border-radius: 6px;
  font-size: 12px; cursor: pointer;
}
.copy-btn:hover { background: rgba(255,255,255,0.2); }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 14px; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--border); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

.empty-state { text-align: center; padding: 40px; color: var(--muted); }
.empty-state p { margin-top: 8px; font-size: 14px; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .dash-layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar .logo { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
  .main { padding: 20px 16px; }
}
