/* Панель Trust Box. Вид по макету заказчика (https://oaiu-trustbox.netlify.app/admin):
   шрифт Onest, тёмное меню слева, карточки, пилюли, переписка «пузырями». */

:root {
  --bg: #f5f6fa;
  --paper: #fff;
  --soft: #f7f8fb;          /* фон переписки, наведение на строку */
  --gray-bg: #eef0f5;
  --line: #e3e6ef;
  --line-soft: #eef0f5;
  --field: #d6dbe6;         /* рамки полей, кнопок, чипов */
  --text: #172033;
  --text-2: #3e475b;
  --muted: #5d667a;
  --blue: #3b5bdb;
  --blue-bg: #e7ecfd;
  --blue-soft: #edf1fe;
  --amber: #8a5a00;
  --amber-bg: #fcf1db;
  --red: #a3261b;
  --red-bg: #fbe9e7;
  --green: #1b6b3a;
  --green-bg: #e7f5ec;
  --violet: #6741c4;
  --violet-bg: #f3edfd;
  --note: #fff7da;
  --note-line: #f0dfa0;
  --side: #141b2d;
  --side-2: #1c2539;
  --side-on: #26324d;
  --side-text: #aab3c8;
  --side-muted: #8b95ad;
  --shadow: 0 1px 2px rgba(20, 27, 45, .04);
  color-scheme: light;
}

/* Основа */

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px; line-height: 1.45; accent-color: var(--blue); -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #a9bdf7; outline-offset: 2px;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0; }

.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.late { color: var(--red); font-weight: 700; }
.push { margin-left: auto; }
.ic { width: 18px; height: 18px; flex: 0 0 auto; }

/* Каркас: меню слева, основная область справа */

