/**
 * CityMaps UI — MapLibre map over own DB buildings.
 * Brand-first topbar; building click → panel with NAP + contacts.
 * No third-party map API live calls — only /api/v1/citymaps/*.
 */

/* RU: Ф6.7 (14.09.2026): цвета этого файла — только токены --k-* из kartivi.css. Тему переключает theme.js (кабинеты) или public.js
       (витрина), и ночная тема меняет токены; зашитый светлый литерал оставался бы белой плашкой на тёмном фоне. Полупрозрачные подложки —
       color-mix от поверхности темы, а не rgba(255,255,255,…). Литералы, если остались, — только печать и нейтральные тени.
   EN: Ф6.7 (2026-09-14): this file's colours are only --k-* tokens from kartivi.css. The theme is switched by theme.js (cabinets) or public.js
       (storefront), and the night theme changes the tokens; a hardcoded light literal would stay a white plate on a dark ground. Translucent backings are color-mix
       from the theme surface rather than rgba(255,255,255,…). Remaining literals, if any, are print-only and neutral shadows. */
:root {
  /* RU: Ниже — алиасы на общий слой токенов public/css/kartivi.css.
     Имена сохранены: на них завязаны существующие правила этого файла.
     EN: Below are aliases onto the shared token layer public/css/kartivi.css.
     The names are kept: this file's existing rules depend on them. */
  --ink: var(--k-text);
  --ink-soft: var(--k-text-muted);
  /* RU: --muted зовут 14 правил витрины (подсказки поиска, панель мощности), а объявлен он был
         только в admin.css. На карте срабатывал запасной #5a6b62 — тёмно-серый и в ночной теме.
     EN: --muted is used by 14 storefront rules (search suggestions, capacity panel) but was declared
         only in admin.css. On the map the #5a6b62 fallback kicked in — dark grey even at night. */
  --muted: var(--k-text-muted);
  --paper: var(--k-bg);
  --panel: var(--k-surface);
  --line: var(--k-border);
  --accent: var(--k-brand);
  --accent-soft: var(--k-brand-soft);
  --warn: var(--k-warn);
  --map-void: var(--k-map-void);
  --shadow: var(--k-shadow-3);
  --font-ui: var(--k-font-ui);
  --font-brand: var(--k-font-brand);
  --min-zoom: 16;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
}

#app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* Shell 2.0 overrides grid via public.css (body.public.shell-v2 #app.shell) */
body.public.shell-v2 #app.shell {
  grid-template-rows: unset;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.25rem;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(180deg, var(--k-atmo-1) 0%, var(--paper) 100%);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}

.rubric-chips {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-top: 0.15rem;
}

.rubric-chips-roots,
.rubric-chips-children {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.rubric-chip {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--k-surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  cursor: pointer;
}

.rubric-chip-child {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.22rem 0.6rem;
  background: var(--k-bg);
}

.rubric-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rubric-chip.is-active {
  background: var(--k-brand-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.rubric-count {
  font-weight: 500;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}

.brand {
  display: flex;
  flex-direction: column;
  min-width: 9rem;
}

.brand-mark {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.ops-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: center;
  font-size: 0.82rem;
}

.ops-nav a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.ops-nav a:hover {
  text-decoration: underline;
}

.ops-badge {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.place-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  align-items: flex-end;
}

.place-switcher-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.68rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.place-switcher-field select {
  font: inherit;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--k-surface);
  padding: 0.4rem 0.55rem;
  min-width: 8.5rem;
  max-width: 14rem;
}

/* Quick filter input above the city select — type to search */
.place-filter-input {
  font: inherit;
  font-size: 0.82rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--k-surface);
  padding: 0.35rem 0.5rem;
  min-width: 8.5rem;
  max-width: 14rem;
  margin-bottom: 2px;
}
.place-filter-input::placeholder {
  color: var(--ink-soft);
  opacity: 0.7;
}

.search {
  flex: 1;
  display: flex;
  gap: 0.5rem;
  max-width: 42rem;
  align-items: stretch;
  position: relative;
  flex-wrap: wrap;
}

.filter-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  align-self: center;
}

.filter-check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.search-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  font: inherit;
  background: var(--panel);
  box-sizing: border-box;
}

.suggest {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0.35rem 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 18rem;
  overflow: auto;
}

.suggest[hidden] {
  display: none;
}

