/* Оформление Sana Trade.
   Две темы, выбираются сами по теме телефона или компьютера:
   тёмная «Винный вечер» (по умолчанию) и светлая «Молочный бутик».
   Бордо — кнопки и действия; цвет денег — только мои деньги;
   изумруд — только «хорошо»; жёлтый — предупреждения.
   Контраст всего текста — не меньше 4,5 в самом неудачном месте
   (стекло над центром пятна, текст прямо на фоне над пятном, сплошная карточка). */

/* ---------- Тёмная «Винный вечер» ---------- */
:root {
  --bg: #17111a;
  --blob-1: rgba(140,37,71,.40);   /* бордо #8c2547 */
  --blob-2: rgba(23,100,76,.40);   /* изумруд #17644c */
  --blob-3: rgba(122,90,20,.40);   /* золото #7a5a14 */
  --glass: rgba(255,255,255,.08); --glass-line: rgba(255,255,255,.14);
  --solid: #2a2330;                /* карточка без размытия */
  --text: #f4eff2; --text-2: #ddd5df; --muted: #b9b2bb; --line: rgba(255,255,255,.12);
  --money: #f0cf78;
  --accent: #8a2a4a; --on-accent: #fbeff3;
  --link: #ec9ab4; --accent-soft: rgba(138,42,74,.30); --accent-line: rgba(236,154,180,.45);
  --good: #2f9a72; --good-text: #5cc79c; --good-soft: rgba(47,154,114,.18); --good-line: rgba(92,199,156,.45);
  --warn-text: #f2d27a; --warn-bg: rgba(242,210,122,.10); --warn-line: rgba(242,210,122,.38);
  --danger: #ff9182; --danger-bg: transparent;   /* на розовой подложке красный не дотягивал до 4,5 */
  --field: #120d14; --field-line: rgba(255,255,255,.20); --placeholder: #8f8792;
  --track: rgba(255,255,255,.14); --ring-ink: #a39aa6;
  --tag-bg: rgba(255,255,255,.10); --tag-text: #ddd5df;
  color-scheme: dark;
}

/* ---------- Светлая «Молочный бутик» ---------- */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f0e8;
    --blob-1: rgba(240,211,220,.70);  /* #f0d3dc */
    --blob-2: rgba(233,220,184,.70);  /* #e9dcb8 */
    --blob-3: rgba(217,236,226,.70);  /* #d9ece2 */
    --glass: rgba(255,255,255,.75); --glass-line: #e8ddd0;
    --solid: #fdfaf6;
    /* второстепенный и деньги темнее заданных (#8a7d73, #9a7420): иначе контраст ниже 4,5 */
    --text: #2a1a20; --text-2: #4a3a40; --muted: #6b6159; --line: #ebe1d5;
    --money: #7d5e1a;
    --accent: #7a2440; --on-accent: #ffffff;
    --link: #7a2440; --accent-soft: rgba(122,36,64,.08); --accent-line: rgba(122,36,64,.35);
    --good: #2f8f6b; --good-text: #1d7050; --good-soft: rgba(47,143,107,.12); --good-line: rgba(29,112,80,.35);
    --warn-text: #7a5a00; --warn-bg: rgba(233,190,80,.16); --warn-line: rgba(154,116,32,.35);
    --danger: #b3261e; --danger-bg: transparent;
    --field: #ffffff; --field-line: #e0d4c6; --placeholder: #6b6159;
    --track: rgba(42,26,32,.12); --ring-ink: #8a7d73;
    --tag-bg: rgba(42,26,32,.06); --tag-text: #4a3a40;
    color-scheme: light;
  }
}

/* ---------- Основа ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 400 17px/1.4 "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
b, strong { font-weight: 600; }
a { color: var(--link); }

/* Пятна стоят за колонкой с карточками, а не по углам окна, — чтобы стекло было видно.
   Слой закреплён и не прокручивается вместе со страницей. */
body::before {
  content: ''; position: fixed; top: 0; bottom: 0; left: 50%; z-index: -1; pointer-events: none;
  width: min(100vw, 620px); transform: translateX(-50%);
  background:
    radial-gradient(closest-side, var(--blob-1), transparent) 0% 8% / 75% 45% no-repeat,
    radial-gradient(closest-side, var(--blob-2), transparent) 100% 38% / 70% 42% no-repeat,
    radial-gradient(closest-side, var(--blob-3), transparent) 70% 92% / 80% 45% no-repeat;
}

/* Колонка с содержимым по центру, не шире 480 */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding: 12px 16px calc(32px + env(safe-area-inset-bottom)); }

