:root {
  --bg-0: #0a0a0a;
  --bg-1: #111111;
  --bg-2: #161616;
  --bg-3: #1c1c1c;
  --bg-4: #232323;
  --border: #262626;
  --border-2: #303030;
  --text: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --accent: #ffffff;
  --accent-bg: #ffffff;
  --accent-text: #000000;
  --green: #22c55e;
  --green-bg: #22c55e1a;
  --orange: #f97316;
  --orange-bg: #f973161a;
  --red: #ef4444;
  --red-bg: #ef44441a;
  --blue: #3b82f6;
  --blue-bg: #3b82f61a;
  --purple: #a855f7;
  --purple-bg: #a855f71a;
  --yellow: #eab308;
  --yellow-bg: #eab3081a;
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-w: 240px;
}

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

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

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar .logo .mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff, #a1a1aa);
  display: grid;
  place-items: center;
  color: #000;
  font-weight: 700;
  font-size: 14px;
}

.sidebar .logo .name {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sidebar .cta {
  margin: 0 0 10px;
  background: var(--accent-bg);
  color: var(--accent-text);
  border: none;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  width: 100%;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
}

.sidebar .cta:hover { opacity: 0.9; }

.sidebar nav { display: flex; flex-direction: column; gap: 1px; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  transition: all 0.1s;
}

.sidebar nav a:hover {
  background: var(--bg-2);
  color: var(--text);
}

.sidebar nav a.active {
  background: var(--bg-3);
  color: var(--text);
}

.sidebar nav a .ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar nav a .badge {
  margin-left: auto;
  background: var(--bg-3);
  color: var(--text-2);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
}

.sidebar .section-title {
  padding: 18px 10px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  font-weight: 500;
}

.sidebar .quota {
  margin: auto 0 0;
  padding: 14px 10px;
  border-top: 1px solid var(--border);
}

.sidebar .quota .title {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quota-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
  color: var(--text-2);
}

.quota-item .val { color: var(--text); font-weight: 500; }

.upgrade-btn {
  width: 100%;
  margin-top: 10px;
  padding: 9px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white;
  border: none;
  font-weight: 500;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.user-card {
  margin-top: 10px;
  padding: 8px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-card .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-4);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
}

.user-card .info { flex: 1; min-width: 0; }
.user-card .info .name { font-size: 13px; font-weight: 500; }
.user-card .info .email { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Main ---------- */
.main {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-0);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .breadcrumb {
  color: var(--text-2);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .breadcrumb .current { color: var(--text); }

.topbar .actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  display: grid;
  place-items: center;
}

.icon-btn:hover { background: var(--bg-2); color: var(--text); }

.content {
  padding: 24px 32px;
  flex: 1;
  overflow-x: auto;
}

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.btn {
  background: var(--accent-bg);
  color: var(--accent-text);
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { opacity: 0.9; }
.btn-secondary {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border-2);
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}

/* ---------- Stats grid (vue d'ensemble) ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

@media (max-width: 1400px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px)  { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-card .head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 12px;
  margin-bottom: 8px;
  text-transform: none;
}

.stat-card .head .ico {
  width: 14px; height: 14px;
}

.stat-card .value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.stat-card .delta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-3);
}

.stat-card.accent-blue   .head .ico { color: var(--blue); }
.stat-card.accent-green  .head .ico { color: var(--green); }
.stat-card.accent-orange .head .ico { color: var(--orange); }
.stat-card.accent-purple .head .ico { color: var(--purple); }
.stat-card.accent-red    .head .ico { color: var(--red); }
.stat-card.accent-yellow .head .ico { color: var(--yellow); }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search-input {
  flex: 0 0 320px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 32px;
  color: var(--text);
  font-size: 13px;
  position: relative;
}

.search-wrapper { position: relative; }
.search-wrapper svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }

.toolbar select {
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
}

.toolbar .right { margin-left: auto; display: flex; gap: 8px; }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 500;
  color: var(--text-3);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th .sort {
  display: inline-flex;
  margin-left: 4px;
  color: var(--text-3);
  opacity: 0.5;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-2); }

/* Site row ----- */
.site-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
}

.site-thumb {
  width: 48px;
  height: 32px;
  background: var(--bg-3);
  border-radius: 4px;
  border: 1px solid var(--border-2);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--text-3);
  background-size: cover;
  background-position: center;
}

