:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --line: #e4e7ec;
  --text: #101828;
  --muted: #667085;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --success: #12b76a;
  --success-soft: #ecfdf3;
  --warning: #f79009;
  --warning-soft: #fffaeb;
  --danger: #f04438;
  --danger-soft: #fef3f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.error { color: var(--danger); white-space: pre-wrap; margin: 0; }
.eyebrow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* Layout */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 20px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 0 6px; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-size: 13px;
}
.site-switch { display: grid; gap: 6px; padding: 0 6px; }
.nav { display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 8px; background: none;
  color: var(--muted); font: inherit; font-weight: 500; cursor: pointer; text-align: left;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--line); }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: 13px;
}
.user-meta { min-width: 0; display: grid; }
.user-meta strong, .user-meta small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--muted); }

.main { min-width: 0; padding: 28px 36px 56px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.topbar h1 { font-size: 24px; font-weight: 700; }
.topbar p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { display: grid; gap: 16px; max-width: 1200px; }

/* Controls */
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; padding: 0; flex: none; accent-color: var(--primary); }
.field { display: grid; gap: 6px; font-weight: 500; font-size: 13px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check span { display: grid; gap: 2px; }
.check small { color: var(--muted); }
.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border-radius: 8px; padding: 9px 14px;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4338ca; }
.cover-wrap { margin: 0; }
.cover { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; display: block; background: var(--surface-2, #f4f4f5); }
.cover-wrap figcaption { margin-top: 6px; color: var(--muted); font-size: 11px; }
.btn-success { background: var(--success); color: #fff; text-decoration: none; }
.btn-success:hover:not(:disabled) { background: #0e9f5b; }
a.btn { text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #fecdca; }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-head h2 { font-size: 16px; font-weight: 600; }
.card-head p { margin: 4px 0 0; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 18px 20px; }
.kpi .label { color: var(--muted); font-weight: 500; font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.kpi .delta { font-size: 12px; font-weight: 600; margin-top: 4px; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.success, .badge.published, .badge.connected, .badge.ready, .badge.easy { background: var(--success-soft); color: #027a48; }
.badge.info, .badge.scheduled, .badge.running, .badge.lectoring { background: var(--primary-soft); color: var(--primary); }
.badge.warning, .badge.review, .badge.draft, .badge.pending, .badge.medium { background: var(--warning-soft); color: #b54708; }
.badge.danger, .badge.error, .badge.failed, .badge.hard { background: var(--danger-soft); color: #b42318; }

/* Lists & tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table .title { font-weight: 600; }
.table .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat-mini { font-size: 12px; line-height: 1.45; white-space: nowrap; }
.stat-mini span { color: var(--muted); font-weight: 600; margin-right: 6px; }
.reach-block + .reach-block { margin-top: 12px; }
.reach-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.table .right { text-align: right; }
.table-wrap { overflow-x: auto; margin: -8px -8px; }
.table th.check, .table td.check { display: table-cell; width: 36px; padding-right: 0; vertical-align: middle; }
.bulkbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px; border-radius: 10px;
  background: var(--primary-soft); border: 1px solid #c7d2fe; color: var(--primary);
}
.plugin-box { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.plugin-box p { margin: 4px 0 0; max-width: 620px; }
.plugin-box strong { color: var(--text); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-x: auto; }
.tab {
  border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted);
  padding: 10px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h3 { color: var(--text); font-size: 15px; margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

/* Home */
.steps { display: grid; gap: 8px; }
.step { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.step .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; }
.step.done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.step.done .dot svg { width: 12px; height: 12px; }
.step .body { flex: 1; min-width: 0; }
.step .body small { color: var(--muted); display: block; }
.step.done strong { color: var(--muted); text-decoration: line-through; }
.stat-line { display: flex; flex-wrap: wrap; gap: 20px; }
.stat-line div { display: grid; gap: 2px; }
.stat-line strong { font-size: 18px; }
.stat-line span { color: var(--muted); font-size: 12px; }

/* Integrations */
.integration { display: grid; gap: 14px; }
.integration-head { display: flex; align-items: center; gap: 12px; }
.integration-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; font-weight: 700; color: #fff; }
.integration-head .body { flex: 1; min-width: 0; }
.integration-head h3 { font-size: 15px; }
.integration-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.property-list { display: grid; gap: 8px; }
.property {
  display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s;
}
.property:hover { border-color: #c7d2fe; }
.property.selected { border-color: var(--primary); background: var(--primary-soft); }
.property input { margin: 0; }
.property .body { flex: 1; min-width: 0; }
.property code { font-size: 13px; overflow-wrap: anywhere; }
.property .badge { flex: none; }
.property small { color: var(--muted); display: block; margin-top: 2px; }
.callout { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.callout.warning { background: var(--warning-soft); color: #93370d; }
.callout.danger { background: var(--danger-soft); color: #b42318; }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.cal-head h2 { font-size: 16px; text-transform: capitalize; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cal-dow { background: var(--surface-2); padding: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-day { background: var(--surface); min-height: 108px; padding: 8px; display: grid; align-content: start; gap: 4px; }
.cal-day.out { background: #fafbfc; }
.cal-day.today .num { background: var(--primary); color: #fff; }
.cal-day .num { font-size: 12px; font-weight: 600; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.cal-item {
  font-size: 12px; padding: 3px 6px; border-radius: 5px; cursor: pointer;
  background: var(--primary-soft); color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-item.published { background: var(--success-soft); color: #027a48; }
.cal-item.draft, .cal-item.review { background: var(--warning-soft); color: #b54708; }

/* Article editor */
.editor-title { font-size: 20px; font-weight: 700; border: 0; padding: 4px 0; box-shadow: none !important; }
.preview { line-height: 1.7; color: #344054; max-height: 70vh; overflow: auto; }
.preview h1, .preview h2, .preview h3 { margin: 1.1em 0 .4em; line-height: 1.3; }
.preview p { margin: 0 0 .8em; }
.preview ol, .preview ul { margin: 0 0 .8em; padding-left: 1.3em; }
.preview li { margin: .25em 0; }
.preview a { color: var(--primary); }
.score { display: flex; align-items: center; gap: 14px; }
.score-ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--c, var(--primary)) calc(var(--p) * 1%), var(--surface-2) 0); }
.score-ring span { width: 50px; height: 50px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 16px; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.checks li { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.checks .great { color: var(--success); }
.checks .ok { color: var(--warning); }
.checks .poor { color: var(--danger); }
.faq-item { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.section-title { font-size: 13px; font-weight: 600; margin: 18px 0 8px; }
pre.code { background: var(--surface-2); border-radius: 8px; padding: 10px; font-size: 12px; white-space: pre-wrap; word-break: break-all; margin: 0; max-height: 220px; overflow: auto; }

/* Chart */
.chart { width: 100%; height: 180px; display: block; }
.chart .area { fill: var(--primary-soft); }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2; }
.legend { display: flex; gap: 18px; color: var(--muted); font-size: 12px; }

/* Login */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(800px 400px at 50% -10%, #e0e7ff, transparent), var(--bg); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 32px rgba(16,24,40,.08); padding: 32px; display: grid; gap: 14px; }
.login-card .logo { padding: 0; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: -8px 0 4px; }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--text); color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(16,24,40,.2); font-weight: 500; max-width: 380px; white-space: pre-line; animation: toast-in .2s ease-out; }
.toast.error { background: var(--danger); }
.toast.success { background: #027a48; }
.toast.warning { background: #b54708; }

.style-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 6px; }
@media (max-width: 720px) { .style-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.style-card { display: grid; gap: 2px; text-align: left; padding: 0 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; cursor: pointer; font: inherit; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.style-card:hover { border-color: #c7c9f5; }
.style-card.active { border: 2px solid var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); padding-bottom: 11px; }
.style-card strong { padding: 10px 12px 0; font-size: 14px; }
.style-card small { padding: 0 12px; color: var(--muted); font-size: 12px; font-weight: 400; }
.style-card.active strong::after { content: " ✓"; color: var(--success); }
.style-swatch { display: block; height: 88px; position: relative; }
.style-swatch::after { content: ""; position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; transform: translate(-50%, -50%); }
.style-minimal { background: #eef0fb; }
.style-minimal::after { background: #7c83e8; border-radius: 8px; }
.style-photo { background: linear-gradient(160deg, #9fb7a0 0%, #587a5c 55%, #2f4533 100%); }
.style-photo::after { background: radial-gradient(circle at 35% 35%, #f3e3cf, #b8906b); border-radius: 50%; box-shadow: 0 6px 14px rgba(0,0,0,.35); }
.style-watercolor { background: radial-gradient(circle at 30% 40%, #f6c9d6 0, transparent 45%), radial-gradient(circle at 70% 60%, #b9d3f2 0, transparent 50%), #f7f3ee; }
.style-watercolor::after { background: rgba(126, 108, 196, .55); border-radius: 46% 54% 40% 60%; filter: blur(1px); }
.style-3d { background: linear-gradient(180deg, #d7e6fb, #b9cff3); }
.style-3d::after { background: radial-gradient(circle at 35% 30%, #c4b5fd, #6d28d9); border-radius: 12px; box-shadow: 0 10px 18px rgba(76, 29, 149, .35); }
.style-vintage { background: repeating-linear-gradient(45deg, #e9c98f 0 6px, #e2bf82 6px 12px); }
.style-vintage::after { background: #c46a2a; border-radius: 50%; border: 3px solid #5b3a1e; }
.style-abstract { background: conic-gradient(from 200deg, #f43f5e, #f59e0b, #22c55e, #3b82f6, #a855f7, #f43f5e); }
.style-abstract::after { background: rgba(255,255,255,.85); border-radius: 50% 0 50% 0; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px 0; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 20px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .cal-day { min-height: 72px; }
  .topbar { flex-direction: column; }
}
