/* Панель оператора ForgetShop Support.
   «Чернила на бумаге»: тёмное на тёплом белом, один акцент — сам чернильный цвет.
   Цвета состояний приглушённые, без градиентов и декоративных эффектов.
   Тёмная тема — через [data-theme="dark"] (авто по ОС или ручной выбор в сайдбаре). */

:root {
  color-scheme: light;

  --bg: #f4f3ef;             /* фон приложения */
  --surface: #ffffff;        /* панели */
  --surface-2: #f5f4f0;      /* вставки: диалог, редакторы, трасса */
  --surface-3: #ebe9e2;      /* аватары, подложки */
  --border: #e4e2da;
  --border-strong: #d3d0c5;

  --ink: #1c1b17;            /* основной текст и главный акцент */
  --ink-hover: #36342d;
  --text-2: #45433c;         /* второстепенный текст */
  --muted: #76736a;
  --faint: #a19e94;
  --on-ink: #ffffff;         /* текст на чернильной заливке */

  --hover: rgba(28, 27, 23, 0.045);
  --active: rgba(28, 27, 23, 0.075);
  --focus: rgba(28, 27, 23, 0.16);
  --selection: rgba(28, 27, 23, 0.2);
  --backdrop: rgba(20, 19, 15, 0.38);

  /* Сдержанные «редакторские» цвета состояний */
  --red: #9c3f30;
  --amber: #8a6320;
  --green: #3f6f50;
  --sky: #3c6678;
  --gray: #6f6c62;

  --seg-bg: #ebe9e2;
  --seg-on: #ffffff;

  --shadow-sm: 0 1px 2px rgba(28, 24, 12, 0.05);
  --shadow-md: 0 8px 24px rgba(28, 24, 12, 0.1);
  --shadow-pop: 0 18px 48px rgba(28, 24, 12, 0.18);

  --r: 10px;
  --r-sm: 7px;
  --r-xs: 5px;
  --sidebar-w: 236px;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b887e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #100f0d;
  --surface: #171613;
  --surface-2: #1b1a16;
  --surface-3: #26241e;
  --border: #2a2823;
  --border-strong: #3b3830;

  --ink: #f3f1ea;
  --ink-hover: #ffffff;
  --text-2: #d3d0c6;
  --muted: #9c988b;
  --faint: #6f6c63;
  --on-ink: #15140f;

  --hover: rgba(243, 241, 234, 0.05);
  --active: rgba(243, 241, 234, 0.085);
  --focus: rgba(243, 241, 234, 0.22);
  --selection: rgba(243, 241, 234, 0.26);
  --backdrop: rgba(0, 0, 0, 0.55);

  --red: #e58a7b;
  --amber: #dcae5e;
  --green: #74c08e;
  --sky: #84b3c6;
  --gray: #a6a294;

  --seg-bg: #0c0b09;
  --seg-on: #26241e;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 18px 48px rgba(0, 0, 0, 0.6);
}

/* ---------------------------------------------------------------- основа */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 14px/1.5 var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--selection); }

a { color: inherit; text-decoration: none; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

h1, h2, h3 { margin: 0; }
p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }

[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.i {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}

.muted { color: var(--muted); }
.faint { color: var(--muted); font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.strong { font-weight: 600; }

/* ---------------------------------------------------------------- каркас */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 16px 12px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 8px 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--ink); color: var(--on-ink);
  font: 600 19px/1 var(--serif);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font: 600 17px/1.1 var(--serif); letter-spacing: -0.01em; }
.brand-sub {
  margin-top: 3px;
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.nav-item .i { width: 17px; height: 17px; }
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.is-active {
  background: var(--active); color: var(--ink); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--ink);
}
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  padding: 0 7px;
  border-radius: 999px;
  font: 500 11px/18px var(--mono);
  color: var(--red);
  background: color-mix(in srgb, var(--red) 12%, transparent);
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }

.system-state {
  display: flex; flex-direction: column; gap: 1px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
}
.system-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.system-mode { font-size: 13px; font-weight: 600; margin-top: 2px; }
.system-auto { font-size: 12px; color: var(--muted); }

.me {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0 0 6px;
  border-top: 1px solid var(--border);
}
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.me-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: 12px; color: var(--muted); }
.inline-form { display: flex; margin: 0; }

.avatar {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-3); color: var(--ink);
  font-size: 13px; font-weight: 600; line-height: 1;
}
.avatar.sm { width: 26px; height: 26px; font-size: 11.5px; }

