/* ==========================================================================
   PawnBox brandkit
   Золото на тёплом тёмном. Unbounded (дисплей) + Golos Text (интерфейс).
   Всё на токенах: темы (themes/*.css) переопределяют только переменные.
   Диалы: VARIANCE 5 / MOTION 3 / DENSITY 5. Радиусы: 4 / 10 / 16 / pill.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Поверхности */
  --bg: #0c0a08;
  --bg-glow: radial-gradient(1100px 520px at 50% -180px, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%);
  --surface: #14110d;
  --surface-2: #1b1712;
  --surface-3: #221d16;
  --line: color-mix(in srgb, var(--accent) 15%, transparent);
  --line-strong: color-mix(in srgb, var(--accent) 30%, transparent);
  --topbar-bg: rgba(12, 10, 8, .82);

  /* Текст */
  --text: #f4ecdc;
  --text-2: #d9cfbb;
  --muted: #a2977f;
  --muted-2: #7d7362;

  /* Акцент: один на весь продукт */
  --accent: #d4af37;
  --accent-ink: #8a6620;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 34%, transparent);
  --on-accent: #14110d;
  --on-accent-strong: #ffffff;
  --accent-grad-top: #a97d24;
  --danger-deep: #8d3a33;
  --scrim: rgba(6, 5, 4, .72);

  /* Статусы */
  --ok: #6fbf7e;
  --ok-soft: rgba(111, 191, 126, .13);
  --warn: #e0a83c;
  --warn-soft: rgba(224, 168, 60, .13);
  --info: #86a8d8;
  --info-soft: rgba(134, 168, 216, .13);
  --danger: #e0736a;
  --danger-soft: rgba(224, 115, 106, .13);
  --neutral: #a2977f;
  --neutral-soft: rgba(162, 151, 127, .13);

  /* Геометрия */
  --radius-xs: 4px;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-pill: 999px;

  /* Ритм */
  --gap-1: 4px;
  --gap-2: 8px;
  --gap-3: 12px;
  --gap-4: 16px;
  --gap-5: 24px;
  --gap-6: 32px;
  --gap-7: 48px;
  --gap-8: 64px;

  /* Тени: тонированы в фон, без чистого чёрного */
  --shadow-1: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 14px 38px rgba(0, 0, 0, .45);
  --shadow-gold: 0 10px 30px rgba(138, 102, 32, .32);

  /* Рабочие поверхности и градиенты: тема переопределяет их, не трогая верстку.
     Без этих токенов тема не может сменить палитру целиком */
  --rail-top: #131009;
  --rail-bottom: #0a0907;
  --sunken: #100e0b;
  --gold-1: #e6c765;
  --gold-2: #a97d24;
  --gold-3: #e2c25f;
  --gold-4: #c9a233;

  /* Движение */
  --ease: cubic-bezier(.2, .7, .3, 1);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 320ms;

  --font-body: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Unbounded', 'Golos Text', system-ui, sans-serif;

  --topbar-h: 60px;
  --tap: 44px;
}

/* --- База ---------------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: var(--bg-glow);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  font-feature-settings: 'ss01' 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.14;
  text-wrap: balance;
}

p { margin: 0; text-wrap: pretty; }

img { max-width: 100%; display: block; }

/* Атрибут hidden должен побеждать display из классов */
[hidden] { display: none !important; }

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 3px;
  transition: color var(--dur-1) var(--ease), text-decoration-color var(--dur-1) var(--ease);
}
a:hover { text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  transition: top var(--dur-2) var(--ease);
}
.skip-link:focus { top: 12px; text-decoration: none; }

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-inline: clamp(16px, 4vw, 24px);
}

