/* Телефон (≤980px), как у Platega: dashboard. Только @media (max-width: 980px).
   Размеры — мобильный кабинет Platega (снимки с телефона 1080×2400, 1 точка CSS ≈ 2,6 пикселя),
   цвета — наши (чёрный лак и золото). Файл подключён в base.html с media="(max-width: 980px)". */

@media (max-width: 980px) {
  /* ---- Отступы между блоками главной: 16 точек, как у Platega ---- */
  .layout .page-shell:has(> .dash-balances) {
    gap: 16px;
  }

  /* ---- Шапка: «Обзор ключевых показателей» в две строки слева, «Создать счёт +» справа ---- */
  .layout .page-header.page-header-dash {
    align-items: center;
    margin: 0;
    padding: 4px 0 0;
    border-bottom: 0;
  }

  .layout .page-header-dash .page-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.22;
    letter-spacing: -0.01em;
  }

  .layout .page-header-dash .page-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
  }

  .layout .page-header-dash .section-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
  }

  /* Плюс после текста и без кружка: «Создать счёт +». */
  .layout .page-header-dash .section-actions .btn-plus {
    order: 2;
    width: auto;
    height: auto;
    border: 0;
    background: none;
    box-shadow: none;
    color: inherit;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
  }

  /* ---- Балансы: плитки во всю ширину одна под другой ---- */
  .layout .dash-balances {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    margin: 0;
  }

  .layout .dash-balance {
    min-height: 0;
    align-content: flex-start;
    column-gap: 14px;
    row-gap: 18px;
    padding: 16px 16px 26px;
    border-radius: 20px;
  }

  .layout .dash-balance-icon {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 10px;
    font-size: 16px;
  }

  .layout .dash-balance-icon svg {
    width: 18px;
    height: 18px;
  }

  .layout .dash-balance-icon .dash-balance-glyph {
    width: 22px;
    height: 22px;
  }

  /* Знак валюты перед суммой — того же цвета и размера, что цифры («₽ 1 804.92» у Platega). */
  .layout .dash-balance-copy .dash-balance-amount-m .dash-balance-sign {
    margin: 0;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
  }

  .layout .dash-balance-copy .dash-balance-amount-m {
    min-width: 0;
    color: var(--text);
    font-size: 24px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .layout .dash-balance-copy > span {
    margin: 0;
    font-size: 18px;
    line-height: 1.3;
  }

  /* Строк «Сегодня оплачено…» у Platega нет; остаётся только «N USD₮ в процессе выплаты». */
  .layout .dash-balance-copy small {
    display: none;
  }

  .layout .dash-balance-copy small.dash-balance-held {
    display: block;
    margin-top: -14px;
    font-size: 14px;
  }

  /* ---- Валюта и период: сегменты высотой 40, «Период» и пояс — плашки той же высоты ---- */
  .layout .dash-toolbar {
    gap: 16px;
    margin: 0;
  }

  .layout .dash-seg {
    gap: 2px;
    padding: 5px;
    border-radius: 10px;
  }

  .layout .dash-seg .dash-seg-item {
    min-height: 27px;
    padding: 0 12px;
    border-radius: 7px;
    font-size: 14px;
  }

  .layout .dash-toolbar .period-range-chip {
    min-height: 40px;
    gap: 10px;
    padding: 0 16px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
  }

  /* Текущее время в выбранном поясе — плашка той же высоты, что «Период». */
  .layout .dash-clock {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--hairline, rgba(255, 255, 255, 0.06));
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--text);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .layout .dash-clock:empty {
    display: none;
  }

  .layout .dash-toolbar .period-range-icon svg {
    width: 16px;
    height: 16px;
  }

  /* «По времени браузера ⌄»: рамка одна — у кнопки своего списка (см. styles.css). */
  .layout .dash-toolbar .dash-tz .select-trigger {
    min-height: 38px;
    gap: 10px;
    padding: 0 16px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
  }

  .layout .dash-toolbar .dash-tz .select-value {
    font-size: 16px;
  }

  /* Окно дат «Период» открывается вправо от кнопки и не шире экрана. */
  .layout .dash-toolbar .period-range-pop {
    left: 0;
    right: auto;
    flex-wrap: wrap;
    width: max-content;
    max-width: calc(100vw - 32px);
  }

  /* ---- Плашки показателей и график в одной панели ---- */
  .layout .dash-chart {
    display: flex;
    flex-direction: column;
    padding: 16px;
    border-radius: 24px;
  }

  .layout .dash-chips {
    order: 1;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    margin: 0 0 12px;
  }

  /* Плашка как у Platega: точка слева по центру, над суммой подпись капсом. */
  .layout .dash-chips .dash-chip {
    position: relative;
    min-height: 0;
    justify-content: center;
    gap: 2px;
    padding: 9px 16px 10px 28px;
    border-radius: 12px;
  }

  .layout .dash-chip-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.03em;
    line-height: 1.35;
    text-transform: uppercase;
  }

  .layout .dash-chip-label .dash-chip-dot {
    position: absolute;
    top: 50%;
    left: 11px;
    width: 8px;
    height: 8px;
    margin-top: -4px;
  }

  .layout .dash-chip-values-m {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 14px;
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
  }

  /* Второе число (USD₮ в режиме «Все») — через тонкую черту. */
  .layout .dash-chip-values-m > span + span {
    position: relative;
  }

  .layout .dash-chip-values-m > span + span::before {
    content: "";
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: -8px;
    width: 1px;
    background: var(--border);
  }

  /* График без своей рамки прямо на панели; «Линии | Столбцы» — под ним справа, как у Platega. */
  .layout .dash-plot {
    order: 2;
    border: 0;
    border-radius: 0;
    background: none;
  }

  .layout .dash-chart-caption {
    order: 3;
    justify-content: flex-end;
    margin: 8px 0 0;
  }

  /* Под графиком у Platega только «Линии | Столбцы»: без заголовка, чипа периода и «в рублях»
     (валюту и так показывает подсказка графика: «13 787 ₽»). */
  .layout .dash-chart-title,
  .layout .dash-chart-actions > .toolbar-chip {
    display: none;
  }

  .layout .dash-chart-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
  }

  .layout .dash-chart-mode {
    padding: 4px;
    border-radius: 12px;
  }

  .layout .dash-chart-mode-btn {
    min-height: 34px;
    gap: 8px;
    padding: 0 16px;
    border-radius: 9px;
    font-size: 14px;
  }

  .layout .dash-chart-mode-btn svg {
    width: 16px;
    height: 16px;
  }

  /* ---- Вкладки «История транзакций · Экспорт транзакций · …» ----
     Две первые целиком в строке, третья — за краем, строка листается вбок, как у Platega. */
  .layout .dash-tabs {
    flex-wrap: nowrap;
    gap: 30px;
    margin: -2px 0 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .layout .dash-tabs::-webkit-scrollbar {
    display: none;
  }

  .layout .dash-tab {
    flex: none;
    padding-bottom: 14px;
    font-size: 16px;
    white-space: nowrap;
  }

  /* ---- Панель истории: поиск + «Фильтры», ниже «Найти» и «Действия» ---- */
  .layout .dash-history.table-surface {
    padding: 16px;
    border-radius: 24px;
  }

  /* Между рядами 10 точек: пустой разрыв строки (::after ниже) сам занимает ряд,
     поэтому зазор рядов — половина. */
  .layout .dash-history-tools {
    gap: 5px 10px;
    margin-bottom: 7px;
  }

  .layout .dash-history .tool-search {
    flex: 1 1 0;
    min-width: 0;
    order: 1;
  }

  .layout .dash-history .tool-search input[type="search"] {
    min-height: 46px;
    padding: 0 44px 0 44px;
    border-color: transparent;
    border-radius: 12px;
    background-color: var(--bg);
    font-size: 16px;
  }

  .layout .dash-history .tool-search-icon {
    left: 16px;
  }

  .layout .dash-history .tool-search-icon svg {
    width: 20px;
    height: 20px;
  }

  /* Значок «!» в поле поиска: касание показывает, что можно искать. */
  /* Значок не позиционирован (лежит поверх конца поля за счёт отрицательного отступа), поэтому
     подсказка ниже меряется от всего поля поиска и не уезжает за левый край экрана. */
  .layout .dash-search-tip {
    display: inline-flex;
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    margin: 0 12px 0 -34px;
    color: var(--muted);
    cursor: pointer;
    outline: none;
  }

  .layout .dash-search-tip svg {
    width: 22px;
    height: 22px;
  }

  .layout .dash-search-tip::after {
    content: attr(data-tip);
    position: absolute;
    z-index: 45;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-strong);
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9);
    color: var(--text);
    font-size: 14px;
    line-height: 1.4;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
  }

  .layout .dash-search-tip.is-open::after,
  .layout .dash-search-tip:focus-visible::after,
  .layout .dash-search-tip:hover::after {
    opacity: 1;
    transform: none;
  }

  .layout .dash-history .dash-filters {
    order: 2;
    flex: none;
  }

  .layout .dash-history-tools > .pill-button {
    order: 3;
  }

  .layout .dash-history .pill-button {
    min-height: 46px;
    gap: 10px;
    padding: 0 16px;
    border-color: transparent;
    border-radius: 12px;
    font-size: 16px;
  }

  /* «Сбросить» (при поиске или фильтрах) — ссылка без рамки, переносится на свою строку. */
  .layout .dash-history .pill-button-ghost {
    min-height: 36px;
    padding: 0 4px;
    font-size: 16px;
  }

  .layout .dash-tool-icon {
    width: 20px;
    height: 20px;
    flex: none;
  }

  /* «Найти» и «Действия» с новой строки, как у Platega. */
  .layout .dash-history-tools > button[type="submit"].pill-button {
    margin-right: 0;
  }

  .layout .dash-history-tools::after {
    content: "";
    order: 2;
    flex: 0 0 100%;
    height: 0;
  }

  /* Окно фильтров открывается под кнопкой к левому краю панели и не шире экрана. */
  .layout .dash-history .dash-filters-pop {
    left: auto;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    width: min(300px, calc(100vw - 64px));
  }

  .layout .dash-history .dash-filters-pop .select-trigger,
  .layout .dash-history .dash-filters-pop .period-range-apply {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  /* «Найдено записей» у Platega отступает от правого края на 16 точек. */
  .layout .dash-history .conversion-board-head {
    padding: 0 16px 0 0;
  }

  .layout .dash-history .records-found {
    color: var(--muted);
    font-size: 14px;
  }

  .layout .dash-history .records-found-count {
    color: var(--text);
    font-weight: 600;
  }

  /* ---- История карточками, как у Platega: разделители внутри одной панели ---- */
  .layout .m-tx-list {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* Размеры — карточка Platega: сумма 20, статус 16, способ и «Подробнее» 14, плашка и даты 12. */
  .layout .m-tx {
    display: flex;
    flex-direction: column;
    gap: 13px;
    padding: 20px 0 13px;
  }

  .layout .m-tx + .m-tx {
    border-top: 1px solid var(--hairline, rgba(255, 255, 255, 0.08));
  }

  .layout .m-tx-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 12px;
    min-width: 0;
  }

  .layout .m-tx-amount {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
  }

  .layout .m-tx-amount strong {
    color: var(--text);
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    line-height: 1.25;
  }

  .layout .m-tx-amount small {
    color: var(--muted);
    font-size: 14px;
  }

  .layout .m-tx-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    color: var(--muted);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
  }

  .layout .m-tx-status svg {
    width: 15px;
    height: 15px;
    flex: none;
  }

  .layout .m-tx-status.success {
    color: var(--success);
  }

  .layout .m-tx-status.danger {
    color: var(--danger);
  }

  .layout .m-tx-status.warning {
    color: var(--warning);
  }

  /* Ожидание с таймером: «В ожидании 14:32 ◔», последние 2 минуты — красным и с пульсом. */
  .layout .m-tx-status.status-timer {
    font-variant-numeric: tabular-nums;
  }

  .layout .m-tx-status.status-timer.is-urgent {
    color: var(--danger);
  }

  .layout .m-tx-status.status-timer.is-urgent .status-timer-ring {
    animation: status-timer-pulse 1s ease-in-out infinite;
  }

  .layout .m-tx-status.status-timer.is-over .status-timer-ring {
    display: none;
  }

  .layout .m-tx-status .status-timer-ring,
  .layout .m-tx-status .status-timer-ring svg {
    width: 16px;
    height: 16px;
  }

  .layout .m-tx .cb-pill {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 17px;
  }

  .layout .m-tx-date {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    opacity: 0.78;
    white-space: nowrap;
  }

  .layout .m-tx .payment-identity {
    gap: 10px;
    min-width: 0;
  }

  .layout .m-tx .payment-identity strong {
    color: var(--text);
    font-size: 14px;
    font-weight: 400;
  }

  /* Значок способа без подложки, как логотип СБП у Platega; у банков плашка остаётся. */
  .layout .m-tx .payment-mark {
    --payment-mark-size: 22px;
  }

  .layout .m-tx .payment-mark:not(.payment-mark-bank) {
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }

  .layout .m-tx .payment-mark-sbp img {
    width: 20px;
    height: 20px;
  }

  .layout .m-tx-more {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: 14px;
  }

  .layout .m-tx-more svg {
    width: 15px;
    height: 15px;
  }

  .layout .m-tx-more:hover,
  .layout .m-tx-more:focus-visible {
    color: var(--text);
  }

  /* ---- Низ истории: «На странице» и номера страниц ---- */
  .layout .dash-foot {
    gap: 12px;
    margin-top: 0;
  }

  .layout .dash-foot .conversion-per-page {
    font-size: 15px;
  }

  .layout .dash-foot .conversion-per-page select {
    min-height: 40px;
    font-size: 15px;
  }

  .layout .dash-foot .conversion-page,
  .layout .dash-foot .conversion-page-gap {
    min-width: 40px;
    min-height: 40px;
    font-size: 15px;
  }
}

