/*
  Личный кабинет AmnesiaOS — базовые стили.
  Медиазапросы вынесены целиком в responsive.css, он подключается следом.

  Визуальный язык — макет «Личный кабинет — финальные экраны» (вариант D2,
  сентябрь 2026): свечение-рендер фоном всего экрана, карточки на стекле,
  объёмные иконки в сайдбаре и быстрых действиях, Unbounded в заголовках,
  Manrope в тексте, Chivo Mono в серийных номерах.

  CSS-комментарии здесь по-русски намеренно: этот файл НЕ проходит через
  tools/extract.py (кабинет не участвует в сборке маркетинговых страниц), так
  что ограничение «комментарии по-английски» на него не распространяется.
*/

@layer tokens, base, layout, components, sections;

/* ══ Токены ═════════════════════════════════════════════════════════════════ */
@layer tokens {
  :root {
    /* Поверхности макета. */
    --bg0: #0b0c14;               /* фон приложения */
    --bg1: #12141f;               /* плотная карточка */
    --bg2: #0f111c;               /* утопленная плитка: быстрые действия, бейджи */
    --bg3: #1b1e2c;
    --bg4: #232336;
    --line:  #171a26;             /* границы шапки и сайдбара */
    --line2: #1c1f2e;             /* граница плотной карточки */
    --line3: #2a2e42;

    /* Стекло: карточки поверх свечения. */
    --glass:    rgba(255,255,255,.05);
    --glass-bd: rgba(255,255,255,.12);
    --glass-blur: blur(16px);

    --p:  #4F7BFF;
    --ph: #6F8CF7;                /* ссылки и акценты текста */
    --ph2: #9FB2FF;               /* ссылка под курсором */
    --v:  #9184D9;                /* фирменный «блёрпл» активного пункта меню */
    --vh: #B5ABFC;

    --tp:  #E9E9ED;
    --ts:  #A5A6B4;
    --tn:  #C7C9D6;               /* пункты навигации */
    --tm:  #858899;
    --tm2: #858899;

    --bs: rgba(255,255,255,.06);
    --bn: rgba(255,255,255,.18);
    --ba: rgba(79,123,255,.38);
    --p10: rgba(79,123,255,.12);

    --fd: 'Unbounded', sans-serif;
    --fb: 'Manrope', system-ui, sans-serif;
    --fm: 'Chivo Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --rxl: 18px;
    --rlg: 18px;
    --rmd: 12px;
    --rsm: 10px;
    --rfull: 9999px;

    /* ── Переопределения, вынужденные WCAG 2.1 AA ─────────────────────────
       Макет красит кнопки в #4F7BFF, но белый текст на нём даёт 3.71 — ПРОВАЛ
       (нужно 4.5). --p-fill #4A6CE6 даёт 4.59 и на глаз от макетного цвета
       неотличим. Сам --p остаётся для границ и крупных элементов.

       Приглушённый текст макета #7A7D90 на стекле даёт 4.34 — провал для
       мелкого текста. --tm #858899 даёт 5.0 и остаётся в той же гамме. */
    --p-fill:   #4A6CE6;
    --p-fill-h: #3E63E0;   /* 5.16 */
    --p-fill-a: #3355C4;   /* 6.49 */

    /* Граница поля ввода — не декор, а признак элемента управления (1.4.11,
       нужно 3.0). Макетные .12 дают 1.3, поэтому поле рисуется чуть ярче. */
    --field-bg: rgba(255,255,255,.04);
    --field-bd: rgba(255,255,255,.34);

    --focus-ring: 0 0 0 2px var(--bg0), 0 0 0 4px var(--ph);

    --red:    #FF7B7B;
    --amber:  #F2C14E;
    --green:  #7BD7A8;
    --red10:    rgba(255,107,107,.08);
    --amber10:  rgba(242,193,78,.08);
    --green10:  rgba(123,215,168,.08);
    --violet10: rgba(145,132,217,.12);
    --red-bd:    rgba(255,107,107,.5);
    --amber-bd:  rgba(242,193,78,.4);
    --green-bd:  rgba(123,215,168,.4);
    --violet-bd: rgba(145,132,217,.35);

    --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
    --s5: 22px; --s6: 32px; --s7: 40px; --s8: 48px;

    --maxw: 1140px;
    --maxw-wide: 1440px;
    --header-h: 60px;
    --nav-w: 220px;
    --bottom-nav-h: 64px;

    --dur-fast: .15s;
    --dur: .2s;
    --ease: cubic-bezier(.2,.7,.3,1);
  }
}