/* --- Верхняя панель ----------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--topbar-bg);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar .wrap {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  min-height: var(--topbar-h);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--text);
  text-decoration: none;
  min-height: var(--tap);
  align-content: center;
  flex-wrap: wrap;
}
.brand:hover { text-decoration: none; }
.brand .gold { color: var(--accent); }

.sub {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .02em;
  text-transform: lowercase;
  padding-left: var(--gap-3);
  border-left: 1px solid var(--line);
  line-height: 1.2;
}

.topbar-out {
  margin-left: auto;
}

/* --- Кнопки ------------------------------------------------------------- */

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text);
  --btn-line: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-2);
  min-height: var(--tap);
  padding: 10px 16px;
  border: 1px solid var(--btn-line);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease), filter var(--dur-1) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--accent-line); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  --btn-bg: linear-gradient(180deg, var(--accent-grad-top), var(--accent-ink));
  --btn-fg: var(--on-accent-strong);
  --btn-line: var(--accent-grad-top);
  font-weight: 600;
  box-shadow: var(--shadow-gold);
}
.btn.primary:hover { filter: brightness(1.08); background: var(--btn-bg); }

.btn.ghost,
.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--text-2);
  --btn-line: var(--line);
}
.btn.ghost:hover,
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn.danger { --btn-fg: var(--danger); --btn-line: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.danger:hover { background: var(--danger-soft); }

.btn.sm,
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: var(--radius-xs); }

.btn.block,
.btn-block { width: 100%; }

.btn .ico { width: 16px; height: 16px; }

/* --- Заголовки секций и служебный текст --------------------------------- */

.hero { padding: clamp(28px, 5vw, 52px) 0 clamp(18px, 3vw, 26px); }
.hero h1 {
  font-size: clamp(26px, 4.4vw, 42px);
  letter-spacing: -.03em;
  margin-bottom: var(--gap-2);
}
.hero p { color: var(--muted); font-size: 15px; max-width: 60ch; }

.eyebrow {
  display: inline-block;
  margin-bottom: var(--gap-2);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap-4);
  flex-wrap: wrap;
  margin-bottom: var(--gap-4);
}
.section-head h1 { font-size: clamp(19px, 2.4vw, 22px); }
.section-head h2 { font-size: 17px; }
.section-head .hint { color: var(--muted); font-size: 12.5px; }

/* --- Витрина: карточки --------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: clamp(12px, 2vw, 20px);
  padding-bottom: var(--gap-8);
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}
.card:hover,
.card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--accent-line);
  box-shadow: var(--shadow-2);
  text-decoration: none;
}
.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(160deg, var(--surface-2), var(--surface-3));
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--line);
}
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media .no-photo { color: var(--muted-2); font-size: 12px; letter-spacing: .04em; }

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--gap-1);
  padding: 14px 16px 16px;
}
.card-body h2,
.card-body .card-title {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.32;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-body .meta {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.price {
  margin-top: auto;
  padding-top: var(--gap-2);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.no-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted-2);
  font-size: 11.5px;
  letter-spacing: .03em;
}
.no-photo .ico { width: 22px; height: 22px; opacity: .55; }

/* --- Бейджи и статусы ---------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: .01em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border: 1px solid var(--pill-line, var(--line));
  border-radius: var(--radius-pill);
  background: var(--pill-soft, var(--neutral-soft));
  color: var(--pill-fg, var(--text-2));
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
}

.status-pill[data-status='draft'] { --pill-fg: var(--neutral); --pill-soft: var(--neutral-soft); --pill-line: color-mix(in srgb, var(--neutral) 34%, transparent); }
.status-pill[data-status='active'] { --pill-fg: var(--ok); --pill-soft: var(--ok-soft); --pill-line: color-mix(in srgb, var(--ok) 34%, transparent); }
.status-pill[data-status='reserved'] { --pill-fg: var(--warn); --pill-soft: var(--warn-soft); --pill-line: color-mix(in srgb, var(--warn) 34%, transparent); }
.status-pill[data-status='sold'] { --pill-fg: var(--info); --pill-soft: var(--info-soft); --pill-line: color-mix(in srgb, var(--info) 34%, transparent); }
.status-pill[data-status='redeemed'] { --pill-fg: var(--accent); --pill-soft: var(--accent-soft); --pill-line: var(--accent-line); }
.status-pill[data-status='expired'] { --pill-fg: var(--danger); --pill-soft: var(--danger-soft); --pill-line: color-mix(in srgb, var(--danger) 34%, transparent); }

/* --- Панели и формы ------------------------------------------------------ */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 2.4vw, 22px);
  margin-bottom: var(--gap-4);
  box-shadow: var(--shadow-1);
}
.panel > h1 { font-size: 20px; margin-bottom: var(--gap-4); }
.panel > h2 { font-size: 16px; margin-bottom: var(--gap-3); }
.panel legend {
  padding: 0 6px;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
fieldset.panel { min-width: 0; margin: 0; }
.panel .panel {
  padding: var(--gap-4);
  margin-bottom: 0;
  background: var(--surface-2);
  box-shadow: none;
}

.form { display: flex; flex-direction: column; gap: var(--gap-3); }
.form > .btn { align-self: flex-start; }

.form label,
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .01em;
}

