/* Kursavo design system — components and layout.
 * Tokens are defined in reset.css. No Pico dependency.
 * Описание языка интерфейса — docs/design-system.md. */

/* ─── Pico nav compat (monitoring platform nav) ──────────────────────────────── */
nav.container-fluid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.75rem;
  border-bottom: 1px solid var(--k-border);
  background: var(--k-surface);
  box-shadow: var(--k-shadow-sm);
  margin-bottom: 1.5rem;
}

nav.container-fluid > ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

nav.container-fluid > ul > li {
  display: inline-flex;
  align-items: center;
}

/* ─── Brand mark ──────────────────────────────────────────────────────────────── */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--k-primary);
  letter-spacing: -0.01em;
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--k-radius-sm);
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  color: #ffffff;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
}

/* ─── Table scroll wrapper ────────────────────────────────────────────────────── */
/* Wrapper carries the visual chrome so border-radius + overflow clip works with border-collapse */
.table-scroll {
  overflow-x: auto;
  background: var(--k-surface);
  border: 1px solid var(--k-border-card);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-sm);
}

.table-scroll table {
  border-radius: 0;
  box-shadow: none;
  border: 0;
}

/* Bare table (not wrapped) gets its own chrome */
table {
  background: var(--k-surface);
  border: 1px solid var(--k-border-card);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-sm);
  overflow: hidden;
}

/* ─── Tables (visual polish over reset.css base) ─────────────────────────────── */
thead th {
  background: var(--k-surface-2);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--k-muted);
}

tbody tr:hover { background: var(--k-surface-3); }

.table-clickable tbody tr { cursor: pointer; }
.table-clickable tbody tr:hover { background: color-mix(in srgb, var(--k-primary) 4%, var(--k-surface)); }
/* Реальная ссылка в первой ячейке кликабельной строки: даёт доступ с клавиатуры
   и скринридера (строка целиком кликабельна только мышью). Цвет наследуется от
   строки, чтобы таблица оставалась спокойной; подчёркивание — на hover/focus. */
.table-clickable .row-link { color: inherit; text-decoration: none; font-weight: 600; }
.table-clickable .row-link:hover,
.table-clickable .row-link:focus-visible { text-decoration: underline; }

table.striped tbody tr:nth-child(even) { background: var(--k-surface-2); }
table.striped tbody tr:hover           { background: var(--k-surface-3); }

/* ─── Юридический документ (Политика ПДн) ─────────────────────────────────────── */
.legal-doc { max-width: 48rem; margin: 2rem auto; }
.legal-doc h2 { margin-top: 1.5rem; }

/* ─── Хлебные крошки ──────────────────────────────────────────────────────────── */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--k-muted);
  margin-bottom: 0.35rem;
}
.crumbs a { color: inherit; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs > * + *::before { content: "›"; margin-right: 0.4rem; color: var(--k-muted); }
.crumbs [aria-current="page"] { color: var(--k-text); }

/* ─── Toolbar & layout ────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.toolbar h1, .toolbar h2 { margin: 0; }

/* Content sections — card-style blocks for main content areas */
.section {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  background: var(--k-surface);
  border: 1px solid var(--k-border-card);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-sm);
}

.section > h2:first-child,
.section > h3:first-child {
  margin-bottom: 0.75rem;
}

/* Tables inside a .section: strip extra chrome to avoid double-borders */
.section > table {
  box-shadow: none;
  border-radius: var(--k-radius-sm);
  border: 1px solid var(--k-border-muted);
  margin-bottom: 0;
}
.section > .table-scroll {
  box-shadow: none;
  border: 1px solid var(--k-border-muted);
  border-radius: var(--k-radius-sm);
  margin-bottom: 0;
}

/* Empty state inside section: no extra card chrome */
.section > .empty {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 1.25rem 0 0.25rem;
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ─── Bare article card (public content wrappers) ────────────────────────────── */
/* Public pages (booking, status, landing) use bare <article> as the page content
   wrapper. Give it card styling. Dialog articles are never inside .container so
   they are not affected. */
.container > article:not([class]) {
  background: var(--k-surface);
  border: 1px solid var(--k-border-card);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-sm);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

/* ─── Cards & grids ───────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1rem;
  align-items: start;
}

article.vehicle-card {
  margin: 0;
  box-shadow: var(--k-shadow-sm);
}

.vehicle-card .spread {
  align-items: flex-start;
  margin-bottom: 0.6rem;
}

.vehicle-card .actions {
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

/* ─── Key-value pairs ─────────────────────────────────────────────────────────── */
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1rem;
  margin: 0;
}