/* ---------- Стекло ---------- */
/* Запасной вид, если браузер не умеет размытие, — сплошная карточка.
   Класс no-blur на <html> включает запасной вид вручную (для проверки). */
.card, .back, .pick a, .pick span { background: var(--solid); border: 1px solid var(--glass-line); }
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html:not(.no-blur) :is(.card, .back, .pick a, .pick span) {
    background: var(--glass);
    -webkit-backdrop-filter: blur(20px) saturate(140%); backdrop-filter: blur(20px) saturate(140%);
  }
}

/* ---------- Шапка ---------- */
.top { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.top h1 { font-size: 22px; font-weight: 600; margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.back {
  width: 48px; height: 48px; flex: none; border-radius: 24px;
  color: var(--text); font-size: 24px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.nav { display: flex; gap: 8px; margin: 4px 0 12px; }
.nav + *, .status + .btn { margin-top: 0; }
.nav a {
  min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--field-line);
  display: inline-flex; align-items: center; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 500;
}
.nav a.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--link); }
.nav .logout { margin-left: auto; }
.nav .logout button { min-height: 44px; background: none; border: 0; color: var(--muted); font: inherit; font-size: 15px; cursor: pointer; }

/* Сообщение после действия. Приходит вместе со страницей, поэтому ничего не сдвигает. */
.status { display: flex; align-items: center; margin-bottom: 12px; }
.status .msg {
  max-width: 100%; padding: 6px 14px; border-radius: 18px; font-size: 15px; font-weight: 500;
  color: var(--link); border: 1px solid var(--accent-line); background: var(--accent-soft);
}
.status .msg.error { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }

/* ---------- Карточки и текст ---------- */
.card { border-radius: 22px; padding: 18px; margin-bottom: 12px; }
.card > :first-child { margin-top: 0; }
a.card { display: block; color: var(--text); text-decoration: none; }
.label { text-transform: uppercase; letter-spacing: 1.4px; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
h2 { color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 1.8px; text-transform: uppercase; margin: 22px 4px 8px; }
.sub { font-size: 14px; color: var(--muted); }
.note-text { white-space: pre-line; color: var(--text-2); font-size: 15px; margin-top: 8px; overflow-wrap: anywhere; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--tag-bg); color: var(--tag-text); white-space: nowrap; }
.nowrap, .money { white-space: nowrap; }
.money, .rows, .sub, .path, input, .warn, .summary { font-variant-numeric: tabular-nums; }
.is-money { color: var(--money); }
.empty { color: var(--muted); font-size: 15px; padding: 6px 0; }

/* Строка «название — значение»: подпись слева не сжимается, длинный текст справа переносится, числа — нет */
.rows { font-size: 15px; }
.rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.rows > div > :first-child { flex: 0 0 auto; max-width: 60%; overflow-wrap: anywhere; }
.rows > div > :last-child { min-width: 0; white-space: nowrap; text-align: right; }
.rows > div > .wrap { white-space: normal; overflow-wrap: anywhere; }
.rows .total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-weight: 600; }

/* ---------- Кнопки: таблетка 52, скругление 26, сплошной цвет, текст 16 / 500 в одну строку ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 52px; border-radius: 26px;
  border: 0; font: 500 16px/1 "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  white-space: nowrap; cursor: pointer; text-decoration: none; touch-action: manipulation; margin-top: 8px;
}
.btn-main { background: var(--accent); color: var(--on-accent); }
.btn-main:active { filter: brightness(.9); }
/* Второстепенные — с рамкой, без заливки */
.btn-second { background: transparent; color: var(--link); border: 1px solid var(--accent-line); }
.btn-quiet { background: transparent; color: var(--muted); border: 1px solid var(--field-line); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-done { background: transparent; color: var(--good-text); border: 1px solid var(--good-line); cursor: default; }

/* ---------- Предупреждение ---------- */
.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text); border-radius: 16px; padding: 10px 12px; font-size: 15px; margin-bottom: 12px; }
.warn-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 8px;
  vertical-align: -4px; border-radius: 50%; border: 1px solid currentColor; font-size: 13px; font-weight: 600;
}

/* ---------- Список выкупов ---------- */
.vykup-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.vykup-title b { font-size: 18px; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Путь статусов (даты) ---------- */
.path { list-style: none; margin: 0; padding: 0; }
.path li { display: flex; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line); }
.path li:last-child { border-bottom: 0; }
.path .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--track); flex: none; }
.path li.passed .dot { background: var(--accent); border-color: var(--accent); }
.path li.passed.is-done .dot { background: var(--good); border-color: var(--good); }
.path .name { flex: 1; min-width: 0; }
.path li:not(.passed) .name { color: var(--muted); }
.path .date {
  min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--field-line);
  display: inline-flex; align-items: center; white-space: nowrap; color: var(--text); text-decoration: none; font-size: 15px;
}
.path span.date { border-color: transparent; color: var(--text-2); }
.path .warn-line { display: block; font-size: 13px; color: var(--warn-text); margin-top: 2px; }

