/* ==========================================================================
   ZUMO ID — дизайн-код ZUMO
   Палитра снята с фирменной доски ZUMO (знак, панель «Почему Ирбис?», плитки сервисов).
   Подробности и правила — docs/design-code.md. Без сборки: файл подключается напрямую.
   ========================================================================== */

/* Montserrat (SIL OFL 1.1, см. /fonts/Montserrat-OFL.txt): латиница, кириллица, узбекские буквы.
   Файл лежит на своём сервере — браузер не обращается к внешним сервисам шрифтов. */
@font-face {
    font-family: "Montserrat";
    src: url("../fonts/montserrat-var.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    /* --- Бренд --- */
    --zumo-green: #00BC70;          /* зелёный сектор знака, иконки, акценты */
    --zumo-green-strong: #00A862;   /* наведение на зелёную кнопку */
    --zumo-green-ink: #007A48;      /* зелёный текст и ссылки на светлом фоне (контраст ≥ 4.5) */
    --zumo-green-soft: #E3F7EE;     /* фон зелёных плашек */
    --zumo-ink: #0A111C;            /* надпись ZUMO, основной текст, текст на зелёном */
    --zumo-night: #0B101A;          /* тёмная панель */
    --zumo-slate: #1C2838;          /* тёмный сектор знака */
    --zumo-cloud: #EEF0F2;          /* светлый сектор знака */

    /* --- Сервисы (плитки на доске) --- */
    --svc-go: #1DB876;
    --svc-eats: #FDC83A;
    --svc-market: #0164FA;
    --svc-delivery: #FB2A0E;
    --svc-pay: #7443F9;
    --svc-services: #15CDD7;

    /* --- Тема: светлая --- */
    --bg: #F5F7F8;
    --surface: #FFFFFF;
    --surface-2: #F0F2F4;
    --text: var(--zumo-ink);
    --muted: #5B636B;
    --line: #E3E7EB;
    --accent: var(--zumo-green);
    --accent-text: var(--zumo-green-ink);
    --accent-soft: var(--zumo-green-soft);
    --on-accent: var(--zumo-ink);
    --error: #D92D20;
    --error-soft: #FDECEA;
    --ok: #006B3F;
    --ok-soft: var(--zumo-green-soft);
    --focus: rgba(0, 188, 112, .35);

    /* --- Форма --- */
    --radius: 20px;
    --radius-sm: 14px;
    --radius-pill: 999px;
    --shadow: 0 1px 2px rgba(10, 17, 28, .04), 0 10px 30px rgba(10, 17, 28, .06);
    --font: "Montserrat", "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: var(--zumo-night);
        --surface: #121926;
        --surface-2: #19212F;
        --text: #F4F6F8;
        --muted: #9AA3AD;
        --line: #243041;
        --accent-text: #2ED38A;
        --accent-soft: #0F2A20;
        --error: #FF6B5E;
        --error-soft: #3A1B1B;
        --ok: #2ED38A;
        --ok-soft: #0F2A20;
        --zumo-cloud: #E9ECEF;
        --shadow: none;
        color-scheme: dark;
    }
}

/* ==========================================================================
   Основа
   ========================================================================== */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 var(--font);
}

h1, h2, h3 { letter-spacing: -.02em; }

h1 { font-size: 28px; line-height: 1.2; font-weight: 800; margin: 0 0 8px; }

.muted { color: var(--muted); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; letter-spacing: .02em; }

.small { font-size: 14px; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ==========================================================================
   Шапка и подвал
   ========================================================================== */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    max-width: 1040px;
    width: 100%;
    margin: 0 auto;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
}

.brand-logo { width: 34px; height: 34px; flex: none; }

.brand-name { font-size: 20px; font-weight: 900; letter-spacing: .01em; }

.brand-name b { color: var(--accent); font-weight: 900; }

.lang select {
    appearance: none;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-pill);
    padding: 7px 16px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.footer {
    text-align: center;
    padding: 20px 16px 28px;
    font-size: 13px;
    color: var(--muted);
}

