/* Шрифт для хинди: подгружается только когда на странице есть символы деванагари. */
@font-face {
  font-family: "Noto Sans Devanagari";
  src: url("/fonts/noto-sans-devanagari.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FF;
}

:root {
  color-scheme: dark;
  --bg: #0d0f14;
  --surface: #171a22;
  --surface-2: #1f2330;
  --field: #0f1218;
  --line: #2c3242;
  --line-strong: #4a5268;
  --text: #f3f5f9;
  --muted: #aab2c3;
  --red: #c81d24;
  --red-hover: #de2a31;
  --gold: #f2c14e;
  --danger: #ff8f94;
  --ok: #7ee2a8;
  --focus: #ffd166;
  --radius: 16px;
  --gutter: clamp(16px, 3vw, 32px);
  /* Вырезы экрана и системные элементы: обычный браузер (env) и Telegram Mini App (--tg-*). */
  --inset-top: calc(max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --inset-bottom: calc(max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px));
  --inset-left: max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px));
  --inset-right: max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px));
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(max(var(--cookie-h, 0px), var(--inset-bottom)) + var(--tg-bottom-gap, 0px));
}
/* Деванагари выше латиницы и ломается от разрядки букв. */
:lang(hi) { line-height: 1.75; }
:lang(hi) * { letter-spacing: 0 !important; }

h1, h2, p { margin: 0; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 8px; top: -100px; z-index: 50;
  padding: 10px 14px; border-radius: 10px; background: #fff; color: #111; font-weight: 600;
}
.skip:focus { top: calc(8px + var(--inset-top)); }

.wrap {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
  padding-left: calc(var(--gutter) + var(--inset-left));
  padding-right: calc(var(--gutter) + var(--inset-right));
}
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }

/* ---------- шапка ---------- */
.top { padding-top: calc(16px + var(--inset-top)); padding-bottom: 8px; }
.top__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.top__text { min-width: 0; display: grid; gap: 6px; padding-top: 4px; }
.top h1 { font-size: clamp(1.375rem, 1rem + 1.6vw, 2.125rem); line-height: 1.2; }
.top__sub { color: var(--muted); }

/* ---------- переключатель языка ---------- */
.lang { position: relative; flex: none; }
.lang__btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 10px 0 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); font-weight: 700;
}
.lang__btn:hover { border-color: var(--line-strong); }
.lang__btn .icon:last-child { width: 16px; height: 16px; }
.lang__menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  min-width: 200px; margin: 0; padding: 6px; list-style: none;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}
.lang__item {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%; min-height: 44px; padding: 6px 12px;
  border: 0; border-radius: 8px; background: none; text-align: left;
}
.lang__item:hover, .lang__item:focus-visible { background: rgba(255, 255, 255, .08); }
.lang__item[aria-checked="true"] { background: rgba(255, 255, 255, .12); font-weight: 700; }
.lang__code { color: var(--muted); font-weight: 700; font-size: .875rem; }

