:root {
    --brand-600: #4f46e5;
    --brand-500: #6366f1;
    --brand-400: #818cf8;
    --violet: #8b5cf6;
    --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --grad-soft: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);

    --ink: #0f172a;
    --body: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-soft: #eef2f7;
    --bg: #f8fafc;
    --card: #ffffff;
    --dark: #0b1020;

    --success-bg: #ecfdf5; --success-fg: #047857;
    --error-bg: #fef2f2;  --error-fg: #b91c1c;
    --warning-bg: #fffbeb; --warning-fg: #b45309;

    --r: 16px;
    --r-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
    --shadow: 0 10px 30px -12px rgba(15,23,42,.18);
    --shadow-lg: 0 30px 60px -20px rgba(79,70,229,.35);
    --container: 1140px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--body);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden; /* страховка от случайного горизонтального скролла на мобильных */
}

h1, h2, h3, h4 { color: var(--ink); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.01em; overflow-wrap: break-word; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-500); }
p { margin: 0 0 1em; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
/* только вертикальные паддинги — иначе на «container section» обнулялись бы боковые 24px */
.section { padding-top: 72px; padding-bottom: 72px; }
.section--alt { background: var(--grad-soft); }
.grad {
    background: var(--grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--grad); color: #fff; font-weight: 600; font-size: 15px;
    padding: 11px 20px; border-radius: var(--r-sm); border: none; cursor: pointer;
    box-shadow: var(--shadow-sm); transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
    white-space: nowrap;
}
.btn:hover { color: #fff; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-lg { padding: 14px 26px; font-size: 16px; border-radius: 12px; }
.btn-sm { padding: 8px 14px; font-size: 14px; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn-ghost:hover { color: var(--brand-600); border-color: var(--brand-400); background: #fff; }
.btn-on-dark { background: #fff; color: var(--brand-600); }
.btn-on-dark:hover { color: var(--brand-600); }

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(255,255,255,.82);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); font-size: 18px; letter-spacing: -.02em; }
.brand:hover { color: var(--ink); }
.brand-mark {
    display: inline-grid; place-items: center; width: 34px; height: 34px;
    border-radius: 10px; background: var(--grad); box-shadow: var(--shadow-sm);
}
.brand-dim { color: var(--muted); font-weight: 700; }
.nav { display: flex; align-items: center; gap: 22px; }
.nav a { color: var(--body); font-weight: 500; }
.nav a:hover { color: var(--brand-600); }
.nav .btn { color: #fff; }
.nav .btn-ghost { color: var(--ink); }
.logout-form { margin: 0; }
.nav-toggle { display: none; flex-direction: column; gap: 5px; width: 42px; height: 38px;
    background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; align-items: center; justify-content: center; }
.nav-toggle span { width: 18px; height: 2px; background: var(--ink); border-radius: 2px; transition: .2s; }

/* ---------- Hero ---------- */
.hero { padding: 84px 0 64px; background:
    radial-gradient(900px 400px at 85% -10%, rgba(139,92,246,.16), transparent 60%),
    radial-gradient(700px 380px at 0% 0%, rgba(99,102,241,.14), transparent 55%); }
.hero-inner { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; }
.badge { display: inline-block; background: #fff; border: 1px solid var(--line); color: var(--brand-600);
    font-weight: 600; font-size: 13px; padding: 6px 12px; border-radius: 999px; box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.hero h1 { font-size: clamp(34px, 5vw, 54px); font-weight: 800; }
.lead { font-size: 18px; color: var(--muted); max-width: 560px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; margin: 28px 0 30px; }
.hero-stats { display: flex; gap: 28px; flex-wrap: wrap; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats strong { color: var(--ink); font-size: 16px; }
.hero-stats span { color: var(--muted); font-size: 13px; }

.hero-visual { display: flex; justify-content: center; }
.mock-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line);
    border-radius: 18px; box-shadow: var(--shadow-lg); padding: 18px; transform: rotate(.5deg); }
.mock-head { display: flex; align-items: center; gap: 6px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); margin-bottom: 12px; }
.mock-head .dot { width: 9px; height: 9px; border-radius: 50%; background: #e2e8f0; }
.mock-title { margin-left: 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.mock-row { display: flex; align-items: center; justify-content: space-between; font-size: 14px; color: var(--ink); padding: 9px 0; border-bottom: 1px dashed var(--line-soft); }
.mock-row--muted { color: var(--muted); }
.pill { background: var(--grad-soft); color: var(--brand-600); font-weight: 600; font-size: 12px; padding: 4px 10px; border-radius: 999px; }
.pill--soft { background: #f1f5f9; color: var(--muted); }
.mock-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; font-size: 15px; }
.mock-foot strong { color: var(--brand-600); font-size: 18px; }

/* ---------- Sections ---------- */
.section-head { text-align: center; max-width: 640px; margin: 0 auto 44px; }
.section-head h2 { font-size: clamp(26px, 3.4vw, 36px); }
.section-head p { color: var(--muted); font-size: 17px; margin: 0; }
.section-head--row { display: flex; align-items: flex-end; justify-content: space-between; text-align: left; max-width: none; gap: 20px; }
.section-head--row p { margin: 0; }

.cards-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }

.feature { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .18s ease; }
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.feature-ico { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--grad-soft); color: var(--brand-600); margin-bottom: 16px; }
.feature-ico svg { width: 24px; height: 24px; }
.feature h3 { font-size: 19px; }
.feature p { color: var(--muted); margin: 0; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.step { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 26px; box-shadow: var(--shadow-sm); }
.step-n { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 700; margin-bottom: 14px; }
.step h4 { font-size: 18px; }
.step p { color: var(--muted); margin: 0; }

/* ---------- Program cards ---------- */
.program-card { display: flex; flex-direction: column; gap: 10px; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r); padding: 22px; box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.program-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand-400); }
.program-card h3 { font-size: 18px; margin: 0; }
.tag { align-self: flex-start; background: var(--grad-soft); color: var(--brand-600); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.program-meta { display: flex; gap: 14px; color: var(--muted); font-size: 14px; margin-top: auto; }

.empty { text-align: center; background: #fff; border: 1px dashed var(--line); border-radius: var(--r); padding: 48px 24px; }
.empty p { color: var(--muted); }

/* ---------- CTA ---------- */
.cta { background: var(--dark); background-image: var(--grad); }
.cta-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 56px; padding-bottom: 56px; flex-wrap: wrap; }
.cta h2 { color: #fff; margin-bottom: 6px; }
.cta p { color: rgba(255,255,255,.85); margin: 0; }

/* ---------- Page content ---------- */
.page-head { margin-bottom: 28px; }
.page-head h1 { font-size: clamp(28px, 4vw, 40px); margin-bottom: 6px; }
.page-head .sub { color: var(--muted); font-size: 17px; }

/* min() — чтобы на узких экранах колонка не была шире контейнера (иначе гориз. скролл) */
.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 20px; }

.breadcrumbs { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--brand-600); }

/* ---------- Program detail ---------- */
.program-hero { background: var(--grad-soft); border: 1px solid var(--line); border-radius: var(--r); padding: 32px; margin-bottom: 28px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.chip { background: #fff; border: 1px solid var(--line); color: var(--body); font-size: 13px; font-weight: 500; padding: 6px 12px; border-radius: 999px; }
.chip strong { color: var(--ink); }

.module { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.module h3 { font-size: 18px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
table.table { width: 100%; border-collapse: collapse; background: #fff; }
table.table th, table.table td { padding: 12px 14px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--line-soft); }
table.table th { background: #f8fafc; color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 12px; letter-spacing: .03em; }
table.table tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: #fbfbfe; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.competences { list-style: none; padding: 0; display: grid; gap: 12px; }
.competences li { background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--brand-500); border-radius: var(--r-sm); padding: 14px 16px; }
.competences .code { color: var(--brand-600); font-weight: 700; }
.cat { color: var(--muted); font-size: 13px; }

/* ---------- Forms / Auth ---------- */
.auth-wrap { min-height: calc(100vh - 68px); display: grid; place-items: center; padding: 48px 24px;
    background: radial-gradient(800px 400px at 50% -10%, rgba(99,102,241,.12), transparent 60%); }
.auth-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 34px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 26px; text-align: center; margin-bottom: 6px; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 24px; }
.auth-alt { text-align: center; color: var(--muted); margin: 18px 0 0; font-size: 14px; }

.form .form-row, .form p { margin: 0 0 16px; }
.form label { display: block; font-weight: 600; color: var(--ink); margin-bottom: 6px; font-size: 14px; }
.form input, .form textarea, .form select {
    width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--r-sm);
    font: inherit; color: var(--ink); background: #fff; transition: border-color .15s, box-shadow .15s;
}
.form input:focus, .form textarea:focus, .form select:focus {
    outline: none; border-color: var(--brand-400); box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form .helptext { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.form .helptext ul { margin: 5px 0 0; padding-left: 18px; }
.form .errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: var(--error-fg); font-size: 13px; }
.form .btn { width: 100%; margin-top: 4px; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.form-actions .btn { width: auto; }
.muted { color: var(--muted); }

/* ---------- Dashboard ---------- */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 26px; }
.dash-head .hi { color: var(--muted); margin: 4px 0 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 30px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow-sm); }
.stat .n { font-size: 30px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 14px; }

.status { display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.status.draft { background: #f1f5f9; color: var(--muted); }
.status.published { background: var(--success-bg); color: var(--success-fg); }
.status.archived { background: var(--warning-bg); color: var(--warning-fg); }
.status.generating { background: #eff6ff; color: #1d4ed8; }

/* ---------- Messages ---------- */
.messages { margin: 18px auto 0; display: grid; gap: 10px; }
.msg { padding: 12px 16px; border-radius: var(--r-sm); font-size: 14px; border: 1px solid transparent; }
.msg.success { background: var(--success-bg); color: var(--success-fg); border-color: #a7f3d0; }
.msg.error { background: var(--error-bg); color: var(--error-fg); border-color: #fecaca; }
.msg.warning { background: var(--warning-bg); color: var(--warning-fg); border-color: #fde68a; }
.msg.info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 32px; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { background: var(--dark); color: #cbd5e1; margin-top: 0; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; padding-top: 56px; padding-bottom: 32px; }
.brand-on-dark, .brand-on-dark:hover { color: #fff; }
.footer-note { color: #94a3b8; max-width: 360px; margin-top: 14px; font-size: 14px; }
.footer-col h4 { color: #fff; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 14px; }
.footer-col a { display: block; color: #94a3b8; padding: 5px 0; font-size: 15px; }
.footer-col a:hover { color: #fff; }
.footer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid rgba(255,255,255,.1); padding-top: 20px; padding-bottom: 20px; font-size: 14px; color: #94a3b8; }
.footer-bottom a { color: #94a3b8; }
.footer-bottom a:hover { color: #fff; }

/* ---------- Quiz / wizard ---------- */
.quiz { max-width: 720px; margin: 0 auto; }
.quiz .badge { margin-bottom: 14px; }
.quiz-form { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 30px; box-shadow: var(--shadow-sm); margin-top: 22px; }
.quiz-progress { height: 6px; background: var(--line-soft); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.quiz-progress span { display: block; height: 100%; width: 33%; background: var(--grad); border-radius: 999px; transition: width .3s ease; }
.quiz-steps-count { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.quiz-step { border: none; padding: 0; margin: 0; }
.quiz-step legend { font-weight: 700; color: var(--ink); font-size: 18px; padding: 0; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.quiz-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; }
.quiz-nav .btn-lg { margin-left: auto; }

/* ---------- Loading overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
    background: rgba(15,23,42,.55); backdrop-filter: blur(3px); }
.overlay-card { background: #fff; border-radius: var(--r); padding: 36px 40px; text-align: center; max-width: 380px; box-shadow: var(--shadow-lg); }
.overlay-card h3 { margin: 18px 0 6px; }
.overlay-card p { color: var(--muted); margin: 0; font-size: 14px; }
.spinner { width: 46px; height: 46px; margin: 0 auto; border: 4px solid var(--line); border-top-color: var(--brand-500); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Program editor ---------- */
.owner-bar { margin: -4px 0 18px; }
.editor-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 24px; box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.editor-card h2 { font-size: 19px; }
.editor-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.editor-card-head h2 { margin: 0; }

.fs-rows { display: grid; gap: 14px; margin: 8px 0 16px; }
.fs-row { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 16px; background: #fcfcfe; }
.fs-fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.fs-field { margin: 0; }
.fs-field--wide { grid-column: 1 / -1; }
.fs-del { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-top: 12px; cursor: pointer; }
.fs-del input { width: auto; }
.fs-remove { margin-top: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 14px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; }
.fs-remove:hover { color: var(--error-fg); border-color: #fecaca; }

.module-list { display: grid; gap: 10px; margin-top: 14px; }
.module-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 16px; }
.module-row-actions { display: flex; gap: 8px; align-items: center; }
.module-row-actions form { margin: 0; }

.btn-danger { background: #fff; color: var(--error-fg); border: 1px solid #fecaca; box-shadow: none; }
.btn-danger:hover { background: var(--error-fg); color: #fff; border-color: var(--error-fg); }
.editor-danger { border-color: #fecaca; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .hero-inner { grid-template-columns: 1fr; }
    .hero-visual { display: none; }
    .cards-3, .steps, .stats { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; gap: 28px; }
    .section-head--row { flex-direction: column; align-items: flex-start; }

    .nav-toggle { display: flex; }
    .nav {
        position: absolute; top: 68px; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 6px;
        background: #fff; border-bottom: 1px solid var(--line); padding: 14px 24px 20px;
        box-shadow: var(--shadow); display: none;
    }
    .nav.open { display: flex; }
    .nav a { padding: 10px 0; }
    .nav .btn, .nav .btn-ghost { width: 100%; }
    .logout-form .btn { width: 100%; }
}

@media (max-width: 560px) {
    .section { padding-top: 52px; padding-bottom: 52px; }
    .hero { padding: 56px 0 40px; }
    .cta-inner { flex-direction: column; align-items: flex-start; }
    .grid-2 { grid-template-columns: 1fr; }
    .quiz-form { padding: 22px; }
    .fs-fields { grid-template-columns: 1fr; }
    /* На узких экранах длинные подписи кнопок переносятся, а не выходят за край */
    .btn { white-space: normal; }
    .hero-actions .btn, .cta-inner .btn { width: 100%; }
}
