/* Интерфейс для телефона в первую очередь: менеджер работает в зале. */

:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f2eee8;
  --text: #1d1a17;
  --muted: #6f6860;
  --line: #e4ded5;
  --accent: #8a6a3b;
  --accent-text: #ffffff;
  --danger: #a33a2c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(40, 30, 15, .06), 0 6px 20px rgba(40, 30, 15, .06);
  --header: 60px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151312;
    --surface: #1f1c1a;
    --surface-2: #2a2623;
    --text: #f1ece5;
    --muted: #a59c91;
    --line: #37322d;
    --accent: #c9a56b;
    --accent-text: #1a1510;
    --danger: #e08070;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", "Leelawadee UI", Roboto, sans-serif;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.2; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }
[hidden] { display: none !important; }

.boot { min-height: 100dvh; display: grid; place-items: center; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }

/* --- элементы форм --- */
input, select {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label input, label select { color: var(--text); font-size: 15px; }

.primary, .ghost {
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; white-space: nowrap;
}
.primary { background: var(--accent); color: var(--accent-text); }
.ghost { background: transparent; border-color: var(--line); }
.primary:disabled, .ghost:disabled { opacity: .55; cursor: default; }
.link { border: 0; background: none; padding: 6px 0; color: var(--accent); font-weight: 600; font-size: 13px; }
.icon { border: 0; background: none; font-size: 26px; line-height: 1; width: 44px; height: 44px; }
.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px;
  border-radius: 10px; background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 700;
}