.kv dt { color: var(--k-muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ─── Status badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  background: var(--k-neutral-bg);
  color: var(--k-neutral-fg);
}

.badge[data-status="open"],
.badge[data-status="created"] {
  background: var(--k-info-bg);
  color: var(--k-info-fg);
}
.badge[data-status="in_progress"] {
  background: var(--k-warn-bg);
  color: var(--k-warn-fg);
}
.badge[data-status="confirmed"] {
  background: var(--k-info-bg);
  color: var(--k-info-fg);
}
.badge[data-status="ready"],
.badge[data-status="done"] {
  background: var(--k-success-bg);
  color: var(--k-success-fg);
}
.badge[data-status="issued"] {
  background: var(--k-neutral-bg);
  color: var(--k-neutral-fg);
}
.badge[data-status="cancelled"] {
  background: var(--k-danger-bg);
  color: var(--k-danger-fg);
}
.badge[data-status="sent"]    { background: var(--k-success-bg); color: var(--k-success-fg); }
.badge[data-status="failed"]  { background: var(--k-danger-bg);  color: var(--k-danger-fg); }
.badge[data-status="skipped"] { background: var(--k-neutral-bg); color: var(--k-neutral-fg); }

h1 .badge, h2 .badge { vertical-align: middle; }

/* ─── Utility classes ─────────────────────────────────────────────────────────── */
.muted    { color: var(--k-muted); }

.back-link {
  display: inline-block;
  font-size: 0.875rem;
  color: var(--k-muted);
  text-decoration: none;
  margin-bottom: 1rem;
}
.back-link:hover { color: var(--k-text); text-decoration: none; }

.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

.search {
  max-width: 24rem;
  margin-bottom: 1.25rem;
}

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--k-muted);
  background: var(--k-surface);
  border: 1px dashed var(--k-border);
  border-radius: var(--k-radius);
}

/* ─── Modal forms (HTMX → #modal) ────────────────────────────────────────────── */
dialog > article {
  box-shadow: var(--k-shadow-lg);
  border-radius: var(--k-radius-lg);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

.form-grid .full { grid-column: 1 / -1; }

@media (max-width: 32rem) {
  .form-grid { grid-template-columns: 1fr; }
}

/* Блок «заполнить из фото СТС» в форме авто (см. crm/vehicle_form.html). */
.sts-scan { margin-bottom: 1rem; }
.sts-scan-btn { width: 100%; }

footer.actions,
dialog footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.close-x {
  width: auto;
  margin: 0;
  padding: 0.25rem 0.5rem;
  height: auto;
  background: none;
  border: 0;
  color: var(--k-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.close-x:hover {
  color: var(--k-text);
  background: var(--k-surface-3);
  border-color: transparent;
}

/* ─── Segmented control (period switch, view toggles) ────────────────────────── */
[role="group"].period-switch,
[role="group"].segmented {
  display: inline-flex;
  gap: 0;
  margin-bottom: 1.25rem;
}

[role="group"].period-switch [role="button"],
[role="group"].segmented [role="button"] {
  border-radius: 0;
  margin: 0;
  border-right-width: 0;
  font-size: 0.8rem;
  padding: 0 0.8rem;
}

[role="group"].period-switch [role="button"]:first-child,
[role="group"].segmented [role="button"]:first-child {
  border-radius: var(--k-radius-sm) 0 0 var(--k-radius-sm);
}

[role="group"].period-switch [role="button"]:last-child,
[role="group"].segmented [role="button"]:last-child {
  border-radius: 0 var(--k-radius-sm) var(--k-radius-sm) 0;
  border-right-width: 1.5px;
}

/* ─── Filters, add-rows, totals ───────────────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.add-row {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--k-border-muted);
}

.add-row label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--k-muted);
}

.add-row input,
.add-row select { margin: 0; }

.catalog-add {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.catalog-add select { flex: 1; min-width: 14rem; }
.catalog-add button { margin: 0; white-space: nowrap; }

.line-add {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.5rem;
  align-items: end;
}

.line-add--part { grid-template-columns: 2fr 1fr 1fr 1fr auto; }
.line-add button { margin: 0; white-space: nowrap; }

@media (max-width: 40rem) {
  .line-add, .line-add--part { grid-template-columns: 1fr; }
}

.totals {
  margin-top: 1.5rem;
  margin-left: auto;
  max-width: 22rem;
  display: grid;
  gap: 0.4rem;
  padding: 1rem 1.1rem;
  background: var(--k-surface);
  border: 1px solid var(--k-border-card);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-sm);
}

.totals .total-grand {
  margin-top: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--k-border-muted);
  font-size: 1.05rem;
}

/* ─── Schedule board navigation ──────────────────────────────────────────────── */
.schedule-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.schedule-nav input[type="date"] { margin: 0; width: auto; }

.schedule-date { text-transform: capitalize; }

/* ─── Board (kanban columns) ──────────────────────────────────────────────────── */
.board {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.board-col {
  flex: 0 0 16rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem;
  background: var(--k-surface-2);
  border: 1px solid var(--k-border-card);
  border-radius: var(--k-radius);
}

.board-col__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.board-empty { margin: 0.25rem 0; text-align: center; font-size: 0.85rem; }
.board-add   { margin: 0; }

/* ─── Appointment cards ───────────────────────────────────────────────────────── */
.appt-card {
  margin: 0;
  padding: 0.6rem 0.7rem;
  cursor: pointer;
  background: var(--k-surface);
  border-left: 3px solid var(--k-neutral-fg);
  box-shadow: var(--k-shadow-sm);
  border-radius: var(--k-radius-sm);
  border-top: 1px solid var(--k-border-card);
  border-right: 1px solid var(--k-border-card);
  border-bottom: 1px solid var(--k-border-card);
}

.appt-card:hover { box-shadow: var(--k-shadow); }

.appt-card[data-status="created"]    { border-left-color: var(--k-info-fg); }
.appt-card[data-status="confirmed"]  { border-left-color: var(--k-primary); }
.appt-card[data-status="done"]       { border-left-color: var(--k-success-fg); }
.appt-card[data-status="in_progress"] { border-left-color: var(--k-warn-fg); }
.appt-card[data-status="cancelled"]   { border-left-color: var(--k-danger-fg); opacity: 0.7; }
.appt-card--conflict                  { border-left-color: var(--k-danger-fg); }

.appt-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.appt-who  { font-weight: 600; }
.appt-veh, .appt-note { font-size: 0.85rem; }

.appt-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.conflict-flag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--k-danger-fg);
  white-space: nowrap;
}

.conflict-warning {
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  background: var(--k-danger-bg);
  color: var(--k-danger-fg);
  border-radius: var(--k-radius-sm);
}

.conflict-warning ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }

.force-check { margin-top: 0.5rem; }

.appt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--k-border-muted);
}