/* ══ База ═══════════════════════════════════════════════════════════════════ */
@layer base {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }
  /* Атрибут hidden сильнее любого display из стилей: шапка и навигация гостя
     скрыты именно им. */
  [hidden] { display: none !important }

  body {
    background: var(--bg0);
    color: var(--tp);
    font-family: var(--fb);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    /* Горизонтальную прокрутку не прячем через overflow-x:hidden: это маскирует
       переполнение вместо того, чтобы его чинить. Тест hygiene падает на
       scrollWidth > innerWidth, и это правильно. */
  }

  /* Свечение фоном всего экрана. Декор: псевдоэлемент не попадает в дерево
     доступности и не перехватывает клики. position: fixed — рендер стоит на
     месте, пока содержимое прокручивается поверх стекла; за край окна он
     выходит без прокрутки (fixed-блок не расширяет прокручиваемую область). */
  body::before {
    content: '';
    position: fixed; z-index: 0; pointer-events: none;
    top: -120px; right: -200px;
    width: clamp(760px, 90vw, 1800px);
    aspect-ratio: 1200 / 896;
    background: url('/account/img/glow-hand-tile.webp') center / contain no-repeat;
    opacity: .35;
    /* Края рендера растворяются в фоне, а не обрываются линией. */
    -webkit-mask-image: radial-gradient(farthest-side at 62% 42%, #000 58%, transparent 100%);
    mask-image: radial-gradient(farthest-side at 62% 42%, #000 58%, transparent 100%);
  }

  /* Ссылка внутри текста подчёркнута ПО УМОЛЧАНИЮ.
     Отличать её от текста одним лишь цветом — нарушение 1.4.1: человек с
     цветовой слепотой такую ссылку просто не увидит. Подчёркивание снимается
     только у элементов, которые и так читаются как элементы управления
     (кнопки, пункты навигации, плитки быстрых действий, логотип). */
  a { color: var(--ph); text-decoration: underline; text-underline-offset: 2px }
  a:hover { color: var(--ph2); text-decoration-thickness: 2px }
  a.btn, a.nav-link, a.quick-action, a.app-logo, a.skip-link {
    text-decoration: none;
  }
  a.btn:hover, a.nav-link:hover, a.quick-action:hover, a.app-logo:hover {
    text-decoration: none;
  }
  img { max-width: 100%; display: block }
  button, input, select, textarea { font: inherit; color: inherit }

  h1, h2, h3, h4 { font-family: var(--fd); font-weight: 700; line-height: 1.15 }
  h1 { font-size: clamp(24px, 3vw, 32px); letter-spacing: -.03em; line-height: 1.05 }
  h2 { font-size: 17px; letter-spacing: -.02em }
  h3 { font-size: 16px; letter-spacing: -.02em }
  h1:focus { outline: none }          /* фокус после навигации виден по заголовку */

  :focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--rsm);
  }

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

  .skip-link {
    position: absolute; left: var(--s4); top: -100px; z-index: 200;
    background: var(--bg3); color: var(--tp);
    padding: var(--s3) var(--s4); border-radius: var(--rsm);
    border: 1px solid var(--bn);
  }
  .skip-link:focus { top: var(--s4) }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: .01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: .01ms !important;
      scroll-behavior: auto !important;
    }
  }
}