.footer .tagline { display: block; margin-bottom: 4px; }

.tagline {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .32em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ==========================================================================
   Страница и карточки
   ========================================================================== */

.page {
    flex: 1;
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: 16px 16px 48px;
}

body.wide .page { max-width: 760px; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
}

.card > .muted { margin: 0 0 24px; }

.auth-mark { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 20px; }

.auth-mark svg { width: 52px; height: 52px; }

.fine-print { margin: 20px 0 0; font-size: 13px; color: var(--muted); }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 4px 20px;
}

.form-panel { padding: 22px 20px; }

.back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
    color: var(--muted);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
}

.back:hover { color: var(--accent-text); }

.lead { margin: 0 0 20px; }

.section-title { font-size: 18px; font-weight: 800; margin: 32px 0 12px; }

.subsection { font-size: 15px; font-weight: 700; margin: 20px 0 8px; }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.page-head > div { flex: 1 1 320px; }

/* ==========================================================================
   Поля
   ========================================================================== */

.field { display: block; margin-bottom: 14px; }

.field-label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 6px; }

.field-label .muted { font-weight: 500; }

.field input,
.field select {
    width: 100%;
    min-height: 54px;
    border: 1.5px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font: inherit;
    font-size: 17px;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.field input:focus,
.field select:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--focus);
}

.field input.invalid { border-color: var(--error); }

.field input::placeholder { color: var(--muted); opacity: .7; }

.code-input {
    letter-spacing: .45em;
    font-variant-numeric: tabular-nums;
    text-align: center;
    font-size: 26px !important;
    font-weight: 700;
}

.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }

.form-grid.four { grid-template-columns: 1fr 1fr; }

@media (min-width: 640px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
    .form-grid.four { grid-template-columns: repeat(4, 1fr); }
}

.hint { margin: -6px 0 14px; font-size: 13px; color: var(--muted); }

.error {
    margin: -6px 0 14px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--error-soft);
    color: var(--error);
    font-size: 14px;
    font-weight: 500;
}

.notice {
    margin: 0 0 16px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--ok-soft);
    color: var(--ok);
    font-size: 14px;
    font-weight: 500;
}

.notice.pending { margin-top: 12px; background: var(--surface-2); color: var(--text); border-left: 3px solid var(--accent); }

.chips { border: 0; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }

.chips legend { margin-bottom: 6px; }

.chip { position: relative; }

.chip input { position: absolute; opacity: 0; pointer-events: none; }

.chip span {
    display: inline-block;
    padding: 9px 18px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
}

.chip input:checked + span { background: var(--zumo-ink); border-color: var(--zumo-ink); color: #fff; }

@media (prefers-color-scheme: dark) {
    .chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
}

.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; cursor: pointer; }

.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.small-select {
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 10px;
    padding: 7px 10px;
    font: inherit;
    font-size: 14px;
}

/* ==========================================================================
   Кнопки и ссылки
   ========================================================================== */

/* Белый текст на фирменном зелёном не проходит по контрасту (2.5:1) — на зелёном всегда тёмный текст. */
.button {
    display: block;
    width: 100%;
    margin-top: 8px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 15px 20px;
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, transform .05s;
}

.button:hover { background: var(--zumo-green-strong); }

.button:active { transform: translateY(1px); }

.button.inline { display: inline-block; width: auto; min-width: 180px; }

.button.small { width: auto; margin: 0; padding: 9px 16px; font-size: 14px; }

.button.secondary {
    background: transparent;
    color: var(--text);
    border: 1.5px solid var(--line);
}

.button.secondary:hover { background: var(--surface-2); }

.link {
    border: 0;
    background: none;
    padding: 0;
    color: var(--accent-text);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.link:hover { text-decoration: underline; }

.link:disabled { color: var(--muted); cursor: default; text-decoration: none; }

.muted-link { color: var(--muted); }

.link.danger, .danger-text { color: var(--error) !important; }

.row-actions { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 20px; }

.danger-zone { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

.logout { margin-top: 32px; }

.badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--muted);
    vertical-align: middle;
}

