:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #dfe2e8;
    --text: #1b1f27;
    --muted: #667085;
    --accent: #3451d1;
    --accent-hover: #2a43b3;
    --accent-text: #ffffff;
    --danger-bg: #fdecec;
    --danger-text: #b42318;
    --focus: rgba(52, 81, 209, .35);
    --radius: 10px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1115;
        --surface: #171a21;
        --border: #2a2f3a;
        --text: #e7e9ee;
        --muted: #98a0b0;
        --accent: #6b83f2;
        --accent-hover: #8496f5;
        --accent-text: #0f1115;
        --danger-bg: #3a1a1a;
        --danger-text: #ff9b91;
        --focus: rgba(107, 131, 242, .4);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .5rem; }
a { color: var(--accent); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); margin: 0; }

/* Шапка */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    color: var(--text);
    font-weight: 650;
    font-size: 1.05rem;
    text-decoration: none;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 700;
    font-size: .95rem;
}

.brand-mark-lg { width: 44px; height: 44px; border-radius: 12px; font-size: 1.3rem; }

.account { display: flex; align-items: center; gap: .75rem; }
.account form { margin: 0; }
.account-name { font-weight: 550; }

.badge {
    padding: .1rem .5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: .75rem;
}

.content { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

/* Вход */
.auth {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1.5rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .06);
}

.auth-head { display: grid; justify-items: center; gap: .35rem; margin-bottom: 1.5rem; text-align: center; }
.auth-head h1 { margin: .5rem 0 0; }

.alert {
    margin-bottom: 1rem;
    padding: .65rem .85rem;
    border-radius: var(--radius);
    background: var(--danger-bg);
    color: var(--danger-text);
    font-size: .925rem;
}

.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field > span:first-child { font-weight: 550; font-size: .9rem; }

.field input {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.field input.input-validation-error { border-color: var(--danger-text); }
.field-error { color: var(--danger-text); font-size: .85rem; }
.field-error:empty { display: none; }

.check { display: flex; align-items: center; gap: .5rem; margin-bottom: 1.25rem; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .55rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); padding: .35rem .8rem; font-weight: 550; }
.btn-ghost:hover { background: var(--bg); }

@media (max-width: 480px) {
    .topbar { padding: .65rem 1rem; }
    .account .badge { display: none; }
    .auth-card { padding: 1.5rem; }
}