.appt-card[draggable="true"] { cursor: grab; }
.appt-card.dragging          { opacity: 0.45; }

.board-col.drop-target {
  outline: 2px dashed var(--k-primary);
  outline-offset: -3px;
  background: #eef4ff;
}

.board-hint { margin-top: 0.5rem; font-size: 0.85rem; }

/* ─── Settings: tabs, cards, fields ──────────────────────────────────────────── */
.set-booking { align-items: start; }

.set-card {
  margin: 0 0 1rem;
  padding: 0.875rem 1rem;
  background: var(--k-surface);
  border: 1px solid var(--k-border-card);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-sm);
}
.set-card h3 { margin: 0 0 0.25rem; }

.set-copy {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin: 0.6rem 0;
}
.set-field { margin: 0; font-size: 0.9rem; }
.set-copy button { margin: 0; white-space: nowrap; width: auto; }
.set-code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  resize: vertical;
}
.set-qr { text-align: center; }
.set-qr-box {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.9rem;
  background: #ffffff;
  border: 1px solid var(--k-border-card);
  border-radius: var(--k-radius-sm);
}
.set-qr-box svg { display: block; width: 180px; height: 180px; }

.set-tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 1.25rem;
  border-bottom: 1px solid var(--k-border);
  overflow-x: auto;
}
.set-tabs a {
  padding: 0.5rem 0.9rem;
  text-decoration: none;
  color: var(--k-muted);
  font-weight: 500;
  font-size: 0.85rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s;
}
.set-tabs a:hover       { color: var(--k-primary); text-decoration: none; }
.set-tabs a.active      { color: var(--k-primary); border-bottom-color: var(--k-primary); }

/* Хаб настроек: плитки-группы с живым статусом (снабжение/подписка). */
.set-hub {
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  margin-top: 1rem;
}
.set-hub-tile { cursor: pointer; margin: 0; }
.set-hub-tile h3 a { color: inherit; text-decoration: none; }
.set-hub-tile:hover h3 a { color: var(--k-primary); }
.set-hub-status { margin: 0.4rem 0 0; font-size: 0.85rem; font-weight: 500; }

/* Pill labels */
.pill {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  line-height: 1.5;
}
.pill-ok    { background: var(--k-success-bg); color: var(--k-success-fg); }
.pill-muted { background: var(--k-neutral-bg); color: var(--k-neutral-fg); }

/* Row actions */
.row-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  white-space: nowrap;
}
.row-actions button {
  margin: 0;
  width: auto;
  padding: 0 0.625rem;
  height: var(--k-btn-sm-h);
  font-size: 12px;
}

/* ─── Parts search (order detail, ADR-0018) ──────────────────────────────────── */
.parts-search {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--k-border-muted);
}

.parts-search__form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

.parts-search__form input { flex: 1; min-width: 12rem; margin: 0; }
.parts-search__form button { margin: 0; }

#parts-search-results { margin-top: 0.75rem; }

.parts-offers { font-size: 0.85rem; }
.parts-offers th, .parts-offers td { padding: 0.3rem 0.5rem; }
.parts-order-links { display: flex; gap: 0.25rem; margin-top: 0.25rem; }
.parts-order-link {
  font-size: 0.75rem; padding: 0.1rem 0.4rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  color: var(--pico-muted-color); text-decoration: none;
  white-space: nowrap;
}
.parts-order-link:hover { border-color: var(--k-accent); color: var(--k-accent); }
.parts-search-hint { font-size: 0.8rem; margin-top: 0.5rem; }
.parts-search-via { font-size: 0.8rem; margin-bottom: 0.5rem; }
.parts-offer-actions { display: flex; align-items: center; gap: 0.25rem; justify-content: flex-end; }
.parts-offer-actions form { margin: 0; }
.parts-qty { width: 3.2rem; padding: 0.2rem 0.35rem; margin: 0; text-align: center; }