/* RU: Второй селектор `.search .suggest-item` не лишний. В оболочке 3.0 список подсказок живёт внутри
       формы `.search`, и правило `.search button` (0,1,1) побеждало `.suggest-item` (0,1,0): каждая
       подсказка становилась сплошной зелёной кнопкой, а адрес и тип в ней сливались с фоном (1:1).
       Снимать `.search button` нельзя — им оформлена кнопка «Найти».
   EN: The second selector `.search .suggest-item` is not redundant. In shell 3.0 the suggestion list lives
       inside the `.search` form, and `.search button` (0,1,1) beat `.suggest-item` (0,1,0): every
       suggestion became a solid green button, its address and type blending into it (1:1).
       `.search button` cannot go — it styles the "Find" button. */
.suggest-item,
.search .suggest-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  border: 0;
  border-radius: 0;
  width: 100%;
  text-align: left;
  background: transparent;
  font: inherit;
  font-weight: inherit;
  color: inherit;
}

.suggest-item:hover,
.suggest-item[aria-selected="true"],
.search .suggest-item:hover,
.search .suggest-item[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.suggest-item .suggest-label {
  font-weight: 600;
  font-size: 0.92rem;
}

.suggest-item .suggest-sub {
  font-size: 0.78rem;
  color: var(--muted, #5c6b63);
}

.suggest-item .suggest-type {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.suggest-section {
  list-style: none;
  padding: 0.45rem 0.85rem 0.15rem;
}

.suggest-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #5c6b63);
}

.suggest-empty {
  display: block;
  padding: 0.45rem 0.85rem 0.75rem;
  font-size: 0.85rem;
  color: var(--muted, #5c6b63);
}

.chip-priority {
  background: var(--k-brand);
  color: var(--k-text-on-accent);
}

.chip-verified {
  background: var(--k-info-soft);
  color: var(--k-info);
}

.search button,
.icon-btn,
.firm-card,
.retry-btn {
  font: inherit;
  cursor: pointer;
}

.search button {
  border: 0;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: var(--k-text-on-accent);
  font-weight: 600;
}

.search select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
  font: inherit;
  background: var(--panel);
  max-width: 9.5rem;
}

.ghost-btn {
  border: 1px solid var(--line) !important;
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  background: var(--k-surface) !important;
  color: var(--ink) !important;
  font-weight: 600;
}

.ghost-btn:hover {
  border-color: var(--accent) !important;
  background: var(--accent-soft) !important;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.dist {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
}

.stage {
  position: relative;
  min-height: 0;
}

#map {
  position: absolute;
  inset: 0;
  background: var(--map-void);
}

.panel {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: min(380px, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.25rem;
  z-index: 3;
  animation: panel-in 220ms ease-out;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.panel[hidden] {
  display: none;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-head h1 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 1.25rem;
  line-height: 1.25;
}

.icon-btn {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--ink-soft);
  padding: 0.1rem 0.35rem;
}

.panel-meta {
  margin: 0.35rem 0 0.9rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.firm-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.firm-card {
  text-align: left;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: var(--k-surface);
  transition: border-color 160ms ease, background 160ms ease;
}

.firm-card-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.save-search-row {
  margin: 0 0 0.65rem;
}

.report-firm {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem 0 0;
  border-top: 1px solid color-mix(in srgb, var(--ink, #1a1a1a) 12%, transparent);
  display: grid;
  gap: 0.55rem;
}
/* RU: Ф6.16: `display: grid` выше сильнее встроенного `[hidden] { display: none }`, и форма жалобы стояла раскрытой в каждой
       карточке — «Что не так», «Отправить», «Отмена» до всякого нажатия. Кнопка «Сообщить об ошибке» при этом ничего не
       меняла.
   EN: Ф6.16: `display: grid` above beats the built-in `[hidden] { display: none }`, so the report form stood open on every card —
       "Что не так", "Отправить", "Отмена" before any click, and the "Сообщить об ошибке" button changed nothing. */
.report-firm[hidden] {
  display: none;
}
.report-firm-label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
}
.report-firm-label select,
.report-firm-label input,
.report-firm-label textarea {
  width: 100%;
  font: inherit;
  padding: 0.45rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--ink, #1a1a1a) 18%, transparent);
  border-radius: 6px;
  background: var(--panel, var(--k-surface));
  color: inherit;
}
.report-firm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.report-firm-msg.err {
  color: var(--k-danger);
}

.claim-cta {
  margin: 0;
  padding: 0 0.15rem;
  font-size: 0.82rem;
}

.claim-cta a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.claim-cta a:hover {
  text-decoration: underline;
}

.claim-cta--contacts .claim-cta-btn,
.claim-cta--contacts a {
  color: var(--k-text-on-accent);
  background: var(--k-warn);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  display: inline-block;
  text-decoration: none;
}
.claim-cta--contacts .claim-cta-btn:hover,
.claim-cta--contacts a:hover {
  background: color-mix(in srgb, var(--k-warn) 85%, var(--k-text));
  text-decoration: none;
}

.firm-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.firm-card h2 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
}

.firm-card p {
  margin: 0.15rem 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.firm-card a {
  color: var(--accent);
}

.fav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.35rem 0 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--k-surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

.fav-btn.is-on {
  color: var(--accent);
  background: var(--k-brand-soft);
  border-color: color-mix(in srgb, var(--k-brand) 30%, transparent);
}

.fav-btn:hover {
  border-color: var(--accent);
}

.hours-badge {
  display: inline-block;
  margin-left: 0.35rem;
  font-style: normal;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  background: var(--k-surface-2);
  color: var(--ink-soft);
  vertical-align: middle;
}

.hours-badge.is-open {
  background: var(--k-brand-soft);
  color: var(--accent);
}

.hours-badge.is-closed {
  background: var(--k-danger-soft);
  color: var(--k-danger);
}

.firm-services {
  list-style: none;
  margin: 0.35rem 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.firm-services li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}

.firm-services em {
  font-style: normal;
  color: var(--ink-soft);
  white-space: nowrap;
}

.firm-media {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin: 0.5rem 0 0.85rem;
}

.firm-media img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--k-surface-2);
}

.empty,
.error {
  padding: 0.75rem 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.error {
  color: var(--warn);
}

.retry-btn {
  margin-top: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  background: var(--k-surface);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.35rem 0 0.5rem;
}

.chip {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: var(--k-surface-2);
  color: var(--ink-soft);
}

.chip-src {
  background: var(--k-info-soft);
  color: var(--k-info);
}

.back-link {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  padding: 0;
  margin-bottom: 0.75rem;
  cursor: pointer;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--k-text-on-accent);
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 4;
  animation: panel-in 180ms ease-out;
}

.toast[hidden] {
  display: none;
}

.attrib {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  font-size: 0.72rem;
  color: var(--ink-soft);
  /* RU: --k-surface-2 днём почти равен прежнему #e8efe9, а ночью темнеет вместе с темой: с зашитым
         цветом приглушённый светлый текст атрибуции и подсказки зума давал 1,78:1.
     EN: --k-surface-2 by day nearly equals the old #e8efe9 and darkens with the theme at night: with the
         hardcoded colour the muted light text of the attribution and zoom hint gave 1.78:1. */
  background: var(--k-surface-2);
  border-top: 1px solid var(--line);
}

.attrib .sep {
  opacity: 0.5;
}

.maplibregl-ctrl-attrib a {
  color: var(--ink-soft);
}

/* RU: Плашка атрибуции MapLibre по умолчанию белая полупрозрачная, а ссылки в ней уже красятся токеном
       выше — ночью светлый текст на белом давал 2,08:1. Фон берём из поверхности темы; значок «i»
       в MapLibre — чёрный SVG, ночью его инвертируем, иначе он пропадает на тёмной плашке.
       Селектор — класс .is-dark, а не [data-theme="dark"]: в режиме «как в системе» атрибут снят
       (public.js, syncVisualModeUi), а класс ставится по фактической теме.
   EN: MapLibre's attribution pill is translucent white by default while its links are already tokenised
       above — at night light text on white gave 2.08:1. The background follows the theme surface;
       MapLibre's "i" icon is a black SVG, so at night it is inverted or it vanishes on the dark pill.
       The selector is the .is-dark class, not [data-theme="dark"]: under "follow the system" the
       attribute is removed (public.js, syncVisualModeUi) while the class follows the effective theme. */
.maplibregl-ctrl.maplibregl-ctrl-attrib,
.maplibregl-ctrl.maplibregl-ctrl-attrib.maplibregl-compact {
  background-color: color-mix(in srgb, var(--k-surface) 88%, transparent);
  color: var(--ink-soft);
}

.is-dark .maplibregl-ctrl-attrib-button {
  filter: invert(1);
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 48%;
    border-radius: 16px 16px 0 0;
  }
}