/* ---------- Позиции ---------- */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.item:last-child { border-bottom: 0; }
.item .name { flex: 1; min-width: 0; }
.item .name b { display: block; font-size: 16px; overflow-wrap: anywhere; }
.item .right { text-align: right; white-space: nowrap; font-size: 15px; }

/* ---------- Выбор товара кнопками ---------- */
.pick { display: flex; flex-direction: column; gap: 8px; }
.pick a, .pick span {
  min-height: 52px; padding: 10px 16px; border-radius: 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text); text-decoration: none;
}
.pick span { color: var(--muted); }

/* ---------- Поля ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  width: 100%; min-height: 52px; border-radius: 16px; padding: 0 14px; font: inherit; font-size: 18px;
  background: var(--field); border: 1px solid var(--field-line); color: var(--text);
}
.field textarea { padding: 12px 14px; min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input::placeholder, .field textarea::placeholder { color: var(--placeholder); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }
.field .help { font-size: 13px; color: var(--muted); margin-top: 4px; }
.field .err { font-size: 14px; color: var(--danger); margin-top: 4px; }
.form-errors { color: var(--danger); font-size: 15px; margin-bottom: 12px; }

.links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; font-size: 15px; }
.links form { display: inline; }
.link { background: none; border: 0; padding: 10px 0; color: var(--link); font: inherit; font-size: 15px; cursor: pointer; text-decoration: underline; }
.link.muted { color: var(--muted); }

/* ---------- Дорога выкупа ---------- */
/* 4 круга, линия между центрами крайних кругов, заполнение до текущего.
   Линия лежит позади кругов (z-index), а у кругов плотная заливка цветом карточки —
   линия видна только между кругами и не перечёркивает иконки.
   Текущий круг крупнее через transform — соседи не сдвигаются. */
.road { position: relative; margin: 2px 0 14px; }
.road-track { position: absolute; z-index: 0; left: 12.5%; right: 12.5%; top: 21px; height: 3px; border-radius: 2px; background: var(--track); }
.road-fill { height: 100%; border-radius: 2px; background: var(--accent); }
.road.is-done .road-fill { background: linear-gradient(90deg, var(--accent), var(--good)); }
.road-stages { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); position: relative; z-index: 1; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.ring {
  position: relative; width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--solid); border: 1px solid var(--field-line); color: var(--ring-ink);   /* плотная заливка */
}
.ring svg { width: 22px; height: 22px; }
/* Пройденный: бордовый оттенок поверх плотной заливки — сквозь круг ничего не просвечивает */
.stage.passed .ring { background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--solid); border-color: var(--accent); color: var(--link); }
.stage.current .ring { background: var(--accent); border-color: var(--accent); color: var(--on-accent); transform: scale(1.14); box-shadow: 0 0 0 4px var(--accent-soft); }
.road.is-done .stage .ring { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.road-check {
  position: absolute; right: -6px; top: -6px; width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--good); color: #fff; box-shadow: 0 0 0 2px var(--bg);
}
.road-check svg { width: 13px; height: 13px; stroke-width: 3; }
.stage-label { font-size: 13px; color: var(--muted); text-align: center; white-space: nowrap; }
.stage.passed .stage-label, .road.is-done .stage-label { color: var(--text-2); }
.stage.current .stage-label { color: var(--text); font-weight: 600; }

