/* Кнопки, чипы, поля, списки операций, шторки, тосты, пустые состояния. */

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border-radius: 12px;
  font-size: 14.5px; font-weight: 600; color: var(--text);
  background: var(--fill); border: 1px solid transparent;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn:hover { background: var(--fill-2); }
.btn:active { transform: scale(0.97); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { color: #fff; background: var(--accent); box-shadow: 0 6px 16px -10px var(--accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--fill); }
.btn-danger, .btn-ghost.danger { color: var(--expense); background: transparent; border-color: transparent; }
.btn-danger:hover, .btn-ghost.danger:hover { background: color-mix(in srgb, var(--expense) 10%, transparent); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 11px; }
.btn-sm svg { width: 15px; height: 15px; }
/* Иконка строго по центру и кнопка не сжимается в строке с длинным текстом: иначе
   один и тот же крестик в соседних карточках выглядит по-разному. */
.btn-icon {
  flex: none; display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border-radius: 12px; background: var(--glass-soft); border: 1px solid var(--glass-edge); color: var(--text-2);
}
.btn-icon svg { display: block; width: 18px; height: 18px; }
.btn-icon.btn-xs { width: 28px; height: 28px; border-radius: 9px; }
.btn-icon.btn-xs svg { width: 16px; height: 16px; stroke-width: 2; }
.btn-icon.btn-sm { width: 34px; height: 34px; border-radius: 11px; }
.btn-icon.btn-sm svg { width: 17px; height: 17px; }

.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn-block { width: 100%; }

/* ---------- Чипы / сегменты ---------- */
.chips { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-2);
  background: var(--glass-soft); border: 1px solid var(--glass-edge);
  transition: all var(--dur) var(--ease);
}
.chip svg { width: 14px; height: 14px; }
.chip.active { color: #fff; background: var(--accent-grad); border-color: transparent; }
.chip.active svg { color: #fff; }

.segment { display: inline-flex; padding: 3px; gap: 2px; border-radius: 13px; background: var(--fill); height: var(--field); }
.segment.segment-block { display: flex; }
.segment.segment-block button { flex: 1; }
.segment button {
  height: 38px; padding: 0 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  transition: all var(--dur) var(--ease);
}
.segment button:hover { color: var(--text); }
.segment button.active { background: var(--segment-active); color: var(--text); box-shadow: var(--segment-shadow); }

/* ---------- Поля ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-3); padding-left: 2px; }
.input, .select, textarea.input {
  height: var(--field); padding: 0 13px; border-radius: 12px; width: 100%;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  font-size: 15px; font-family: inherit;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea.input { height: auto; padding: 11px 13px; resize: vertical; min-height: 76px; }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--accent); outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-3); }
.select { appearance: none; background-image: none; }
.input-lg { height: var(--field-lg); font-size: 26px; font-weight: 700; font-family: var(--font-num); letter-spacing: -0.02em; }
/* Переключатель в стиле iOS: используем везде вместо галочек. */
.switch { position: relative; width: 48px; height: 29px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--fill-2);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 25px; height: 25px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18), 0 3px 8px rgba(15, 23, 42, 0.16);
  transition: transform 220ms cubic-bezier(0.32, 1.2, 0.5, 1);
}
.switch input:checked + span { background: var(--accent); box-shadow: inset 0 0 0 1px transparent; }
.switch input:checked + span::after { transform: translateX(19px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch input[disabled] { cursor: default; }
.switch input[disabled] + span { opacity: 0.45; }

/* Компактный переключатель с подписью — для строки внутри шторки. */
.switch-sm { width: 38px; height: 23px; }
.switch-sm span::after { width: 19px; height: 19px; }
.switch-sm input:checked + span::after { transform: translateX(15px); }
.switch-row {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; font-weight: 550; color: var(--text-2); user-select: none;
}
.switch-row:has(input:checked) .switch-label { color: var(--text); }

.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); }
.search .input { padding-left: 38px; }

/* ---------- Списки ---------- */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 4px; width: 100%; text-align: left;
  border-radius: 12px; transition: background var(--dur) var(--ease);
}
.list-row:hover { background: var(--fill); }
/* Разделитель — отдельной линией: inset-тень на скруглённой строке рисовала «ушки» по углам. */
.list-row { position: relative; }
.list-row + .list-row::before { content: ""; position: absolute; left: 4px; right: 4px; top: 0; height: 1px; background: var(--line); pointer-events: none; }

.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: none; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px;
}
.avatar svg { width: 19px; height: 19px; stroke-width: 2; }
.avatar-sm { width: 32px; height: 32px; border-radius: 11px; }
.avatar-sm svg { width: 18px; height: 18px; stroke-width: 1.75; }

/* Логотип банка: плитка приложения во всю ячейку. Сами файлы уже приведены к одному
   квадрату (scripts/logos.py), поэтому здесь ни полей, ни масштабирования не нужно. */