/* Карточка-группа «одна деталь» в результатах поиска (бренд+артикул, склады внутри). */
.parts-group {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.4rem;
}
.parts-group summary {
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1.5;
}
.parts-group[open] summary { margin-bottom: 0.4rem; }
.parts-group .parts-offers { margin-bottom: 0.25rem; }
.parts-group .table-scroll { margin-bottom: 0.25rem; }
/* Панель чипов-фильтров и сортировки над выдачей поиска. */
.parts-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}
.parts-filters-label { font-size: 0.75rem; margin-left: auto; }

/* Заголовок секции выдачи («Запрошенный артикул» / «Аналоги»). */
.parts-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--pico-muted-color);
  margin: 0.75rem 0 0.35rem;
}
/* Ярлык финалиста в карточке («Оптимально» / «Дешевле» / «Быстрее»). */
.badge.parts-best { background: var(--k-info-bg); color: var(--k-info-fg); }
/* Alpine: скрыть элемент до инициализации (строки за «Показать все»). */
[x-cloak] { display: none !important; }

/* Статусы заказа запчасти у поставщика (PartOrder, ADR-0019). */
.badge[data-status="pending"]   { background: var(--k-info-bg);    color: var(--k-info-fg); }
.badge[data-status="placed"]    { background: var(--k-info-bg);    color: var(--k-info-fg); }
.badge[data-status="shipped"]   { background: var(--k-warn-bg);    color: var(--k-warn-fg); }
.badge[data-status="delivered"] { background: var(--k-success-bg); color: var(--k-success-fg); }

/* ─── Service catalogue ───────────────────────────────────────────────────────── */
.svc-group  { margin-top: 1.5rem; }
.svc-cat    { font-size: 1.05rem; margin-bottom: 0.5rem; }
.svc-cat-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.svc-cat-row .svc-cat { margin-bottom: 0; }
.svc-group-actions { display: flex; gap: .25rem; margin-left: auto; }
.icon-btn   { background: none; border: 1px solid var(--pico-muted-border-color);
              border-radius: .375rem; padding: .2rem .45rem; cursor: pointer;
              font-size: .85rem; line-height: 1; color: var(--pico-color); }
.icon-btn:hover { background: var(--pico-secondary-background); }
.icon-btn.danger { color: var(--pico-del-color, #c62828); }
.inline-select { padding: .2rem .4rem; font-size: .85rem; border-radius: .375rem;
                 border: 1px solid var(--pico-muted-border-color);
                 background: var(--pico-background-color); color: var(--pico-color); }

.svc-tpl-modal { max-width: 40rem; }
.svc-tpl-list  { max-height: 55vh; overflow-y: auto; padding-right: 0.4rem; }
.svc-tpl-group {
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius-sm);
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.8rem;
}
.svc-tpl-group legend { font-weight: 600; padding: 0 0.4rem; }
.svc-tpl-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  margin: 0;
}
.svc-tpl-item input[type="checkbox"] { width: auto; margin: 0; }
.svc-tpl-item .svc-tpl-name { flex: 1; }
.svc-tpl-item.is-added { opacity: 0.6; }

/* ─── Notification event toggles ─────────────────────────────────────────────── */
.notif-events {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}

.notif-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--k-border-muted);
  font-weight: 400;
  font-size: 0.875rem;
  color: var(--k-text);
  cursor: pointer;
  margin: 0;
  line-height: 1.4;
}

.notif-events li:first-child .notif-toggle { border-top: 1px solid var(--k-border-muted); }

/* ─── Settings: general forms ─────────────────────────────────────────────────── */
.set-form {
  max-width: 36rem;
  background: var(--k-surface);
  border: 1px solid var(--k-border-card);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-sm);
  padding: 1.25rem 1.5rem;
  margin-top: 1rem;
}
.set-form button[type="submit"] { width: auto; }
.set-form > table {
  box-shadow: none;
  border: 1px solid var(--k-border-muted);
  border-radius: var(--k-radius-sm);
  margin-bottom: 1rem;
}