.form input,
.form select,
.form textarea,
.panel select {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.3;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.form input::placeholder { color: var(--muted-2); }
.form input:hover,
.form select:hover { border-color: var(--accent-line); }
.form input:focus,
.form select:focus,
.form textarea:focus,
.panel select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form input[type='file'],
.modal-card input[type='file'] { padding: 9px 12px; font-size: 13px; color: var(--text-2); }
.form input[type='file']::file-selector-button,
.modal-card input[type='file']::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-3);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
}

.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-3); }

.form .check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
}
.form .check input {
  width: 24px;
  height: 24px;
  min-height: 24px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.form .field-hint { color: var(--muted); font-size: 11.5px; font-weight: 400; }

/* --- Сообщения: статус, тосты ------------------------------------------- */

.status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.45;
}
.alert .ico { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.alert[data-tone='err'] { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); color: var(--text); }
.alert[data-tone='err'] .ico { color: var(--danger); }
.alert[data-tone='ok'] { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); }
.alert[data-tone='ok'] .ico { color: var(--ok); }
.alert[data-tone='info'] .ico { color: var(--accent); }
.alert a { font-weight: 600; }

.toast-stack {
  position: fixed;
  inset: auto 16px calc(16px + env(safe-area-inset-bottom)) 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--gap-2);
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: min(460px, 100%);
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text);
  font-size: 13.5px;
  box-shadow: var(--shadow-2);
  pointer-events: auto;
  animation: toast-in var(--dur-3) var(--ease);
}
.toast[data-tone='err'] { border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.toast[data-tone='ok'] { border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.toast .ico { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.toast[data-tone='err'] .ico { color: var(--danger); }
.toast[data-tone='ok'] .ico { color: var(--ok); }
.toast button {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* --- Пустые состояния и скелетоны --------------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-2);
  padding: clamp(28px, 6vw, 48px) var(--gap-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  text-align: center;
}
.empty-state .ico { width: 30px; height: 30px; color: var(--accent); opacity: .85; }
.empty-state h2,
.empty-state h3 { font-family: var(--font-body); font-size: 15px; font-weight: 600; letter-spacing: 0; }
.empty-state p { color: var(--muted); font-size: 13.5px; max-width: 42ch; }
.empty-state .btn { margin-top: var(--gap-2); }

.empty { color: var(--muted); font-size: 14px; }

.skeleton {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--accent) 7%, transparent) 45%, transparent 70%);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
.skeleton-media { aspect-ratio: 4 / 3; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.skeleton-line { height: 10px; margin: 12px 16px; border-radius: var(--radius-pill); background: var(--surface-3); }
.skeleton-line.short { width: 45%; }
@keyframes shimmer {
  to { transform: translateX(100%); }
}

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

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap-2);
}

.list-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color var(--dur-1) var(--ease);
}
.list-item:hover { border-color: var(--accent-line); }
.list-item .title-row {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  flex-wrap: wrap;
}
.list-item .title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}
.list-item .meta { color: var(--muted); font-size: 12.5px; }
.list-item .row-actions { display: flex; flex-wrap: wrap; gap: var(--gap-2); margin-top: 2px; }

/* Смена статуса на телефоне: нативный выбор вместо ряда кнопок */
.status-select {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 13.5px;
  cursor: pointer;
}
.status-select:hover { border-color: var(--accent-line); color: var(--text); }