.main { min-width: 0; display: flex; flex-direction: column; }

.page-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  gap: 14px 24px;
  padding: 22px 32px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.page-head-main { min-width: 0; }
.page-title {
  font: 600 27px/1.15 var(--serif);
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.page-sub { margin: 6px 0 0; max-width: 120ch; font-size: 13.5px; color: var(--muted); }
.page-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.content { padding: 24px 32px 56px; min-width: 0; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

/* ---------------------------------------------------------------- панели */
.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px 12px;
  min-height: 52px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 {
  display: flex; align-items: center; gap: 8px;
  font-size: 14.5px; font-weight: 600; letter-spacing: -0.005em;
}
.panel-head h2 .i { color: var(--muted); }
.panel-body { padding: 16px 18px; }
.panel-foot {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 10px 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
}
.panel-foot-end { justify-content: flex-end; }
.panel-foot.chips { justify-content: flex-start; gap: 6px; }
/* Главное действие в подвале остаётся справа, даже когда переносится на свою строку. */
.panel-foot > .actions:last-child, .panel-foot > button:last-child { margin-left: auto; }

details.panel > summary { list-style: none; cursor: pointer; border-bottom: 0; border-radius: var(--r); }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary .i { color: var(--muted); transition: transform .15s ease; }
details.panel > summary:hover .i { color: var(--ink); }
details.panel[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--r) var(--r) 0 0; }
details.panel[open] > summary .i { transform: rotate(180deg); }

.editor {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.subhead {
  margin: 18px 0 8px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted);
}
.subhead:first-child { margin-top: 0; }

.hint { margin: 10px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.hint-top { margin: 0 0 12px; }

/* ---------------------------------------------------------------- кнопки */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 34px;
  padding: 6px 13px;
  font: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.2;
  white-space: nowrap;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
button:hover, .button:hover { background: var(--surface-2); }
button .i { width: 15px; height: 15px; }

button.primary { color: var(--on-ink); background: var(--ink); border-color: var(--ink); }
button.primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }

button.ghost { color: var(--muted); background: transparent; border-color: transparent; }
button.ghost:hover { color: var(--ink); background: var(--hover); }

button.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--border-strong)); }
button.danger:hover { background: color-mix(in srgb, var(--red) 7%, var(--surface)); }

button.small { min-height: 28px; padding: 3px 10px; font-size: 12.5px; gap: 6px; }
button.small .i { width: 14px; height: 14px; }

button:disabled, button:disabled:hover { opacity: 0.45; cursor: not-allowed; }
button.is-busy { opacity: 0.6; cursor: progress; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; min-height: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
}
.icon-btn:hover { color: var(--ink); background: var(--hover); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------------------------------------- поля */
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  font: inherit; font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--focus); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=search]::-webkit-search-cancel-button { cursor: pointer; }

select {
  appearance: none; -webkit-appearance: none;
  padding-right: 32px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  cursor: pointer;
  text-overflow: ellipsis;
}

textarea { display: block; min-height: 84px; resize: vertical; line-height: 1.5; }
textarea.mono { font-family: var(--mono); font-size: 12.5px; }

input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); cursor: pointer; flex: none; }

input[type=file] { width: 100%; font: inherit; font-size: 13px; color: var(--muted); }
input[type=file]::file-selector-button {
  margin-right: 12px;
  padding: 7px 13px;
  font: inherit; font-size: 13px; font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background-color .15s ease;
}
input[type=file]::file-selector-button:hover { background: var(--surface-2); }

label { display: block; margin-bottom: 5px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field { margin-bottom: 14px; min-width: 0; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 14px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }

.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.row > * { flex: 1 1 160px; }

.check {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0;
  font-size: 13.5px; font-weight: 400; color: var(--text-2);
  cursor: pointer; user-select: none;
}

/* переключатель */
.switch-list { display: flex; flex-direction: column; gap: 14px; margin: 4px 0 18px; }
.switch { position: relative; display: flex; align-items: flex-start; gap: 12px; margin: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch-track {
  position: relative; flex: none;
  width: 34px; height: 20px; margin-top: 1px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background-color .15s ease;
}
.switch-track::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  transition: transform .15s ease;
}
.switch input:checked + .switch-track { background: var(--ink); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--focus); }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-title { font-size: 14px; font-weight: 500; color: var(--ink); }
.switch-hint { font-size: 12.5px; font-weight: 400; color: var(--muted); }

