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

:root {
  --brand: #6366f1;
  --brand-dark: #4f46e5;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --info: #3b82f6;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

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

/* ── Auth page ── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  margin-bottom: 28px;
}

.auth-card h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--muted);
  margin-bottom: 28px;
  font-size: 14px;
}

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 20px;
}

/* ── Forms ── */
form { display: flex; flex-direction: column; gap: 14px; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: 5px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

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

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

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 20px;
  transition: background .15s, opacity .15s, transform .1s;
}

button:active { transform: scale(.98); }

.btn-primary {
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

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

/* ── Spinner ── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Banners ── */
.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
}

.success-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
}

/* ── App layout ── */
.app { display: flex; flex-direction: column; min-height: 100vh; }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 10px; }

.site-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.site-url {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}

.site-url:hover { color: var(--brand); }

.user-badge {
  font-size: 13px;
  color: var(--muted);
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 8px;
}

.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

main { flex: 1; padding: 28px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  border-radius: 0;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Analytics iframe ── */
.analytics-frame {
  width: 100%;
  height: 700px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.analytics-placeholder {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}

.analytics-placeholder p { margin-top: 8px; font-size: 14px; }

/* ── Changelog ── */
.changelog-list { display: flex; flex-direction: column; gap: 14px; }

.changelog-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  gap: 16px;
}

.changelog-date {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 2px;
  min-width: 80px;
}

.changelog-body { flex: 1; }

.changelog-title {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.changelog-desc { font-size: 14px; color: var(--muted); }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: capitalize;
}

.badge-feature  { background: #ede9fe; color: #6d28d9; }
.badge-fix      { background: #fef2f2; color: #b91c1c; }
.badge-update   { background: #eff6ff; color: #1d4ed8; }
.badge-design   { background: #fdf4ff; color: #9333ea; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 14px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

/* ── Admin layout ── */
.admin-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: start;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ── Client table ── */
.client-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.client-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}

.client-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.client-table tr:last-child td { border-bottom: none; }
.client-table tr:hover td { background: var(--bg); }

.page-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}

/* ── Loading skeleton ── */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 6px;
}

@keyframes shimmer { to { background-position: -200% 0; } }
