/* ============================================================
   back.kv — Стили ЛК (на основе CRM-KV Design System)
   ============================================================ */
:root {
    /* Brand */
    --primary: #c8102e;
    --primary-dark: #a00d25;
    --primary-light: rgba(200,16,46,0.08);
    /* Navy */
    --navy: #152733;
    --navy-light: #1e3a4f;
    /* Surface */
    --bg: #f4f5f7;
    --bg-card: #ffffff;
    /* Border */
    --border: #e1e4e8;
    --border-focus: var(--primary);
    /* Text */
    --text: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    /* Status */
    --success: #059669;
    --success-bg: #ecfdf5;
    --error: #dc2626;
    --error-bg: #fef2f2;
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    /* Misc */
    --radius: 6px;
    --radius-xl: 14px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.app-header {
    background: var(--navy);
    color: #fff;
    height: 52px;
    padding: 0 24px;
    flex-shrink: 0;
}
.app-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}
.app-header__logo {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.3px;
}
.app-header__auth {
    display: flex;
    align-items: center;
    gap: 12px;
}
.app-header__user {
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 500;
}

/* ===== Auth buttons ===== */
.btn-auth {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background .15s;
}
.btn-auth--logout {
    color: #fff;
    background: var(--primary);
}
.btn-auth--logout:hover {
    background: var(--primary-dark);
}

/* ===== Footer ===== */
.app-footer {
    margin-top: auto;
    background: var(--navy);
    color: #94a3b8;
    padding: 16px 24px;
    font-size: 13px;
    text-align: center;
    flex-shrink: 0;
}

/* ===== Main ===== */
.main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
}

/* ===== Alerts ===== */
.alerts { margin-bottom: 20px; }
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 8px;
    line-height: 1.4;
}
.alert--error { background: var(--error-bg); color: var(--error); }
.alert--success { background: var(--success-bg); color: var(--success); }

/* ===== Login page ===== */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 120px);
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 32px 36px;
    box-shadow: var(--shadow-md);
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo__icon {
    width: 48px;
    height: 48px;
    background: var(--navy);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.login-logo__icon svg {
    width: 26px;
    height: 26px;
}
.login-logo__title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}
.login-logo__sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.login-field {
    margin-bottom: 16px;
}
.login-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}
.login-field input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color .2s, box-shadow .2s;
}
.login-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(200,16,46,0.1);
}
.login-field input::placeholder { color: var(--text-muted); }
.login-btn {
    width: 100%;
    padding: 11px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background .2s;
    margin-top: 8px;
}
.login-btn:hover { background: var(--primary-dark); }
.login-btn:disabled {
    background: #b0b0b0;
    color: #fff;
    cursor: not-allowed;
}
.login-btn:disabled:hover { background: #b0b0b0; }
.login-flash {
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.4;
}
.login-flash--error { background: var(--error-bg); color: var(--error); }
.login-flash--success { background: var(--success-bg); color: var(--success); }

.login-divider {
    display: flex;
    align-items: center;
    margin: 18px 0 10px;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.login-divider::before, .login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.login-divider span { padding: 0 10px; }

.login-btn--ecp {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}
.login-btn--ecp:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }
.login-btn--ecp:disabled { background: #f1f5f9; color: var(--text-muted); border-color: var(--border); }

/* ===== Cert picker (ЭЦП) ===== */
.cert-picker {
    position: fixed; inset: 0; z-index: 1000;
    align-items: center; justify-content: center;
}
.cert-picker__backdrop {
    position: absolute; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
}
.cert-picker__dialog {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.cert-picker__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.cert-picker__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
.cert-picker__close {
    background: transparent;
    border: 0;
    font-size: 24px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
}
.cert-picker__close:hover { color: var(--text); }
.cert-picker__list {
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cert-picker__hint {
    padding: 10px 20px 14px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.cert-card {
    display: block;
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    font-family: var(--font);
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.cert-card:hover {
    border-color: var(--primary);
    background: var(--bg);
    box-shadow: 0 2px 8px rgba(200,16,46,0.08);
}
.cert-card:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}
.cert-card__fio {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.cert-card__post {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.cert-card__org {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.cert-card__meta {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: .02em;
}
.cert-card__valid--warn { color: #b45309; font-weight: 600; }

/* ===== Dashboard ===== */
.dashboard h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}
.dashboard__subtitle {
    color: var(--text-secondary);
    font-size: 15px;
}

/* ===== Registration ===== */
.reg-required { color: var(--primary); font-weight: 600; }
.reg-hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}
.reg-captcha {
    background: var(--bg);
    padding: 14px;
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}
.reg-captcha label { font-weight: 600; font-size: 14px; }
.reg-login-link {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}
.reg-login-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.reg-login-link a:hover { text-decoration: underline; }

/* ===== Email verification ===== */
.email-verify-row {
    display: flex;
    gap: 8px;
}
.email-verify-row input {
    flex: 1;
    min-width: 0;
}
.btn-send-code {
    flex-shrink: 0;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, opacity .15s;
}
.btn-send-code:hover { background: var(--primary-dark); }
.btn-send-code:disabled {
    background: #b0b0b0;
    color: #fff;
    opacity: 1;
    cursor: not-allowed;
}
.btn-send-code:disabled:hover { background: #b0b0b0; }
.reg-hint--ok { color: var(--success); font-weight: 500; }

/* ===== Responsive — iPhone / Mobile ===== */
@media (max-width: 768px) {
    .app-header { padding: 0 12px; height: 48px; }
    .app-header__logo { font-size: 13px; }
    .app-header__user { display: none; }
    .app-header__auth { gap: 6px; }
    .app-header__auth .btn-auth { padding: 5px 10px; font-size: 11px; }
    .app-header__auth a[href*="switch"] { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; line-height: 28px; }
    .main { padding: 12px 10px; }
    .app-footer { padding: 12px 16px; font-size: 11px; }
}

@media (max-width: 480px) {
    .login-card { padding: 24px 18px; margin: 12px; }
    .login-logo__title { font-size: 17px; }
    .login-field input { font-size: 16px; /* prevents iOS zoom on focus */ }
    .app-header { padding: 0 10px; }
    .app-header__logo { font-size: 12px; letter-spacing: -0.5px; }
    .main { padding: 8px 8px; }

    /* Email verify row */
    .email-verify-row { flex-direction: column; }
    .btn-send-code { width: 100%; }
}