.shell { min-height: 100vh; display: flex; }
/* Полоса тестового сервера (APP_ENV=dev), чтобы его не путали с настоящим */
.env-bar {
  padding: 6px 16px; text-align: center;
  background: var(--amber-bg); color: var(--amber); border-bottom: 1px solid var(--note-line); font-size: 13px; font-weight: 600;
}
.shell > .side {
  width: 240px; flex: 0 0 240px; background: var(--side); color: #e8ecf5; display: flex; flex-direction: column; gap: 24px;
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand b, .login-brand b { display: block; font-size: 15px; font-weight: 700; color: #fff; }
.brand small, .login-brand small { display: block; font-size: 12px; color: var(--side-muted); }
.logo {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 11px; background: linear-gradient(135deg, #4c6ef5, #2f4ab8);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.logo .ic { width: 20px; height: 20px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--side-text); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.on { background: var(--side-on); color: #fff; box-shadow: inset 3px 0 0 #6d8cf5; }
.badge {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--blue); color: #fff;
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums;
}

.user { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; background: var(--side-2); }
.user-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.av {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; background: #2c3854; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.user .info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user .info b { font-size: 14px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user .info span { font-size: 12px; color: var(--side-muted); }
.logout { margin-left: auto; }
.logout button {
  display: flex; padding: 6px; border: 0; border-radius: 8px; background: none; color: var(--side-text); cursor: pointer;
}
.logout button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.user-links { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.user-links a { color: var(--side-text); font-weight: 600; }
.user-links a:hover { color: #fff; }

/* Переключатель языка: две кнопки, текущая подсвечена */
.lang { display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--gray-bg); }
.lang button {
  height: 26px; min-width: 34px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer;
}
.lang button:hover { color: var(--text); }
.lang button.on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(20, 27, 45, .12); }
.shell > .side .lang { background: rgba(255, 255, 255, .06); }
.shell > .side .lang button { color: var(--side-text); }
.shell > .side .lang button:hover { color: #fff; }
.shell > .side .lang button.on { background: var(--side-on); color: #fff; box-shadow: none; }

.main { flex: 1; min-width: 0; padding: 28px 32px 32px; display: flex; flex-direction: column; gap: 20px; }
.main > * { min-width: 0; }
/* Экран, который занимает ровно высоту окна (обращения): блоки внутри прокручиваются сами */
.main.fill { height: 100vh; overflow-y: auto; gap: 16px; }
/* На невысоком экране (ноутбук 1366x768) не даём переписке сжаться в полоску: тогда прокручивается вся область */
.main.fill > .split { flex: 1 1 0; min-height: 560px; }

/* Заголовок страницы */
.ph { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.ph h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.ph p { margin-top: 4px; font-size: 14px; color: var(--muted); max-width: 760px; }
.ph-side { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.back:hover { color: var(--text); text-decoration: none; }

/* Счётчики в заголовке (цветные плашки) */
.stat {
  min-width: 120px; padding: 10px 16px; border-radius: 12px; display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--line); color: var(--text);
}
a.stat:hover { text-decoration: none; filter: brightness(.97); }
.stat span { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat b { font-size: 24px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat.blue { background: var(--blue-bg); border-color: var(--blue-bg); }
.stat.blue span { color: var(--blue); }
.stat.amber { background: var(--amber-bg); border-color: var(--amber-bg); }
.stat.amber span { color: var(--amber); }
.stat.red { background: var(--red-bg); border-color: var(--red-bg); }
.stat.red span { color: var(--red); }
.stat.green { background: var(--green-bg); border-color: var(--green-bg); }
.stat.green span { color: var(--green); }
.stat.violet { background: var(--violet-bg); border-color: var(--violet-bg); }
.stat.violet span { color: var(--violet); }
.stat.on { box-shadow: inset 0 0 0 2px currentColor; }

/* Счётчики-карточки в ряд (как «Отчёты» в макете) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border-radius: 14px;
  background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text);
}
a.kpi:hover { text-decoration: none; border-color: #c9cfdd; }
.kpi span { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi b { font-size: 28px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi small { font-size: 12.5px; color: var(--muted); }
.kpi.blue b { color: var(--blue); }
.kpi.amber b { color: var(--amber); }
.kpi.red b { color: var(--red); }
.kpi.green b { color: var(--green); }
.kpi.violet b { color: var(--violet); }

/* Сообщения после действий */
.flashes { display: flex; flex-direction: column; gap: 8px; }
.flash {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper); font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
}
.flash > span { flex: 1; }
.flash-success { background: var(--green-bg); border-color: #b7dcc4; color: var(--green); }
.flash-error { background: #fbefed; border-color: #ecc9c4; color: var(--red); }
.flash-warning { background: #fdf6e6; border-color: #ecd9a8; color: #7a5000; }
.flash-info, .flash-debug { background: var(--blue-soft); border-color: #c9d4f8; color: #2c46b0; }
.flash-x { display: flex; padding: 2px; border: 0; border-radius: 6px; background: none; color: inherit; opacity: .6; cursor: pointer; }
.flash-x:hover { opacity: 1; }
.flash-x .ic { width: 16px; height: 16px; }

/* Плашка «В обращении новое сообщение» */
.update-bar {
  position: fixed; top: 16px; left: calc(50% + 120px); transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 18px; border-radius: 12px;
  background: var(--side); color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(20, 27, 45, .25);
  max-width: calc(100vw - 32px);
}

/* Карточки и таблицы */

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.pad, .card-b { padding: 20px; }
.card-h {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line-soft);
}
.card-h h2 { font-size: 16px; }
.card-h p { font-size: 13px; color: var(--muted); }
.card-f {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--muted);
}
/* position: relative, чтобы скрытые подписи (.sr) в шапке таблицы не выходили за её прокрутку и не растягивали страницу */
.tbl { overflow-x: auto; position: relative; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: var(--soft); }
tr.inactive td { color: var(--muted); }
.line2 { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.preview { max-width: 520px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }

/* Пилюли: статус, тип, метки */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  font-size: 12px; font-weight: 700; line-height: 1.5; background: var(--gray-bg); color: var(--muted);
}
.pill.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.st-new, .pill.t-question, .pill.blue { background: var(--blue-bg); color: var(--blue); }
.pill.st-in_progress, .pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.violet { background: var(--violet-bg); color: var(--violet); }
.pill.st-rejected, .pill.gray { background: var(--gray-bg); color: var(--muted); }
.pill.t-complaint, .pill.late, .pill.red { background: var(--red-bg); color: var(--red); }
.pill.st-resolved, .pill.green { background: var(--green-bg); color: var(--green); }
/* Белая пилюля с рамкой цвета текста, как тип обращения в шапке макета */
.pill.outline { background: #fff; border: 1px solid; border-color: color-mix(in srgb, currentColor 35%, transparent); padding: 1px 8px; }
/* Тип обращения цветным текстом, как в списке макета */
.tp { font-size: 13px; font-weight: 700; }
.tp.complaint { color: var(--red); }
.tp.question { color: var(--blue); }
/* Короткая метка вроде RU / KZ */
.tag {
  display: inline-block; padding: 1px 6px; border-radius: 6px; background: var(--gray-bg); color: var(--muted);
  font-size: 11px; font-weight: 700; letter-spacing: .03em;
}

/* Чипы и вкладки */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--field); background: #fff; color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.chip:hover { border-color: #b9c1d3; text-decoration: none; }
.chip.on { background: var(--text); border-color: var(--text); color: #fff; }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.on .n { color: #c5cbe0; }
.chip .n.late { color: var(--red); }
.chip.on .n.late { color: #ffb4ab; }

.tabs {
  display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--gray-bg);
  width: fit-content; max-width: 100%; overflow-x: auto;
}
.tabs > a, .tabs > button {
  flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.tabs > a:hover, .tabs > button:hover { color: var(--text); text-decoration: none; }
.tabs > .on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(20, 27, 45, .12); }

/* Кнопки и поля */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px;
  border: 1px solid var(--field); border-radius: 10px; background: #fff; color: var(--text);
  font-size: 14px; font-weight: 700; line-height: 1; white-space: nowrap; cursor: pointer;
}
.btn:hover { filter: brightness(.96); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; filter: none; }
.btn .ic { width: 16px; height: 16px; }
.btn.p { border-color: var(--blue); background: var(--blue); color: #fff; padding: 0 18px; }
.btn.ok { border-color: #b7dcc4; background: var(--green-bg); color: var(--green); }
.btn.no { border-color: #ecc9c4; background: #fbefed; color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 32px; padding: 0 12px; border-radius: 8px; font-size: 13px; }
.btn.wide { width: 100%; }

.inp {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--field); border-radius: 10px;
  background: #fff; color: var(--text); font-size: 14px;
}
textarea.inp { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.inp::placeholder { color: #8a92a6; }
.inp:disabled { background: var(--soft); color: var(--muted); cursor: not-allowed; }
.sel {
  height: 36px; max-width: 100%; padding: 0 10px; border: 1px solid var(--field); border-radius: 9px;
  background: #fff; color: var(--text); font-size: 13px;
}
.lbl { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.req { color: var(--red); }
.lnk {
  padding: 0; border: 0; border-bottom: 1px dashed #9db0ef; background: none; color: var(--blue);
  font-size: 14px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.lnk:hover { text-decoration: none; border-bottom-style: solid; }

/* Формы в карточке */
.form { max-width: 640px; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.form.narrow { max-width: 440px; }
.fld { display: flex; flex-direction: column; min-width: 0; }
.form input[type=text], .form input[type=password], .form input[type=number], .form input[type=email],
.form input[type=url], .form input[type=tel], .form input[type=search], .form input[type=date], .form select, .form textarea {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--field); border-radius: 10px;
  background: #fff; color: var(--text); font-size: 14px;
}
.form textarea { height: auto; min-height: 110px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.help { margin-top: 6px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.help ul { margin: 4px 0 0; padding-left: 18px; }
.err, .errorlist { margin: 6px 0 0; font-size: 13px; color: var(--red); }
.errorlist { padding: 0; list-style: none; }
.has-err input:not([type=checkbox]):not([type=radio]), .has-err select, .has-err textarea { border-color: #e2a59d; background: #fffafa; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; flex: 0 0 16px; margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 4px; }

/* Окна (<dialog class="dlg">) */
dialog.dlg {
  width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 24px; overflow-y: auto;
  border: 0; border-radius: 16px; background: #fff; color: var(--text); box-shadow: 0 20px 50px rgba(20, 27, 45, .25);
}
dialog.dlg::backdrop { background: rgba(20, 27, 45, .45); }
.dlg form, .dlg-body { display: flex; flex-direction: column; gap: 16px; }
.dlg h2 { font-size: 19px; font-weight: 800; }
.dlg p { font-size: 14px; color: var(--muted); }
.dlg-head { display: flex; flex-direction: column; gap: 4px; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  font-size: 14px; cursor: pointer;
}
.choice:hover { background: var(--soft); }
.choice:has(input:checked) { border-color: #9db0ef; background: var(--blue-soft); }
.choice input { width: 16px; height: 16px; flex: 0 0 16px; margin: 2px 0 0; }
.choice b { display: block; font-weight: 700; }
.choice small { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }

/* Выпадающее меню (<details class="dropdown">), по умолчанию открывается вверх */
.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > summary::after {
  content: ""; width: 6px; height: 6px; margin-left: 2px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg); opacity: .6;
}
.dropdown[open] > summary::after { transform: translateY(1px) rotate(-135deg); }
.menu {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 30; min-width: 260px; max-width: min(380px, calc(100vw - 32px));
  max-height: 320px; overflow-y: auto; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(20, 27, 45, .16);
}
.dropdown.down .menu { top: calc(100% + 6px); bottom: auto; }
.dropdown.right .menu { left: auto; right: 0; }
.menu button, .menu a {
  display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--text);
  font-size: 14px; text-align: left; cursor: pointer;
}
.menu button:hover, .menu a:hover { background: var(--soft); text-decoration: none; }

/* Пустое состояние */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 40px 24px;
  text-align: center; font-size: 14px; color: var(--muted);
}
.empty .ic { width: 36px; height: 36px; color: #b6bdcc; }
.empty b { font-size: 15px; color: var(--text); }
td.empty { display: table-cell; }

/* Страница ошибки (panel/error.html). Без входа она показывается без меню, по центру экрана. */
.errbox { max-width: 560px; }
.errbox h1 { font-size: 20px; font-weight: 800; color: var(--text); }
.errbox .btn { margin-top: 8px; }
.errpage { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.errpage .errbox { width: 100%; }

/* Страницы */
.pager { display: flex; align-items: center; gap: 6px; }
.pg {
  min-width: 32px; height: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--field); border-radius: 8px; background: #fff; color: var(--text); font-size: 13px; font-weight: 700;
}
.pg:hover { background: var(--soft); text-decoration: none; }
.pg.on { background: var(--text); border-color: var(--text); color: #fff; }
.pg.off { opacity: .4; pointer-events: none; }

/* Обращения: список слева, выбранное справа */

.split { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: 16px; }
.listp, .detail { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.lp-head { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line-soft); }
.lp-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.lp-filters .sel { flex: 1 1 120px; min-width: 0; }
.search { position: relative; }
.search .ic { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .inp { height: 40px; padding-left: 36px; background: var(--bg); }
.lp-count {
  display: flex; justify-content: space-between; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--line-soft);
  font-size: 12px; color: var(--muted);
}
.rows { flex: 1 1 auto; min-height: 0; overflow-y: auto; position: relative; }
.it {
  display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
  background: #fff; color: var(--text);
}
.it:hover { background: #f7f8fc; text-decoration: none; }
.it.on { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
.it-top { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.it-top b { font-size: 14px; font-weight: 700; }
.it-top .dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--blue); }
.when { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.when.late { color: var(--red); }
.prev {
  font-size: 14px; line-height: 1.4; color: var(--text-2); overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.it-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.lp-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--muted);
}

/* Шапка обращения */
.dh { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.dh-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.dh-top h2 { margin-right: 4px; font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.dh-date { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.metas { display: flex; flex-wrap: wrap; gap: 6px; }
.meta { padding: 6px 10px; border-radius: 8px; background: var(--bg); color: var(--muted); font-size: 13px; }
.meta b { margin-left: 4px; color: var(--text); font-weight: 600; }
.meta small { margin-left: 4px; font-size: 12px; color: var(--muted); }
.meta.late b { color: var(--red); }
.meta.on { background: var(--amber-bg); color: var(--amber); }
.acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
/* Выделенный блок: контакты студента, запрос контактов */
.ask {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 12px 14px; border-radius: 12px;
  background: var(--violet-bg); border: 1px solid #ddd0f7; font-size: 14px;
}
.ask.plain { background: var(--bg); border-color: var(--line); }

/* Переписка: .msg.student / .staff / .note / .system, как значения Message.sender */
.chat { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 22px; background: var(--soft); }
.msg { display: flex; }
.msg.student { justify-content: flex-start; }
.msg.staff, .msg.note { justify-content: flex-end; }
.msg.system { justify-content: center; }
.bub { max-width: 72%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.msg.student .bub { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.staff .bub { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.note .bub { background: var(--note); border: 1px solid var(--note-line); border-bottom-right-radius: 4px; }
.msg.staff .bub a { color: #fff; text-decoration: underline; }
.txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.who { margin-bottom: 4px; font-size: 12px; font-weight: 700; opacity: .75; }
.mt { margin-top: 6px; font-size: 11px; text-align: right; color: var(--muted); }
.msg.staff .mt { color: #d6e0ff; }
.sys { max-width: 90%; padding: 5px 12px; border-radius: 999px; background: #e9ecf2; color: #5b6478; font-size: 12px; text-align: center; }
.sys.ok { background: #dff1e6; color: var(--green); font-weight: 700; }
.sys.bad { background: #fbe4e1; color: var(--red); font-weight: 700; }
.sys time { margin-left: 4px; font-weight: 500; opacity: .75; }
.file {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 10px; border-radius: 8px;
  background: #eef1f7; color: var(--text); font-size: 13px; font-weight: 600;
}
a.file:hover { background: #e3e8f2; text-decoration: none; }
.file .ic { width: 16px; height: 16px; color: var(--muted); }
.msg.staff .bub .file { background: rgba(255, 255, 255, .16); color: #fff; text-decoration: none; }
.msg.staff .file .ic { color: #fff; }
.photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.photo { display: block; margin-top: 8px; }
.photos .photo { margin-top: 0; }
.photo img { display: block; max-width: min(260px, 100%); max-height: 260px; border-radius: 10px; border: 1px solid var(--line); background: #eef1f7; }
.note-act { display: flex; justify-content: flex-end; margin-top: 8px; }
.fbk {
  align-self: center; max-width: 80%; padding: 10px 16px; border-radius: 12px; text-align: center;
  background: var(--green-bg); border: 1px solid #b7dcc4; color: var(--green); font-size: 14px;
}
.fbk .txt { margin-top: 4px; color: var(--text); }
.stars { color: #d99a00; letter-spacing: 1px; }

/* Поле ответа под перепиской */
.reply { display: flex; flex-direction: column; gap: 10px; padding: 14px 20px 16px; border-top: 1px solid var(--line-soft); background: #fff; }
.reply-h { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.reply-h .muted { font-weight: 500; }
.reply textarea { min-height: 76px; max-height: 40vh; }
.reply-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Вход */

.login { min-height: 100vh; display: flex; flex-wrap: wrap; }
.login-side {
  flex: 1 1 480px; display: flex; flex-direction: column; gap: 40px; padding: 48px;
  background: var(--side); color: #e8ecf5;
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-hero { margin: auto 0; max-width: 520px; display: flex; flex-direction: column; gap: 16px; }
.login-hero h1 { font-size: 40px; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; color: #fff; }
.login-hero p { font-size: 16px; line-height: 1.6; color: var(--side-text); }
.login-main { position: relative; flex: 1 1 420px; display: flex; align-items: center; justify-content: center; padding: 72px 20px 40px; }
.login-lang { position: absolute; top: 20px; right: 20px; }
.login-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.login-form h2 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.login-form .help { margin-top: 0; }
.login-head { display: flex; flex-direction: column; gap: 6px; }
.login-head p { font-size: 14px; color: var(--muted); }

/* Узкий экран */

@media (max-width: 1100px) {
  /* Список и обращение рядом не помещаются: показываем что-то одно, страница прокручивается целиком */
  .split { grid-template-columns: minmax(0, 1fr); }
  .split.selected .listp { display: none; }
  .split:not(.selected) .detail { display: none; }
  .main.fill { height: auto; overflow: visible; }
  .main.fill > .split { flex: none; min-height: 0; }
  .detail .chat { min-height: 200px; max-height: 65vh; }
}
@media (min-width: 1101px) {
  .only-narrow { display: none !important; }
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .shell > .side {
    width: auto; flex: none; height: auto; position: static; overflow: visible;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px;
  }
  .nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  .nav a { height: 38px; padding: 0 10px; gap: 8px; font-size: 13px; }
  .nav a.on { box-shadow: none; }
  .badge { margin-left: 2px; }
  .brand small { display: none; }
  .user { flex-direction: row-reverse; align-items: center; margin: 0 0 0 auto; padding: 0; background: transparent; }
  .user .info, .user .av { display: none; }
  .user-links { gap: 10px; }
  .main { padding: 16px; gap: 16px; }
  .detail .chat { max-height: 60vh; padding: 16px; }
  .ph h1 { font-size: 22px; }
  .ph-side { width: 100%; }
  .ph-side > .stat { flex: 1 1 0; min-width: 0; padding: 8px 12px; }
  .stat b { font-size: 20px; }
  .bub { max-width: 88%; }
  .tbl table { min-width: 620px; }
  .form { padding: 18px; }
  .update-bar { left: 50%; }
  .login-side { flex-basis: 100%; gap: 24px; padding: 28px; }
  .login-hero h1 { font-size: 28px; }
  .login-main { padding: 64px 16px 40px; }
}

/* other pages: отзывы, статистика, шаблоны, сотрудники, департаменты */

/* Раздел страницы: заголовок слева, переключатели (чипы периода) справа */
.sect { display: flex; flex-direction: column; gap: 12px; }
.sect-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.card-h > div > p { margin-top: 2px; }

/* Фильтры над таблицей: чипы слева, форма справа */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.toolbar-f { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.toolbar-f .check { font-size: 13px; }

/* Отзывы: три счётчика и распределение оценок шириной в два */
.kpis.fb { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 2fr); }
.bars { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.bars li { display: grid; grid-template-columns: 30px minmax(0, 1fr) 32px; align-items: center; gap: 10px; font-size: 12px; line-height: 14px; color: var(--muted); }
.bars li > span:first-child { font-weight: 600; white-space: nowrap; }
.bar { height: 8px; border-radius: 999px; background: var(--gray-bg); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: #3fae6a; }
.bars .r3 .bar i { background: #e3a008; }
.bars .r2 .bar i, .bars .r1 .bar i { background: #d9493e; }

/* Оценка звёздами в таблице и средняя оценка со звездой */
.rating { white-space: nowrap; letter-spacing: 1px; }
.rating i { font-style: normal; color: #d99a00; }
.rating i.off { color: var(--field); }
.rate { white-space: nowrap; }
.rate::before { content: "\2605"; margin-right: 4px; color: #d99a00; }

/* Ячейки таблиц */
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.line2.clamp { display: -webkit-box; }
.fb-ticket { min-width: 170px; max-width: 280px; }
.fb-text { min-width: 200px; max-width: 380px; }
.tpl-title { min-width: 160px; }
.tpl-text { min-width: 240px; }
td.act { width: 1%; text-align: right; white-space: nowrap; }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pills > .pill { flex: none; }
/* Широкая таблица (департаменты): поуже отступы, длинные заголовки колонок переносятся */
table.dense th, table.dense td { padding-left: 12px; padding-right: 12px; }
table.dense th { white-space: normal; }

/* Сотрудник в таблице: кружок с буквой, имя, логин второй строкой */
.person { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.person .av { width: 32px; height: 32px; flex: 0 0 32px; background: var(--blue-bg); color: var(--blue); font-size: 13px; }
tr.inactive .person .av { background: var(--gray-bg); color: var(--muted); }

.pg.gap { border-color: transparent; background: none; pointer-events: none; }
/* Длинное значение счётчика («1 ч 58 мин») мельче, чтобы помещалось в одну строку */
.kpi b.long { font-size: 22px; line-height: 34px; }

@media (max-width: 1100px) {
  .kpis.fb { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis.fb .wide { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .toolbar-f { width: 100%; }
  .toolbar-f .sel { flex: 1 1 180px; }
  .kpis.fb { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis.fb .kpi:first-child { grid-column: 1 / -1; }
  .kpis.fb .kpi b { font-size: 24px; }
}

/* tickets screen */

/* Список занимает треть ширины (от 300 до 420px): на ноутбуке обращению справа нужна ширина для кнопок */
@media (min-width: 1101px) {
  .split { grid-template-columns: clamp(300px, 34%, 420px) minmax(0, 1fr); }
}

/* Фильтры списка: департамент на всю ширину, ниже тип, исполнитель и кнопка */
.lp-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px; }
.lp-filters .sel { width: 100%; }
.lp-filters .sel.dept { grid-column: 1 / -1; }
.lp-filters .btn { height: 36px; }
/* С JavaScript кнопки «Найти» нет (фильтр применяется сразу), селекты делят строку поровну */
.lp-head.auto .lp-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.lp-count { align-items: center; }
.lp-count a { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; white-space: nowrap; }
.lp-count .ic { width: 14px; height: 14px; }
/* Пункт списка: кто взял в работу и имя студента, если он оставил контакты */
.it-foot .asg { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; color: var(--text-2); }
.it-foot .ic { width: 13px; height: 13px; }
.it-foot .contact { font-weight: 600; color: var(--violet); }

/* Правая часть, пока обращение не выбрано */
.detail-empty { flex: 1 1 auto; }

/* Шапка обращения и блок контактов. Всё компактно: главное место на экране у переписки. */
.dh { gap: 8px; padding: 12px 20px; }
.dh > .back { align-self: flex-start; margin: 0; }
.meta { padding: 4px 9px; font-size: 12.5px; }
.ask .ic { width: 16px; height: 16px; }
.ask-t { display: inline-flex; align-items: center; gap: 6px; color: var(--violet); }
.contacts { gap: 4px 14px; padding: 8px 12px; font-size: 13px; }
.contacts a { font-weight: 600; }
.ask-more { color: var(--text-2); overflow-wrap: anywhere; }
.ask.plain { flex-wrap: nowrap; padding: 8px 12px; color: var(--muted); font-size: 13px; }

/* Переписка: не сжимается в полоску; взято в работу жёлтым, как пилюля «В работе»; несколько фото квадратами */
.detail .chat { padding: 18px 22px; }
@media (min-width: 1101px) {
  .detail .chat { min-height: 140px; }
}
.sys.work { background: var(--amber-bg); color: var(--amber); font-weight: 700; }
.photos.multi .photo img { width: 116px; height: 116px; object-fit: cover; }
.fbk time { display: block; margin-top: 4px; font-size: 11px; opacity: .75; }
.fbk.bad { background: var(--red-bg); border-color: #ecc9c4; color: var(--red); }

/* Поле ответа: шаблоны в строке подписи, над полем */
.reply { gap: 8px; padding: 10px 20px 12px; }
/* Строка не переносится (переносится сама подпись), поэтому меню шаблонов всегда у правого края и не уходит за экран */
.reply-h { flex-wrap: nowrap; align-items: center; }
.reply-h label { flex: 1 1 auto; min-width: 0; }
.reply-h > .muted { white-space: nowrap; }
.reply-h .dropdown summary { height: 28px; padding: 0 10px; font-size: 12.5px; }
.reply-h .menu { max-height: 240px; }
.reply textarea { min-height: 60px; }

/* Невысокий экран (ноутбук 1366x768): заголовок страницы ниже, переписке больше места */
@media (max-height: 820px) and (min-width: 1101px) {
  .main.fill { padding-top: 16px; padding-bottom: 16px; gap: 12px; }
  .main.fill .ph h1 { font-size: 22px; }
  .main.fill .ph p { margin-top: 2px; font-size: 13px; }
  .main.fill .stat { padding: 6px 14px; }
  .main.fill .stat b { font-size: 20px; }
}

@media (max-width: 860px) {
  /* Когда открыто обращение, заголовок со счётчиками скрыт: к списку ведёт ссылка в карточке */
  .main.fill:has(> .split.selected) > .ph { display: none; }
  .dh { padding: 12px 16px; }
  .detail .chat { padding: 16px; }
  .reply { padding: 10px 16px 12px; }
  /* Тип и исполнитель в две колонки, кнопка «Найти» под ними */
  .lp-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .lp-filters .btn { grid-column: 1 / -1; }
}

/* Схема из макета: плашка «Бот спросил автора», фильтр категорий, отчёты */
.ask-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.35; flex: 1 1 240px; min-width: 0; }
.ask-text b { color: #3d1d80; }
.ask-text span { font-size: 13px; color: var(--muted); }
.reply .err { margin: 0; font-weight: 600; }
.lp-filters.one, .lp-head.auto .lp-filters.one { grid-template-columns: minmax(0, 1fr) auto; }
.lp-head.auto .lp-filters.one { grid-template-columns: minmax(0, 1fr); }
.fieldset { margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; gap: 10px; }
.fieldset legend { padding: 0 6px; margin: 0; }
.lbl.inline { display: inline; margin: 0; }
.inp.date { width: auto; height: 36px; padding: 0 10px; font-size: 13px; }
.ok-text { color: var(--green); font-weight: 700; }
table.report td { vertical-align: top; }
table.report .fb { display: block; min-width: 160px; max-width: 280px; }
.reply.closed { gap: 8px; }
.closed-note { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--bg); color: var(--muted); font-size: 14px; }
.dlg .fld textarea { min-height: 70px; }