/* ---------- фильтры ---------- */
.filters {
  display: flex; gap: 8px;
  min-height: 56px; padding: 6px var(--gutter);
  margin: 8px calc(var(--gutter) * -1) 12px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 44px; padding: 4px 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-weight: 600; white-space: nowrap;
}
.chip:hover { border-color: var(--line-strong); }
.chip[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
@media (min-width: 768px) {
  .filters { flex-wrap: wrap; overflow: visible; margin-inline: 0; padding-inline: 0; }
}

/* ---------- сетка и карточки ---------- */
main { flex: 1; }
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
}
.card {
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
  padding: 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.card__head { display: flex; align-items: center; gap: 14px; }
.card__logo {
  flex: none; display: grid; place-items: center;
  width: 72px; height: 72px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 14px; background: var(--field);
  text-decoration: none;
}
.card__logo:hover { border-color: var(--line-strong); }
.card__img { display: block; width: 100%; height: 100%; object-fit: contain; }
.card__initials { font-weight: 800; font-size: 1.25rem; color: var(--muted); }
.card__title { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.card__brand { font-size: 1.125rem; line-height: 1.3; }
.badge {
  display: inline-block; max-width: 100%; padding: 2px 10px;
  border-radius: 999px; background: var(--gold); color: #1a1300;
  font-size: .75rem; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere;
}
:lang(hi) .badge { line-height: 1.75; }
.card__desc { flex: 1; color: var(--muted); }
.card__actions { display: grid; gap: 10px; }

.promo {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 60px; padding: 8px 10px 8px 14px;
  border: 0; border-radius: 12px; background: var(--red); color: #fff; text-align: left;
}
.promo:hover { background: var(--red-hover); }
.promo__text { min-width: 0; display: flex; flex-direction: column; }
.promo__label { font-size: .75rem; font-weight: 500; }
.promo__code {
  font: 700 1.125rem/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  letter-spacing: .04em; overflow-wrap: anywhere;
}
.promo__action {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 8px; background: rgba(0, 0, 0, .28);
  font-size: .875rem; font-weight: 600;
}
.promo__action .icon { width: 18px; height: 18px; }
.promo__manual {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--field);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
  font-weight: 600; text-align: center; text-decoration: none;
}
.btn:hover { border-color: var(--line-strong); }
.btn:disabled { opacity: .6; cursor: default; }
.btn--primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn--primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn--danger { color: var(--danger); }
.btn--sm { min-height: 44px; padding: 6px 14px; }
.btn .icon { width: 18px; height: 18px; }

/* ---------- состояния: загрузка, пусто, ошибка ---------- */
.state {
  display: grid; justify-items: center; gap: 16px;
  padding: 48px 16px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.skeleton { pointer-events: none; }
.skeleton__box { border-radius: 10px; background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton__box { animation: none; }
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* ---------- подвал, cookie-баннер, уведомление ---------- */
.foot { margin-top: 32px; padding-bottom: 24px; color: var(--muted); font-size: .875rem; }
.cookie {
  position: fixed; left: 0; right: 0; bottom: var(--tg-bottom-gap, 0px); z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px;
  padding: 12px calc(16px + var(--inset-right)) calc(12px + var(--inset-bottom)) calc(16px + var(--inset-left));
  background: #1c2030; border-top: 1px solid var(--line-strong);
}
.cookie p { flex: 1 1 260px; max-width: 80ch; font-size: .875rem; }
.toast {
  position: fixed; left: 50%; z-index: 60;
  bottom: calc(max(var(--cookie-h, 0px), var(--inset-bottom)) + var(--tg-bottom-gap, 0px) + 16px);
  width: max-content; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 10px; background: #fff; color: #111; font-weight: 600; text-align: center;
  transform: translateX(-50%); opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.is-visible { opacity: 1; }

/* ---------- админ-панель ---------- */
.subbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 16px; }
.subbar__nav, .subbar__tools { display: flex; flex-wrap: wrap; gap: 8px; }
.tab[aria-current="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.toolbar h2 { font-size: 1.25rem; }
.rows { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.row__thumb {
  display: grid; place-items: center; width: 56px; height: 56px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 10px; background: var(--field);
  font-weight: 800; color: var(--muted);
}
.row__thumb img { width: 100%; height: 100%; object-fit: contain; }
.row__main { min-width: 0; display: grid; gap: 4px; justify-items: start; overflow-wrap: anywhere; }
.row__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.row--plain { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 560px) {
  .row { grid-template-columns: 56px minmax(0, 1fr); }
  .row--plain { grid-template-columns: minmax(0, 1fr); }
  .row__actions { grid-column: 1 / -1; justify-content: stretch; }
  .row__actions .btn { flex: 1; }
}
.pill { padding: 1px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; border: 1px solid currentColor; }
.pill--on { color: var(--ok); }
.pill--off { color: var(--muted); }

.panel-form, .login { max-width: 720px; }
.login { margin: 24px auto; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); max-width: 420px; }
.login h2 { margin-bottom: 16px; font-size: 1.25rem; }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; margin: 0 0 18px; padding: 0; border: 0; }
.field label, .field legend { font-weight: 600; padding: 0; }
.field input:not([type="checkbox"]):not([type="file"]), .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--field);
}
.field textarea { resize: vertical; min-height: 88px; }
.field .file-btn { font-weight: 600; cursor: pointer; }
.field input[type="file"]:focus-visible + .file-btn { outline: 3px solid var(--focus); outline-offset: 2px; }
.file-name { flex: 1 1 100%; min-width: 0; font-size: .875rem; overflow-wrap: anywhere; }
.field [aria-invalid="true"] { border-color: var(--danger) !important; }
.field__hint { color: var(--muted); font-size: .875rem; }
.field__error, .form-error { color: var(--danger); font-size: .875rem; font-weight: 600; }
.form-error:empty { display: none; }
.field__lang { display: grid; gap: 4px; margin-top: 8px; }
.field__lang label { font-weight: 500; font-size: .875rem; color: var(--muted); }
.field--group { padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.field--group legend { padding: 0 6px; }
.field--check { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 10px; }
.field--check input { width: 22px; height: 22px; accent-color: var(--red); }
.field--check .field__hint, .field--check .field__error { grid-column: 1 / -1; }
.req { color: var(--danger); }
.logo-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.editor {
  width: min(720px, calc(100vw - 16px)); max-height: calc(100dvh - 16px);
  padding: 0; overflow: hidden;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.editor::backdrop { background: rgba(0, 0, 0, .65); }
.editor__form { display: flex; flex-direction: column; max-height: calc(100dvh - 18px); }
.editor__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.editor__head h2 { font-size: 1.125rem; }
.editor__body { padding: 18px; overflow-y: auto; }
.editor__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.editor__foot .form-error { flex: 1 1 100%; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: none; }
.icon-btn:hover { background: rgba(255, 255, 255, .08); }