.avatar.logo {
  position: relative;
  background: #fff;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}
.avatar.logo img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
/* Значок «перевод/обмен» поверх логотипа. */
.avatar.logo .badge-kind {
  position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%;
  display: grid; place-items: center; background: var(--neutral); color: #fff; border: 1.5px solid var(--glass-strong);
}
.avatar.logo .badge-kind svg { width: 10px; height: 10px; }

.amount { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.amount-lg { font-size: 34px; font-weight: 760; letter-spacing: -0.035em; }
.amount-xl { font-size: 42px; font-weight: 780; letter-spacing: -0.04em; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--fill); color: var(--text-2); }
.pill svg { width: 12px; height: 12px; }
.pill-warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill-ok { background: color-mix(in srgb, var(--income) 14%, transparent); color: var(--income); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Шторка / модалка ----------
   Телефон: лист снизу с ручкой. Большой экран: окно по центру.
   Скроллится только тело — шапка и кнопки всегда на виду. */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: var(--scrim);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in 160ms var(--ease);
}
.sheet-backdrop.closing { animation: fade-out 150ms var(--ease) forwards; }
.sheet-backdrop.closing .sheet { animation: sheet-down 150ms var(--ease) forwards; }

.sheet {
  position: relative;
  /* Матовое стекло: сильное размытие с подъёмом насыщенности, сверху светлая кромка —
     фон чувствуется, но не мешает читать. */
  background: var(--sheet-bg);
  backdrop-filter: var(--sheet-blur); -webkit-backdrop-filter: var(--sheet-blur);
  border: 1px solid var(--sheet-edge);
  display: flex; flex-direction: column;
  width: 100%; max-width: 540px; max-height: min(92vh, 900px);
  overflow: hidden; overscroll-behavior: contain;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -12px 48px rgba(8, 10, 16, 0.32);
  animation: sheet-up 280ms cubic-bezier(0.22, 1, 0.36, 1);
  transition: transform 180ms var(--ease);
}
.sheet-wide { max-width: 760px; }

@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sheet-down { to { transform: translateY(24px); opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

.sheet-grip {
  flex: none; height: 22px; display: grid; place-items: center; cursor: grab; touch-action: none;
}
.sheet-grip::before { content: ""; width: 40px; height: 4px; border-radius: 999px; background: var(--fill-2); }

.sheet-head {
  flex: none; display: flex; align-items: flex-start; gap: 12px;
  padding: 2px 20px 14px;
}
.sheet-title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.sheet-sub { font-size: 13px; color: var(--text-3); margin-top: 3px; line-height: 1.35; }
.sheet-close {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--fill); color: var(--text-2); border: none; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sheet-close:hover { background: var(--fill-2); color: var(--text); }
.sheet-close svg { width: 17px; height: 17px; }

.sheet-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 2px 20px 18px;
  scrollbar-width: thin; scrollbar-color: var(--fill-2) transparent;
}
.sheet-body::-webkit-scrollbar { width: 8px; }
.sheet-body::-webkit-scrollbar-thumb { background: var(--fill-2); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
.sheet-body > :first-child { margin-top: 0; }

.sheet-foot {
  flex: none; padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--sheet-bg);
  backdrop-filter: var(--sheet-blur); -webkit-backdrop-filter: var(--sheet-blur);
}
.sheet-foot .btn { height: 48px; }

@media (min-width: 720px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet {
    border-radius: var(--radius-xl); max-height: min(86vh, 860px);
    box-shadow: 0 24px 64px rgba(8, 10, 16, 0.38);
    animation: sheet-in 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 18px; }
  @keyframes sheet-in { from { transform: scale(0.97) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* Содержимое шторки: шапка операции, пары «поле — значение», секции. */
.sheet-hero { display: flex; align-items: center; gap: 13px; padding: 2px 0 14px; border-bottom: 1px solid var(--line); }
.sheet-hero-title { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.sheet-hero .amount-lg { margin-left: auto; white-space: nowrap; font-size: 26px; font-weight: 700; }

.kv { display: flex; flex-direction: column; margin: 0; }
.kv-row { display: flex; align-items: baseline; gap: 16px; padding: 11px 2px; font-size: 14px; }
.kv-row + .kv-row { border-top: 1px solid var(--line); }
.kv-row dt { color: var(--text-2); flex: none; }
.kv-row dd { margin: 0; margin-left: auto; text-align: right; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }

.sheet-section { margin-top: 20px; }
.sheet-label { font-size: 13px; font-weight: 650; color: var(--text-2); margin: 0; }

/* ---------- Тосты ---------- */
.toasts { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 22px); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; padding: 10px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  animation: fade-in 180ms var(--ease); max-width: min(92vw, 460px);
}
.toast.error { color: var(--expense); }
.toast.ok { color: var(--income); }
@media (min-width: 980px) { .toasts { bottom: 26px; } }

/* ---------- Пустые состояния и загрузка ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 34px 16px; text-align: center; color: var(--text-3); }
.empty svg { width: 30px; height: 30px; opacity: 0.6; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--fill-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Прогресс-полоски ---------- */
.bar { height: 8px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