/* ══ Каркас ═════════════════════════════════════════════════════════════════ */
@layer layout {
  .boot { position: relative; z-index: 1; padding: var(--s8) var(--s4); text-align: center }
  .boot-text { color: var(--ts) }

  .app-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--header-h);
    display: flex; align-items: center; gap: var(--s3);
    padding: 0 28px;
    background: rgba(11,12,20,.72);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--line);
  }

  .app-logo { display: flex; align-items: center; gap: var(--s3); color: var(--tp) }
  .app-logo:hover { color: var(--tp); text-decoration: none }
  .app-logo-mark {
    display: block; flex: none;
    width: 28px; height: 28px; border-radius: 8px;
    background: #16161c url('/account/img/logo-tile.webp') center / cover no-repeat;
  }
  .app-logo-text {
    font-family: var(--fd); font-weight: 700; font-size: 15px;
    letter-spacing: -.02em;
  }

  .app-header-section {
    margin-left: var(--s1);
    font-family: var(--fb); font-weight: 500; font-size: 13px;
    color: var(--tm); letter-spacing: 0;
  }
  .app-header-actions { margin-left: auto; display: flex; gap: var(--s2) }
  .app-header-actions .btn { font-size: 13px; font-weight: 500; color: var(--ts) }

  .app-nav { display: flex; position: relative; z-index: 2 }
  .nav-link {
    display: flex; align-items: center; gap: var(--s3);
    min-height: 44px; padding: 11px 14px;
    color: var(--tn); font-size: 14px;
    border: 1px solid transparent; border-radius: var(--rsm);
    transition: background var(--dur-fast), color var(--dur-fast),
                border-color var(--dur-fast);
  }
  .nav-link:hover { background: rgba(255,255,255,.04); color: var(--tp); text-decoration: none }
  .nav-link[aria-current="page"] {
    background: var(--violet10); border-color: var(--violet-bd); color: var(--tp);
  }
  /* Объёмная иконка — декор: подпись пункта рядом, alt пустой. */
  .nav-icon { width: 22px; height: 22px; flex: none; object-fit: contain }
  .nav-label { font-weight: 500 }

  .app-main { position: relative; z-index: 1; min-height: 100vh; outline: none }
  .app-main:focus { outline: none }

  .page {
    width: 100%; margin: 0 auto; max-width: var(--maxw);
    display: flex; flex-direction: column; gap: var(--s5);
  }
  /* Пустые точки монтирования (баннер возврата с оплаты, уведомления) не
     должны добавлять лишний интервал в колонке. */
  .page > div:empty { display: none }
  .page-head { display: flex; align-items: flex-start; justify-content: space-between;
               gap: var(--s4) var(--s5); flex-wrap: wrap }
  .page-head-text { min-width: 0 }
  .page-head-actions { display: flex; gap: var(--s2); flex-wrap: wrap }
  /* Заголовок раздела в рамке — приём макета для всех разделов, кроме
     приветствия на обзоре. */
  .page-head-boxed h1 {
    display: inline-block; max-width: 100%;
    border: 1.5px solid var(--p); border-radius: var(--rmd);
    padding: 6px 12px;
    overflow-wrap: anywhere;
  }
  .page-lead { color: var(--ts); font-size: 14px; margin-top: 10px; max-width: 62ch }

  .grid { display: grid; gap: var(--s4) }
  .stack { display: flex; flex-direction: column; gap: var(--s4) }
  .row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap }
}