/* ---- Шторка «Подробнее» платежа (содержимое из <template>, открывается только на телефоне) ---- */
/* Строки, размеры и отступ под ✕ задаёт общая шторка (styles.css) — они уже как у Platega:
   текст 18, значения с 162-й точки, шаг строк 45. Здесь только своё содержимое платежа. */
@media (max-width: 980px) {
  /* ID переносится по знакам, чтобы строки были полными (у нашего ID нет дефисов, как у Platega). */
  .m-tx-sheet-id {
    min-width: 0;
    word-break: break-all;
  }

  .m-tx-sheet-stack {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
  }

  .m-tx-sheet-stack small {
    color: var(--muted);
    font-size: 15px;
    overflow-wrap: anywhere;
  }

  .m-tx-sheet .provider-badge {
    font-size: 14px;
  }

  .m-tx-sheet .cb-pill {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 14px;
  }

  /* Переключатель «Статус · Данные заказа · Вебхуки». */
  .m-tx-seg {
    display: flex;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-soft);
  }

  .m-tx-seg-item {
    flex: 1 1 auto;
    min-height: 30px;
    padding: 0 8px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: 18px;
    font-weight: 400;
    line-height: 1.2;
    white-space: nowrap;
  }

  .m-tx-seg-item.is-active {
    background: linear-gradient(180deg, #ecd9a4, #cbb069);
    color: #1a1610;
    font-weight: 500;
  }

  .m-tx-view {
    margin-top: 32px;
  }

  .m-tx-view[hidden] {
    display: none;
  }

  /* Блок состояния, как «Платёж успешно завершён / Статус: Подтверждён» у Platega. */
  .m-tx-state {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 21px 22px;
    border-radius: 16px;
    background: var(--panel-soft);
  }

  .m-tx-state-icon {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--muted);
    color: #0b0b0b;
  }

  .m-tx-state-icon svg {
    width: 15px;
    height: 15px;
  }

  .m-tx-state-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
  }

  .m-tx-state-copy strong {
    color: var(--text);
    font-size: 18px;
    font-weight: 400;
    line-height: 1.35;
  }

  .m-tx-state-copy small {
    color: var(--muted);
    font-size: 14px;
  }

  .m-tx-state-success {
    background: color-mix(in srgb, var(--success) 13%, transparent);
  }

  .m-tx-state-success .m-tx-state-icon {
    background: var(--success);
  }

  .m-tx-state-danger {
    background: color-mix(in srgb, var(--danger) 13%, transparent);
  }

  .m-tx-state-danger .m-tx-state-icon {
    background: var(--danger);
  }

  .m-tx-state-warning {
    background: color-mix(in srgb, var(--warning) 13%, transparent);
  }

  .m-tx-state-warning .m-tx-state-icon {
    background: var(--warning);
  }
}

/* Узкий телефон (360 точек): четыре кнопки периода влезают без прокрутки. */
@media (max-width: 380px) {
  .layout .dash-seg .dash-seg-item {
    padding: 0 10px;
  }

  /* «Период» и плашка времени остаются в одной строке, как у Platega. */
  .layout .dash-toolbar .period-range-chip,
  .layout .dash-clock {
    padding: 0 12px;
  }

  /* Две вкладки по-прежнему целиком в строке. */
  .layout .dash-tabs {
    gap: 24px;
  }

  .layout .dash-tab {
    font-size: 15px;
  }

  .m-tx-seg-item {
    padding: 0 6px;
  }
}
