:root {
    --bg: #f4f5f8;
    --surface: #ffffff;
    --ink: #17121a;
    --muted: #77717c;
    --line: #e8e5eb;
    --brand: #e92176;
    --brand-dark: #b90f56;
    --brand-soft: #fff0f6;
    --dark: #17131b;
    --success: #138a59;
    --warning: #b66a07;
    --danger: #c8374d;
    --radius: 18px;
    --shadow: 0 14px 40px rgba(35, 20, 35, .07);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif; font-size: 15px; line-height: 1.55; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; letter-spacing: -.04em; }
h2 { font-size: clamp(28px, 4vw, 44px); line-height: 1.08; letter-spacing: -.045em; }
h3 { margin-bottom: 14px; font-size: 18px; letter-spacing: -.025em; }
small { display: block; color: var(--muted); line-height: 1.4; }
code { padding: 2px 6px; background: #f1edf2; border-radius: 5px; font-size: 13px; }
hr { margin: 20px 0; border: 0; border-top: 1px solid var(--line); }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; display: flex; flex-direction: column; width: 255px; padding: 26px 18px 20px; color: #fff; background: var(--dark); transition: transform .25s ease; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 42px; width: 42px; height: 42px; color: #fff; background: var(--brand); border-radius: 13px; font-weight: 900; font-size: 21px; box-shadow: 0 10px 22px rgba(233, 33, 118, .28); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; }
.brand small { color: #a69da8; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.nav-list { display: flex; flex-direction: column; gap: 6px; }
.nav-list a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: #bcb4bf; border-radius: 12px; font-weight: 650; transition: .2s ease; }
.nav-list a span { display: inline-flex; align-items: center; justify-content: center; width: 22px; font-size: 18px; }
.nav-list a:hover, .nav-list a.active { color: #fff; background: rgba(255,255,255,.08); }
.nav-list a.active { box-shadow: inset 3px 0 0 var(--brand); }
.sidebar-footer { display: flex; flex-direction: column; gap: 14px; margin-top: auto; padding: 18px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-chip .avatar { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 36px; width: 36px; height: 36px; color: var(--brand); background: #fff; border-radius: 50%; font-weight: 800; }
.user-chip strong, .user-chip small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { max-width: 145px; color: #9f96a2; font-size: 11px; }
.text-button { padding: 0; color: #9f96a2; background: none; border: 0; font-size: 12px; }
.text-button:hover { color: #fff; }

.main-area { display: flex; flex-direction: column; width: calc(100% - 255px); min-height: 100vh; margin-left: 255px; }
.topbar { display: flex; align-items: center; gap: 18px; min-height: 94px; padding: 18px 34px; background: rgba(255,255,255,.9); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.topbar > div { min-width: 0; }
.topbar-action { margin-left: auto; }
.menu-button { display: none; padding: 7px 10px; background: #fff; border: 1px solid var(--line); border-radius: 9px; }
.eyebrow { margin-bottom: 4px; color: var(--brand); font-weight: 850; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
.page-content { width: 100%; max-width: 1500px; margin: 0 auto; padding: 30px 34px 50px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 17px; border: 1px solid transparent; border-radius: 11px; font-weight: 750; transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--brand); box-shadow: 0 9px 20px rgba(233,33,118,.2); }
.button-primary:hover { background: var(--brand-dark); }
.button-secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.button-light { color: var(--dark); background: #fff; }
.button-danger-outline { color: var(--danger); background: transparent; border-color: #f1cbd2; }
.button-block { width: 100%; }
.row-link { color: var(--brand); font-weight: 800; white-space: nowrap; }

.alert { margin-bottom: 20px; padding: 13px 16px; border: 1px solid; border-radius: 12px; }
.alert-success { color: #0e6844; background: #effbf6; border-color: #bdebd7; }
.alert-warning { color: #80500a; background: #fff9e8; border-color: #f3dda5; }
.alert-error { color: #9a2437; background: #fff1f3; border-color: #f2c6ce; }

.hero-panel { position: relative; overflow: hidden; display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 24px; padding: 38px; color: #fff; background: var(--dark); border-radius: 22px; box-shadow: var(--shadow); }
.hero-panel::after { position: absolute; right: -70px; bottom: -120px; width: 310px; height: 310px; content: ""; background: radial-gradient(circle, rgba(233,33,118,.65), transparent 68%); }
.hero-panel > * { position: relative; z-index: 1; }
.hero-panel h2 { max-width: 720px; margin: 10px 0 12px; }
.hero-panel p { max-width: 650px; margin-bottom: 0; color: #c3bac6; font-size: 16px; }
.pill { display: inline-flex; padding: 6px 10px; color: #ffd8e9; background: rgba(233,33,118,.15); border: 1px solid rgba(233,33,118,.35); border-radius: 99px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }

.stats-row { display: flex; gap: 16px; margin-bottom: 24px; }
.stat-card { display: flex; flex: 1; flex-direction: column; min-width: 0; padding: 21px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card > span { color: var(--muted); font-size: 12px; font-weight: 750; }
.stat-card strong { margin: 5px 0; font-size: 34px; letter-spacing: -.05em; }
.stat-card.accent { color: #fff; background: var(--brand); border-color: var(--brand); }
.stat-card.accent span, .stat-card.accent small { color: #ffd8e9; }
.content-row, .workspace-row, .settings-row { display: flex; align-items: flex-start; gap: 20px; }
.flex-grow { flex: 1; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel-heading h3 { margin-bottom: 0; }
.panel-heading > a { color: var(--brand); font-size: 13px; font-weight: 800; }
.quick-panel { flex: 0 0 290px; padding: 24px; }
.step-list { display: flex; flex-direction: column; gap: 17px; margin: 20px 0 0; padding: 0; list-style: none; }
.step-list li { display: flex; align-items: center; gap: 12px; }
.step-list li > span { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 32px; width: 32px; height: 32px; color: var(--brand); background: var(--brand-soft); border-radius: 10px; font-weight: 850; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 20px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); background: #fbfafc; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 3px; font-size: 11px; }
.score { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; padding: 5px 8px; border-radius: 9px; font-size: 12px; font-weight: 850; }
.score-good { color: var(--success); background: #eaf8f2; }
.score-low { color: var(--warning); background: #fff5df; }
.status { display: inline-flex; align-items: center; padding: 5px 9px; color: #6f6972; background: #f1eff2; border-radius: 99px; font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.status-active, .status-ready { color: var(--success); background: #eaf8f2; }
.status-error { color: var(--danger); background: #fff0f2; }
.status-research_completed, .status-brief_completed, .status-draft_completed, .status-seo_reviewed, .status-images_completed { color: #7f3a60; background: var(--brand-soft); }

.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-intro { max-width: 750px; margin: 0; color: var(--muted); }
.empty-state { display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 42px 20px; text-align: center; }
.empty-state.large { min-height: 350px; }
.empty-state strong { font-size: 17px; }
.empty-state p { max-width: 460px; margin: 7px 0 18px; color: var(--muted); }
.empty-icon { display: inline-flex; align-items: center; justify-content: center; min-width: 58px; height: 58px; margin-bottom: 15px; padding: 0 12px; color: var(--brand); background: var(--brand-soft); border-radius: 17px; font-size: 24px; font-weight: 900; }
.card-list { display: flex; flex-direction: column; gap: 14px; }
.site-card { display: flex; align-items: center; gap: 18px; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.site-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 54px; width: 54px; height: 54px; color: #fff; background: var(--dark); border-radius: 16px; font-size: 21px; font-weight: 900; }
.site-card-body { flex: 1; min-width: 0; }
.site-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.site-card-heading h3 { margin-bottom: 0; }
.site-card-heading a { color: var(--brand); font-size: 12px; }
.site-card-body > p { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.meta-row span { padding: 4px 8px; color: #6f6972; background: #f3f1f4; border-radius: 7px; font-size: 10px; font-weight: 700; }
.card-actions { display: flex; gap: 8px; }

.form-panel { padding: 26px; }
.form-section { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.form-section h3 { margin-bottom: 0; }
.form-stack, .ajax-form { display: flex; flex-direction: column; gap: 18px; }
.form-row { display: flex; align-items: flex-start; gap: 14px; }
label { display: flex; flex-direction: column; gap: 7px; color: #4f4952; font-size: 12px; font-weight: 750; }
.field-grow { flex: 1; min-width: 0; }
input, textarea, select { width: 100%; min-height: 43px; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #ddd8df; border-radius: 10px; outline: none; transition: border .2s ease, box-shadow .2s ease; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(233,33,118,.09); }
.code-editor { color: #29222c; background: #fbfafc; font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; line-height: 1.65; }
.form-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 7px; }

.project-head { display: flex; align-items: center; justify-content: space-between; gap: 25px; margin-bottom: 18px; padding: 21px 24px; color: #fff; background: var(--dark); border-radius: var(--radius); }
.project-head p { margin: 9px 0 0; color: #c6bdc8; }
.project-head .meta-row { margin: 0; }
.project-head .meta-row span { color: #d7ced9; background: rgba(255,255,255,.08); }
.project-score { display: flex; align-items: baseline; gap: 2px; }
.project-score > span { margin-right: 8px; color: #9f96a2; font-size: 10px; font-weight: 800; }
.project-score strong { color: #fff; font-size: 42px; line-height: 1; }
.project-score small { color: #9f96a2; }
.workflow-bar { display: flex; gap: 8px; margin-bottom: 20px; padding: 9px; overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.workflow-step { display: flex; align-items: center; flex: 1; gap: 8px; min-width: 125px; padding: 9px 11px; color: #7e7781; background: transparent; border: 0; border-radius: 10px; }
.workflow-step > span { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 28px; width: 28px; height: 28px; background: #f1eff2; border-radius: 9px; font-size: 11px; font-weight: 900; }
.workflow-step strong { font-size: 11px; white-space: nowrap; }
.workflow-step.current { color: var(--brand); background: var(--brand-soft); }
.workflow-step.current > span { color: #fff; background: var(--brand); }
.workflow-step.done { color: var(--success); }
.workflow-step.done > span { color: #fff; background: var(--success); }
.workspace-main { flex: 1; min-width: 0; }
.workspace-aside { display: flex; flex: 0 0 295px; flex-direction: column; gap: 16px; }
.tabs { display: flex; gap: 4px; margin-bottom: 13px; padding: 5px; overflow-x: auto; background: #eae7ec; border-radius: 12px; }
.tabs button { flex: 1; min-width: max-content; padding: 9px 12px; color: #6d6670; background: transparent; border: 0; border-radius: 8px; font-size: 12px; font-weight: 800; }
.tabs button.active { color: var(--ink); background: #fff; box-shadow: 0 4px 14px rgba(24,17,26,.07); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.sticky-panel, .log-panel { padding: 22px; }
.sticky-panel { position: sticky; top: 18px; }
dl { display: flex; flex-direction: column; gap: 0; margin: 15px 0 0; }
dl div { display: flex; justify-content: space-between; gap: 15px; padding: 10px 0; border-bottom: 1px solid var(--line); }
dt { color: var(--muted); font-size: 11px; }
dd { margin: 0; font-size: 11px; font-weight: 750; text-align: right; overflow-wrap: anywhere; }
.log-panel ul { display: flex; flex-direction: column; gap: 16px; margin: 18px 0 0; padding: 0; list-style: none; }
.log-panel li { display: flex; gap: 10px; }
.log-panel li > span { flex: 0 0 8px; width: 8px; height: 8px; margin-top: 6px; background: var(--success); border-radius: 50%; }
.log-panel li.error > span { background: var(--danger); }
.log-panel li strong { display: block; font-size: 11px; }
.log-panel li small { font-size: 10px; }
.prose-panel, .seo-panel { min-height: 450px; padding: 27px; }
.prose-panel p, .prose-panel li { color: #58515b; }
.info-banner { display: flex; flex-direction: column; gap: 4px; margin-bottom: 25px; padding: 18px; background: var(--brand-soft); border-left: 4px solid var(--brand); border-radius: 11px; }
.info-banner span { color: var(--brand-dark); font-size: 10px; font-weight: 850; text-transform: uppercase; }
.info-banner strong { font-size: 19px; }
.two-columns { display: flex; gap: 30px; }
.two-columns > div { flex: 1; }
.source-list { display: flex; flex-direction: column; gap: 9px; }
.source-list a { padding: 13px; background: #faf9fb; border: 1px solid var(--line); border-radius: 10px; }
.source-list small { margin-top: 3px; }
.outline-list { display: flex; flex-direction: column; gap: 10px; padding: 0; list-style: none; }
.outline-list li { display: flex; align-items: flex-start; gap: 11px; padding: 12px; background: #faf9fb; border: 1px solid var(--line); border-radius: 10px; }
.outline-list li > span { color: var(--brand); font-size: 10px; font-weight: 900; }
.seo-summary { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; }
.score-ring { display: flex; align-items: baseline; justify-content: center; flex: 0 0 86px; width: 86px; height: 86px; padding-top: 26px; color: var(--brand); background: var(--brand-soft); border: 6px solid #ffd2e5; border-radius: 50%; }
.score-ring strong { font-size: 25px; line-height: 1; }
.score-ring small { font-size: 10px; }
.seo-summary h3, .seo-summary p { margin-bottom: 3px; }
.seo-summary p { color: var(--muted); }
.test-list { display: flex; flex-direction: column; gap: 9px; }
.test-list article { display: flex; align-items: center; gap: 12px; padding: 13px; background: #faf9fb; border: 1px solid var(--line); border-radius: 11px; }
.test-list article > span { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 27px; width: 27px; height: 27px; border-radius: 50%; font-weight: 900; }
.test-list article > div { flex: 1; }
.test-list article strong, .test-list article small { display: block; }
.test-list article b { color: var(--muted); font-size: 11px; }
.test-list article.passed > span { color: var(--success); background: #e3f6ee; }
.test-list article.failed > span { color: var(--danger); background: #ffedf0; }
.image-list { display: flex; flex-wrap: wrap; gap: 16px; padding: 20px; }
.image-list article { display: flex; flex: 1 1 280px; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; }
.image-list img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: #eee; }
.image-list article > div { padding: 13px; }
.image-list strong, .image-list small { display: block; }

.settings-row > * { flex: 1; }
.settings-card { max-width: 390px; padding: 26px; }
.connection-state { display: flex; align-items: center; gap: 12px; margin: 20px 0; padding: 14px; border-radius: 11px; }
.connection-state > span { flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; }
.connection-state.connected { background: #eaf8f2; }
.connection-state.connected > span { background: var(--success); box-shadow: 0 0 0 5px rgba(19,138,89,.12); }
.connection-state.disconnected { background: #fff5df; }
.connection-state.disconnected > span { background: var(--warning); box-shadow: 0 0 0 5px rgba(182,106,7,.12); }
.security-note { margin: 18px 0 0; color: var(--muted); font-size: 11px; }

.auth-body { min-height: 100vh; color: #fff; background: var(--dark); }
.auth-shell { display: flex; align-items: center; justify-content: center; gap: clamp(40px, 8vw, 120px); width: min(1150px, calc(100% - 40px)); min-height: 100vh; margin: 0 auto; padding: 50px 0; }
.auth-brand { flex: 1; max-width: 620px; }
.auth-brand .brand-mark { margin-bottom: 28px; }
.auth-brand h1 { margin-bottom: 18px; font-size: clamp(38px, 6vw, 70px); line-height: .98; }
.auth-brand > p:not(.eyebrow) { max-width: 570px; color: #aaa0ad; font-size: 17px; }
.auth-feature-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.auth-feature-row span { padding: 7px 11px; color: #cabfcd; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); border-radius: 99px; font-size: 11px; font-weight: 750; }
.auth-card { display: flex; flex: 0 0 400px; flex-direction: column; gap: 24px; padding: 34px; color: var(--ink); background: #fff; border-radius: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.auth-card h2 { margin-bottom: 5px; font-size: 30px; }
.auth-card p { margin-bottom: 0; color: var(--muted); }
.auth-card .muted { text-align: center; }
.installer-shell { max-width: 960px; }

.toast-container { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; }
.toast { max-width: 380px; padding: 13px 16px; color: #fff; background: var(--dark); border-left: 4px solid var(--brand); border-radius: 10px; box-shadow: 0 16px 40px rgba(0,0,0,.2); animation: toastIn .25s ease; }
.toast.error { border-color: var(--danger); }
.loading-layer { position: fixed; z-index: 90; inset: 0; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(20,15,21,.6); backdrop-filter: blur(4px); }
.loading-layer.active { display: flex; }
.loading-card { display: flex; align-items: center; justify-content: center; flex-direction: column; min-width: 280px; padding: 28px; background: #fff; border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.loading-card small { margin-top: 3px; }
.spinner { width: 34px; height: 34px; margin-bottom: 13px; border: 3px solid #f3d5e2; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1100px) {
    .stats-row { flex-wrap: wrap; }
    .stat-card { flex: 1 1 calc(50% - 10px); }
    .content-row { flex-direction: column; }
    .content-row > * { width: 100%; }
    .quick-panel { flex-basis: auto; }
    .workspace-row { flex-direction: column; }
    .workspace-aside { width: 100%; flex-basis: auto; flex-direction: row; }
    .workspace-aside > * { flex: 1; }
    .sticky-panel { position: static; }
}

@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 20px 0 50px rgba(0,0,0,.25); }
    .main-area { width: 100%; margin-left: 0; }
    .menu-button { display: inline-flex; }
    .topbar { padding: 14px 18px; }
    .topbar-action { display: none; }
    .page-content { padding: 22px 18px 40px; }
    .hero-panel { align-items: flex-start; flex-direction: column; padding: 28px; }
    .site-card { align-items: flex-start; flex-wrap: wrap; }
    .site-card-body { flex-basis: calc(100% - 80px); }
    .card-actions { width: 100%; justify-content: flex-end; }
    .form-row { flex-direction: column; }
    .form-row > label { width: 100%; }
    .settings-row { flex-direction: column; }
    .settings-row > *, .settings-card { width: 100%; max-width: none; }
    .auth-shell { align-items: stretch; flex-direction: column; }
    .auth-brand { padding-top: 20px; }
    .auth-card { flex-basis: auto; width: 100%; }
}

@media (max-width: 560px) {
    h1 { font-size: 21px; }
    .stats-row { flex-direction: column; }
    .stat-card { flex-basis: auto; }
    .page-actions { align-items: flex-start; flex-direction: column; }
    .page-actions .button { width: 100%; }
    .project-head { align-items: flex-start; flex-direction: column; }
    .project-score { align-self: flex-end; }
    .workspace-aside { flex-direction: column; }
    .two-columns { flex-direction: column; gap: 10px; }
    .form-panel, .prose-panel, .seo-panel { padding: 20px; }
    .form-footer { align-items: stretch; flex-direction: column-reverse; }
    .form-footer .button { width: 100%; }
    .site-card-body { flex-basis: 100%; }
    .site-icon { width: 46px; height: 46px; flex-basis: 46px; }
    .auth-card { padding: 25px; }
}