.badge.ok { background: var(--ok-soft); color: var(--ok); margin-left: 6px; white-space: nowrap; }

/* ==========================================================================
   Кабинет: шапка профиля — тёмная панель бренда
   ========================================================================== */

.hero {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 26px 24px;
    margin-bottom: 16px;
    border-radius: var(--radius);
    background: var(--zumo-night);
    color: #F4F6F8;
}

/* Зелёный клин — как на фирменной доске. */
.hero::after {
    content: "";
    position: absolute;
    right: -60px; top: -40px;
    width: 220px; height: 260px;
    background: var(--zumo-green);
    transform: rotate(28deg);
    opacity: .9;
    border-radius: 28px;
}

.hero > * { position: relative; z-index: 1; }

.hero h1 { color: #fff; margin: 0; font-size: 26px; }

.hero p { margin: 4px 0 0; color: #AEB6BF; }

.hero .avatar { background: var(--zumo-green); color: var(--zumo-ink); }

.profile { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }

.profile h1 { margin: 0; }

.profile p { margin: 4px 0 0; }

.avatar {
    flex: none;
    display: grid;
    place-items: center;
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 26px;
    font-weight: 900;
}

.avatar.org { border-radius: 18px; background: var(--zumo-ink); color: var(--zumo-green); }

@media (prefers-color-scheme: dark) {
    .avatar.org { background: var(--zumo-green); color: var(--zumo-ink); }
}

.facts { margin: 0; }

.facts > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 15px 0;
    border-bottom: 1px solid var(--line);
}

.facts > div:last-child { border-bottom: 0; }

.facts dt { color: var(--muted); }

.facts dd { margin: 0; text-align: right; word-break: break-all; font-weight: 600; }

/* --- Сервисы ZUMO: плитки цвета сервиса --- */

.services {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 520px) { .services { grid-template-columns: repeat(3, 1fr); } }

.service {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.service-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px; height: 44px;
    border-radius: 13px;
    font-size: 19px;
    font-weight: 900;
    color: var(--zumo-ink);
}

.service-text { min-width: 0; line-height: 1.25; }

.service-name { display: block; font-weight: 800; white-space: nowrap; }

.service-name b { font-weight: 800; }

.service-caption { display: block; font-size: 13px; color: var(--muted); }

/* Тёмный текст на светлых цветах, белый — на насыщенных (крупный жирный, контраст ≥ 3:1). */
.service-go { background: var(--svc-go); }
.service-eats { background: var(--svc-eats); }
.service-market { background: var(--svc-market); color: #fff; }
.service-delivery { background: var(--svc-delivery); color: #fff; }
.service-pay { background: var(--svc-pay); color: #fff; }
.service-services { background: var(--svc-services); }

/* Название сервиса в цвете сервиса — как «ZUMO Eats» на доске (на светлом фоне — затемнённые оттенки). */
.svc-text-go { color: #0E8A55; }
.svc-text-eats { color: #A66F00; }
.svc-text-market { color: #0157D6; }
.svc-text-delivery { color: #D52008; }
.svc-text-pay { color: #6A37F0; }
.svc-text-services { color: #0A8A93; }

@media (prefers-color-scheme: dark) {
    .svc-text-go { color: var(--svc-go); }
    .svc-text-eats { color: var(--svc-eats); }
    .svc-text-market { color: #5B9BFF; }
    .svc-text-delivery { color: #FF6B55; }
    .svc-text-pay { color: #A58BFF; }
    .svc-text-services { color: var(--svc-services); }
}

/* --- Разделы кабинета --- */

.sections, .list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.section-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 17px 20px;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
}

.section-item:last-child { border-bottom: 0; }

.section-item:has(.section-link) { padding: 0; }

.section-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 17px 20px;
    color: inherit;
    text-decoration: none;
}

.section-link:hover { background: var(--surface-2); }

.chevron { color: var(--muted); font-size: 22px; line-height: 1; }

/* --- Списки: устройства, адреса, организации --- */

.list-item { display: flex; align-items: center; gap: 14px; padding: 15px 20px; border-bottom: 1px solid var(--line); }

.list-item:last-child { border-bottom: 0; }

.list-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 42px; height: 42px;
    border-radius: 13px;
    background: var(--accent-soft);
    color: var(--accent-text);
}

.list-main { flex: 1; min-width: 0; }

.list-link { color: inherit; text-decoration: none; }

.list-title { font-weight: 700; overflow-wrap: anywhere; }

.list-sub { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.list-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }

.list-actions form { margin: 0; }

.after-list { margin-top: 12px; }

.empty {
    padding: 30px 20px;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: 1.5px dashed var(--line);
    border-radius: var(--radius);
}

.org-mark {
    flex: none;
    display: grid;
    place-items: center;
    width: 42px; height: 42px;
    border-radius: 13px;
    background: var(--zumo-ink);
    color: var(--zumo-green);
    font-weight: 900;
}

@media (prefers-color-scheme: dark) {
    .org-mark { background: var(--zumo-green); color: var(--zumo-ink); }
}

.org-mark.person { border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); }

.plain-list { list-style: none; margin: 0; padding: 0; }

.plain-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
    border-top: 1px solid var(--line);
    font-size: 14px;
}

.inline-form { display: flex; align-items: center; gap: 8px; }

.email-form { margin-top: 16px; }

/* ==========================================================================
   Мобильные
   ========================================================================== */

@media (max-width: 520px) {
    .list-item { flex-wrap: wrap; }
    .list-actions { width: 100%; justify-content: flex-start; padding-left: 56px; }
    .hero { padding: 22px 18px; }
    .hero h1 { font-size: 22px; }
}

@media (max-width: 420px) {
    .card { padding: 24px 18px; }
    h1 { font-size: 23px; }
    .brand-name { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ==========================================================================
   Правки после проверки на экранах 390 px и в тёмной теме
   ========================================================================== */

/* Плитки сервисов не шире колонки: длинные названия переносятся. */
.services { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 520px) { .services { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.service { min-width: 0; }
.service-name { white-space: normal; overflow-wrap: anywhere; }

/* В тёмной теме панель приветствия отделена от фона страницы. */
@media (prefers-color-scheme: dark) {
    .hero { background: var(--surface); border: 1px solid var(--line); }
}

/* Подписи в «фактах» не разрываются. */
.facts dt { white-space: nowrap; }

@media (max-width: 520px) {
    /* Клин уходит в угол и не ложится на текст. */
    .hero::after { right: -150px; top: -70px; width: 200px; height: 240px; }
    .hero > div:last-child { padding-right: 24px; }
    .facts dd.mono { font-size: 12px; }
    .facts > div { align-items: flex-start; }
}

@media (max-width: 520px) {
    /* Клин — узкая полоса у правого края, текст не перекрывает. */
    .hero::after { right: -128px; top: -60px; width: 150px; height: 240px; }

    /* Плитки сервисов — вертикально, как на фирменной доске: значок сверху, подпись снизу. */
    .service { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
    .service-name { font-size: 15px; white-space: nowrap; }
    .service-caption { font-size: 12.5px; }
}

@media (max-width: 520px) {
    /* На телефоне клин — зелёный уголок в правом нижнем углу, под текстом его нет. */
    .hero::after {
        top: auto; bottom: 0; right: 0;
        width: 64px; height: 64px;
        transform: none;
        border-radius: 0;
        clip-path: polygon(100% 0, 100% 100%, 0 100%);
    }
}

/* ---------- Вход в приложения (OIDC): согласие и выход ---------- */
.consent-scopes { margin: 18px 0 14px; }
.consent-scopes li { justify-content: flex-start; }
.consent-scopes li::before {
    content: "";
    flex: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent, #00BC70) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.2l2.6 2.6L12 5.4' fill='none' stroke='%230A111C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
}
.card .row-actions .button { flex: 1 1 160px; }