.site-info .name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.site-info .name .wp-icon {
  width: 14px;
  height: 14px;
  background: #21759B;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-size: 9px;
  font-weight: 700;
}

.site-info .actions-mini {
  display: flex;
  gap: 4px;
}

.site-info .actions-mini button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px;
  color: var(--text-3);
  display: grid;
  place-items: center;
}
.site-info .actions-mini button:hover { color: var(--text); border-color: var(--border-2); }

/* Metrics cells ----- */
.metric-tag {
  display: inline-block;
  min-width: 28px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.metric-green  { background: var(--green-bg);  color: var(--green); }
.metric-orange { background: var(--orange-bg); color: var(--orange); }
.metric-red    { background: var(--red-bg);    color: var(--red); }
.metric-blue   { background: var(--blue-bg);   color: var(--blue); }
.metric-purple { background: var(--purple-bg); color: var(--purple); }
.metric-yellow { background: var(--yellow-bg); color: var(--yellow); }
.metric-muted  { background: var(--bg-3);      color: var(--text-3); }

.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.score-easy   { background: var(--green-bg);  color: var(--green); }
.score-med    { background: var(--yellow-bg); color: var(--yellow); }
.score-hard   { background: var(--orange-bg); color: var(--orange); }
.score-vhard  { background: var(--red-bg);    color: var(--red); }

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-published { background: var(--green-bg); color: var(--green); }
.status-draft     { background: var(--bg-3);     color: var(--text-2); }
.status-failed    { background: var(--red-bg);   color: var(--red); }
.status-skipped   { background: var(--orange-bg); color: var(--orange); }
.status-analyzed  { background: var(--blue-bg);  color: var(--blue); }
.status-generated { background: var(--purple-bg); color: var(--purple); }
.status-pending   { background: var(--bg-3);     color: var(--text-2); }
.status-go        { background: var(--green-bg); color: var(--green); }
.status-skip      { background: var(--orange-bg); color: var(--orange); }
.status-review    { background: var(--bg-3);     color: var(--text-2); }

.muted { color: var(--text-3); }
.success { color: var(--green); }
.warn { color: var(--orange); }
.error { color: var(--red); }

/* ---------- Sparkline placeholder ---------- */
.sparkline {
  display: inline-block;
  width: 70px;
  height: 22px;
  vertical-align: middle;
}

/* ---------- Forms ---------- */
.form-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 720px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }

label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 6px;
}

input[type=text], input[type=url], input[type=password], input[type=email], input[type=number], select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
textarea { font-family: ui-monospace, SFMono-Regular, monospace; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--text-3);
  background: var(--bg-3);
}

/* ---------- Article preview ---------- */
.article-preview {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  max-width: 900px;
}

.article-preview h1 { font-size: 28px; margin: 16px 0 10px; }
.article-preview h2 { font-size: 20px; margin: 22px 0 10px; }
.article-preview h3 { font-size: 16px; margin: 18px 0 8px; }
.article-preview p { margin: 0 0 12px; color: var(--text-2); }
.article-preview ul { margin: 0 0 14px 22px; color: var(--text-2); }
.article-preview a { color: var(--blue); text-decoration: underline; }
.article-preview pre { background: var(--bg-3); padding: 14px; border-radius: 6px; overflow-x: auto; font-size: 12px; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.kv {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.kv .k { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.kv .v { font-size: 14px; font-weight: 500; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty .ico { font-size: 32px; margin-bottom: 12px; opacity: 0.6; }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 16px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs a {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--text); }
.tabs a:hover:not(.active) { color: var(--text); }

/* ---------- Auth screen ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg-0);
}
.auth-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  padding: 28px;
  border-radius: var(--radius);
  width: 360px;
}
.auth-card h2 { margin-bottom: 6px; font-size: 18px; }
.auth-card p { color: var(--text-3); font-size: 13px; margin-bottom: 16px; }