/* ---------- Карточка в списке выкупов ---------- */
.vcard-supplier { margin-top: 2px; overflow-wrap: anywhere; }
.mini { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.mini-road { display: inline-flex; align-items: center; flex: none; }
.mini-road i { width: 8px; height: 8px; border-radius: 50%; background: var(--track); position: relative; }
.mini-road i + i { margin-left: 12px; }
.mini-road i + i::before { content: ''; position: absolute; right: 8px; top: 3.5px; width: 12px; height: 1px; background: var(--track); }
.mini-road i.passed, .mini-road i.current { background: var(--accent); }
.mini-road i.passed + i.passed::before, .mini-road i.passed + i.current::before { background: var(--accent); }
.mini-road i.current { box-shadow: 0 0 0 3px var(--accent-soft); }
.mini-road.is-done i, .mini-road.is-done i + i::before { background: var(--good); box-shadow: none; }
.step-text { font-size: 14px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.step-text.done { color: var(--good-text); }
.vcard-sums { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-top: 10px; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.need-rate {
  display: inline-flex; align-items: center; white-space: nowrap; font-size: 14px; font-weight: 500;
  color: var(--warn-text); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 999px; padding: 2px 10px 2px 4px;
}
.need-rate .warn-icon { margin-right: 6px; vertical-align: 0; width: 18px; height: 18px; font-size: 12px; }
.issued { margin-top: 10px; }
.issued-line { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.issued-bar { height: 4px; border-radius: 2px; background: var(--track); margin-top: 6px; overflow: hidden; }
.issued-bar i { display: block; height: 100%; background: var(--accent); }

/* ---------- Плитки видов товара ---------- */
/* Шесть мягких цветов, подходят к обеим темам. Иконка — тёмная на светлой плитке и светлая на тёмной. */
.tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; border-radius: 14px; background: var(--tile-bg); color: var(--tile-ink);
}
.tile svg { width: 24px; height: 24px; }
.tile-s { width: 28px; height: 28px; border-radius: 9px; }
.tile-s svg { width: 17px; height: 17px; }
:root {
  --t0-bg: rgba(236,154,180,.18); --t0-ink: #f2b3c7;   /* роза */
  --t1-bg: rgba(240,207,120,.16); --t1-ink: #f0cf78;   /* песок */
  --t2-bg: rgba(92,199,156,.16);  --t2-ink: #8fdcbb;   /* шалфей */
  --t3-bg: rgba(130,175,230,.16); --t3-ink: #a9c8ef;   /* небо */
  --t4-bg: rgba(180,150,230,.16); --t4-ink: #cdb8f0;   /* сирень */
  --t5-bg: rgba(240,160,120,.16); --t5-ink: #f3bc9a;   /* персик */
  --tn-bg: rgba(255,255,255,.10); --tn-ink: #b9b2bb;   /* без вида */
}
@media (prefers-color-scheme: light) {
  :root {
    --t0-bg: #f6dde5; --t0-ink: #8a2a4a;
    --t1-bg: #f1e4c6; --t1-ink: #7d5e1a;
    --t2-bg: #dcefe5; --t2-ink: #1d7050;
    --t3-bg: #dde9f5; --t3-ink: #2d5f8f;
    --t4-bg: #e9e0f3; --t4-ink: #5f3f8a;
    --t5-bg: #f7e1d3; --t5-ink: #94502a;
    --tn-bg: #efe8df; --tn-ink: #6b6159;
  }
}
.tile-c0 { --tile-bg: var(--t0-bg); --tile-ink: var(--t0-ink); }
.tile-c1 { --tile-bg: var(--t1-bg); --tile-ink: var(--t1-ink); }
.tile-c2 { --tile-bg: var(--t2-bg); --tile-ink: var(--t2-ink); }
.tile-c3 { --tile-bg: var(--t3-bg); --tile-ink: var(--t3-ink); }
.tile-c4 { --tile-bg: var(--t4-bg); --tile-ink: var(--t4-ink); }
.tile-c5 { --tile-bg: var(--t5-bg); --tile-ink: var(--t5-ink); }
.tile-cnone { --tile-bg: var(--tn-bg); --tile-ink: var(--tn-ink); }

.vcard-head { display: flex; align-items: center; gap: 12px; }
.vcard-head-text { flex: 1; min-width: 0; }
.type-head { display: flex; align-items: center; gap: 10px; }

/* Выбор иконки вида — крупные кнопки по три в ряд */
.icon-field { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.icon-field legend { font-size: 14px; color: var(--muted); margin-bottom: 6px; padding: 0; }
.icon-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.icon-choice { position: relative; display: block; cursor: pointer; }
.icon-choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.icon-choice-box {
  display: flex; align-items: center; justify-content: center; height: 56px; border-radius: 16px;
  background: var(--field); border: 1px solid var(--field-line); color: var(--text-2);
}
.icon-choice-box svg { width: 26px; height: 26px; }
.icon-choice-name { display: block; text-align: center; font-size: 13px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.icon-choice input:checked + .icon-choice-box { border: 2px solid var(--link); background: var(--accent-soft); color: var(--link); }
.icon-choice input:checked ~ .icon-choice-name { color: var(--text); font-weight: 500; }
.icon-choice input:focus-visible + .icon-choice-box { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Сводка над «+ Выкуп» ---------- */
/* «В работе» и «В пути» — в одну строку, «Закуплено» — на всю ширину ниже:
   в трети ширины не помещалось уже 999 999,99 ¥. Числа не переносятся. */
.summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; padding: 16px 18px; }
.summary-cell.wide { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 12px; }
.summary .label { margin-bottom: 4px; white-space: nowrap; }
.summary-num { font-size: 21px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.summary + .btn { margin-top: 0; }