/* ─── Subscription (ADR-0017) ─────────────────────────────────────────────────── */
.sub-card {
  max-width: 40rem;
  background: var(--k-surface);
  border: 1px solid var(--k-border-card);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-sm);
  padding: 0.875rem 1rem;
  margin: 0 0 1.25rem;
}
.sub-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.sub-plan { font-size: 1.15rem; font-weight: 700; }
.sub-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--k-primary);
  white-space: nowrap;
}
.sub-badge--active   { background: #dcfce7; color: #166534; }
.sub-badge--trialing { background: #e0e7ff; color: #3730a3; }
.sub-badge--past_due { background: #fef3c7; color: #92400e; }
.sub-badge--suspended,
.sub-badge--cancelled { background: #fee2e2; color: #991b1b; }
.sub-facts {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  font-size: 0.92rem;
}
.sub-warn { color: var(--k-warn-fg); }
.sub-usage {
  list-style: none;
  margin: 1rem 0;
  padding: 0.9rem 0;
  border-top: 1px solid var(--k-border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.6rem;
}
.sub-usage li    { display: flex; flex-direction: column; }
.sub-usage span  { font-size: 0.78rem; color: var(--k-muted); }
.sub-usage strong { font-size: 1.05rem; }
.sub-pay {
  display: grid;
  gap: 0.5rem;
  max-width: 22rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--k-border);
}
.sub-pay button[type="submit"] { width: auto; }
.sub-autorenew {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--k-border);
  font-size: 0.92rem;
}
.sub-autorenew span { flex: 1 1 16rem; }
.sub-autorenew button[type="submit"] { width: auto; flex-shrink: 0; }
.sub-h2 { font-size: 1.05rem; margin: 1.5rem 0 0.6rem; }
.sub-change { display: grid; gap: 0.9rem; }
.sub-change button[type="submit"] { width: auto; justify-self: start; }
.sub-interval {
  border: 0; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 1.2rem;
}
.sub-interval legend { font-size: 0.78rem; color: var(--k-muted); margin-bottom: 0.3rem; }
.sub-interval label  { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.sub-save {
  font-size: 0.72rem; font-weight: 700;
  color: #166534; background: #dcfce7;
  padding: 0.05rem 0.4rem; border-radius: 999px;
}
.sub-plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.6rem;
}
.sub-plan-opt {
  position: relative;
  display: grid;
  gap: 0.2rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius-sm);
  cursor: pointer;
  transition: border-color 0.12s;
}
.sub-plan-opt:hover { border-color: var(--k-primary); }
.sub-plan-opt:has(input:checked) {
  border-color: var(--k-primary);
  box-shadow: 0 0 0 1px var(--k-primary);
  background: #f5f3ff;
}
.sub-plan-opt:has(input:focus-visible) { outline: 2px solid var(--k-primary); outline-offset: 2px; }
.sub-plan-opt input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none;
}
.sub-plan-opt--current { background: var(--k-surface-2); }
.sub-plan-name  { font-weight: 700; }
.sub-plan-posts { font-size: 0.8rem; color: var(--k-muted); }
.sub-plan-price { font-size: 0.9rem; }
.sub-txns { max-width: 40rem; font-size: 0.9rem; }
.sub-card > .sub-h2:first-child { margin-top: 0; }

/* ─── Analytics ──────────────────────────────────────────────────────────────── */
.analytics-facts {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--k-text);
}
.analytics-facts li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--k-border-muted);
}
.analytics-facts li:last-child { border-bottom: 0; }

/* ─── Django form error list ─────────────────────────────────────────────────── */
ul.errorlist {
  list-style: none;
  padding: 0;
  margin: 0.2rem 0 0.4rem;
}
ul.errorlist li {
  color: var(--k-danger);
  font-size: 0.75rem;
  margin: 0.1rem 0;
}

/* ─── Flash messages ──────────────────────────────────────────────────────────── */
.flash {
  padding: 0.7rem 1rem;
  border-radius: var(--k-radius-sm);
  margin: 0 0 1rem;
  font-size: 0.875rem;
}
.flash-ok  { background: var(--k-success-bg); color: var(--k-success-fg); }
.flash-err { background: var(--k-danger-bg);  color: var(--k-danger-fg); }

/* ─── Standalone centered card page (suspended, errors) ──────────────────────── */
.page-card {
  max-width: 28rem;
  margin: 4rem auto;
  background: var(--k-surface);
  border: 1px solid var(--k-border-card);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-sm);
  padding: 2rem;
}
.page-card > .brand { margin-bottom: 1.25rem; display: inline-flex; }
.page-card > h1 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.page-card > p  { color: var(--k-muted); margin-bottom: 0; }
.page-card > form { margin-top: 1.25rem; }

/* ─── Public booking pages ────────────────────────────────────────────────────── */
.public-layout {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.public-layout > main { flex: 1; }

.public-header {
  display: flex;
  align-items: center;
  padding-top: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--k-border);
  margin-bottom: 1.5rem;
}

.public-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--k-border);
  text-align: center;
  color: var(--k-muted);
}

/* Booking form — collapsible optional section */
.booking-more {
  margin: 0.75rem 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--k-border-muted);
  border-radius: var(--k-radius-sm);
  background: var(--k-surface-2);
}
.booking-more summary {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--k-primary);
  margin: 0;
}
.booking-more[open] summary { margin-bottom: 0.75rem; }

.booking-consent {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  margin: 0.75rem 0;
  font-weight: 400;
  color: var(--k-text);
}
.booking-consent input[type="checkbox"] { margin-top: 0.2rem; }