/* ══ Компоненты ═════════════════════════════════════════════════════════════ */
@layer components {

  /* ── Кнопки ── */
  .btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--s2);
    min-height: 44px;              /* минимальная цель по AA */
    min-width: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--rsm);
    font-family: var(--fb); font-weight: 700; font-size: 13px;
    line-height: 1.2; white-space: nowrap;
    cursor: pointer;
    transition: background var(--dur-fast), border-color var(--dur-fast),
                transform var(--dur-fast), color var(--dur-fast);
    background: none;
  }
  .btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed }
  .btn:not(:disabled):active { transform: translateY(1px) }

  .btn-primary { background: var(--p-fill); color: #fff; border-color: var(--p-fill) }
  .btn-primary:not(:disabled):hover { background: var(--p-fill-h); border-color: var(--p-fill-h) }
  a.btn-primary, a.btn-primary:hover { color: #fff }

  /* «Вторичная» — контурная кнопка макета. */
  .btn-secondary { background: transparent; color: var(--tp); border-color: var(--bn) }
  .btn-secondary:not(:disabled):hover { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.3) }
  a.btn-secondary, a.btn-secondary:hover { color: var(--tp) }

  .btn-ghost { color: var(--ts); padding: 0 var(--s3) }
  .btn-ghost:not(:disabled):hover { color: var(--tp); background: rgba(255,255,255,.06) }

  .btn-danger { background: transparent; color: var(--red); border-color: var(--red-bd) }
  .btn-danger:not(:disabled):hover { background: var(--red10) }

  /* «Маленькая» кнопка — про плотность, а не про размер цели нажатия.
     Высота остаётся 44px (наследуется от .btn): уменьшать её значило бы
     сделать кнопку недоступной для пальца и для человека с тремором. Меньше
     становятся отступы и шрифт. */
  .btn-sm { padding: 0 14px; font-size: 12px }
  .btn-block { width: 100% }
  .btn-icon { width: 16px; height: 16px; flex: none }

  /* Спиннер отправки. Ширина кнопки не меняется — иначе форма прыгает и CLS
     растёт ровно в момент, когда пользователь смотрит на кнопку. */
  .btn[aria-busy="true"] .btn-label { opacity: .35 }
  .spinner {
    width: 16px; height: 16px; flex: none;
    border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg) } }

  /* ── Карточки: стекло поверх свечения ── */
  .card {
    position: relative;
    display: flex; flex-direction: column; gap: 10px;
    min-width: 0;
    background: var(--glass);
    border: 1px solid var(--glass-bd);
    border-radius: var(--rlg);
    padding: var(--s5);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    transition: border-color var(--dur);
  }
  /* :where — нулевой вес: любой класс на абзаце (.big, .mono, .device-line)
     перебивает это умолчание без борьбы за специфичность. */
  :where(.card) p { font-size: 13px; line-height: 1.5; color: var(--ts) }
  .card > p:empty { display: none }
  .card-interactive:hover { border-color: rgba(255,255,255,.22) }
  .card-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: var(--s2) var(--s3); flex-wrap: wrap;
  }
  .card-title { min-width: 0; font-size: 17px }
  .card-link { font-size: 12px; color: var(--tm); white-space: nowrap }
  .card-link:hover { color: var(--tp) }
  .card-note { color: var(--ts); font-size: 13px }
  .card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px }
  .card-accent { border-color: var(--ba) }
  .card-warn { border-color: var(--amber-bd); background: var(--amber10) }
  /* Декоративный рендер внутри карточки: лежит под содержимым. */
  .card-art { position: absolute; z-index: 0; pointer-events: none; max-width: none }
  .card > :not(.card-art) { position: relative; z-index: 1 }

  /* ── Бейджи: «таблетки» макета ── */
  /* Всегда иконка + текст: смысл не должен зависеть только от цвета. */
  .badge {
    display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
    padding: 5px 12px; border-radius: var(--rfull);
    font-size: 12px; font-weight: 600; line-height: 1.3; white-space: nowrap;
    border: 1px solid;
  }
  .badge-icon { width: 13px; height: 13px; flex: none }
  .badge-green  { background: var(--green10);  border-color: var(--green-bd);  color: var(--green) }
  .badge-blue   { background: var(--p10);      border-color: var(--ba);        color: var(--ph) }
  .badge-violet { background: var(--violet10); border-color: var(--violet-bd); color: var(--vh) }
  .badge-amber  { background: var(--amber10);  border-color: var(--amber-bd);  color: var(--amber) }
  .badge-red    { background: var(--red10);    border-color: var(--red-bd);    color: var(--red) }
  .badge-muted  { background: var(--bg2);      border-color: var(--line3);     color: var(--tn) }
  .badges { display: flex; flex-wrap: wrap; gap: var(--s2) }

  /* ── Формы ── */
  .form { display: flex; flex-direction: column; gap: 14px }
  .field { display: flex; flex-direction: column; gap: 6px }
  .field-label { font-weight: 600; font-size: 12px; color: var(--ts) }
  .field-required { color: var(--ph) }
  .field-hint { font-size: 12px; color: var(--tm) }

  .input, .select {
    min-height: 44px;
    padding: 0 14px;
    background: var(--field-bg);
    color: var(--tp);
    font-size: 14px;
    border: 1px solid var(--field-bd);
    border-radius: var(--rsm);
    width: 100%;
    transition: border-color var(--dur-fast);
  }
  .select { background-color: var(--bg1) }
  .input::placeholder { color: #6B6F85 }
  .input:hover, .select:hover { border-color: rgba(255,255,255,.5) }
  .input:focus-visible, .select:focus-visible { border-color: var(--ph) }
  /* readonly, а НЕ disabled, на время отправки: значения остаются в дереве
     доступности, скринридер продолжает их читать. */
  .input[readonly] { opacity: .7; cursor: default }
  .input[aria-invalid="true"] { border-color: var(--red) }
  .input-mono { font-family: var(--fm); letter-spacing: .04em }

  .field-error {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--red);
  }
  .field-error-icon { width: 14px; height: 14px; flex: none }

  /* min-inline-size: 0 обязателен.
     У <fieldset> в браузерах особое поведение: он не сжимается уже своего
     min-content, игнорируя ширину родителя. Из-за этого один неразрывный
     элемент внутри раздвигал всю страницу и давал горизонтальную прокрутку
     на 360px. */
  fieldset { border: 0; min-inline-size: 0 }
  .fieldset { display: flex; flex-direction: column; gap: var(--s4); min-width: 0 }
  .form, .field { min-width: 0 }
  .fieldset > legend {
    font-family: var(--fd); font-weight: 700; font-size: 16px;
    margin-bottom: var(--s3); padding: 0;
  }

  .radio-card {
    display: flex; align-items: center; gap: var(--s3);
    min-height: 56px; padding: var(--s3) var(--s4);
    background: var(--field-bg); border: 1px solid var(--field-bd);
    border-radius: var(--rmd); cursor: pointer;
  }
  .radio-card:hover { border-color: rgba(255,255,255,.5) }
  .radio-card:has(input:checked) { border-color: var(--p); background: var(--p10) }
  .radio-card input { width: 18px; height: 18px; accent-color: var(--p-fill) }

  .checkbox-row { display: flex; align-items: flex-start; gap: var(--s3) }
  .checkbox-row input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--p-fill) }

  /* ── Сводка ошибок ── */
  .error-summary {
    background: var(--red10); border: 1px solid var(--red-bd);
    border-radius: var(--rmd); padding: var(--s4);
  }
  .error-summary:focus { outline: none; box-shadow: var(--focus-ring) }
  .error-summary-title { font-weight: 700; margin-bottom: var(--s2) }
  .error-summary ul { list-style: none; display: flex; flex-direction: column; gap: 4px }
  .error-summary a { color: var(--red) }

  /* ── Состояния разделов ── */
  .state {
    display: flex; flex-direction: column; align-items: center;
    gap: var(--s3); padding: var(--s7) var(--s4); text-align: center;
  }
  .state-icon {
    width: 48px; height: 48px; border-radius: var(--rmd);
    background: var(--p10); border: 1px solid var(--ba); color: var(--ph);
    display: flex; align-items: center; justify-content: center;
  }
  .state-icon svg { width: 22px; height: 22px }
  .state-title { font-family: var(--fd); font-weight: 700; font-size: 17px; letter-spacing: -.02em }
  .state-text { color: var(--ts); max-width: 46ch }
  .state-compact { padding: var(--s4) var(--s3) }
  .state-error .state-icon {
    background: var(--red10); border-color: var(--red-bd); color: var(--red);
  }

  /* ── Скелетоны ── */
  /* Фиксированные высоты — чтобы подстановка данных не двигала вёрстку. */
  .skeleton { display: flex; flex-direction: column; gap: var(--s3) }
  .skeleton-line {
    height: 14px; border-radius: var(--rsm);
    background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.09) 37%, rgba(255,255,255,.04) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s linear infinite;
  }
  .skeleton-line.short { width: 45% }
  .skeleton-line.tall  { height: 34px }
  .skeleton-card { height: 168px; border-radius: var(--rlg) }
  @keyframes shimmer { to { background-position: -200% 0 } }

  /* ── Тосты ── */
  .toast-root {
    position: fixed; z-index: 300;
    left: 50%; transform: translateX(-50%);
    bottom: calc(var(--bottom-nav-h) + var(--s4));
    display: flex; flex-direction: column; gap: var(--s2);
    width: min(420px, calc(100vw - var(--s5)));
  }
  .toast {
    display: flex; align-items: center; gap: var(--s3);
    padding: var(--s3) var(--s4);
    background: var(--bg3); border: 1px solid var(--bn);
    border-radius: var(--rmd);
    box-shadow: 0 12px 32px rgba(0,0,0,.45);
    animation: toast-in var(--dur) var(--ease);
  }
  .toast-success { border-color: var(--green-bd) }
  .toast-error   { border-color: var(--red-bd) }
  .toast-icon { width: 18px; height: 18px; flex: none }
  .toast-success .toast-icon { color: var(--green) }
  .toast-error   .toast-icon { color: var(--red) }
  @keyframes toast-in { from { opacity: 0; transform: translateY(8px) } }

  /* ── Модальные окна ── */
  .modal-overlay {
    position: fixed; inset: 0; z-index: 400;
    background: rgba(3,3,8,.72);
    display: flex; align-items: center; justify-content: center;
    padding: var(--s4);
  }
  .modal {
    background: var(--bg1); border: 1px solid var(--glass-bd);
    border-radius: var(--rlg); padding: var(--s5);
    width: min(480px, 100%); max-height: 90vh; overflow-y: auto;
    box-shadow: 0 30px 80px rgba(0,0,0,.5);
  }
  .modal-head { display: flex; align-items: flex-start; gap: var(--s3); margin-bottom: var(--s4) }
  .modal-title { flex: 1 }
  .modal-actions { display: flex; gap: var(--s3); margin-top: var(--s5); justify-content: flex-end }

  /* ── Серийный номер ── */
  .serial { display: inline-flex; align-items: center; gap: var(--s1) }
  .serial-value {
    font-family: var(--fm); font-size: 13px; color: var(--ts);
    letter-spacing: .06em;
  }
  .serial-toggle { padding: 0 var(--s2); min-height: 44px; min-width: 44px }

  /* ── Числа и моно ── */
  .mono { font-family: var(--fm); font-size: 13px; color: var(--ts); letter-spacing: .06em }
  .big { font-family: var(--fd); font-weight: 700; font-size: 22px; letter-spacing: -.02em;
         line-height: 1.15; color: var(--tp) }
  .num { font-family: var(--fd); font-weight: 700; font-size: 30px; line-height: 1; color: var(--tp) }
  .kicker {
    font-size: 12px; font-weight: 600; letter-spacing: .12em;
    text-transform: uppercase; color: var(--tm);
  }

  /* ── Разное ── */
  .divider { height: 1px; background: rgba(255,255,255,.1); border: 0 }
  .muted { color: var(--tm); font-size: 13px }
  .strong { font-weight: 600 }
  .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
  .scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch }
}