/* --- вход --- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); display: grid; gap: 14px; padding: 28px 24px;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow);
}
.login-card .logo { font-size: 24px; text-align: center; }
.login-sub { margin: -8px 0 6px; text-align: center; color: var(--muted); }
.logo { font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }

.lang { display: inline-flex; justify-self: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang button { border: 0; background: none; min-height: 34px; padding: 0 12px; font-size: 13px; color: var(--muted); }
.lang button.is-active { background: var(--surface-2); color: var(--text); font-weight: 600; }

/* --- шапка --- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "logo nav" "search search";
  align-items: center; gap: 8px 12px; padding: 8px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .logo { grid-area: logo; display: grid; font-size: 15px; }
.top .logo small { font-size: 11px; letter-spacing: .04em; text-transform: none; color: var(--muted); font-weight: 400; }
.top nav { grid-area: nav; display: flex; justify-content: flex-end; align-items: center; gap: 4px; }
.nav-link { border: 0; background: none; min-height: 40px; padding: 0 8px; font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; }
.search { grid-area: search; display: flex; gap: 8px; }
.search:empty { display: none; }
.search input { flex: 1; min-width: 0; }
.filter-button {
  min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; display: inline-flex; align-items: center;
}

/* --- каталог --- */
.catalog { padding: 12px 16px 40px; max-width: 1400px; margin: 0 auto; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.count { color: var(--muted); font-size: 13px; }
.sort { width: auto; min-height: 38px; font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13px;
}
.chip span { color: var(--muted); font-size: 16px; line-height: 1; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; transition: opacity .15s; }
.grid.is-loading { opacity: .5; }
.card { display: block; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.card-photo { aspect-ratio: 1; background: #fff; display: grid; place-items: center; color: #9a938a; font-size: 12px; }
.card-photo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card-body { padding: 10px 12px 12px; display: grid; gap: 2px; }
.card-type { font-size: 12px; color: var(--muted); }
.card-article { font-weight: 600; overflow-wrap: anywhere; }
.card-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.card-meta b { color: var(--text); font-size: 13px; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.more { display: grid; place-items: center; padding: 20px 0; }

/* --- фильтры: на телефоне выезжают снизу на весь экран --- */
.filters {
  position: fixed; inset: 0; z-index: 30; display: none; flex-direction: column; background: var(--bg);
}
.filters.is-open { display: flex; }
.filters-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 6px 16px; border-bottom: 1px solid var(--line); font-size: 17px; }
.filters-body { flex: 1; overflow-y: auto; padding: 4px 16px 16px; overscroll-behavior: contain; }
.filters-foot { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }

.facet { border: 0; border-bottom: 1px solid var(--line); margin: 0; padding: 14px 0; min-width: 0; }
.facet:last-child { border-bottom: 0; }
.facet legend { padding: 0; font-weight: 600; font-size: 14px; float: left; width: 100%; margin-bottom: 8px; }
.facet-values { clear: both; display: grid; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 14px; color: var(--text); cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; padding: 0; flex: none; accent-color: var(--accent); }
.check span { flex: 1; min-width: 0; }
.check i { font-style: normal; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.check.is-empty { opacity: .5; }

/* короткие значения (проба, размер, караты) — плитками */
.facet-values.is-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.is-chips .check { min-height: 36px; padding: 0 10px; gap: 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13px; }
.is-chips .check input { position: absolute; opacity: 0; pointer-events: none; }
.is-chips .check:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); font-weight: 600; }
.is-chips .check:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- карточка модели --- */
.model, .admin { padding: 8px 16px 48px; max-width: 1200px; margin: 0 auto; }
.back { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); font-size: 14px; }
.model-layout { display: grid; gap: 18px; }
.gallery-main { aspect-ratio: 1; background: #fff; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; color: #9a938a; box-shadow: var(--shadow); }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; padding-bottom: 4px; }
.thumb { flex: none; width: 64px; height: 64px; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: #fff; }
.thumb.is-active { border-color: var(--accent); }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }

.model-type { color: var(--muted); font-size: 13px; }
.model-info h1 { font-size: 24px; overflow-wrap: anywhere; }
.model-info h2 { font-size: 15px; margin: 22px 0 8px; }

.price-box { margin: 12px 0 4px; }
.price { display: grid; gap: 2px; padding: 14px 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); min-height: 92px; align-content: center; }
.price small { color: var(--muted); font-size: 12px; }
.price strong { font-size: 32px; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.price-request { font-size: 18px; font-weight: 600; color: var(--muted); }
.skeleton { display: block; width: 160px; height: 34px; border-radius: 8px; background: var(--surface-2); animation: pulse 1.1s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .45; } }

.selector { margin-top: 16px; }
.selector-title { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.options { display: flex; flex-wrap: wrap; gap: 8px; }
.options.is-stacked { display: grid; }
.option {
  min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  text-align: left; font-size: 14px;
}
.option span { display: block; }
.option.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }

.specs { margin: 0; display: grid; }
.specs div { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; overflow-wrap: anywhere; }

/* --- настройки --- */
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 16px; margin-bottom: 14px; }
.panel h2 { font-size: 17px; margin-bottom: 12px; }
.panel h3 { font-size: 14px; margin: 18px 0 10px; }
.panel p { margin: 0 0 8px; }
.hint { color: var(--muted); font-size: 13px; }
.row { display: grid; gap: 10px; align-items: end; }
.users { list-style: none; margin: 0; padding: 0; display: grid; }
.users li { display: grid; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.users li > div { display: grid; }
.users li span { color: var(--muted); font-size: 13px; }
.users li.is-disabled b { color: var(--muted); text-decoration: line-through; }
details { margin: 8px 0 12px; font-size: 13px; }
details ul { margin: 8px 0 0; padding-left: 18px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow);
}

/* --- планшет и компьютер --- */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .users li { grid-template-columns: 1fr minmax(0, 1.4fr); align-items: center; }
}

@media (min-width: 960px) {
  .top { grid-template-columns: auto minmax(0, 520px) 1fr; grid-template-areas: "logo search nav"; padding: 10px 24px; gap: 20px; }
  .search:empty { display: block; }
  .filter-button { display: none; }
  .catalog { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 28px; padding: 20px 24px 60px; align-items: start; }
  .filters {
    position: sticky; top: calc(var(--header) + 16px); inset: auto; z-index: 1; display: flex;
    max-height: calc(100dvh - var(--header) - 32px); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  .filters-head .icon, .filters-foot { display: none; }
  .filters-head { padding: 12px 16px; font-size: 15px; }
  .check { min-height: 34px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
  .model, .admin { padding: 12px 24px 60px; }
  .model-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 36px; align-items: start; }
  .gallery { position: sticky; top: calc(var(--header) + 16px); }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .grid { transition: none; }
}
