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

:root {
  --primary: #5c6ef8;
  --primary-dark: #4a5ce6;
  --danger: #ef4444;
  --success: #22c55e;
  --bg: #f4f5f9;
  --card: #fff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --sidebar-bg: #16162a;
  --sidebar-w: 224px;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Auth ── */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.auth-card {
  background: #fff; border-radius: 16px; padding: 44px;
  width: 100%; max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,.18);
}
.auth-logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.3rem; font-weight: 700; color: var(--primary);
  margin-bottom: 28px;
}
.auth-logo svg { color: var(--primary); }
.auth-card h1 { font-size: 1.5rem; margin-bottom: 24px; }
.auth-link { margin-top: 20px; text-align: center; color: var(--text-muted); }
.auth-link a { color: var(--primary); text-decoration: none; font-weight: 500; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: inherit;
  background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(92,110,248,.15);
}
.form-group small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 12px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: background .15s, box-shadow .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(92,110,248,.35); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); border-color: #c9cdd6; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; }

/* ── Alert ── */
.alert { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; left: 0; height: 100vh;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; font-size: 1.1rem; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo svg { color: var(--primary); flex-shrink: 0; }
.sidebar-nav { list-style: none; padding: 10px 0; flex: 1; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; margin: 2px 8px; border-radius: 7px;
  color: rgba(255,255,255,.62); text-decoration: none;
  font-size: 13.5px; font-weight: 450;
  transition: background .15s, color .15s;
}
.sidebar-nav li a svg { flex-shrink: 0; opacity: .75; }
.sidebar-nav li a:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.9); }
.sidebar-nav li a:hover svg { opacity: 1; }
.sidebar-nav li.active a {
  background: rgba(92,110,248,.25); color: #fff;
  box-shadow: inset 3px 0 0 var(--primary);
  padding-left: 11px;
}
.sidebar-nav li.active a svg { opacity: 1; }

.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: space-between;
}
.plan-badge {
  font-size: 10px; font-weight: 700; padding: 3px 9px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: .04em;
}
.plan-free { background: rgba(255,255,255,.1); color: rgba(255,255,255,.65); }
.plan-pro { background: var(--primary); color: #fff; }
.plan-agency { background: #f59e0b; color: #fff; }
.btn-logout {
  color: rgba(255,255,255,.5); text-decoration: none; font-size: 12px;
  transition: color .15s;
}
.btn-logout:hover { color: rgba(255,255,255,.85); }

/* ── Main content ── */
.main-content { margin-left: var(--sidebar-w); padding: 32px; flex: 1; min-width: 0; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; }

/* ── Pages grid ── */
.pages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.page-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; cursor: default;
  transition: box-shadow .2s, transform .2s;
}
.page-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.08); transform: translateY(-2px); }

.page-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.page-card-actions { display: flex; gap: 6px; }
.page-card-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.page-card-slug { color: var(--text-muted); font-size: 12px; margin-bottom: 14px; font-family: ui-monospace, monospace; }
.page-card-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* ── Status badges ── */
.status-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; letter-spacing: .02em; }
.status-draft { background: #f3f4f6; color: #6b7280; }
.status-published { background: #dcfce7; color: #15803d; }
.status-archived { background: #fef9c3; color: #854d0e; }

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 80px 20px; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center;
}
.empty-state p { margin-bottom: 16px; font-size: 15px; }

/* ── Modal ── */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; }
.modal.open { display: flex; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(4px); }
.modal-box {
  position: relative; background: #fff; border-radius: 14px; padding: 28px;
  width: 100%; max-width: 480px;
  box-shadow: 0 24px 64px rgba(0,0,0,.22);
  animation: modal-in .2s ease;
}
@keyframes modal-in { from { opacity: 0; transform: scale(.95) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-box h2 { margin-bottom: 20px; font-size: 1.2rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* ── Admin stats ── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; text-align: center;
}
.stat-num { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ── Data table ── */
.data-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.data-table th {
  background: var(--bg); padding: 12px 16px; text-align: left;
  font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafbff; }
.data-table select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }

/* ── Media library ── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.media-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  overflow: hidden; transition: box-shadow .2s, transform .2s;
}
.media-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); transform: translateY(-2px); }
.media-thumb {
  height: 140px; background: #f3f4f6;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-info { padding: 10px 12px 6px; }
.media-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.media-meta { font-size: 11px; color: #9ca3af; }
.media-actions { padding: 8px 12px 12px; display: flex; gap: 6px; }
