/* ==========================================================================
   Панель владельца — дизайн-система.
   Порядок: токены → база → компоненты (кнопки, чипы, карточки, поля,
   таблицы) → каркас (сайдбар, topbar, таббар) → экраны.
   ========================================================================== */

:root {
  color-scheme: light;

  /* --- токены сайта --- */
  --bg: #F7F7F8;
  --surface: #FFFFFF;
  --surface-2: #EFEFF2;
  --ink: #0A0A0D;
  --ink-2: #5B5B66;
  --ink-3: #9A9AA5;
  --line: rgba(10, 10, 13, .08);
  --line-2: rgba(10, 10, 13, .14);
  --dark: #0A0A0F;
  --on-dark: #F4F4F6;
  --on-dark-2: rgba(244, 244, 246, .62);
  --accent: #5B4CFF;
  --grad: linear-gradient(135deg, #1B1150 0%, #3B2BD9 38%, #7C5CFF 70%, #C9B8FF 100%);
  --glow: rgba(91, 76, 255, .35);
  --shadow-1: 0 8px 30px rgba(10, 10, 13, .06);
  --shadow-2: 0 24px 70px rgba(10, 10, 13, .10);
  --shadow-glow: 0 40px 100px -30px rgba(91, 76, 255, .35);
  --r-xl: 28px;
  --r-lg: 20px;
  --r-md: 12px;
  --r-sm: 10px;
  --r-pill: 999px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);

  /* --- тона статусов --- */
  --accent-bg: #5B4CFF14;
  --ok: #1F9D67;
  --ok-bg: #1F9D6714;
  --warn: #C77700;
  --warn-bg: #F5B94226;
  --danger: #D64545;
  --danger-bg: #D6454514;

  /* --- метрики каркаса --- */
  --sidebar-w: 248px;
  --topbar-h: 72px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, .num, .display {
  font-family: 'Inter Tight', Inter, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  letter-spacing: -.03em;
  font-weight: 600;
  margin: 0;
}

h1 { font-size: 27px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

p { margin: 0; }

a { color: inherit; }

.num {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
}

.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.empty { color: var(--ink-3); font-size: 14px; padding: 18px 2px; }

/* Единая рамка фокуса с клавиатуры: кнопки, ссылки, поля и кликабельные строки */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* У полей ввода своя подсветка фокуса (box-shadow ниже) — вторую рамку не рисуем */
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
.drawer-title:focus-visible { outline-offset: 4px; }

/* Плашка вместо «Загрузка…», когда запрос упал (см. errorNode в panel.js) */
.load-error {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 2px;
  color: var(--ink-2);
  font-size: 14px;
}
.load-error-text::after { content: ' ·'; color: var(--ink-3); }

/* Текстовая кнопка-ссылка («снять все / выбрать все») */
.link-btn {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--ink); }

/* Пока открыта шторка, фон не прокручивается */
body.drawer-open { overflow: hidden; }
.eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.mono {
  font-family: ui-monospace, 'JetBrains Mono', SF Mono, Menlo, monospace;
}
[hidden] { display: none !important; }
tr[hidden] { display: none !important; }

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

button, input, select, textarea { font-family: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .2s var(--ease-out), border-color .2s var(--ease-out),
              box-shadow .2s var(--ease-out), transform .2s var(--ease-out), opacity .2s var(--ease-out);
}
.btn:disabled { opacity: .45; pointer-events: none; }

/* primary — чёрная капсула */
.btn-primary { background: var(--dark); color: var(--on-dark); }
.btn-primary:hover { background: #22222B; }

/* secondary — белая капсула с рамкой */
.btn-ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-2); }

/* акцентная кнопка живёт только на градиентной карточке */
.btn-on-grad {
  background: #fff;
  color: #1B1150;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(10, 10, 13, .18);
}
.btn-on-grad:hover { background: #F4F2FF; transform: translateY(-1px); }

.btn-quiet {
  background: transparent;
  color: var(--ink-2);
  height: 36px;
  padding: 0 12px;
  font-weight: 400;
}
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #D6454524; }

.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-lg { height: 50px; padding: 0 26px; font-size: 15px; }
.btn-block { width: 100%; }

/* круглая кнопка-иконка (⋯, ×, стрелки недели) */
.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  border-color: var(--line-2);
  color: var(--ink-2);
  background: var(--surface);
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.link-btn {
  border: none;
  background: none;
  padding: 0;
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
  transition: color .2s var(--ease-out);
}
.link-btn:hover { color: var(--ink); }

/* ==========================================================================
   Чипы статусов и дельты
   ========================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 11px 0 9px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--ink-2);
}
.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.chip-accent { background: var(--accent-bg); color: var(--accent); }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-mute { background: var(--surface-2); color: var(--ink-3); }
.chip-danger { background: var(--danger-bg); color: var(--danger); }

/* чип без точки — на градиентной карточке */
.chip-glass {
  background: rgba(255, 255, 255, .16);
  color: #fff;
  height: 28px;
  padding: 0 13px;
  font-size: 12px;
  letter-spacing: .01em;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.chip-glass::before { display: none; }

.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  color: var(--ink-3);
}
.delta-up { background: var(--ok-bg); color: var(--ok); }
.delta-down { background: var(--danger-bg); color: var(--danger); }

/* ==========================================================================
   Аватары
   ========================================================================== */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: 'Inter Tight', Inter, sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .01em;
  text-transform: uppercase;
}
.avatar-grad { background: var(--grad); color: #fff; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }

/* ==========================================================================
   Карточки
   ========================================================================== */

.card {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-1);
  padding: 24px 26px;
}
.card-hover { transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.card-flush { padding: 24px 8px 8px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.card-flush .card-head { padding: 0 18px; }
.card-head-sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

/* градиентная карточка — единственный яркий акцент на экране */
.grad-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xl);
  background: var(--grad);
  color: #fff;
  box-shadow: var(--shadow-glow);
  padding: 28px;
}
.grad-card::after {
  content: "";
  position: absolute;
  top: -70px;
  right: -60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 184, 255, .6), transparent 68%);
  pointer-events: none;
}
.grad-card > * { position: relative; z-index: 1; }
/* Свечение градиентной карточки не должно ложиться на плитки ниже: карточка — отдельный контекст с z-index 0 */
.grad-card { z-index: 0; }