/* ---------------------------------------------------------------- метки и чипы */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 1px 8px;
  font-size: 12px; font-weight: 500; line-height: 20px;
  white-space: nowrap;
  color: var(--tone, var(--gray));
  background: color-mix(in srgb, var(--tone, var(--gray)) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--tone, var(--gray)) 24%, transparent);
  border-radius: 6px;
}
.badge .dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: currentColor; }

.tone-attention { --tone: var(--red); }
.tone-pending { --tone: var(--amber); }
.tone-ok { --tone: var(--green); }
.tone-info { --tone: var(--sky); }
.tone-neutral { --tone: var(--gray); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block;
  max-width: 100%;
  padding: 1px 7px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 500 11.5px/18px var(--mono);
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  vertical-align: middle;
}
.chip-sans { font-family: var(--sans); font-size: 12px; }

.flag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.flag .i { width: 13px; height: 13px; }
.flag.tone-attention { color: var(--red); }

.callout {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px;
  font-size: 13.5px;
  color: var(--ink);
  background: color-mix(in srgb, var(--tone, var(--gray)) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--tone, var(--gray)) 28%, transparent);
  border-radius: var(--r-sm);
}
.callout > .i { margin-top: 2px; color: var(--tone, var(--gray)); }
.callout-title { font-weight: 600; color: var(--tone, var(--gray)); }
.callout-text { overflow-wrap: anywhere; }
.callout + .callout { margin-top: 8px; }

/* ---------------------------------------------------------------- таблицы */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  padding: 10px 14px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  text-align: left; white-space: nowrap;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.cell-actions { text-align: right; white-space: nowrap; }
td.cell-actions .actions { justify-content: flex-end; flex-wrap: nowrap; }

.table-empty { padding: 44px 18px !important; text-align: center; color: var(--muted); }
tbody tr:hover td.table-empty { background: none; }
.empty-title { font: 600 18px/1.3 var(--serif); color: var(--ink); }
.empty-hint { margin-top: 4px; font-size: 13px; }

.cell-strong { font-weight: 500; }
.cell-sub { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------------------------------------------------------------- очередь */
.queue-bar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.queue-bar-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }

.segmented {
  display: inline-flex; align-self: flex-start; flex-wrap: wrap; gap: 2px;
  padding: 3px;
  background: var(--seg-bg);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.tab {
  min-height: 30px;
  padding: 4px 12px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}
.tab:hover { color: var(--ink); background: transparent; }
.tab.is-active {
  color: var(--ink); font-weight: 600;
  background: var(--seg-on);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.count { font: 500 11.5px var(--mono); color: var(--muted); }
.count:empty { display: none; }
.tab .count { margin-left: 2px; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filters-end { display: flex; flex-wrap: wrap; gap: 8px; }

.search { position: relative; flex: 1 1 260px; max-width: 380px; margin: 0; }
.search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 34px; }

.toggle-chip {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 36px;
  margin: 0;
  padding: 6px 13px;
  font-size: 13.5px; font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer; user-select: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.toggle-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.toggle-chip .i { width: 14px; height: 14px; }
.toggle-chip:hover { color: var(--ink); background: var(--surface-2); }
.toggle-chip:has(input:checked) { color: var(--on-ink); background: var(--ink); border-color: var(--ink); }
.toggle-chip:has(input:checked) .count { color: inherit; opacity: 0.75; }
.toggle-chip:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--focus); }

.select-inline {
  display: inline-flex; align-items: center; gap: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.select-inline > span { padding-left: 11px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.select-inline select { width: auto; min-width: 0; border: 0; background-color: transparent; box-shadow: none; padding-left: 7px; font-weight: 500; }
.select-inline select:focus { box-shadow: none; }
.select-inline:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--focus); }

/* Узкие колонки ужимаются по содержимому — место достаётся «Проблеме». */
.table-queue th:nth-child(1), .table-queue th:nth-child(2), .table-queue th:nth-child(5),
.table-queue th:nth-child(6), .table-queue th:nth-child(7) { width: 1%; }
.table-queue td:nth-child(2), .table-queue td:nth-child(6), .table-queue td:nth-child(7) { white-space: nowrap; }
.table-queue td:nth-child(3) { min-width: 170px; }
.table-queue .cell-subject { min-width: 260px; }
.table-queue .cell-subject > div:first-child { max-width: 80ch; }

.row-link { cursor: pointer; }
.row-link.is-attention td:first-child { box-shadow: inset 3px 0 0 var(--red); }

.ticket-no { font: 500 13px var(--mono); white-space: nowrap; border-bottom: 1px solid transparent; }
.ticket-no:hover { border-bottom-color: currentColor; }
.cell-no { white-space: nowrap; }
.unread {
  display: inline-block;
  margin-left: 7px;
  padding: 0 6px;
  font: 600 11px/17px var(--mono);
  color: var(--on-ink);
  background: var(--ink);
  border-radius: 999px;
  vertical-align: 1px;
}

.person { display: flex; align-items: center; gap: 9px; min-width: 0; }
.person-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.state-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }

/* ---------------------------------------------------------------- обращение */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
  font-size: 13px; color: var(--muted);
}
.back-link:hover { color: var(--ink); }
.back-link .i { width: 15px; height: 15px; }

.title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: 13.5px; color: var(--muted); }
.meta-item + .meta-item::before { content: "·"; margin: 0 8px; color: var(--faint); }
.meta-item.strong { color: var(--ink); font-weight: 500; }

.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.ticket-main, .ticket-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.alerts:empty { display: none; }

/* ---------------------------------------------------------------- чат обращения
   Переписка как в мессенджере: клиент слева, поддержка справа чернилами, заметки —
   пунктиром, служебные события — строкой по центру. */
.chat { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 520px; }
.chat.is-drop { outline: 2px dashed var(--ink); outline-offset: -6px; }

.chat-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.chat-state { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; min-width: 0; }
.chat-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.chat-chip .i { width: 14px; height: 14px; }
.chat-chip.is-rating { color: var(--amber); font-weight: 600; }
.chat-chip.is-rating .i { fill: currentColor; }
.chat-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.chat-messages {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 16px 12px;
  overflow-y: auto;
  background: var(--surface-2);
}
.chat-day { align-self: center; margin: 6px 0 2px; }
.chat-day span {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11.5px; font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.chat-sys { align-self: center; max-width: 92%; padding: 1px 8px; font-size: 12.5px; text-align: center; color: var(--muted); }
.chat-empty { margin: auto; }

.chat-row { display: flex; max-width: min(80%, 720px); min-width: 0; }
.chat-row.is-in { align-self: flex-start; }
.chat-row.is-out, .chat-row.is-note { align-self: flex-end; }
.chat-bubble {
  min-width: 0; max-width: 100%;
  padding: 8px 12px 6px;
  overflow-wrap: anywhere;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.chat-row.is-in .chat-bubble { border-bottom-left-radius: 4px; }
.chat-row.is-out .chat-bubble { color: var(--on-ink); background: var(--ink); border-color: var(--ink); border-bottom-right-radius: 4px; }
.chat-row.is-note .chat-bubble {
  background: color-mix(in srgb, var(--amber) 7%, var(--surface));
  border: 1px dashed color-mix(in srgb, var(--amber) 55%, transparent);
  border-bottom-right-radius: 4px;
}
.chat-row.is-failed .chat-bubble { color: var(--ink); background: var(--surface); border: 1px solid var(--red); }
.chat-row.is-cancelled .chat-text { text-decoration: line-through; opacity: 0.7; }
.chat-note-label {
  display: flex; align-items: center; gap: 5px;
  margin-bottom: 3px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--amber);
}
.chat-note-label .i { width: 12px; height: 12px; }
.chat-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.chat-text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.chat-flag { margin-top: 4px; font-size: 12px; color: var(--amber); }
.chat-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  margin-top: 3px;
  font-size: 11.5px; white-space: nowrap;
  opacity: 0.7;
}
.chat-meta .i { width: 13px; height: 13px; }
.chat-delivery { display: flex; align-items: flex-start; gap: 5px; margin-top: 4px; font-size: 12px; color: var(--amber); }
.chat-delivery .i { width: 13px; height: 13px; margin-top: 2px; }
.chat-delivery.is-failed, .chat-delivery.is-delivery_unknown { color: var(--red); }
.chat-row.is-out:not(.is-failed) .chat-delivery { color: color-mix(in srgb, var(--on-ink) 80%, transparent); }