/* Form inline errors */
.error, small.error {
  display: block;
  color: var(--k-danger);
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

.errors {
  padding: 0.6rem 0.9rem;
  background: var(--k-danger-bg);
  color: var(--k-danger-fg);
  border-radius: var(--k-radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* ─── Repair status progress (public) ─────────────────────────────────────────── */
.repair-cancelled {
  padding: 0.75rem 1rem;
  background: var(--k-danger-bg);
  color: var(--k-danger-fg);
  border-radius: var(--k-radius-sm);
  margin: 1rem 0;
}

.repair-stages {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.repair-stage {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.45rem 0;
  position: relative;
}

.repair-stage:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 8px;
  top: calc(0.45rem + 18px);
  bottom: 0;
  width: 2px;
  background: var(--k-border);
}

.repair-stage--done::after { background: var(--k-success-fg); }

.repair-stage__dot {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 50%;
  border: 2px solid var(--k-border);
  background: var(--k-surface);
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  z-index: 1;
}

.repair-stage--done .repair-stage__dot {
  background: var(--k-success-fg);
  border-color: var(--k-success-fg);
}
.repair-stage--current .repair-stage__dot {
  border-color: var(--k-primary);
  background: var(--k-primary);
  box-shadow: 0 0 0 3px var(--k-primary-focus);
}

.repair-stage__label {
  font-weight: 500;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--k-text);
}

.repair-stage--done     .repair-stage__label { color: var(--k-muted); font-weight: 400; }
.repair-stage--current  .repair-stage__label { color: var(--k-text-strong); font-weight: 700; }
.repair-stage--upcoming .repair-stage__label { color: var(--k-muted); }

.repair-stage__now {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--k-primary);
  color: #fff;
  vertical-align: middle;
}

.repair-works {
  padding-left: 1.25rem;
  margin: 0.5rem 0 1rem;
}
.repair-works li { margin: 0.25rem 0; font-size: 0.9rem; }

/* ─── Public profile ──────────────────────────────────────────────────────────── */
.pub-contacts {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--k-border);
  font-size: 0.9rem;
  color: var(--k-muted);
}
.pub-contacts p { margin: 0.2rem 0; }

/* ─── Booking time slots ──────────────────────────────────────────────────────── */
.slots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.slot {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  margin: 0;
  font-weight: 400;
}

.slot input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.slot span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 1rem;
  border: 1.5px solid var(--k-input-border);
  border-radius: var(--k-radius-sm);
  background: var(--k-surface);
  font-size: 0.875rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--k-text);
  transition: border-color 0.12s, background-color 0.12s, color 0.12s;
}

.slot:hover span {
  border-color: var(--k-primary);
  color: var(--k-primary);
}

.slot input:checked + span {
  border-color: var(--k-primary);
  background: color-mix(in srgb, var(--k-primary) 10%, #fff);
  color: var(--k-primary);
  font-weight: 700;
  box-shadow: 0 0 0 1px var(--k-primary);
}

/* ─── Review stars (public) ───────────────────────────────────────────────────── */
.repair-review {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--k-border);
}
.repair-stars {
  font-size: 1.4rem;
  color: #f59e0b;
  letter-spacing: 0.1rem;
  margin: 0.2rem 0;
}
.star-input {
  display: inline-flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  font-size: 2rem;
  line-height: 1;
  margin: 0.3rem 0 0.6rem;
}
.star-input input { position: absolute; opacity: 0; width: 0; height: 0; }
.star-input label {
  color: var(--k-border-muted);
  cursor: pointer;
  padding: 0 0.05rem;
  transition: color 0.1s;
}
.star-input input:checked ~ label,
.star-input label:hover,
.star-input label:hover ~ label { color: #f59e0b; }

.repair-rebook  { margin-top: 1.25rem; }
.repair-history { margin-top: 1.25rem; }
.repair-history summary { cursor: pointer; font-weight: 600; }
.repair-history__list   { margin: 0.6rem 0 0; padding-left: 1.1rem; }
.repair-history__list li { margin: 0.25rem 0; }

/* ─── Micro-transitions ────────────────────────────────────────────────────────── */
button, [role="button"], .set-card, article.vehicle-card, .pill {
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.1s ease;
}

.card-grid article:hover,
.set-card:hover { box-shadow: var(--k-shadow); }

@media (prefers-reduced-motion: reduce) {
  button, [role="button"], .set-card, article.vehicle-card, .pill {
    transition: none;
  }
  button:active, [role="button"]:active { transform: none; }
}

/* ─── Schedule layout: left panel + timeline ─────────────────────────────────── */
.sched-layout {
  display: grid;
  grid-template-columns: 15rem 1fr;
  gap: 1rem;
  align-items: start;
}
.sched-layout.panel-collapsed { grid-template-columns: 0 1fr; }
.sched-layout.panel-collapsed .sched-panel { display: none; }

.sched-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.6rem;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  background: var(--k-surface);
  position: sticky;
  top: 3.75rem; /* below the ~52px topbar + gap */
  font-size: 0.85rem;
}

/* Compact controls in schedule panel */
.sched-panel button,
.sched-panel [role="button"],
.sched-panel input,
.sched-panel select {
  font-size: 12px;
  height: 28px;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
}
.sched-panel button,
.sched-panel [role="button"] {
  padding: 0 0.625rem;
}
.sched-panel input[type="date"] {
  padding: 0 0.5rem;
  line-height: 26px;
}

.schedp-block { display: flex; flex-direction: column; gap: 0.35rem; }
.schedp-block + .schedp-block {
  border-top: 1px solid var(--k-border-muted);
  padding-top: 0.6rem;
}
.schedp-block .schedule-date { font-size: 0.88rem; }