.money { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 500; }

/* --- Карточка тарифа ----------------------------------------------------- */

.tier {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--gap-2) var(--gap-3);
}
.tier .tier-name { font-family: var(--font-display); font-size: 15px; }
.tier .tier-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.meter {
  flex: 1 1 100%;
  order: 3;
  margin-top: 4px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-ink), var(--accent));
}
.meter[data-full='1'] > span { background: linear-gradient(90deg, var(--danger-deep), var(--danger)); }

/* --- Страница товара ----------------------------------------------------- */

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  color: var(--muted);
  font-size: 13.5px;
}
.back .ico { width: 16px; height: 16px; }

.detail {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: clamp(20px, 4vw, 40px);
  padding: var(--gap-2) 0 var(--gap-7);
  align-items: start;
}
.detail-gallery { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.detail-main {
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(160deg, var(--surface-2), var(--surface-3));
  display: grid;
  place-items: center;
}
.detail-main img { width: 100%; height: 100%; object-fit: cover; }
.detail-thumbs { display: flex; gap: var(--gap-2); flex-wrap: wrap; }
.detail-thumbs button {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease);
}
.detail-thumbs button[aria-pressed='true'] { border-color: var(--accent); }
.detail-thumbs img { width: 64px; height: 64px; object-fit: cover; display: block; }
.detail-info { min-width: 0; }
.detail-info h1 { font-size: clamp(22px, 3.4vw, 30px); margin: var(--gap-2) 0 var(--gap-1); }
.detail-info .meta { color: var(--muted); font-size: 13.5px; max-width: 48ch; }
.detail-info .status-pill { margin-left: 6px; }
.detail-price {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.6vw, 30px);
  font-weight: 600;
  letter-spacing: -.03em;
  color: var(--accent);
  margin: var(--gap-2) 0 var(--gap-4);
  font-variant-numeric: tabular-nums;
}
.detail-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--line);
  margin-bottom: var(--gap-5);
}
.detail-rows .row {
  display: flex;
  justify-content: space-between;
  gap: var(--gap-4);
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.detail-rows .k { color: var(--muted); }
.detail-rows .v { font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.detail-contact {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-top: var(--gap-4); padding: 14px 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.detail-contact__label { color: var(--muted); font-size: 13px; margin-right: 4px; }
.detail-contact .btn { display: inline-flex; align-items: center; gap: 8px; }
.similar { margin-top: var(--gap-6); }
.similar__title { font-size: 20px; margin: 0 0 var(--gap-4); }

/* --- Подвал -------------------------------------------------------------- */

.footer {
  margin-top: var(--gap-6);
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2) var(--gap-4);
  justify-content: space-between;
  padding-block: var(--gap-5);
  color: var(--muted);
  font-size: 12.5px;
}
.footer__line { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.footer__links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer a,
.auth-back a,
.auth-note a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--text-2);
}

/* --- Юридические страницы ------------------------------------------------ */

.doc {
  max-width: 72ch;
  padding-block: var(--gap-6) var(--gap-7);
}
.doc h1 { font-size: clamp(22px, 3vw, 28px); margin-bottom: var(--gap-1); }
.doc h2 { font-family: var(--font-body); font-size: 17px; font-weight: 600; letter-spacing: 0; margin: var(--gap-5) 0 var(--gap-2); }
.doc p { color: var(--text-2); margin-bottom: var(--gap-3); font-size: 14.5px; }
.doc ul { color: var(--text-2); font-size: 14.5px; padding-left: 20px; }
.doc-date { color: var(--muted); font-size: 12.5px; }

/* --- Вход ---------------------------------------------------------------- */

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--gap-5) var(--gap-4);
}
.auth-card {
  width: min(420px, 100%);
  padding: clamp(22px, 5vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.auth-brand { margin-bottom: var(--gap-5); }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-lead { color: var(--muted); font-size: 13.5px; margin-bottom: var(--gap-5); }
.auth-back { margin-top: var(--gap-4); font-size: 13px; }
.auth-note {
  display: flex;
  gap: 8px;
  margin-top: var(--gap-4);
  padding-top: var(--gap-4);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.auth-note .ico { width: 15px; height: 15px; flex: 0 0 auto; color: var(--accent); }

/* --- Модалка ------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: var(--gap-4);
  background: var(--scrim);
  backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(480px, 100%);
  max-height: min(86dvh, 720px);
  overflow: auto;
  padding: clamp(18px, 3vw, 24px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: var(--gap-3);
  margin-bottom: var(--gap-3);
}
.modal-head h2 { font-family: var(--font-display); font-size: 17px; }
.modal-head .ico { width: 22px; height: 22px; color: var(--accent); flex: 0 0 auto; }
.modal-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: none;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); border-color: var(--accent-line); }
.modal-body { display: flex; flex-direction: column; gap: var(--gap-3); color: var(--text-2); font-size: 13.5px; }
.modal-steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.modal-foot { display: flex; flex-wrap: wrap; gap: var(--gap-2); margin-top: var(--gap-4); }
.modal-foot .btn { flex: 1 1 140px; }

.scan-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-2);
  padding: var(--gap-4);
  border: 1px dashed var(--accent-line);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  text-align: center;
  font-size: 12.5px;
  color: var(--text-2);
}
.scan-drop .ico { width: 26px; height: 26px; color: var(--accent); }

/* Скан паспорта: кнопка + пометка «фото не храним» */
.ocr-row {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  flex-wrap: wrap;
  margin-bottom: var(--gap-1);
}
.field-hint { color: var(--muted); font-size: 11.5px; font-weight: 400; }

/* --- Касса: сетка и липкая панель --------------------------------------- */

/* Тарифы залога: карточки выбора и блок расчёта */
.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .01em;
}

.tariff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: var(--gap-2);
}

.tariff-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease);
}
.tariff-card:hover { border-color: var(--accent-line); }
.tariff-card:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.tariff-card.is-active {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft), transparent 70%), var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.tariff-card.is-active::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.tariff-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.tariff-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-right: 16px;
}
.tariff-card__name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.tariff-card__rate {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.03em;
  color: var(--accent);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.tariff-card__rate small {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
}
.tariff-card__meta {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tariff-card__default {
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.calc {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}
.calc-empty { color: var(--muted); font-size: 13px; }
.calc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-2);
  flex-wrap: wrap;
}
.calc-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.calc-rows { display: flex; flex-direction: column; gap: 6px; }
.calc-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap-3);
  color: var(--muted);
  font-size: 13.5px;
}
.calc-row b {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.calc-row--total {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--text-2);
}
.calc-row--total b {
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: -.02em;
  color: var(--accent);
}
.calc-row--total small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .01em;
}
.calc-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.4;
}
.calc-error .ico { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 2px; }

