:root {
  --sidebar-bg: #171426;
  --sidebar-ink: #c9c4dd;
  --accent: #5b4cf5;
  --accent-2: #7c6cfb;
  --accent-soft: #efeafe;
  --accent-ink: #ffffff;
  --bg: #f5f5f8;
  --panel: #ffffff;
  --ink: #191726;
  --muted: #8b879c;
  --border: #ececf2;
  --danger: #e5484d;
  --green: #1ba672;
  --amber: #e59a00;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--accent); text-decoration: none; }

/* ================= shell: sidebar + topbar ================= */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 224px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-ink);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; font-size: 14px; flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 13.5px; color: #fff; line-height: 1.2; }
.brand-sub { font-size: 10.5px; color: #8d87a8; }
.nav-group-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #726c94; padding: 14px 10px 6px; }
.sidebar-nav a, .sidebar-nav .nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 13px;
  font-weight: 500; margin-bottom: 2px; color: var(--sidebar-ink); cursor: pointer;
}
.sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.sidebar-nav a:hover { background: #242038; color: #fff; }
.sidebar-nav a.active { background: var(--accent); color: #fff; }
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-foot { margin-top: auto; border-top: 1px solid #2a2640; padding-top: 12px; }
.user-pill { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #ffb56b, #ff7a7a);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #fff; flex-shrink: 0;
}
.user-name { font-size: 12px; font-weight: 600; color: #fff; }
.user-role-btn { background: none; border: none; color: #8d87a8; font-size: 10.5px; cursor: pointer; padding: 0; font-family: inherit; }
.user-role-btn:hover { color: #fff; }

.main { flex: 1; min-width: 0; }
.topbar {
  height: 60px; flex-shrink: 0; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 5;
}
.topbar .who { color: var(--muted); font-size: 13px; }
.content { max-width: 1120px; margin: 0 auto; padding: 24px 24px 60px; }

/* legacy .wrap kept as an alias so any page not yet using .content still gets sane spacing */
.wrap { max-width: 1080px; margin: 0 auto; padding: 24px; }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 16px;
}
h1 { font-size: 21px; margin: 0 0 4px; font-weight: 800; }
h2 { font-size: 15px; margin: 0 0 14px; font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; }
label { display: block; font-size: 12.5px; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=email], input[type=url], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 13.5px; font-family: inherit; background: var(--bg); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: none;
  padding: 10px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 700;
}
button:hover, .btn:hover { background: #4a3de0; }
button.secondary, .btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--border); }
button.secondary:hover, .btn.secondary:hover { background: var(--bg); }
button.danger, .btn.danger { background: #fff; color: var(--danger); border: 1px solid #f3c6c6; }
button.danger:hover, .btn.danger:hover { background: #fdeaea; }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; background: #fdeaea; border: 1px solid #f3c6c6; border-radius: 8px; padding: 10px 12px; }
.success { color: var(--green); font-size: 13px; margin-top: 8px; background: #e6f8f1; border: 1px solid #b9e9d3; border-radius: 8px; padding: 10px 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; }
.badge.draft { background: #eef0f4; color: var(--muted); }
.badge.published { background: #e6f8f1; color: var(--green); }
.badge.scheduled { background: #fff3de; color: var(--amber); }

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { width: 360px; }
.checkbox-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 9px; padding: 10px; }
.checkbox-list label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; font-size: 13.5px; }
#siteSelectCount { font-weight: 600; }
#siteSelectCount.all-selected { color: #1a9e5c; }
.toolbar { display: flex; gap: 4px; border: 1px solid var(--border); border-bottom: none; border-radius: 9px 9px 0 0; padding: 6px; background: var(--bg); flex-wrap: wrap; }
.toolbar button { background: #fff; color: var(--ink); border: 1px solid var(--border); padding: 5px 10px; font-size: 12.5px; font-weight: 500; }
#editorBody {
  min-height: 360px; border: 1px solid var(--border); border-radius: 0 0 9px 9px;
  padding: 14px; font-size: 15px; line-height: 1.6; background: #fff;
}
#editorBody img { max-width: 100%; border-radius: 6px; }
#editorBody:focus { outline: none; }
.headline-preview img { max-width: 240px; border-radius: 8px; display: block; margin-top: 8px; }
.two-col { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-box .num { font-size: 25px; font-weight: 800; line-height: 1.1; }
.stat-box .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; margin-top: 4px; }

/* ---- Recent activity (grouped) + bulk edit ---- */
.activity-row { padding: 14px 0; border-top: 1px solid var(--border); }
.activity-row:first-child { border-top: none; padding-top: 0; }
.activity-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.activity-row .post-title-line { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; }
.activity-row .site-chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.activity-row .site-chip { font-size: 10.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent); padding: 3px 9px; border-radius: 20px; }
.activity-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.activity-actions button, .activity-actions a { white-space: nowrap; font-size: 12px; padding: 8px 12px; border-radius: 8px; text-decoration: none; display: inline-flex; align-items: center; cursor: pointer; }
.activity-actions button.edit, .activity-actions a.edit { background: #fff; color: var(--accent); border: 1px solid #d8d3fb; }
.activity-actions button.edit:hover, .activity-actions a.edit:hover { background: var(--accent-soft); }
.activity-actions button.ghost, .activity-actions a.ghost { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.activity-actions button.ghost:hover, .activity-actions a.ghost:hover { background: var(--bg); }

.bulk-edit-panel { display: none; margin-top: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.bulk-edit-panel.open { display: block; }
.bulk-edit-panel .note { font-size: 12px; color: #6b5a15; background: #fff8e8; border: 1px solid #f4e3ad; border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; }
.bulk-edit-panel textarea { min-height: 120px; }
.bulk-edit-panel .save-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.bulk-edit-panel .save-confirm { display: none; font-size: 12.5px; color: var(--green); font-weight: 600; }
.bulk-edit-panel .save-confirm.show { display: block; }

.field-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.char-count { color: var(--muted); font-size: 12px; text-align: right; margin-top: 2px; }
.char-count.over { color: var(--danger); }

.snippet-preview { border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; margin-top: 8px; background: #fff; }
.snippet-preview .snippet-title { color: #1a0dab; font-size: 17px; line-height: 1.3; margin: 0 0 2px; }
.snippet-preview .snippet-url { color: #006621; font-size: 13px; margin: 0 0 4px; }
.snippet-preview .snippet-desc { color: #545454; font-size: 13px; margin: 0; }

.cat-picker { position: relative; }
.cat-dropdown { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(20,20,40,.10); max-height: 220px; overflow-y: auto; z-index: 40; }
.cat-dropdown .cat-option { padding: 9px 12px; font-size: 13.5px; cursor: pointer; }
.cat-dropdown .cat-option:hover, .cat-dropdown .cat-option.active { background: var(--accent-soft); color: var(--accent); }
.cat-dropdown .cat-empty { padding: 9px 12px; font-size: 13px; color: var(--muted); }

.tag-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 4px 10px; font-size: 13px; }
.tag-pill button { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.media-item { position: relative; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: #fff; }
.media-item img { width: 100%; height: 110px; object-fit: cover; display: block; }
.media-item .media-actions { display: flex; justify-content: space-between; padding: 6px 8px; font-size: 12px; }
.media-item .media-actions button { padding: 3px 8px; font-size: 12px; }

.inline-toggle { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.inline-toggle input { width: auto; }

.cat-row { display: grid; grid-template-columns: 60px 1fr 90px 130px 80px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cat-row input[type=number] { width: 60px; padding: 6px; }
.cat-row.header-row { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--border); }

select[multiple] { min-height: 90px; }

/* ================= hero + site cards (dashboard) ================= */
.hero-banner {
  background: linear-gradient(120deg, #5b4cf5 0%, #8b6cf7 55%, #a97bf3 100%); border-radius: 16px;
  padding: 28px 30px; color: #fff; display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; overflow: hidden; position: relative;
}
.hero-banner::after { content: ""; position: absolute; right: -40px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.1); }
.hero-banner h1 { margin: 0 0 6px; font-size: 21px; font-weight: 800; color: #fff; }
.hero-banner p { margin: 0; font-size: 13px; color: #eae6ff; max-width: 460px; }

.sites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.site-card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; position: relative; overflow: hidden; background: #fff; }
.site-card .stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.site-card h3 { margin: 0 0 3px; font-size: 14px; }
.site-card p.muted { margin: 0 0 12px; font-size: 12px; }
.site-card .site-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.site-card .site-row b { color: var(--ink); font-size: 13px; }
.manage-link { display: inline-block; margin-top: 12px; font-size: 12px; font-weight: 700; color: var(--accent); }
.site-card .card-actions { display: flex; gap: 8px; margin-top: 12px; }
.site-card .card-actions .btn, .site-card .card-actions button { font-size: 12px; padding: 7px 12px; }

/* ================= create/customize site: theme gallery + live preview ================= */
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 21px; font-weight: 800; margin: 0 0 4px; }
.page-head p { margin: 0; font-size: 13px; color: var(--muted); }
.layout { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 700px) { .theme-grid { grid-template-columns: repeat(2, 1fr); } }
.theme-card { border: 2px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; position: relative; }
.theme-card:hover { border-color: #cfcbe8; }
.theme-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.theme-swatch { height: 52px; border-radius: 8px; margin-bottom: 9px; }
.theme-card h4 { font-size: 12.5px; margin: 0 0 2px; }
.theme-card p { font-size: 10.5px; color: var(--muted); margin: 0; }
.theme-card .check {
  position: absolute; top: 8px; right: 8px; width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 11px; display: none; align-items: center; justify-content: center;
}
.theme-card.selected .check { display: flex; }

.row-inline { display: flex; gap: 10px; align-items: center; }
.color-swatch-input { width: 52px; height: 38px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; }

.preview-panel { position: sticky; top: 76px; }
.browser-mock { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.browser-bar { background: #eceef2; padding: 9px 12px; display: flex; align-items: center; gap: 6px; }
.browser-dot { width: 8px; height: 8px; border-radius: 50%; background: #cfd2da; }
.browser-url { flex: 1; background: #fff; border-radius: 6px; padding: 4px 10px; font-size: 10.5px; color: var(--muted); margin-left: 6px; }
.mock-header { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; color: #fff; transition: background .2s; }
.mock-brand { display: flex; align-items: center; gap: 8px; }
.mock-logo { width: 26px; height: 26px; border-radius: 6px; background: rgba(255,255,255,.25); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; overflow: hidden; }
.mock-logo img { width: 100%; height: 100%; object-fit: cover; }
.mock-name { font-size: 13px; font-weight: 700; }
.mock-nav { display: flex; gap: 10px; font-size: 10.5px; }
.mock-body { padding: 16px; }
.mock-hero { height: 70px; background: #eceef2; border-radius: 8px; margin-bottom: 10px; }
.mock-line { height: 8px; background: #eceef2; border-radius: 4px; margin-bottom: 6px; }
.mock-line.short { width: 60%; }
.preview-caption { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 10px; }
.preview-card h3 { font-size: 12.5px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.preview-card .kv { display: flex; justify-content: space-between; font-size: 12.5px; padding: 6px 0; border-top: 1px solid var(--border); }
.preview-card .kv:first-of-type { border-top: none; }

.danger-zone { border: 1px solid #f3c6c6; background: #fff8f8; }
.danger-zone h2 { color: var(--danger); }