/* ==========================================================================
   Поля ввода
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: 7px; }
.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.field-hint { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }

input, select, textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: background-color .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
textarea {
  height: auto;
  min-height: 88px;
  padding: 12px 14px;
  line-height: 1.5;
  resize: vertical;
}
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 20px, calc(100% - 12px) 20px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, select:focus, textarea:focus {
  background: var(--surface);
  box-shadow: 0 0 0 3px #5B4CFF33;
}
input[type="date"] { padding-right: 10px; }

input.is-draft, textarea.is-draft {
  background: var(--accent-bg);
  box-shadow: 0 0 0 1.5px var(--accent) inset;
}

.draft-badge {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--accent);
}

.form { display: flex; flex-direction: column; gap: 18px; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 4px; }

.error {
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 13px;
}

.draft-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--accent-bg);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 13px;
  margin-bottom: 18px;
}

/* ==========================================================================
   Сегментированный контрол
   ========================================================================== */

.seg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg-item {
  border: none;
  background: transparent;
  height: 34px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s var(--ease-out), color .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.seg-item:hover { color: var(--ink); }
.seg-item.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(10, 10, 13, .08);
}

/* ==========================================================================
   Таблицы и строки-списки
   ========================================================================== */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  padding: 0 14px 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
.table td {
  padding: 0 14px;
  height: 56px;
  font-size: 14px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:first-child td { border-top: 1px solid var(--line); }
/* Растягиваемая колонка (текст заявки): занимает остаток ширины, лишнее — в многоточие, без горизонтального скролла */
.table td.td-grow { width: 100%; max-width: 0; }
.table td.td-grow .ellipsis { max-width: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table tr.clickable:hover td:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.table tr.clickable:hover td:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.cell-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-title { font-weight: 500; }
.cell-sub { font-size: 12.5px; color: var(--ink-3); }
.cell-stack { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.actions-cell { display: flex; gap: 8px; justify-content: flex-end; }
.nowrap { white-space: nowrap; }

/* строки-списки (брони/заявки на «Сегодня», детали) */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-radius: var(--r-lg);
  transition: background-color .2s var(--ease-out);
}
.row + .row { box-shadow: 0 -1px 0 var(--line); }
.row.clickable { cursor: pointer; }
.row.clickable:hover { background: var(--surface-2); box-shadow: none; }
.row-flush { padding-left: 0; padding-right: 0; }
.row-body { flex: 1 1 auto; min-width: 0; }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-aside { display: flex; align-items: center; gap: 10px; flex: none; }

/* Узкие экраны: боковая часть строки (чипы, переключатели, кнопки) уходит на вторую строку, текст переносится */
@media (max-width: 900px) {
  .row { flex-wrap: wrap; }
  .row-aside { flex-basis: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .row-title, .row-sub { white-space: normal; }
}

/* Черновики ресурсов из базы знаний (SPEC §13.1) */
.resource-drafts { margin-top: 18px; }
.draft-selection { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.draft-check { display: flex; align-items: center; gap: 12px; cursor: pointer; flex: 1 1 auto; min-width: 0; }
.draft-check > div { flex: 1 1 auto; min-width: 0; }
.draft-check input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; flex: none; }
.draft-fields { display: flex; gap: 14px; flex: none; }
.draft-fields .field { gap: 4px; }
.draft-fields .field-label { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.draft-fields input { width: 96px; }
@media (max-width: 900px) {
  .draft-fields { flex-basis: 100%; padding-left: 32px; }
}

/* ==========================================================================
   Каркас: сайдбар, topbar, таббар
   ========================================================================== */

.screen.is-hidden { display: none !important; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 26px 16px 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px 22px;
  font-family: 'Inter Tight', Inter, sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  font-size: 15px;
  line-height: 1;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; }
button.nav-link { border: none; background: none; font-family: inherit; cursor: pointer; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 42px;
  padding: 0 12px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background-color .2s var(--ease-out), color .2s var(--ease-out);
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { background: var(--surface-2); color: var(--ink); }
.nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: var(--r-pill);
  background: var(--accent);
}
.nav-icon { display: flex; flex: none; width: 19px; height: 19px; }
.nav-icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-text { flex: 1 1 auto; }
.nav-count {
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 20px;
  text-align: center;
}
.nav-count[hidden] { display: none !important; }

/* Роли (§15.2): manager/viewer не видят разделы, доступные только владельцу. */
body.role-manager .nav-restricted,
body.role-viewer .nav-restricted { display: none; }

/* viewer видит всё, но ничего не может изменить. */
body.role-viewer .btn-primary,
body.role-viewer .btn-danger { display: none; }

/* Сценарий тенанта (SPEC §17): lead — без броней и ресурсов, вместо ресурсов «Вопросы клиенту». */
.nav-scenario-lead { display: none; }
body.scenario-lead .nav-scenario-lead { display: flex; }
body.scenario-lead .nav-scenario-rental { display: none; }

.sidebar-promo {
  padding: 20px;
  border-radius: var(--r-lg);
  background: var(--grad);
  color: #fff;
  box-shadow: 0 18px 40px -22px var(--glow);
  position: relative;
  overflow: hidden;
}
.sidebar-promo::after {
  content: "";
  position: absolute;
  top: -50px; right: -40px;
  width: 150px; height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 184, 255, .6), transparent 70%);
}
.sidebar-promo > * { position: relative; z-index: 1; }
.promo-title { font-family: 'Inter Tight', Inter, sans-serif; font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.promo-text { font-size: 12.5px; color: rgba(255, 255, 255, .74); margin: 6px 0 14px; line-height: 1.45; }
.sidebar-foot { display: flex; justify-content: center; padding-top: 12px; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 34px;
  background: rgba(247, 247, 248, .86);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 460px;
}
.search svg {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  stroke: var(--ink-3);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  pointer-events: none;
}
.search input {
  height: 42px;
  padding: 0 56px 0 42px;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.search input:focus { box-shadow: inset 0 0 0 1px transparent, 0 0 0 3px #5B4CFF33; }
.kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  height: 24px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 11.5px;
  line-height: 24px;
  pointer-events: none;
}
.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
/* Приветствие/название экрана — показывается вместо поиска там, где искать нечего */
.topbar-greet {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.topbar-greet[hidden], .search[hidden] { display: none; }
.tenant-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view { padding: 30px 34px 90px; max-width: 1280px; }
.view-inner { animation: view-in .26s var(--ease-out) both; }
/* Экраны со списком: карточка таблицы растягивается до низа окна */
.view-inner.view-fill { display: flex; flex-direction: column; min-height: calc(100vh - 64px - 120px); }
.view-fill .card-fill { flex: 1 1 auto; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head-sub { font-size: 13.5px; color: var(--ink-2); margin-top: 4px; }
.page-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.tabbar { display: none; }

/* ==========================================================================
   Сетка экранов
   ========================================================================== */

.mt-18 { margin-top: 18px; }

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }
.grid + .grid { margin-top: 20px; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-12 { grid-column: span 12; }

/* ==========================================================================
   «Сегодня»: hero, KPI, диаграмма
   ========================================================================== */

.hero { display: flex; flex-direction: column; height: 100%; min-height: 236px; }
.hero-title {
  font-family: 'Inter Tight', Inter, sans-serif;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -.03em;
  margin: 18px 0 10px;
}
.hero-sub { font-size: 13.5px; color: rgba(255, 255, 255, .72); }
.hero-actions { margin-top: auto; padding-top: 22px; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.kpi { display: flex; flex-direction: column; gap: 10px; min-height: 108px; position: relative; z-index: 1; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kpi-label { font-size: 13px; color: var(--ink-2); }
.kpi-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.kpi-value {
  font-family: 'Inter Tight', Inter, sans-serif;
  font-size: 42px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.kpi-foot { font-size: 12px; color: var(--ink-3); margin-top: auto; }

.bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 26px 6px 0;
}
.bar-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
/* Столбец открывает шторку дня — ведёт себя как кнопка */
.bar-col.clickable { cursor: pointer; }
.bar-slot { position: relative; width: 100%; height: 150px; display: flex; align-items: flex-end; }
.bar {
  width: 100%;
  height: var(--h, 6px);
  min-height: 6px;
  border-radius: 10px;
  background: var(--surface-2);
  transition: background-color .2s var(--ease-out), transform .2s var(--ease-out);
}
.bar-col:hover .bar { transform: scaleY(1.02); transform-origin: bottom; }
.bar-col.is-max .bar { background: var(--accent); }
.bar-col.is-today .bar { background: #5B4CFF4D; }
.bar-col.is-max.is-today .bar { background: var(--accent); }
.bar-tip {
  position: absolute;
  left: 50%;
  bottom: calc(var(--h, 6px) + 10px);
  transform: translateX(-50%);
  height: 24px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--dark);
  color: var(--on-dark);
  font-size: 12px;
  font-weight: 500;
  line-height: 24px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .18s var(--ease-out);
  pointer-events: none;
}
.bar-col.is-max .bar-tip, .bar-col:hover .bar-tip { opacity: 1; }
.bar-day { font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-col.is-today .bar-day { color: var(--accent); font-weight: 500; }

/* ==========================================================================
   Недельная сетка броней
   ========================================================================== */

.grid-wrap { overflow-x: auto; }
.week-grid { table-layout: fixed; min-width: 880px; width: 100%; border-collapse: separate; border-spacing: 0; }
.week-grid th { padding: 0 8px 12px; text-align: center; }
.week-grid th:first-child { text-align: left; width: 168px; }
.week-grid td {
  height: auto;
  min-height: 64px;
  padding: 8px;
  vertical-align: top;
  border-top: 1px solid var(--line);
}
.week-grid td:first-child {
  vertical-align: middle;
  font-weight: 500;
  font-size: 14px;
  padding-left: 14px;
}
/* Название ресурса остаётся видимым при горизонтальной прокрутке сетки. */
.week-grid th:first-child, .week-grid td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
}
.week-grid .is-today { background: #5B4CFF0F; }
.week-grid th.is-today { color: var(--accent); font-weight: 600; background: transparent; }
.week-grid th.is-today .day-num { color: var(--accent); }
.day-head { display: flex; flex-direction: column; gap: 2px; align-items: center; }
.day-name { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.day-num { font-family: 'Inter Tight', Inter, sans-serif; font-size: 14px; font-weight: 500; letter-spacing: -.02em; color: var(--ink); }

.bk {
  display: block;
  width: 100%;
  border: none;
  text-align: left;
  border-radius: var(--r-pill);
  padding: 6px 12px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.bk:hover { transform: translateY(-1px); box-shadow: var(--shadow-1); }
.bk-accent { background: var(--accent-bg); color: var(--accent); }
.bk-ok { background: var(--ok-bg); color: var(--ok); }
.bk-warn { background: var(--warn-bg); color: var(--warn); }
.bk-mute { background: var(--surface-2); color: var(--ink-3); text-decoration: line-through; }
.bk-danger { background: var(--danger-bg); color: var(--danger); }

/* ==========================================================================
   Выезжающая панель деталей и меню
   ========================================================================== */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(10, 10, 13, .28);
  animation: fade-in .2s var(--ease-out);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 460px;
  max-width: 100vw;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  animation: drawer-in .28s var(--ease-out);
}
@keyframes drawer-in {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: none; }
}
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 26px 26px 16px;
}
.drawer-title { font-family: 'Inter Tight', Inter, sans-serif; font-size: 20px; font-weight: 600; letter-spacing: -.03em; }
.drawer-sub { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 0 26px 26px; }
.drawer-foot {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 18px 26px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.drawer-foot .btn { flex: 1 1 140px; }

.block { margin-top: 24px; }
.block-title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.facts { display: flex; flex-direction: column; gap: 10px; }
.fact { display: flex; gap: 14px; font-size: 14px; }
.fact-key { color: var(--ink-3); flex: none; width: 118px; }
.fact-val { color: var(--ink); word-break: break-word; }

.dialog { display: flex; flex-direction: column; gap: 10px; }
.dialog-msg {
  border-radius: var(--r-lg);
  padding: 12px 14px;
  background: var(--surface-2);
  max-width: 92%;
}
.dialog-msg.dialog-assistant { background: #5B4CFF0F; align-self: flex-end; }
.dialog-role { display: block; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.dialog-text { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.dialog-time { display: block; font-size: 11px; color: var(--ink-3); margin-top: 6px; }

.menu {
  position: fixed;
  z-index: 120;
  min-width: 208px;
  padding: 8px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--line);
  animation: view-in .16s var(--ease-out) both;
}
.menu-item {
  display: block;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  transition: background-color .15s var(--ease-out);
}
.menu-item:hover { background: var(--surface-2); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* ==========================================================================
   Настройки
   ========================================================================== */

.settings { display: flex; flex-direction: column; gap: 20px; max-width: 980px; }
.settings input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.set-row {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
}
.set-row:first-of-type { border-top: none; padding-top: 6px; }
.set-side-title { font-size: 14px; font-weight: 500; }
.set-side-text { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; margin-top: 4px; }

.code-block {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, 'JetBrains Mono', SF Mono, Menlo, monospace;
  margin: 0;
}

/* ==========================================================================
   FAQ (#/faq)
   ========================================================================== */

.faq-stats { display: flex; gap: 40px; flex-wrap: wrap; }
.faq-stat { display: flex; flex-direction: column; gap: 6px; }
.faq-stats-caption { font-size: 12.5px; color: var(--ink-2); margin-top: 16px; }

/* ==========================================================================
   Мастер настройки (#/setup)
   ========================================================================== */

.setup-progress-wrap { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.setup-progress-label { font-size: 13.5px; color: var(--ink-2); }
.setup-progress-bar {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  overflow: hidden;
}
.setup-progress-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--grad);
  transition: width .3s var(--ease-out);
}

.setup-steps { display: flex; flex-direction: column; gap: 14px; }
.setup-step { padding: 0; overflow: hidden; }
.setup-step-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  cursor: pointer;
}
.setup-step-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: 'Inter Tight', Inter, sans-serif;
  font-size: 13px;
  font-weight: 600;
}
.setup-step-circle.is-done { background: var(--accent); color: #fff; }
.setup-step-circle svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.setup-step-title { flex: 1 1 auto; font-weight: 500; }
.setup-step-toggle svg { transition: transform .2s var(--ease-out); }
.setup-step-toggle.is-open svg { transform: rotate(180deg); }
.setup-step-body { padding: 0 24px 24px; }
.setup-step-body[hidden] { display: none; }

.setup-scenario-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.setup-scenario-card {
  text-align: left;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color .2s var(--ease-out), background-color .2s var(--ease-out);
}
.setup-scenario-card:hover { background: var(--surface-2); }
.setup-scenario-card.is-active { border-color: var(--accent); background: var(--accent-bg); }
.setup-scenario-title { font-weight: 500; margin-bottom: 4px; }
.setup-scenario-text { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }

.setup-material-row { display: flex; align-items: center; gap: 10px; }
.setup-material-row input { flex: 1 1 auto; }

.setup-step-body input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }

@media (max-width: 900px) {
  .setup-scenario-pick { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Внешний вид виджета (шаг «Сайт»)
   ========================================================================== */

.widget-theme-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.widget-theme-card { text-align: center; padding: 14px; }
.widget-theme-card .setup-scenario-title { margin-bottom: 0; font-size: 13px; }

.widget-theme-preview {
  position: relative;
  height: 60px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  margin-bottom: 10px;
  overflow: hidden;
}
.widget-theme-preview .wtp-bubble {
  position: absolute;
  left: 10px;
  top: 12px;
  width: 56%;
  height: 22px;
  border-radius: 10px 10px 10px 2px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(10, 10, 13, .08);
}
.widget-theme-preview .wtp-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
}
/* минимализм: контур вместо заливки, пузырь — линия слева */
.widget-theme-preview-minimal .wtp-bubble {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  border-left: 2px solid var(--accent);
}
.widget-theme-preview-minimal .wtp-btn {
  background: transparent;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
}
/* мессенджер: крупный пузырь-кнопка */
.widget-theme-preview-bubble .wtp-btn { width: 26px; height: 26px; }
.widget-theme-preview-bubble .wtp-bubble { border-radius: 14px 14px 14px 2px; }

@media (max-width: 900px) {
  .widget-theme-pick { grid-template-columns: 1fr; }
}

.widget-auto-color { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; cursor: pointer; font-size: 13.5px; }
.widget-auto-color input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }

input[type="color"] { width: 64px; height: 44px; padding: 4px; cursor: pointer; }
input[type="color"]:disabled { opacity: .45; cursor: not-allowed; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.segmented-btn {
  border: none;
  background: transparent;
  padding: 8px 18px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color .2s var(--ease-out), color .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.segmented-btn.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ==========================================================================
   Расход токенов (#/subscription)
   ========================================================================== */

.usage-bar {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--grad);
  transition: width .3s var(--ease-out), background-color .2s var(--ease-out);
}
.usage-bar-fill.is-warn { background: var(--warn); }
.usage-bar-fill.is-danger { background: var(--danger); }

/* ==========================================================================
   Экран входа
   ========================================================================== */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% -20%, #5B4CFF14, transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 420px;
  padding: 34px 34px 32px;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  animation: view-in .3s var(--ease-out) both;
}
.login-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--grad);
  box-shadow: 0 12px 30px -10px var(--glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 17px;
  margin-bottom: 20px;
}
.login-card h1 { font-size: 26px; margin-bottom: 8px; }
.login-hint { color: var(--ink-2); font-size: 13px; line-height: 1.55; margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-tenants-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* Ссылка «Забыли пароль?» в одной строке с подписью поля */
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.field-label-link { font-size: 12.5px; color: var(--accent); text-decoration: none; }
.field-label-link:hover { text-decoration: underline; }

/* Приглашение зарегистрироваться под формой входа: появляется, только когда known signup_enabled */
.login-signup-invite {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 6px;
  animation: fade-in .25s var(--ease-out) both;
}
.login-divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 12px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--line); }

/* Скрытая ссылка входа по ключу — внизу карточки, маленькая и малозаметная */
.login-key-toggle { margin-top: 20px; text-align: center; }
.login-key-toggle .link-btn + .link-btn { margin-left: 4px; }

/* ==========================================================================
   Регистрация (#/signup): двухколоночный экран
   ========================================================================== */

.signup-screen {
  min-height: 100vh;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% -20%, #5B4CFF14, transparent 60%),
    var(--bg);
}
.signup-shell {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 24px;
  align-items: stretch;
  animation: view-in .3s var(--ease-out) both;
}
.signup-hero {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 36px 32px;
}
.signup-hero-title {
  font-family: 'Inter Tight', Inter, sans-serif;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -.03em;
  margin: 0;
}
.signup-hero-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.signup-hero-points li {
  position: relative;
  padding-left: 22px;
  font-size: 13.5px;
  line-height: 1.5;
  color: rgba(255, 255, 255, .86);
}
.signup-hero-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  opacity: .8;
}
.signup-trial-badge { align-self: flex-start; margin-top: auto; }
.signup-form-panel {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  padding: 34px;
}
.signup-form-panel h1 { font-size: 24px; margin-bottom: 6px; }

@media (max-width: 900px) {
  .signup-shell { grid-template-columns: 1fr; }
  .signup-hero { padding: 22px 20px; border-radius: var(--r-lg); gap: 12px; }
  .signup-hero-title { font-size: 22px; }
  .signup-hero-points { display: none; }
  .signup-form-panel { padding: 24px; border-radius: var(--r-lg); }
}

/* Поле-пароль с кнопкой показать/скрыть */
.password-field { position: relative; }
.password-field input { padding-right: 46px; }
.password-toggle {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.password-toggle:hover { background: var(--surface-2); color: var(--ink); }
.password-toggle svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle-slash { display: none; }
.password-toggle.is-shown .password-toggle-slash { display: inline; }

/* Индикатор надёжности пароля: три деления */
.password-strength { display: flex; gap: 6px; margin-top: 2px; }
.password-strength-seg { flex: 1 1 0; height: 4px; border-radius: var(--r-pill); background: var(--surface-2); transition: background-color .2s var(--ease-out); }
.password-strength-seg.is-weak { background: var(--danger); }
.password-strength-seg.is-medium { background: var(--warn); }
.password-strength-seg.is-strong { background: var(--ok); }

/* Чекбокс согласия с политикой */
.check-field { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--ink-2); line-height: 1.5; cursor: pointer; }
.check-field input[type="checkbox"] { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--accent); cursor: pointer; flex: none; }
.check-field a { color: var(--accent); }

/* Ошибка конкретного поля — под ним, не тостом */
.field-error { color: var(--danger); font-size: 12.5px; line-height: 1.4; }
.error a { color: inherit; text-decoration: underline; font-weight: 500; }

/* Общая утилита «видно только скринридерам»: подписи для доступности и поле-ловушка от ботов (.hp-field) */
.visually-hidden, .hp-field {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ==========================================================================
   Баннер подтверждения e-mail
   ========================================================================== */

.verify-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 34px;
  background: var(--accent-bg);
  border-bottom: 1px solid var(--line);
}
.verify-banner-text { font-size: 13.5px; color: var(--ink); }
.verify-banner-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.verify-banner-code {
  width: 116px;
  height: 38px;
  text-align: center;
  letter-spacing: .3em;
  font-variant-numeric: tabular-nums;
}
.verify-banner-error { flex-basis: 100%; color: var(--danger); font-size: 12.5px; }
@media (max-width: 900px) {
  .verify-banner { padding: 12px 16px; }
  .verify-banner-form { margin-left: 0; width: 100%; }
}

/* ==========================================================================
   Тосты
   ========================================================================== */

.toast-container {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1000;
  width: 100%;
  max-width: 380px;
  padding: 0 16px;
}
.toast {
  background: var(--dark);
  color: var(--on-dark);
  border-radius: var(--r-pill);
  padding: 12px 20px;
  font-size: 13px;
  box-shadow: var(--shadow-2);
  transition: opacity .24s var(--ease-out), transform .24s var(--ease-out);
}
.toast-error { background: var(--danger); color: #fff; }
.toast-hide { opacity: 0; transform: translateY(8px); }

/* Узкий график: подписи дней через одну, чтобы не наезжали друг на друга */
@media (max-width: 1100px) {
  .bar-col:nth-child(even) .bar-label { visibility: hidden; }
}

/* ==========================================================================
   Мобильная раскладка
   ========================================================================== */

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }

  .topbar { padding: 0 16px; height: 64px; gap: 10px; }
  .search { max-width: none; }
  .search .kbd { display: none; }
  .search input { padding-right: 16px; }
  .tenant-name { display: none; }

  .view { padding: 20px 16px 110px; }

  .grid { gap: 16px; }
  .col-4, .col-5, .col-6, .col-7 { grid-column: span 12; }
  .kpi-grid { gap: 16px; }
  html, body { overflow-x: hidden; }
  .card { padding: 20px; border-radius: var(--r-lg); }
  .card-flush { padding: 20px 4px 4px; }
  .card-flush .card-head { padding: 0 14px; }
  .grad-card { padding: 24px; border-radius: var(--r-lg); }
  .hero-title { font-size: 26px; }

  /* Шаги мастера: .card выше задаёт 20px, но у шага отступы — у шапки и тела */
  .setup-step { padding: 0; }
  .setup-step-head { padding: 16px 18px; gap: 12px; }
  .setup-step-body { padding: 0 18px 18px; }
  .view-inner.view-fill { min-height: calc(100vh - 64px - 110px - 36px); }

  /* Таблицы (кроме сетки броней) — стопка карточек: подпись из data-label, которую ставит labelTable() */
  .table-wrap { overflow-x: visible; }
  .table:not(.week-grid) thead { display: none; }
  .table:not(.week-grid), .table:not(.week-grid) tbody, .table:not(.week-grid) tr { display: block; width: 100%; }
  .table:not(.week-grid) tr { padding: 14px 16px; }
  .table:not(.week-grid) tr + tr { box-shadow: 0 -1px 0 var(--line); }
  .table:not(.week-grid) tbody tr:first-child td { border-top: 0; }
  .table:not(.week-grid) td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    height: auto;
    border: 0;
    text-align: left;
    min-width: 0;
  }
  .table:not(.week-grid) td::before {
    content: attr(data-label);
    color: var(--ink-3);
    font-size: 12.5px;
    flex: none;
  }
  .table:not(.week-grid) td:first-child { font-weight: 500; padding-bottom: 8px; }
  .table:not(.week-grid) td:first-child::before, .table:not(.week-grid) td:not([data-label])::before { content: none; }
  .table:not(.week-grid) td:empty, .table:not(.week-grid) td[data-empty] { display: none; }
  .table:not(.week-grid) td.td-grow { width: auto; max-width: none; flex-direction: column; align-items: flex-start; gap: 4px; }
  .table:not(.week-grid) td.td-grow .ellipsis { white-space: normal; overflow: visible; text-overflow: clip; }
  .table:not(.week-grid) td > * { min-width: 0; }
  .table tr.clickable:hover td { background: transparent; border-radius: 0; }
  .table tr.clickable:hover { background: var(--surface-2); }

  .set-row { grid-template-columns: 1fr; gap: 12px; }

  .drawer { width: 100vw; top: auto; height: 92vh; border-radius: var(--r-xl) var(--r-xl) 0 0; animation: sheet-in .28s var(--ease-out); }
  @keyframes sheet-in {
    from { opacity: 0; transform: translateY(28px); }
    to { opacity: 1; transform: none; }
  }

  .tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: 70px;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .tabbar .nav-link {
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    height: auto;
    padding: 8px 2px;
    border-radius: 0;
    background: none;
    font-size: 10.5px;
    font-weight: 500;
  }
  .tabbar .nav-link.active { color: var(--accent); background: none; }
  .tabbar .nav-link.active::before { display: none; }
  .tabbar .nav-text { flex: none; }
  .tabbar .nav-icon { width: 21px; height: 21px; }
  .tabbar .nav-count {
    position: absolute;
    top: 4px;
    left: 50%;
    margin-left: 4px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    font-size: 10.5px;
    background: var(--accent);
    color: #fff;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .card-hover:hover, .bk:hover, .btn-on-grad:hover { transform: none; }
}

/* Текст фрагмента внутри группы страницы: переносится целиком, без многоточия */
.knowledge-text { white-space: normal; line-height: 1.5; }

/* Индикатор ожидания: три точки, мигающие по очереди */
.draft-waiting { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13.5px; padding: 12px 0; }
.dots { display: inline-flex; gap: 4px; align-items: center; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .25; animation: dot-blink 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dot-blink { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }

/* Опасный пункт меню (удаление) */
.menu-item-danger { color: var(--danger); }

/* ==========================================================================
   Мастер после регистрации (#/welcome, SPEC §16.5) — полноэкранный, без бокового меню
   ========================================================================== */

body.wizard-open .sidebar,
body.wizard-open .topbar,
body.wizard-open .tabbar,
body.wizard-open #verify-banner,
body.wizard-open #readonly-banner { display: none !important; }
body.wizard-open .main { margin-left: 0; }
body.wizard-open .view { padding: 0; max-width: none; }

.wizard { display: flex; flex-direction: column; min-height: 100vh; background: var(--bg); }

.wizard-head {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.wizard-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Inter Tight', Inter, sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink);
}
.wizard-brand-mark {
  font-size: 15px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.wizard-progress { display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; min-width: 160px; max-width: 340px; margin: 0 auto; }
.wizard-progress-label { font-size: 12.5px; color: var(--ink-2); text-align: center; }
.wizard-progress-dots { display: flex; gap: 6px; }
.wizard-dot { flex: 1 1 auto; height: 4px; border-radius: var(--r-pill); background: var(--surface-2); }
.wizard-dot.is-active { background: var(--accent); }
.wizard-exit { flex: none; white-space: nowrap; }

.wizard-body { display: flex; align-items: flex-start; gap: 32px; padding: 28px; max-width: 1120px; margin: 0 auto; width: 100%; flex: 1 1 auto; }

.wizard-nav { display: flex; flex-direction: column; gap: 4px; width: 216px; flex: none; }
.wizard-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  background: none;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--r-md);
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-3);
  cursor: pointer;
  transition: background-color .2s var(--ease-out), color .2s var(--ease-out);
}
.wizard-nav-item:disabled { cursor: default; opacity: .55; }
.wizard-nav-item.is-current { background: var(--surface-2); color: var(--ink); font-weight: 500; opacity: 1; }
.wizard-nav-item.is-done, .wizard-nav-item.is-skipped { color: var(--ink-2); }
.wizard-nav-item:not(:disabled):hover { background: var(--surface-2); color: var(--ink); }
.wizard-nav-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-3);
  font-family: 'Inter Tight', Inter, sans-serif;
  font-size: 12px;
  font-weight: 600;
}
.wizard-nav-circle svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wizard-nav-item.is-done .wizard-nav-circle { background: var(--accent); color: #fff; }
.wizard-nav-item.is-current .wizard-nav-circle { background: var(--dark); color: #fff; }

.wizard-stage { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.wizard-card { min-height: 320px; }
.wizard-step-enter { animation: view-in .28s var(--ease-out) both; }

.wizard-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.wizard-actions-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.wizard-lead { color: var(--ink-2); font-size: 13.5px; line-height: 1.5; margin: 6px 0 18px; }
.wizard-hint { font-size: 12.5px; color: var(--ink-3); margin: 0 0 8px; }

.wizard-toggle { display: flex; align-items: center; gap: 10px; font-size: 13.5px; margin-bottom: 16px; cursor: pointer; }
.wizard-toggle input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.wizard-toggle-sm { font-size: 12.5px; gap: 6px; margin-bottom: 0; white-space: nowrap; }

/* Прогресс анализа сайта — запасной вариант, если magic.js недоступен */
.wizard-progress-steps { display: flex; flex-direction: column; gap: 12px; margin: 18px 0; }
.wizard-progress-step { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 14px; }
.wizard-progress-step.is-active { color: var(--ink); font-weight: 500; }
.wizard-progress-step.is-done { color: var(--ok); }
.wizard-progress-step-icon {
  width: 20px; height: 20px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--surface-2);
}
.wizard-progress-step.is-done .wizard-progress-step-icon { background: var(--ok-bg); color: var(--ok); }
.wizard-progress-step-icon svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Шаг «Отрасль»: hero-карточка решения + сетка отраслей */
.wizard-hero-title {
  font-family: 'Inter Tight', Inter, sans-serif;
  font-size: 25px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -.02em;
  margin: 14px 0 8px;
}
.wizard-hero-text { font-size: 13.5px; color: rgba(255, 255, 255, .85); line-height: 1.5; margin: 0; }
.wizard-hero-scenario { margin-top: 8px; font-weight: 500; color: #fff; }
.wizard-quotes { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.wizard-quote { font-size: 12.5px; color: rgba(255, 255, 255, .7); font-style: italic; }
.wizard-warning-list { margin: 16px 0 0; padding-left: 18px; color: var(--warn); font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.wizard-vertical-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 10px; }
.wizard-vertical-card { text-align: left; }
@media (max-width: 900px) {
  .wizard-vertical-grid { grid-template-columns: 1fr; }
}

.wizard-question-row .row-aside { gap: 6px; flex-wrap: nowrap; }

/* Шаг «Голос»: форма + живое превью */
.wizard-voice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; }
.wizard-voice-form { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.wizard-voice-preview { position: sticky; top: 20px; align-self: start; }
@media (max-width: 900px) {
  .wizard-voice-layout { grid-template-columns: 1fr; }
  .wizard-voice-preview { position: static; margin-top: 8px; }
}
.wizard-chat-preview { background: var(--surface-2); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.wizard-chat-msg { max-width: 88%; padding: 10px 14px; border-radius: var(--r-lg); font-size: 13.5px; line-height: 1.4; background: var(--surface); }
.wizard-chat-assistant { align-self: flex-start; }
.wizard-chat-user { align-self: flex-end; background: var(--accent-bg); color: var(--accent); }
.wizard-faq-row { cursor: pointer; align-items: flex-start; gap: 12px; }
.wizard-faq-row input { margin-top: 3px; width: 20px; height: 20px; accent-color: var(--accent); flex: none; cursor: pointer; }

/* Шаг «Проверка»: тестовый чат */
.wizard-suggestions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.wizard-suggestion { cursor: pointer; border: none; }
.wizard-test-chat { max-height: 320px; overflow-y: auto; padding: 4px 2px; margin-bottom: 14px; }
.wizard-test-form { display: flex; gap: 10px; }
.wizard-test-form input { flex: 1 1 auto; }

/* Карточка «Продолжить настройку» на «Сегодня» */
.wizard-continue-card { padding: 24px; }
.wizard-continue-title { font-family: 'Inter Tight', Inter, sans-serif; font-size: 19px; font-weight: 500; margin: 14px 0 6px; }
/* Карточка светлая (единственный градиент на экране — hero), поэтому текст и полоса — в тёмной палитре. */
.wizard-continue-sub { font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
.wizard-continue-bar { background: var(--surface-2); }
.wizard-continue-bar .setup-progress-fill { background: var(--grad); }
.wizard-continue-card .hero-actions { margin-top: 16px; }

/* Баннер состояния триала на «Сегодня» (SPEC §16.8) */
.trial-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 20px;
  margin-bottom: 18px;
}
.trial-banner-limited { background: var(--accent-bg); }
.trial-banner-denied { background: var(--warn-bg); }
.trial-banner-body { min-width: 220px; }
.trial-banner-text { font-size: 14px; font-weight: 500; color: var(--ink); }
.trial-banner-sub { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.trial-banner-actions { display: flex; align-items: center; gap: 8px; flex: none; }
@media (max-width: 640px) {
  .trial-banner { flex-direction: column; align-items: stretch; }
  .trial-banner-actions { justify-content: flex-end; }
}

@media (max-width: 900px) {
  .wizard-head { padding: 14px 16px; gap: 12px; }
  .wizard-exit { order: 3; flex-basis: 100%; text-align: center; }
  .wizard-body { flex-direction: column; padding: 16px 16px 96px; gap: 16px; }
  .wizard-nav { display: none; }
  .wizard-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: var(--surface);
    padding: 14px 16px;
    margin: 0 -16px -96px;
    border-top: 1px solid var(--line);
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .wizard-step-enter { animation: none; }
}

/* ==========================================================================
   Режим «только чтение» после окончания подписки (SPEC §18.3)
   ========================================================================== */

/* Кнопки/переключатели изменения данных (data-write, см. panel.js) гаснут, пока подписка не продлена.
   /admin/subscription/* разрешён всегда — на кнопках «Тарифов» и «Подписки» атрибута нет специально. */
body.read-only [data-write] {
  pointer-events: none;
  opacity: .45;
}

.readonly-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 34px;
  background: var(--warn-bg);
  border-bottom: 1px solid var(--line);
}
.readonly-banner-text { font-size: 13.5px; color: var(--ink); font-weight: 500; }
@media (max-width: 900px) {
  .readonly-banner { padding: 12px 16px; }
}

/* ==========================================================================
   «Тарифы» (SPEC §18.1)
   ========================================================================== */

.plans-page { max-width: 1120px; }

.plan-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.plan-status-text { font-family: 'Inter Tight', Inter, sans-serif; font-size: 17px; font-weight: 600; letter-spacing: -.02em; }

.plan-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  position: relative;
  border: 1px solid transparent;
}
.plan-card.is-recommended { border-color: var(--accent); }
.plan-card.is-current { border-color: var(--line-2); }
.plan-badge { position: absolute; top: -13px; left: 24px; }
.plan-title { font-size: 19px; }
.plan-price { display: flex; align-items: baseline; gap: 4px; }
.plan-price-num { font-family: 'Inter Tight', Inter, sans-serif; font-size: 30px; font-weight: 600; letter-spacing: -.03em; }
.plan-price-period { font-size: 14px; color: var(--ink-3); }
.plan-summary { font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.plan-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.plan-features li { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; color: var(--ink); }
.plan-features svg { width: 16px; height: 16px; flex: none; margin-top: 2px; stroke: var(--ok); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.plan-addons { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-cta { margin-top: auto; padding-top: 4px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.plan-cta .btn-block { width: 100%; }

@media (max-width: 640px) {
  .plan-status { flex-direction: column; align-items: flex-start; }
}

.plan-features .plan-limit { color: var(--ink-3); }
.plan-limit-dash { display: inline-flex; width: 18px; justify-content: center; color: var(--ink-3); }