.schedp-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--k-muted);
}
.schedp-nav { display: flex; gap: 0.3rem; }
.schedp-nav [role="button"] { flex: 1; }
.schedp-toggle { display: flex; gap: 0.3rem; }
.schedp-toggle [role="button"] { flex: 1; text-align: center; }
.sched-panel .full { width: 100%; }

/* Collapse toggle button */
.schedp-collapse {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 0.35rem;
  padding: 0;
  background: none;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius-sm);
  color: var(--k-muted);
  cursor: pointer;
  vertical-align: middle;
  flex-shrink: 0;
}
.schedp-collapse:hover {
  background: var(--k-surface-3);
  color: var(--k-text);
  border-color: var(--k-border);
}

.sched-heading {
  display: flex;
  align-items: center;
  gap: 0;
}

.sched-main { min-width: 0; }
.sched-main .toolbar { margin-bottom: 0.6rem; }
.sched-main .toolbar h1 { font-size: 1.1rem; font-weight: 700; }

@media (max-width: 640px) {
  .sched-layout, .sched-layout.panel-collapsed {
    grid-template-columns: 1fr;
  }
  .sched-panel { position: static; }
}

/* ─── Timeline (#1): grid, columns, drag/resize ──────────────────────────────── */
.tl-board { overflow-x: auto; padding-bottom: 0.5rem; }

.tl {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: max-content;
}

.tl-axis {
  flex: 0 0 44px;
  padding-top: 1px;
}
.tl-axis-body { position: relative; }
.tl-hour {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-size: 0.68rem;
  color: var(--k-muted);
}

.tl-col {
  flex: 0 0 11rem;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius-sm);
  overflow: hidden;
  background: var(--k-surface);
}

.tl-col-head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
  height: 3.25rem;
  box-sizing: border-box;
  padding: 0.35rem 0.55rem;
  overflow: hidden;
  border-bottom: 1px solid var(--k-border);
  background: var(--k-surface);
}
.tl-col-head strong { font-size: 0.8rem; font-weight: 600; }
.tl-col-head .muted { font-size: 0.68rem; }

.tl[data-view="week"] .tl-col { flex: 0 0 8.5rem; }