/* ══ Разделы ════════════════════════════════════════════════════════════════ */
@layer sections {

  /* ── Аутентификация ── */
  .auth-shell {
    position: relative; z-index: 1;
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: var(--s6) var(--s4);
  }
  .auth-card {
    width: min(440px, 100%);
    padding: 28px;
    background: var(--glass);
    border: 1px solid var(--glass-bd);
    border-radius: var(--rlg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
  }
  .auth-brand { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s5) }
  .auth-title { margin-bottom: var(--s2) }
  .auth-lead { color: var(--ts); margin-bottom: var(--s5) }
  .auth-alt { margin-top: var(--s5); color: var(--ts); font-size: 14px; text-align: center }
  .auth-links { display: flex; justify-content: space-between; gap: var(--s3); margin-top: var(--s2) }

  /* ── Обзор ── */
  .overview-grid { display: grid; gap: var(--s4) }
  .kpi { display: flex; flex-direction: column; gap: 2px }
  .kpi-value { font-family: var(--fd); font-weight: 700; font-size: 22px; letter-spacing: -.02em }
  .kpi-label { color: var(--tm); font-size: 13px }
  .next-steps { display: flex; flex-direction: column; gap: var(--s2); padding-left: var(--s5) }
  .next-steps li { color: var(--ts); font-size: 14px }
  .next-steps li::marker { color: var(--ph); font-weight: 700 }
  .next-strong { color: var(--tp); font-weight: 600; font-size: 15px }
  .next-text { font-size: 14px }

  /* Всегда одна колонка.
     Плитки живут в узкой карточке обзора (около 360px на 1440), и три колонки
     обрезали подписи: «Приложения» превращалось в «Прило». Вертикальный список
     читается лучше и не зависит от длины перевода. */
  .quick-actions { display: grid; grid-template-columns: 1fr; gap: 10px }
  .quick-action {
    display: flex; align-items: center; gap: var(--s3);
    min-height: 58px; padding: 12px 14px;
    background: var(--bg2); border: 1px solid var(--line2);
    border-radius: var(--rmd); color: var(--tp); text-align: left;
    font-size: 14px; font-weight: 500;
    cursor: pointer; width: 100%; overflow-wrap: anywhere;
    transition: border-color var(--dur-fast), background var(--dur-fast);
  }
  a.quick-action, a.quick-action:hover { color: var(--tp) }
  .quick-action:hover { border-color: var(--violet-bd); background: #121524; text-decoration: none }
  .quick-action-icon { width: 34px; height: 34px; flex: none; object-fit: contain }

  .device-line { font-size: 16px; font-weight: 700; color: var(--tp); margin-top: 6px }
  .overview-order { flex-direction: row; flex-wrap: wrap; align-items: center;
                    justify-content: space-between; gap: var(--s4) var(--s5) }
  .overview-order-main { display: flex; flex-direction: column; gap: 6px; min-width: 0 }
  .overview-order-side { display: flex; align-items: center; gap: 18px; flex-wrap: wrap }
  .overview-order-sum { text-align: right }
  .overview-order .card-link { align-self: flex-start }
  .overview-order .state { flex: 1 }

  /* ── Устройства ── */
  .devices-grid { display: flex; flex-wrap: wrap; gap: var(--s4); align-items: stretch }
  .devices-grid > .skeleton { flex: 1 1 300px }
  .device-card {
    flex: 0 1 460px; min-width: min(100%, 320px);
    gap: var(--s3); overflow: hidden;
  }
  .device-art {
    right: -160px; top: -120px; width: 520px; opacity: .55;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 50%);
    mask-image: linear-gradient(90deg, transparent, #000 50%);
  }
  .device-head { display: flex; flex-direction: column; gap: 4px }
  .device-name { font-family: var(--fd); font-weight: 700; font-size: 17px; letter-spacing: -.02em }
  .device-serial-label { margin-bottom: 2px }
  .device-serial .serial-value { font-size: 15px; color: var(--tp) }
  .device-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; padding-top: 4px }

  /* Плитка «Добавить проектор» рядом с карточками. Настоящая кнопка. */
  .device-add {
    flex: 0 1 300px; min-width: min(100%, 240px); min-height: 220px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: var(--s3); padding: 30px; text-align: center;
    color: var(--tp); cursor: pointer;
    background: var(--glass);
    border: 1.5px dashed var(--bn); border-radius: var(--rlg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    transition: border-color var(--dur-fast), background var(--dur-fast);
  }
  .device-add:hover { border-color: rgba(255,255,255,.34); background: rgba(255,255,255,.07) }
  .device-add-icon { width: 56px; height: 56px; object-fit: contain }
  .device-add-title { font-size: 15px; font-weight: 700 }
  .device-add-text { font-size: 12px; color: var(--ts) }

  /* ── Приложения ── */
  .apps-toolbar { display: flex; flex-wrap: wrap; gap: var(--s3) }
  .apps-toolbar .field { flex: 1 1 220px }
  .chips { display: flex; flex-wrap: wrap; gap: var(--s2) }
  .chip {
    min-height: 44px; padding: 0 var(--s4);
    background: var(--glass); border: 1px solid var(--bn);
    border-radius: var(--rfull); color: var(--ts); cursor: pointer;
    font-size: 13px; font-weight: 600;
  }
  .chip:hover { color: var(--tp) }
  .chip[aria-pressed="true"] { background: var(--violet10); border-color: var(--violet-bd); color: var(--tp) }
  .apps-grid { display: grid; gap: var(--s4) }
  /* Отступы карточки убраны сверху: плитка выходит под самый край. */
  .app-card {
    display: flex; flex-direction: column; gap: var(--s3);
    padding: 0; overflow: hidden;
  }
  .app-body {
    display: flex; flex-direction: column; gap: var(--s3);
    padding: var(--s3) var(--s4) var(--s4); flex: 1;
  }

  /* Фиксированное соотношение 16:9. Картинка вписывается целиком, а не
     обрезается: у части приложений вместо баннера приходит квадратная иконка,
     и кадрирование съело бы её края. */
  .app-tile {
    position: relative; width: 100%; aspect-ratio: 16 / 9;
    background: rgba(255,255,255,.03); border-bottom: 1px solid var(--glass-bd);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
  }
  .app-tile-img { width: 100%; height: 100%; object-fit: contain; padding: 6px }
  .app-tile-empty {
    background: linear-gradient(135deg, rgba(79,123,255,.10) 0%, rgba(145,132,217,.12) 100%);
  }
  .app-tile-letter {
    font-family: var(--fd); font-weight: 700; font-size: 34px;
    color: var(--ts); letter-spacing: -1px;
  }

  .app-head { display: flex; align-items: center; gap: var(--s3) }
  .app-name { font-weight: 700; color: var(--tp) }
  .app-desc { color: var(--ts); font-size: 13px; flex: 1 }
  .app-body .btn, .app-body .badge { align-self: stretch; justify-content: center }

  /* ── Покупки ── */
  .orders-layout { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr); align-items: start }
  .orders-table-card { padding: 10px 18px }
  .orders-table { width: 100%; border-collapse: collapse; font-size: 13px }
  .orders-table th, .orders-table td {
    padding: 7px 6px; height: 58px; text-align: left; white-space: nowrap;
    border-bottom: 1px solid rgba(255,255,255,.06);
  }
  .orders-table th {
    height: 50px; color: var(--tm); font-weight: 600; font-size: 13px;
    border-bottom-color: rgba(255,255,255,.1);
  }
  .orders-table tbody tr:last-child td { border-bottom: 0 }
  .orders-table tbody tr:hover td { background: rgba(255,255,255,.025) }
  .orders-model { font-weight: 600; color: var(--tp); white-space: normal; min-width: 150px }
  .orders-table .muted { color: var(--tm) }
  .orders-cards { display: grid; gap: var(--s3) }
  .order-card { gap: var(--s3) }
  .order-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s3) }
  .order-key { color: var(--tm); font-size: 13px }
  .order-amount { font-family: var(--fd); font-weight: 700; font-size: 14px }
  .order-card .btn { align-self: flex-start }

  .summary-card { gap: 18px; overflow: hidden }
  .summary-art { right: -110px; bottom: -84px; width: 260px; opacity: .6 }
  .summary-item { display: flex; flex-direction: column; gap: 6px }
  .summary-card p { margin: 0 }

  /* ── Мастер покупки ── */
  .wizard { max-width: 640px }
  .stepper { display: flex; gap: var(--s2); margin-bottom: var(--s5); list-style: none }
  .step {
    flex: 1; display: flex; flex-direction: column; gap: 6px;
    font-size: 12px; color: var(--tm);
  }
  .step-bar { height: 4px; border-radius: var(--rfull); background: rgba(255,255,255,.1) }
  .step-done .step-bar { background: var(--green) }
  .step-current .step-bar { background: var(--p) }
  .step-current { color: var(--tp); font-weight: 600 }
  .summary-row {
    display: flex; justify-content: space-between; gap: var(--s3);
    padding: var(--s3) 0; border-bottom: 1px solid var(--bs);
  }
  .summary-total { font-family: var(--fd); font-weight: 700; font-size: 20px }

  /* ── Профиль ── */
  .profile-grid { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr) }
  .profile-card { gap: 14px }
  .profile-card .form { gap: 14px }
  /* Поля формы профиля — сеткой в две колонки, кнопка — справа.
     .form-cols висит на самом <form>: его прямой потомок .form — блок полей,
     а блок с кнопкой отправки находится по :has. */
  .form-cols > .form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px 12px }
  .form-cols .btn-block { width: auto }
  .form-cols > div:has(> .btn[type="submit"]) { display: flex; justify-content: flex-end }
  /* Подсказка длины пароля видна в поле как placeholder и остаётся связанной с
     полем через aria-describedby: скрывается визуально, а не из дерева. */
  .form-quiet-hints .field-hint {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
  .readonly-value {
    /* Перенос обязателен: на 360px адрес и пометка в одну строку не
       помещаются, а обрезать адрес нельзя — он нужен целиком. */
    display: flex; align-items: center; justify-content: space-between;
    gap: 4px var(--s3); flex-wrap: wrap;
    min-height: 44px; padding: 8px 14px;
    background: var(--field-bg); border: 1px dashed var(--field-bd);
    border-radius: var(--rsm); color: var(--tp); font-size: 14px;
    overflow-wrap: anywhere;
  }
  .readonly-note { font-size: 11px; color: var(--tm) }
  .sessions-card { flex-direction: row; flex-wrap: wrap; align-items: center;
                   justify-content: space-between; gap: var(--s4) }
  .sessions-text { display: flex; flex-direction: column; gap: 6px; flex: 1 1 180px; min-width: 0 }
  .sessions-text p { max-width: 320px }
  .sessions-actions { display: flex; flex-wrap: wrap; gap: var(--s2) }
  .sessions-actions .btn { padding: 0 14px }
  .sessions-status:empty { display: none }
  .sessions-status { flex-basis: 100% }
  .stats-card { flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--s4) 26px }
  .stats-item { display: flex; flex-direction: column; gap: 6px }
  .stats-sep { width: 1px; height: 40px; background: rgba(255,255,255,.1) }
}