.kassa-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-3);
  align-items: start;
}

.submit-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  margin: var(--gap-3) calc(-1 * clamp(16px, 2.4vw, 22px)) calc(-1 * clamp(16px, 2.4vw, 22px));
  padding: var(--gap-3) clamp(16px, 2.4vw, 22px) calc(var(--gap-3) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.submit-bar .btn { flex: 1 1 auto; }
.submit-bar .status { flex: 1 1 100%; }

/* --- Админка ------------------------------------------------------------- */

.admin-list { display: flex; flex-direction: column; gap: var(--gap-2); list-style: none; margin: 0; padding: 0; }
.admin-list li {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.admin-list .thumb {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: var(--radius-xs);
  object-fit: cover;
  background: var(--surface-3);
}
.admin-list .t { flex: 1 1 0; min-width: 0; }
.admin-list .t strong { font-size: 14px; font-weight: 600; }
.admin-list .t small { display: block; color: var(--muted); font-size: 12px; }
.admin-list .ops { display: flex; flex-wrap: wrap; gap: 6px; }

/* --- Админка: тарифы залогов -------------------------------------------- */

.tariff-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-2);
  margin-bottom: var(--gap-4);
}

.tariff-row,
.tariff-new {
  display: flex;
  flex-direction: column;
  gap: var(--gap-3);
  padding: var(--gap-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.tariff-new {
  border-style: dashed;
  border-color: var(--accent-line);
  background: color-mix(in srgb, var(--accent-soft) 60%, transparent);
}

.tariff-grid-fields {
  display: grid;
  grid-template-columns: minmax(140px, 1.6fr) repeat(4, minmax(92px, 1fr));
  gap: var(--gap-2);
}
.tariff-grid-fields label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}
.tariff-grid-fields input {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.tariff-grid-fields input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tariff-row__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-3);
  flex-wrap: wrap;
}
.tariff-row__summary {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}
.tariff-row__actions {
  display: flex;
  gap: var(--gap-2);
  flex-wrap: wrap;
}