.chat-media { margin: 2px 0 6px; }
.chat-media img { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; cursor: zoom-in; }
.chat-media video { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; background: #000; }
.chat-media video.is-round { width: 220px; height: 220px; object-fit: cover; border-radius: 50%; }
.chat-media audio { display: block; width: 280px; max-width: 100%; }
.chat-media.is-sticker img, .chat-media.is-sticker video { max-width: 160px; max-height: 160px; background: transparent; cursor: default; }
.chat-file {
  display: inline-flex; align-items: center; gap: 7px;
  max-width: 100%;
  margin-top: 2px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.chat-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-file:hover { border-color: var(--border-strong); }
.chat-file.is-missing { color: var(--red); border-style: dashed; }
.chat-row.is-out .chat-file {
  color: var(--on-ink);
  background: color-mix(in srgb, var(--on-ink) 12%, transparent);
  border-color: color-mix(in srgb, var(--on-ink) 28%, transparent);
}
.chat-file-name { margin-top: 3px; font-size: 12px; opacity: 0.8; }

/* поле ответа */
.composer { padding: 10px 16px 14px; border-top: 1px solid var(--border); background: var(--surface); border-radius: 0 0 var(--r) var(--r); }
.composer-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 8px; }
.composer-kind .tab { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 3px 10px; font-size: 13px; }
.composer-kind .tab .i { width: 14px; height: 14px; }
.composer-kind .tab[data-kind="note"].is-active { color: var(--amber); }
.composer textarea { min-height: 46px; max-height: 240px; resize: none; }
.composer.is-note textarea {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--amber) 60%, transparent);
  background: color-mix(in srgb, var(--amber) 5%, var(--surface));
}
.composer-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.composer-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; }
.composer-tools .attach { margin: 0; cursor: pointer; }
.composer.is-note .attach { opacity: 0.4; pointer-events: none; }
.composer-send { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.hint-key { font-size: 12px; color: var(--muted); }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 300px;
  padding: 2px 2px 2px 10px;
  font-size: 12.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.file-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .icon-btn { width: 24px; height: 24px; }
.file-chip .icon-btn:hover { color: var(--red); }
.draft-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--amber); }
.draft-note:not(:empty)::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* выпадающие меню */
.menu { position: relative; display: inline-flex; }
.menu-toggle .i:last-child { width: 13px; height: 13px; }
.menu-pop {
  position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 40;
  display: flex; flex-direction: column;
  width: min(380px, 86vw); max-height: 360px;
  padding: 4px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-pop);
}
.chat-actions .menu-pop { top: calc(100% + 6px); bottom: auto; width: max-content; }
.menu-pop-end { left: auto; right: 0; }
.menu-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 0;
  padding: 8px 10px;
  font-size: 13.5px; font-weight: 500; text-align: left; white-space: normal;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: var(--r-xs);
}
.menu-item:hover { background: var(--hover); }
.tpl-item span {
  font-size: 12.5px; font-weight: 400; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.menu-foot { flex-direction: row; align-items: center; gap: 6px; margin-top: 2px; border-top: 1px solid var(--border); border-radius: 0; color: var(--muted); font-size: 12.5px; }
.menu-foot .i { width: 13px; height: 13px; }
.menu-empty { padding: 10px; font-size: 13px; color: var(--muted); }
.split .split-main { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split .split-toggle {
  padding: 3px 7px;
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  border-left-color: color-mix(in srgb, var(--on-ink) 25%, var(--ink));
}

/* карточка клиента и боковые списки */
.side-title {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 8px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted);
}
.side-title .i { width: 14px; height: 14px; }
.side-order { border-color: var(--ink); }
.order-big { display: flex; flex-direction: column; gap: 3px; }
.order-big span { font-size: 13px; color: var(--muted); }
.client-card { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.avatar.lg { width: 42px; height: 42px; font: 600 18px/1 var(--serif); }
.client-text { min-width: 0; }
.client-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.client-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 2px; font-size: 13px; color: var(--muted); }
.client-sub a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.copy-id {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 0; padding: 0 5px;
  font: 500 12.5px var(--mono);
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  cursor: copy;
}
.copy-id .i { width: 12px; height: 12px; color: var(--muted); }
.client-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.kv-compact { grid-template-columns: minmax(120px, 46%) minmax(0, 1fr); gap: 6px 10px; }
.kv-tight { grid-template-columns: 120px minmax(0, 1fr); gap: 4px 10px; font-size: 13px; }
.side-list { display: flex; flex-direction: column; margin: 10px 0 0; padding: 0; list-style: none; }
.side-list:first-child { margin-top: 0; }
.side-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 0;
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.side-list > li:first-child > .side-item, .side-list > .side-item:first-child { border-top: 0; }
.side-link:hover .side-main { text-decoration: underline; text-underline-offset: 2px; }
.side-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-meta { flex: none; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.instruction-panel .panel-head { background: var(--surface-2); border-radius: var(--r) var(--r) 0 0; }
.instruction-actions { margin-top: 10px; }

.kv { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 9px 12px; margin: 0; font-size: 13.5px; }
.kv dt { padding-top: 1px; font-size: 12.5px; color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv-wide { grid-template-columns: minmax(150px, 38%) minmax(0, 1fr); }

.list-plain { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.list-plain li { position: relative; padding-left: 14px; overflow-wrap: anywhere; }
.list-plain li::before {
  content: "";
  position: absolute; left: 2px; top: 0.62em;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--faint);
}
.list-plain li.is-violation { color: var(--red); }
.list-plain li.is-violation::before { background: var(--red); }

.run-text { font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }

.action-pair {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.action-pair > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 11px; }
.action-pair > div + div { border-left: 1px solid var(--border); }
.action-pair .k { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.action-pair .v { font-size: 13px; font-weight: 500; }

.fact-list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.fact-list li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 9px; }
.fact-list li > .i { width: 15px; height: 15px; margin-top: 3px; }
.fact-list .is-confirmed > .i { color: var(--green); }
.fact-list .is-unconfirmed > .i { color: var(--amber); }
.fact-list li > div { min-width: 0; overflow-wrap: anywhere; }

.source-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.source-list li { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.source-list .ref { font: 12px/1.5 var(--mono); color: var(--text-2); overflow-wrap: anywhere; }

.refund-list:empty { display: none; }
.refund-list { margin-top: 14px; border-top: 1px solid var(--border); }
.refund-row { padding: 9px 0; border-bottom: 1px solid var(--border); }
.refund-row:last-child { border-bottom: 0; padding-bottom: 0; }
.refund-main { display: flex; justify-content: space-between; gap: 10px; }

.trace {
  max-height: 320px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  font: 11.5px/1.55 var(--mono);
  white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

/* ---------------------------------------------------------------- прогоны */
.preview-box {
  margin: 2px 0 14px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.participant {
  display: grid; grid-template-columns: minmax(0, 1fr) 190px; align-items: center; gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.participant-name { font-weight: 500; overflow-wrap: anywhere; }
.import-report:empty { display: none; }
.import-report { margin-top: 4px; font-size: 13px; color: var(--text-2); }

.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 20px; }
.metric { padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--r-sm); }
.metric .value { font: 600 21px/1.2 var(--serif); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric .label { margin-top: 3px; font-size: 12px; color: var(--muted); }

.result-card { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.result-card + .result-card { margin-top: 14px; }
.result-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.compare { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compare-col { padding: 14px; min-width: 0; }
.compare-col + .compare-col { border-left: 1px solid var(--border); }
.compare-col p { overflow-wrap: anywhere; }
.reference {
  margin: 0;
  padding: 8px 10px;
  font: 11.5px/1.5 var(--mono);
  white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: var(--r-xs);
}

/* ---------------------------------------------------------------- знания */
.conflicts { padding: 12px 18px 0; }
.candidate { padding: 14px; border: 1px solid var(--border); border-radius: var(--r-sm); }
.candidate + .candidate { margin-top: 12px; }
.candidate-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.candidate-title { font-weight: 600; }
.candidate .trace { margin: 8px 0; max-height: 220px; }

/* ---------------------------------------------------------------- диалоговое окно */
dialog.dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-pop);
}
dialog.dialog::backdrop { background: var(--backdrop); }
.dialog-body { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.dialog-head h2 { font: 600 20px/1.2 var(--serif); letter-spacing: -0.01em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---------------------------------------------------------------- уведомление */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  display: flex; align-items: flex-start; gap: 10px;
  max-width: min(440px, calc(100vw - 40px));
  padding: 11px 15px;
  font-size: 13.5px;
  color: var(--on-ink);
  background: var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-pop);
}
.toast .i { margin-top: 2px; }
.toast.error { background: var(--red); }

/* ---------------------------------------------------------------- вход */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 384px;
  padding: 28px 28px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}
.login-brand { padding: 0 0 20px; margin-bottom: 22px; }
.login-title { font: 600 24px/1.2 var(--serif); letter-spacing: -0.01em; }
.login-sub { margin: 6px 0 20px; font-size: 13.5px; color: var(--muted); }
.login-card .callout { margin-bottom: 16px; }
.login-form button[type=submit] { width: 100%; min-height: 40px; margin-top: 4px; }

/* ---------------------------------------------------------------- адаптив */
@media (max-width: 1280px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .ticket-layout { grid-template-columns: minmax(0, 1fr) 340px; }
}

@media (max-width: 1060px) {
  .ticket-layout { grid-template-columns: minmax(0, 1fr); }
  .chat { height: 78vh; min-height: 460px; }
  .compare { grid-template-columns: minmax(0, 1fr); }
  .compare-col + .compare-col { border-left: 0; border-top: 1px solid var(--border); }
}

@media (max-width: 900px) {
  .app { display: block; }
  .sidebar {
    position: sticky; top: 0; z-index: 30;
    height: auto;
    flex-direction: row; align-items: center; gap: 6px;
    padding: 8px 12px;
    border-right: 0; border-bottom: 1px solid var(--border);
    overflow: visible;
  }
  .brand { padding: 0; margin: 0 4px 0 0; border: 0; }
  .brand-text { display: none; }
  .nav { flex-direction: row; gap: 2px; min-width: 0; overflow-x: auto; }
  .nav-item { padding: 7px 9px; }
  .nav-item.is-active { box-shadow: none; }
  .sidebar-foot { flex-direction: row; align-items: center; margin: 0 0 0 auto; padding: 0; }
  .system-state, .me-text, .me .avatar { display: none; }
  .me { padding: 0; border: 0; gap: 2px; }
  .page-head { position: static; padding: 18px 16px 14px; }
  .page-title { font-size: 23px; }
  .content { padding: 16px 16px 40px; }
  .panel-head, .panel-body, .panel-foot, .editor, .composer { padding-left: 14px; padding-right: 14px; }
  .chat-messages { padding: 12px; }
  .chat-row { max-width: 92%; }
  .hint-key { display: none; }
  th:first-child, td:first-child { padding-left: 14px; }
  th:last-child, td:last-child { padding-right: 14px; }
  .search { max-width: none; flex-basis: 100%; }
}

@media (max-width: 620px) {
  .nav-label { display: none; }
  .nav-item { padding: 8px; }
  .form-grid-2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .participant { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .filters-end, .select-inline { width: 100%; }
  .select-inline select { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Поведение из диалогов: подсказки перед включением черновика */
.warnings {
  margin: 0 0 14px;
  padding: 10px 14px 10px 30px;
  border-left: 2px solid var(--amber);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
}
.warnings li + li { margin-top: 4px; }
#behavior-panel textarea { font-size: 13px; line-height: 1.55; }

/* ---------------------------------------------------------------- меню: группа владельца */
.nav-group {
  display: block;
  margin: 14px 10px 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--faint);
}

/* ---------------------------------------------------------------- живой чат: список */
.live-alerts:not(:empty) { margin-bottom: 14px; }
.live-summary:empty { display: none; }
.live-summary { font-size: 13px; color: var(--muted); }
.live-list { overflow: hidden; }
.live-row {
  display: grid; grid-template-columns: 128px minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 12px 18px;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  transition: background-color .12s ease;
}
.live-row:last-child { border-bottom: 0; }
.live-row:hover { background: var(--hover); }
.live-row.is-unread { background: color-mix(in srgb, var(--ink) 4%, var(--surface)); }
.live-row.is-unread .live-name { font-weight: 700; }
.live-status { justify-self: start; }
.live-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.live-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.live-name { font-weight: 600; overflow-wrap: anywhere; }
.live-username { font-size: 13px; color: var(--muted); }
.live-preview { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; white-space: nowrap; }
.live-time { font-size: 12.5px; color: var(--muted); }
.live-side-line { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.live-side-line .i { width: 13px; height: 13px; }
.live-assignee, .live-rating { display: inline-flex; align-items: center; gap: 4px; }
.live-rating { color: var(--amber); font-weight: 600; }
.live-rating .i { fill: currentColor; }
.live-row .unread { margin-left: 0; }
.chip-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); font-family: var(--sans); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }

/* ---------------------------------------------------------------- звёзды и оценки */
.stars { display: inline-flex; gap: 1px; color: var(--amber); vertical-align: middle; }
.stars .i { width: 14px; height: 14px; }
.stars .i.is-on { fill: currentColor; }
.stars .i:not(.is-on) { color: var(--border-strong); }

.rating-total { display: grid; grid-template-columns: auto minmax(0, 360px) 1fr; align-items: center; gap: 24px 36px; }
.rating-big { display: flex; flex-direction: column; gap: 4px; }
.rating-big-value { font: 600 40px/1 var(--serif); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.rating-big .stars .i { width: 17px; height: 17px; }
.rating-actions { justify-self: end; align-self: end; }
.dist { display: flex; flex-direction: column; gap: 5px; }
.dist-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 36px; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.dist-label { display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; }
.dist-label .i { width: 12px; height: 12px; }
.dist-bar { height: 7px; overflow: hidden; background: var(--surface-3); border-radius: 999px; }
.dist-bar > span { display: block; height: 100%; background: var(--ink); border-radius: inherit; }
.dist-row.is-low .dist-bar > span { background: var(--red); }
.dist-row.is-low .dist-value { color: var(--red); font-weight: 600; }
.dist-value { text-align: right; font-variant-numeric: tabular-nums; }

.rating-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13px; }
.rating-avg { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rating-avg .i { width: 14px; height: 14px; color: var(--amber); fill: currentColor; }
.rating-low { font-size: 12px; color: var(--red); }
.table-staff tr.is-off td { color: var(--muted); }
.table-staff th:nth-child(2), .table-staff th:nth-child(3), .table-staff th:nth-child(5) { width: 1%; white-space: nowrap; }
.table-staff td:nth-child(3), .table-staff td:nth-child(5) { white-space: nowrap; }

.ratings-list { display: flex; flex-direction: column; }
.ratings-empty { padding: 16px 18px; margin: 0; }
.rating-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 10px 18px;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
}
.rating-row:last-child { border-bottom: 0; }
.rating-row:hover { background: var(--hover); }
.rating-row.is-low { box-shadow: inset 3px 0 0 var(--red); }
.rating-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.rating-client { font-weight: 500; }
.rating-subject { flex-basis: 100%; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rating-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ---------------------------------------------------------------- настройки: режим бота и шаблоны */
.mode-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.mode-card {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  margin: 0;
  padding: 14px 16px 14px 44px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.mode-card:hover { background: var(--surface-2); }
.mode-card input { position: absolute; left: 16px; top: 17px; width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.mode-card:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.mode-card:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--focus); }
.mode-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.mode-title .i { width: 17px; height: 17px; color: var(--muted); }
.mode-desc { font-size: 13px; font-weight: 400; line-height: 1.5; color: var(--muted); }
.field-hint { display: block; margin-top: 5px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.howto li { line-height: 1.5; }
.tpl-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.tpl-row { padding: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
.tpl-head { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.tpl-head .tpl-title { flex: 1; min-width: 0; font-weight: 600; }
.tpl-row .tpl-text { min-height: 72px; }
.tpl-row:first-child .tpl-up, .tpl-row:last-child .tpl-down { visibility: hidden; }
.tpl-del:hover { color: var(--red); }
.i.rot-90 { transform: rotate(90deg); }
.i.rot-270 { transform: rotate(270deg); }

/* ---------------------------------------------------------------- диалоги */
.dialog-wide { width: min(560px, calc(100vw - 32px)); }
.dialog-text { margin: 0; color: var(--text-2); line-height: 1.55; }
.dialog-error { margin: 4px 0 0; font-size: 13px; color: var(--red); }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
button.danger-solid { color: #fff; background: var(--red); border-color: var(--red); }
button.danger-solid:hover { background: color-mix(in srgb, var(--red) 88%, #000); }

@media (max-width: 1060px) {
  .rating-total { grid-template-columns: minmax(0, 1fr); }
  .rating-actions { justify-self: start; }
}

@media (max-width: 760px) {
  .mode-cards { grid-template-columns: minmax(0, 1fr); }
  .live-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "status side" "main main"; gap: 6px 10px; padding: 11px 14px; }
  .live-status { grid-area: status; }
  .live-main { grid-area: main; }
  .live-side { grid-area: side; }
  .rating-row { grid-template-columns: minmax(0, 1fr) auto; }
  .rating-row .stars { grid-column: 1 / -1; }
}