.tl-col--today { border-color: var(--k-primary); }
.tl-col--today .tl-col-head {
  background: color-mix(in srgb, var(--k-primary) 8%, #fff);
}
.tl-col--today .tl-col-head strong { color: var(--k-primary); }

.tl-lane { position: relative; }

.tl-line {
  position: absolute;
  left: 0; right: 0;
  border-top: 1px dashed color-mix(in srgb, var(--k-border) 55%, transparent);
  pointer-events: none;
}
.tl-line--hour {
  border-top-style: solid;
  border-top-color: var(--k-border);
}

.tl-appt {
  position: absolute;
  left: 4px; right: 4px;
  overflow: hidden;
  box-sizing: border-box;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  border-left: 3px solid var(--k-primary);
  background: color-mix(in srgb, var(--k-primary) 12%, #fff);
  font-size: 0.75rem;
  line-height: 1.25;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.tl-appt:active { cursor: grabbing; }

.tl-appt[data-status="confirmed"] {
  border-left-color: #2563eb;
  background: color-mix(in srgb, #2563eb 12%, #fff);
}
.tl-appt[data-status="in_progress"] {
  border-left-color: #d97706;
  background: color-mix(in srgb, #d97706 14%, #fff);
}
.tl-appt[data-status="done"] {
  border-left-color: #16a34a;
  background: color-mix(in srgb, #16a34a 12%, #fff);
}
.tl-appt--conflict {
  outline: 2px solid #dc2626;
  outline-offset: -2px;
}

.tl-appt-time { font-weight: 600; }
.tl-appt-flag {
  position: absolute;
  top: 2px; right: 4px;
  color: #dc2626;
}

.tl-resize {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 8px;
  cursor: ns-resize;
  background: linear-gradient(transparent, color-mix(in srgb, var(--k-primary) 30%, transparent));
}

/* Column load bar */
.tl-load {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--k-muted);
}
.tl-loadbar {
  margin-top: 0.25rem;
  height: 3px;
  border-radius: 2px;
  background: var(--k-border);
  overflow: hidden;
}
.tl-loadbar span {
  display: block;
  height: 100%;
  background: var(--k-primary);
}

/* Mechanic chips on appointment block */
.tl-appt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 2px;
}
.tl-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.2rem;
  border-radius: 99px;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}
.tl-appt-post { font-size: 0.7rem; }

/* Axis spacer — same height as col-head for alignment, visually invisible */
.tl-axis .tl-col-head {
  background: transparent;
  border-bottom-color: transparent;
}

/* Appointment hover */
.tl-appt:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  z-index: 5;
}

/* Dragging visual feedback */
.tl-appt--dragging {
  opacity: 0.80;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  z-index: 50;
}

/* Плавная привязка к сетке при отпускании */
.tl-appt--snapping {
  transition: top 0.10s cubic-bezier(0.2, 0, 0.3, 1), height 0.10s cubic-bezier(0.2, 0, 0.3, 1);
}

/* Current time indicator */
.tl-now {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: #ef4444;
  pointer-events: none;
  z-index: 10;
}
.tl-now::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
}

/* ─── Span utility ────────────────────────────────────────────────────────────── */
.span-2 { grid-column: 1 / -1; }

/* ─── Vehicle search hits (appointment form) ─────────────────────────────────── */
.veh-hits {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius-sm);
  overflow: hidden;
  max-height: 12rem;
  overflow-y: auto;
}
.veh-hits li + li { border-top: 1px solid var(--k-border-muted); }
.veh-hit {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.6rem;
  background: none;
  border: 0;
  height: auto;
  border-radius: 0;
  color: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.veh-hit:hover, .veh-hit:focus {
  background: color-mix(in srgb, var(--k-primary) 8%, #fff);
}
.veh-hit strong { font-variant-numeric: tabular-nums; }
.veh-hits-empty { margin: 0.35rem 0 0; font-size: 0.85rem; }

/* ─── App shell: business panel density ──────────────────────────────────────── */
.app-shell {
  font-size: 14px;
}
.app-shell main.container {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}
.app-shell h1 { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.app-shell h2 { font-size: 1rem;    font-weight: 700; line-height: 1.3; }
.app-shell h3 { font-size: 0.9rem;  font-weight: 700; }
.app-shell hgroup > p {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--k-muted);
}
.app-shell .app-topbar-inner { padding-block: 0.5rem; }
.app-shell .app-menu > a     { font-size: 0.875rem; }
.app-shell main.container > h1,
.app-shell main.container .toolbar h1 { margin-bottom: 1.25rem; }
.app-shell main.container > hgroup    { margin-bottom: 1.25rem; }
.app-shell .toolbar   { margin-bottom: 1rem; }
.app-shell .section   { margin-top: 1.5rem; }
.app-shell main.container > h1 { font-size: 1.25rem; }

/* ─── Support chat ────────────────────────────────────────────────────────────── */
.support-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 16px;
  align-items: start;
  /* topbar ≈45px + container padding-top 24px + padding-bottom 48px = 117px;
     use 120px so layout never causes page scroll (scroll → textarea focus → layout jumps) */
  height: calc(100dvh - 120px);
  max-height: 680px;
}
.support-chat-col {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--k-surface);
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-sm);
  overflow: hidden;
}
.support-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--k-border);
  background: var(--k-surface-2);
  flex-shrink: 0;
}
.support-chat-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
}
.support-chat-sub {
  display: block;
  font-size: 11px;
  color: var(--k-muted);
  margin-top: 1px;
}
.support-escalate-btn {
  margin: 0;
  width: auto !important;
  white-space: nowrap;
  font-size: 12px !important;
}
.support-notice {
  padding: 6px 14px;
  font-size: 12px;
  flex-shrink: 0;
}
.support-notice.escalated {
  background: #eef2ff;
  border-bottom: 1px solid #c7d2fe;
  color: #4338ca;
}
#support-messages {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0; /* flex item must shrink to let overflow-y:auto work */
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--k-surface-2);
}
.support-msg {
  padding: 6px 10px;
  border-radius: 10px;
  width: fit-content;
  max-width: min(72%, 440px);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
}
.support-msg.user {
  align-self: flex-end;
  background: var(--k-primary);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.support-msg.assistant {
  align-self: flex-start;
  background: var(--k-surface);
  border: 1px solid var(--k-border-muted);
  border-bottom-left-radius: 3px;
}
.support-msg.owner {
  align-self: flex-start;
  background: #fef9c3;
  border: 1px solid #fde68a;
  border-bottom-left-radius: 3px;
}
.msg-meta {
  font-size: 10px;
  opacity: 0.5;
  margin-top: 3px;
  line-height: 1.3;
  white-space: normal;
}
.support-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 14px;
  border-top: 1px solid var(--k-border);
  background: var(--k-surface);
  flex-shrink: 0;
  margin: 0;
}
.support-input-row textarea {
  flex: 1;
  resize: none;
  margin-bottom: 0;
  font-size: 13px;
}
.support-send-btn {
  width: auto !important;
  white-space: nowrap;
  flex-shrink: 0;
  margin-bottom: 0;
  font-size: 13px;
}
.support-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.support-sidebar-block {
  background: var(--k-surface);
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  padding: 12px 14px;
}
.support-sidebar-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--k-muted);
  margin: 0 0 8px;
}
.support-faq {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.support-faq li {
  font-size: 12px;
  color: var(--k-primary);
  cursor: default;
}
.support-sidebar-text {
  font-size: 12px;
  color: var(--k-muted);
  margin: 0;
  line-height: 1.5;
}
.support-empty-hint {
  color: var(--k-muted);
  text-align: center;
  margin: 2rem 0;
  font-size: 0.875rem;
}
@media (max-width: 640px) {
  .support-layout {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }
  .support-chat-col {
    height: 70dvh; /* dvh tracks viewport dynamically (adjusts when keyboard opens) */
    min-height: 380px;
  }
  .support-sidebar { display: none; }
  .support-msg { max-width: 88%; }
}