@media (max-width: 860px) {
  .tariff-grid-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tariff-grid-fields label:first-child { grid-column: 1 / -1; }
  .tariff-row__actions { width: 100%; }
  .tariff-row__actions .btn { flex: 1 1 auto; }
}

/* --- Адаптив ------------------------------------------------------------- */

@media (max-width: 1024px) {
  .detail { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .kassa-grid { grid-template-columns: 1fr; }
  .admin-list li { flex-wrap: wrap; }
  .admin-list .ops { width: 100%; }
}

@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-body { padding: 10px 12px 12px; gap: 2px; }
  .card-body h2,
  .card-body .card-title { font-size: 13.5px; -webkit-line-clamp: 2; }
  .card-body .meta { font-size: 11.5px; }
  .price { font-size: 16px; margin-top: 6px; }
  .badge { font-size: 10.5px; padding: 2px 8px; }
  .card-media .no-photo { font-size: 10.5px; }

  .form .row { grid-template-columns: 1fr; }
  .form > .btn { align-self: stretch; }

  /* Палец, а не курсор: мелкие элементы доводим до 44px */
  .btn-sm,
  .btn.sm,
  .status-select { min-height: var(--tap); }
  .modal-close { width: var(--tap); height: var(--tap); }

  /* Тарифы на телефоне: компактнее, но всё ещё читаемо */
  .tariff-card { padding: 10px 12px 11px; }
  .tariff-card__rate { font-size: 19px; }
  .tariff-card__name { font-size: 12.5px; }
  .tariff-card__meta { font-size: 11px; }
  .calc-row b { font-size: 13.5px; }
  .calc-row--total b { font-size: 17px; }
  .detail-thumbs img { width: 56px; height: 56px; }
  .topbar .wrap { min-height: 56px; }
  .sub { display: none; }
  .submit-bar { margin-inline: calc(-1 * clamp(16px, 4vw, 24px)); }
  .toast-stack { inset: auto 10px calc(10px + env(safe-area-inset-bottom)) 10px; }
}

@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr; }
}

/* Тач-устройства шире 600px (планшет): те же 44px */
@media (pointer: coarse) {
  .btn-sm,
  .btn.sm,
  .status-select { min-height: var(--tap); }
  .modal-close { width: var(--tap); height: var(--tap); }
}

/* --- Печать -------------------------------------------------------------- */

@media print {
  .topbar, .footer, .submit-bar, .toast-stack, .modal, .btn { display: none !important; }
  body { background: #fff; color: #111; } /* печать всегда на белом */
  .panel, .card { border-color: #ccc; box-shadow: none; }
}

/* --- Доступность: движение ---------------------------------------------- */

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

/* Карточка витрины: фото держит 4:3, а лишнюю высоту забирает тело карточки.
   Без этого сетка растягивала карточки до равной высоты и кадры выходили разными */
.grid > .card > .card-media { flex: 0 0 auto; }
.grid > .card > .card-body { flex: 1 1 auto; }

/* Фото витрины: кадр 4:3 держим жёстко, картинку кладём поверх абсолютом.
   Процентная высота внутри бокса с aspect-ratio не разрешается, и кадр растягивался
   по натуральной высоте фотографии - сетка выходила рваной */
.grid > .card > .card-media { flex: 0 0 auto; position: relative; }
.grid > .card > .card-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.grid > .card > .card-body { flex: 1 1 auto; justify-content: space-between; }
