:root {
  --bg-main: #f5f6f8;
  /* полупрозрачный, чтобы сквозь плашки просвечивал размытый фирменный фон */
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-header: #3a4d59;
  --bg-header-strong: #303e48;
  --bg-sidebar: #f5f6f8;
  --text-main: #111827;
  --text-muted: #6b7280;
  --text-on-dark: #f9fafb;
  --accent: #f97316;
  --accent-strong: #ea580c;
  --accent-soft: rgba(249, 115, 22, 0.12);
  --border-subtle: #e5e7eb;
  --border-strong: #d1d5db;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #ca8a04;
  --info: #2563eb;
  --radius: 12px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  background: var(--bg-main);
  color: var(--text-main);
}

/* Фирменный фон — размытая подложка на весь вьюпорт; inset с запасом,
   чтобы у краёв не проступала кромка блюра. Картинка почти вся белая
   (цвет только в правом верхнем углу), поэтому зумим её в цветную зону —
   иначе контентные страницы ложатся на белую часть и фон не виден. */
body::before {
  content: "";
  position: fixed;
  inset: -80px;
  z-index: -1;
  background:
    linear-gradient(rgba(245, 246, 248, 0.2), rgba(245, 246, 248, 0.2)),
    url("../assets/bg-brand.png") 70% 30% / 180% no-repeat;
  filter: blur(48px);
  /* transform, а не background-position — анимация уходит на GPU
     и не пересчитывает блюр; амплитуда меньше запаса inset */
  animation: bg-drift 90s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes bg-drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(-1.8%, -1.2%, 0) scale(1.05); }
  100% { transform: translate3d(1.4%, 0.9%, 0) scale(1.02); }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}

a { color: var(--text-main); text-decoration: none; }
a:hover { color: var(--accent); }

/* ─────────── Header ─────────── */

.app-header {
  background: var(--bg-header);
  color: var(--text-on-dark);
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.5rem;
}

.app-header a { color: var(--text-on-dark); }

.app-header-left { display: flex; align-items: center; gap: 1.25rem; }

.app-logo { display: flex; align-items: center; gap: 0.9rem; }

.app-logo img {
  height: 32px;
  width: auto;
  display: block;
}
.app-logo .divider {
  width: 1px;
  height: 32px;
  background: rgba(255,255,255,0.2);
  margin: 0 0.25rem;
}

.app-title-group { display: flex; flex-direction: column; line-height: 1.2; }
.app-title { font-size: 1rem; font-weight: 600; color: var(--text-on-dark); }
.app-subtitle { font-size: 0.78rem; color: #9ca3af; }

/* Шапка переносится, если не помещается в строку: у головной переключатель
   юрлица добавляет ~390px, и на ширине до ~1100px шапка распирала страницу
   вбок. Пока всё помещается, перенос ничего не меняет. */
.app-header { flex-wrap: wrap; row-gap: 0.5rem; }
.app-header-right {
  display: flex; align-items: center; gap: 0.75rem;
  flex-wrap: wrap; justify-content: flex-end; row-gap: 0.5rem;
  margin-left: auto; min-width: 0;
}
/* RND-1115: переключатель юрлица группы в шапке головной организации. */
.company-switch { display: flex; align-items: center; gap: 0.4rem; margin-right: 0.6rem; min-width: 0; }
.company-switch-label { font-size: 0.72rem; color: rgba(255, 255, 255, 0.8); white-space: nowrap; }
.company-switch-select.input { width: auto; max-width: 16rem; min-width: 0; padding: 0.25rem 0.5rem; font-size: 0.85rem; }

.user-button {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.85rem 0.35rem 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-on-dark);
  cursor: pointer;
}
.user-button:hover { background: rgba(255,255,255,0.08); color: white; }

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f97316;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.link-ghost,
button.link-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-pill);
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  color: var(--text-on-dark);
  cursor: pointer;
  text-decoration: none;
}
.link-ghost:hover { background: rgba(255,255,255,0.08); color: white; }

/* ─────────── Layout shell ─────────── */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 56px);
  transition: grid-template-columns 0.2s ease;
}
.app-shell.sidebar-collapsed,
html.pp-sidebar-collapsed-preload .app-shell { grid-template-columns: 40px 1fr; }
html.pp-sidebar-collapsed-preload .sidebar-nav-wrap { display: none; }
html.pp-sidebar-collapsed-preload .sidebar-toggle { margin: 0 auto 0.25rem; }
html.pp-sidebar-collapsed-preload .sidebar-toggle-icon { transform: rotate(180deg); display: inline-block; }

.app-sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  padding: 0.5rem 0.5rem 1rem;
  position: relative;
  overflow: hidden;
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  margin: 0 0 0.25rem auto;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s, transform 0.2s;
}
.sidebar-toggle:hover { background: rgba(249,115,22,0.1); color: var(--accent-strong); }
.app-shell.sidebar-collapsed .sidebar-toggle { margin: 0 auto 0.25rem; }
.app-shell.sidebar-collapsed .sidebar-toggle-icon { transform: rotate(180deg); display: inline-block; }
.app-shell.sidebar-collapsed .sidebar-nav-wrap { display: none; }

.sidebar-section { padding: 0.5rem 0.5rem 0.5rem 0.75rem; }

.sidebar-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  margin: 0.5rem 0 0.5rem 0.5rem;
  font-weight: 600;
}

/* Сворачиваемые группы (RND-1116): заголовок — <summary>, стрелка справа. */
.sidebar-group { padding-top: 0.15rem; padding-bottom: 0.15rem; }
.sidebar-group-title {
  display: flex;
  align-items: center;
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 0.35rem 0.5rem;
  margin: 0.2rem 0;
  border-radius: 6px;
}
.sidebar-group-title::-webkit-details-marker { display: none; }
.sidebar-group-title::after {
  content: "›";
  margin-left: auto;
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.15s;
}
.sidebar-group[open] > .sidebar-group-title::after { transform: rotate(90deg); }
.sidebar-group-title:hover { color: var(--text-main); background: rgba(249, 115, 22, 0.06); }
.sidebar-group-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.sidebar-nav { list-style: none; padding: 0; margin: 0; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #374151;
}
.sidebar-link:hover { background: rgba(249, 115, 22, 0.08); color: var(--text-main); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

/* Индикатор «есть новые» в сайдбаре — только когда data/JS включает точку */
.nav-alert-dot {
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 0.45rem;
  flex-shrink: 0;
  vertical-align: middle;
}
.nav-alert-dot.is-on {
  display: inline-block;
}

/* Сделка, которую сотрудник ещё не открывал (RND-1128) */
.table tr.deal-row--new > td { background: var(--accent-soft); }
.table tr.deal-row--new > td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* ─────────── Main content ─────────── */

.app-main { padding: 1.5rem 2rem; min-width: 0; }

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 0.35rem 0;
  color: var(--text-main);
}
.page-subtitle { color: var(--text-muted); margin: 0 0 1.75rem 0; font-size: 0.9rem; }

/* Заголовок без подзаголовка тоже отделяем от следующей таблицы/карточки */
.page-title + .surface,
.page-title + .card,
.page-title + .surface-soft,
.page-title + .table { margin-top: 1.5rem; }

/* ─────────── Cards ─────────── */

.surface, .card, .surface-soft {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-card);
}

.card { margin-bottom: 1rem; }

.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--text-main); }
.card-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

/* ─────────── Дерево «партнёр → заказчик → заявки» (partner-tickets.html) ───────────
   Родные <details>: клавиатура и скринридеры работают без своего кода. Маркер
   системы скрыт, вместо него уголок (::before у <summary>, первая колонка
   сетки): вправо — свёрнуто, вниз — раскрыто. */

.pt-tree { display: flex; flex-direction: column; gap: 1rem; margin-top: 0.75rem; }
.pt-partner { padding: 0; }
.pt-summary {
  /* уголок | название (+ продукты) | счётчики; длинное название переносится
     в своей колонке, уголок и счётчики остаются на месте */
  display: grid; grid-template-columns: 0.75rem minmax(0, 1fr) auto;
  align-items: center; gap: 0.25rem 0.75rem;
  list-style: none; cursor: pointer;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
}
.pt-summary::-webkit-details-marker { display: none; }
.pt-summary::marker { content: ""; }
.pt-summary::before {
  content: "";
  width: 0.45rem; height: 0.45rem;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 120ms ease;
}
details[open] > .pt-summary::before { transform: rotate(45deg); }
.pt-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pt-summary:hover { background: var(--accent-soft); }
.pt-summary-main {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem 0.6rem;
  min-width: 0;
}
.pt-summary-meta { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; text-align: right; }
.pt-partner-name { font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
.pt-customer-name { font-weight: 600; overflow-wrap: anywhere; }

.pt-customers { padding: 0 1.25rem 0.75rem 2rem; }
.pt-customer { border-top: 1px solid var(--border-subtle); }
.pt-customer > .pt-summary { padding: 0.65rem 0.5rem; }
.pt-customer > .table-scroll,
.pt-customer > .pt-tickets { margin: 0 0 0.75rem 1.5rem; }

/* Таблица на каждого заказчика: фиксированная раскладка, чтобы колонки
   совпадали у всех заказчиков, и минимальная ширина — на узком экране
   таблица прокручивается в .table-scroll, а не сжимается в столбик.
   Блок стоит выше общих .table и .table-scroll > table.table — отсюда
   префикс .pt-customer, чтобы перебить их по специфичности. */
.pt-customer table.table.pt-tickets { table-layout: fixed; min-width: 820px; }
.pt-customer table.table.pt-tickets th, .pt-customer table.table.pt-tickets td {
  padding: 0.6rem 0.75rem; vertical-align: top; overflow-wrap: anywhere;
}
/* даты — фиксированно (в ячейках nowrap), остальное в долях; саммари — остаток */
.pt-customer table.table.pt-tickets th:nth-child(1) { width: 10%; }
.pt-customer table.table.pt-tickets th:nth-child(2) { width: 6.75rem; }
.pt-customer table.table.pt-tickets th:nth-child(3) { width: 22%; }
.pt-customer table.table.pt-tickets th:nth-child(4) { width: 10%; }
.pt-customer table.table.pt-tickets th:nth-child(5) { width: 6.75rem; }

@media (max-width: 600px) {
  .pt-summary { grid-template-columns: 0.75rem minmax(0, 1fr); padding: 0.75rem 0.85rem; }
  .pt-summary-meta { grid-column: 2; white-space: normal; text-align: left; }
  .pt-customers { padding: 0 0.85rem 0.6rem 0.85rem; }
  .pt-customer > .table-scroll,
  .pt-customer > .pt-tickets { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .pt-summary::before { transition: none; }
}

/* ─────────── Модальное окно ─────────── */

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 1.25rem;
  width: 90%;
  max-width: 560px;
  background: #ffffff;
  color: var(--text-main);
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.25);
}
.modal::backdrop { background: rgba(15, 23, 42, 0.45); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

/* Список выбора внутри окна: прокручивается сам, окно остаётся на месте */
.picker-list {
  margin-top: 0.75rem;
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}
.picker-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}
.picker-item:last-child { border-bottom: none; }
.picker-item:hover { background: var(--accent-soft); color: var(--text-main); }
.picker-item[hidden] { display: none; }

/* ─────────── Pills (KPI) ─────────── */

.kpi-row { display: flex; flex-wrap: wrap; gap: 0.65rem; }

.kpi {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: #f9fafb;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 0.45rem 0.95rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.kpi .value { color: var(--text-main); font-weight: 700; }

/* Плашка-фильтр: тот же вид, что у обычной, плюс отклик на курсор и
   выделение выбранного отбора (kpi-filter.js) */
button.kpi { font: inherit; font-size: 0.9rem; }
.kpi-clickable { cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.kpi-clickable:hover { background: var(--accent-soft); border-color: var(--accent); }
.kpi-clickable.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 600;
}

/* ─────────── Buttons ─────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: var(--radius-pill);
  padding: 0.5rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-strong); color: white; }
.btn-ghost {
  background: white;
  color: var(--text-main);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: #f3f4f6; color: var(--text-main); }
.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; color: white; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }

/* ─────────── Forms ─────────── */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-field { display: flex; flex-direction: column; gap: 0.3rem; }

.form-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.input,
input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="number"],
select, textarea {
  border: 1px solid var(--border-strong);
  background: white;
  color: var(--text-main);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 80px; resize: vertical; }

select.input { background: white; appearance: auto; }

/* ─────────── Tables ─────────── */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th, .table td {
  text-align: left;
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.table thead th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0.02em;
  background: #f9fafb;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafafa; }
.table tbody tr[data-href] { cursor: pointer; }

/* ─────────── Status pills (chips) ─────────── */

.chip,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 500;
  background: #f3f4f6;
  color: #374151;
  border: none;
}
a.chip { cursor: pointer; transition: filter 120ms ease, transform 120ms ease; }
a.chip:hover { filter: brightness(0.94); transform: translateY(-1px); }
.chip-warn { background: #fef3c7; color: #92400e; }
.chip-info { background: #dbeafe; color: #1e40af; }
.chip-success { background: #dcfce7; color: #166534; }
.chip-muted { background: #f3f4f6; color: #4b5563; }
.chip-danger { background: #fee2e2; color: #991b1b; }
.chip-accent { background: var(--accent-soft); color: var(--accent-strong); }

/* company status (catalog `code`) */
.chip-status-platinum        { background: #e5e7eb; color: #1f2937; }
.chip-status-gold            { background: #fef3c7; color: #92400e; }
.chip-status-silver          { background: #f3f4f6; color: #374151; }
.chip-status-regional-expert { background: #dbeafe; color: #1e40af; }
.chip-status-none            { background: transparent; color: var(--text-muted); }

.service-partner-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #ffffff;
  border: 1px solid rgba(234, 88, 12, 0.35);
  box-shadow: 0 8px 18px rgba(249, 115, 22, 0.18);
  font-weight: 800;
  letter-spacing: 0.02em;
}
.service-partner-badge::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.24);
}
.service-partner-badge-sm {
  padding: 0.18rem 0.55rem;
  font-size: 0.72rem;
  box-shadow: none;
}
.service-partner-badge-lg {
  padding: 0.55rem 1.05rem;
  font-size: 1rem;
  text-transform: uppercase;
}
.service-partner-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}
.service-partner-panel-text {
  font-size: 0.9rem;
  font-weight: 600;
}
.service-partner-panel + .kpi-row { margin-top: 0.85rem; }

/* status mapping */
.status-submitted    { background: #fef3c7; color: #92400e; }
.status-approved     { background: #dcfce7; color: #166534; }
.status-rejected     { background: #fee2e2; color: #991b1b; }
.status-clarification{ background: #ffedd5; color: #9a3412; }
.status-shipped      { background: #dbeafe; color: #1e40af; }
.status-expired_unsuccessful { background: #f3f4f6; color: #6b7280; }

/* ─────────── Banner ─────────── */

.banner {
  background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
  border: 1px solid #fdba74;
  color: #9a3412;
  border-radius: var(--radius);
  padding: 0.9rem 1.2rem;
  font-size: 0.9rem;
}

/* ─────────── Progress ─────────── */

.progress-track {
  background: #f3f4f6;
  border-radius: var(--radius-pill);
  height: 8px;
  overflow: hidden;
}
.progress-fill {
  background: linear-gradient(to right, var(--accent), var(--accent-strong));
  height: 100%;
  border-radius: var(--radius-pill);
}

/* ─────────── Dashboard grid ─────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.tag-strip { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; }
.chips-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ─────────── Auth shell ─────────── */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  /* фон прозрачный — сквозь него виден размытый фирменный фон (body::before) */
  background: transparent;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-header);
  color: var(--text-on-dark);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}

/* Override text colors for the dark card */
.auth-card .auth-title { color: #ffffff; }
.auth-card .auth-subtitle { color: #cbd5e1; }
.auth-card .form-label { color: #cbd5e1; }

/* Inputs inside the dark auth card stay white so they're clearly editable */
.auth-card .input,
.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="number"] {
  background: #ffffff;
  color: var(--text-main);
}

/* Поле пароля с кнопкой «Показать / Скрыть» (js/password-toggle.js). */
.pw-wrap { position: relative; display: block; }
.pw-wrap > input { width: 100%; padding-right: 5.5rem; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
}
.pw-toggle:hover { color: var(--accent-strong); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Logo on dark card — already dark grey, so make it transparent (just show the white svg) */
.auth-card .auth-logo { background: transparent; padding: 0; }

/* "Ghost" buttons on the dark card need lighter borders */
.auth-card .btn-ghost {
  background: transparent;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
}
.auth-card .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}
/* Логотип над заголовком — иначе «Личный кабинет» переносится в две строки. */
.auth-logo-row { display: flex; flex-direction: column; align-items: flex-start; gap: 0.9rem; margin-bottom: 1.5rem; }
.auth-logo-row > div { min-width: 0; }
.auth-title { font-size: 1.2rem; font-weight: 700; line-height: 1.2; }
.auth-subtitle { font-size: 0.85rem; color: var(--text-muted); word-break: break-word; overflow-wrap: anywhere; }

.auth-logo {
  height: 32px;
  width: auto;
  background: var(--bg-header);
  padding: 6px 10px;
  border-radius: 6px;
  display: block;
}

/* Форма входа: поля колонкой, широкая основная кнопка, ссылка под ней. */
.auth-form { display: flex; flex-direction: column; gap: 0.9rem; }
.auth-btn-wide { width: 100%; justify-content: center; padding: 0.6rem 1.1rem; }
.auth-form .auth-btn-wide { margin-top: 0.35rem; }

.auth-link {
  display: block;
  text-align: center;
  font-size: 0.82rem;
  color: #cbd5e1;
  text-decoration: none;
}
.auth-link:hover { color: #ffffff; text-decoration: underline; }
.auth-legal-link { margin-top: 1.25rem; font-size: 0.75rem; color: #94a3b8; }

/* Подсказка заявителям на странице входа: пароль приходит после одобрения. */
.auth-hint { margin: 1rem 0 0; padding: 0.75rem; border-radius: 8px; border: 1px solid rgba(249, 115, 22, 0.4); background: rgba(249, 115, 22, 0.08); font-size: 0.85rem; color: #cbd5e1; }

/* Разделитель «или» между входом по паролю и входом через Ворота. */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 1.5rem 0 1.15rem;
  color: #94a3b8;
  font-size: 0.8rem;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.14);
}

/* Отдельный блок под SSO — чтобы он не выглядел продолжением формы. */
.auth-sso {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 1rem;
}
.auth-sso-title {
  font-size: 0.82rem;
  color: #cbd5e1;
  text-align: center;
  margin-bottom: 0.75rem;
}

/* ─────────── Сообщения: отметка о прочтении (RND-1127) ─────────── */

.msg-receipt {
  margin-top: 0.25rem;
  font-size: 0.75em;
  color: var(--text-muted);
  text-align: right;
}
.msg-receipt--read { color: var(--success); }
details.msg-receipt > summary { cursor: pointer; list-style: none; }
details.msg-receipt > summary::-webkit-details-marker { display: none; }
details.msg-receipt > summary:hover { text-decoration: underline dotted; }
.msg-receipt-who { color: var(--text-muted); margin-top: 0.15rem; }
.msg-receipt-list { margin: 0.1rem 0 0; padding: 0; list-style: none; color: var(--text-muted); }

/* ─────────── Flash messages ─────────── */

.flash {
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.flash-error   { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.flash-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.flash-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.flash-info    { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

/* ─────────── Definition list ─────────── */

.dl {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0.6rem 1rem;
  font-size: 0.9rem;
  margin: 0;
}
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; color: var(--text-main); }

/* ─────────── Timeline ─────────── */

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.timeline > li {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border-subtle);
}
.timeline > li:last-child { border-bottom: none; }
.timeline-time { color: var(--text-muted); font-size: 0.8rem; }
.timeline-comment { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; padding: 0.4rem 0.6rem; background: #f9fafb; border-radius: 6px; }

/* ─────────── Renewals block ─────────── */

.renewal-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.6rem;
}
.renewal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius-pill);
  padding: 0.5rem 0.5rem 0.5rem 1.1rem;
  font-size: 0.88rem;
  color: #9a3412;
  gap: 0.6rem;
}
.renewal-item .btn { padding: 0.35rem 1rem; font-size: 0.82rem; }
.renewal-cta-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  border-color: #fed7aa;
  background: #fff7ed;
}

/* ─────────── Misc ─────────── */

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  background: #f3f4f6;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Шапка на телефоне (RND-991): в одну строку логотип, заголовок, компания,
   пользователь и «Выйти» занимали ~740px и давали прокрутку вбок на любой
   странице. Две строки: логотип с заголовком, под ними пользователь и выход.
   Компания скрыта — она есть в профиле; :not(#u) — вес служебных классов
   u-*, а utilities.css подключён позже: где нужно, класс повторён дважды. */
@media (max-width: 600px) {
  .app-header { flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem 1rem; }
  .app-header-left { flex: 1 1 100%; min-width: 0; gap: 0.75rem; }
  .app-logo img { height: 24px; }
  .app-header .divider { display: none; }
  .app-title-group { min-width: 0; }
  .app-title, .app-subtitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-header-right { flex: 1 1 100%; min-width: 0; justify-content: space-between; }
  .app-header .user-company-block:not(#u) { display: none; }
  /* Переключатель юрлица — своей строкой во всю ширину, над пользователем. */
  .company-switch { flex: 1 1 100%; margin-right: 0; }
  .company-switch-select.input { flex: 1 1 auto; max-width: none; }
  .user-button { min-width: 0; }
  .user-button > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Формы в одну колонку, которая сжимается: иначе длинный пункт списка
     (название партнёра) и span-2 из служебных классов растягивали сетку
     шире экрана (/admin/deals, /admin/assignments, /admin/plans). */
  .form-grid.form-grid:not(#u) { grid-template-columns: minmax(0, 1fr); }
  .form-grid.form-grid > *:not(#u) { grid-column: auto; min-width: 0; }
  .form-grid .input { max-width: 100%; }
}

/* Длинные адреса в юридических текстах переносятся, а не растягивают страницу */
.legal-doc a { overflow-wrap: anywhere; }

@media (max-width: 900px) {
  /* С переключателем юрлица блок компании в шапке не помещается и дублирует
     выбранное в переключателе название — скрываем, иначе «Выйти» уезжает
     отдельной строкой. */
  .app-header-right:has(.company-switch) .user-company-block:not(#u) { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar { border-right: none; border-bottom: 1px solid var(--border-subtle); }
  .form-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; }
/* Между телефоном и планшетом переключатель с пользователем и «Выйти» не
   помещаются в строку при полной ширине списка — сужаем список, полные
   названия видны в раскрытом списке. */
@media (min-width: 601px) and (max-width: 700px) {
  .company-switch-select.input { max-width: 10rem; }
}
}

/* ─── Драг-ресайз колонок таблиц (column-resize.js, RND-111) ─── */
table.table th.pp-resizable-th { position: relative; }
.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
}
/* видимая полоска-разделитель по центру захвата */
.col-resizer::after {
  content: "";
  position: absolute;
  right: 3px;
  top: 25%;
  bottom: 25%;
  width: 2px;
  border-radius: 1px;
  background: var(--border-subtle, #d0d5dd);
  transition: background-color 0.12s ease, top 0.12s ease, bottom 0.12s ease;
}
/* при наведении и во время перетаскивания активной колонки — акцент во всю высоту */
.col-resizer:hover::after,
.col-resizer.active::after {
  top: 0;
  bottom: 0;
  background: var(--accent, #ea5b0c);
}
body.pp-col-resizing { cursor: col-resize; user-select: none; }
body.pp-col-resizing * { user-select: none; }

/* ─── Адаптивные таблицы: горизонтальная прокрутка (table-responsive.js) ─── */
.table-scroll {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.table-scroll > table.table { min-width: 100%; }

/* ─── База знаний: документы и результаты поиска (RND-183) ─── */
.kb-doc-item { padding: 0.75rem 0; border-bottom: 1px solid var(--border-soft, #e5e7eb); }
.kb-doc-item:last-child { border-bottom: none; }
.kb-doc-title { font-weight: 600; }
.kb-doc-meta { color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }
.kb-snippet {
  margin-top: 0.4rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--accent-soft, rgba(249, 115, 22, 0.12));
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}
.kb-snippet mark { background: #fef3c7; color: inherit; padding: 0 1px; border-radius: 2px; }
.kb-snippet-page { font-weight: 600; color: var(--accent-strong, #ea580c); }
/* Разделы — мини-таблица: название слева, счётчик прижат вправо. Без линий:
   колонки выравниваются сами, разделители только зашумляли бы список. */
.kb-tree { font-size: 0.875rem; }
.kb-tree-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: baseline;
  padding: 3px 6px;
  border-radius: 4px;
}
.kb-tree-row:hover { background: var(--accent-soft, rgba(249, 115, 22, 0.12)); }
.kb-tree-row.is-active { background: var(--accent-soft, rgba(249, 115, 22, 0.12)); font-weight: 600; }
.kb-tree-cat { font-weight: 600; margin-top: 0.6rem; }
.kb-tree-sub { padding-left: 1.1rem; }
.kb-tree-count {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.kb-doc-list { list-style: none; margin: 0; padding: 0; }
.kb-layout { display: grid; grid-template-columns: minmax(210px, 260px) 1fr; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .kb-layout { grid-template-columns: 1fr; } }

/* Действия над документом в админ-таблице — одной строкой, иначе три кнопки
   встают друг под друга и раздувают высоту строки. */
.kb-admin-actions { display: flex; gap: 0.25rem; flex-wrap: nowrap; }
.kb-admin-actions form { display: inline; }
.kb-admin-actions .btn { white-space: nowrap; }

/* Предпросмотр партнёрского вида в админке: рамка отделяет чужой экран от
   админского, иначе непонятно, где кончается панель и начинается вид партнёра. */
.kb-preview-frame {
  border: 1px solid var(--border-soft, #e5e7eb);
  border-radius: 8px;
  padding: 1rem;
  background: #fafafa;
}
.kb-preview-frame .page-title { margin-top: 0; }
.kb-preview-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

/* Плашка демо-стенда (DEMO_BANNER). Держится сверху при прокрутке, чтобы
   демо нельзя было спутать с боевым порталом ни на одном экране. */
.pp-demo-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 6px 16px;
  background: var(--warning);
  color: var(--text-on-dark);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* Уведомление о cookie (cookie-notice.js). Внизу экрана поверх содержимого,
   пока посетитель не нажмёт «Понятно». */
.pp-cookie-notice {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 1001;
  width: calc(100% - 32px);
  max-width: 720px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
  font-size: 0.88rem;
  color: var(--text-main);
}
.pp-cookie-notice[hidden] { display: none; }
.pp-cookie-notice-text { margin: 0; flex: 1; line-height: 1.45; }
/* Ссылки портала по умолчанию цвета текста — здесь ссылку на политику
   видно сразу. #c2410c темнее --accent-strong: контраст с белым 5,2:1 (AA). */
.pp-cookie-notice-text a {
  color: #c2410c;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pp-cookie-notice-text a:hover { color: var(--accent-strong); }
.pp-cookie-notice .btn { flex-shrink: 0; }
@media (max-width: 600px) {
  .pp-cookie-notice { flex-direction: column; align-items: stretch; }
  .pp-cookie-notice .btn { justify-content: center; }
}

/* ─────────── Сервисная поддержка (RND-991) ─────────── */
/* Данные портала поддержки: проекты партнёра 1-й линии, обращения, флаги.
   Таблицы фиксированной раскладки с табличными цифрами; узкие колонки
   заданы в rem, широкой остаётся остаток. Уже ~60rem таблица прокручивается
   внутри карточки (table-responsive.js), на телефоне строка — карточка
   «подпись — значение», без прокрутки вбок. */

.ss-state .card-title { margin-bottom: 0.4rem; }
.ss-state-text { margin: 0 0 0.6rem 0; color: var(--text-muted); max-width: 72ch; }
.ss-sub { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.15rem; }
.ss-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ss-result { white-space: pre-wrap; margin-top: 0.4rem; }
.ss-pair + .ss-pair, .ss-sla { margin-top: 0.2rem; }
.ss-pair .ss-sub { display: inline-block; min-width: 4.5rem; margin-top: 0; }

.table.ss-table { table-layout: fixed; }
.table.ss-table td { vertical-align: top; overflow-wrap: anywhere; }
/* Обёртка .table-scroll ставит таблице min-width: 100% более сильным
   селектором — повторяем её, иначе на 1024 px первая колонка схлопывается. */
.table.ss-tickets,
.table-scroll > table.table.ss-tickets { min-width: 58rem; }
.ss-tickets th:nth-child(2) { width: 13rem; }
.ss-tickets th:nth-child(3) { width: 10rem; }
.ss-tickets th:nth-child(4) { width: 9rem; }
.ss-tickets th:nth-child(5) { width: 12rem; }
.ss-projects th:nth-child(1) { width: 26%; }
.ss-projects th:nth-child(4) { width: 11rem; }
.ss-flags th:nth-child(1) { width: 8rem; }
.ss-flags th:nth-child(2) { width: 10rem; }
.ss-flags th:nth-child(6) { width: 10rem; }

.ss-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 0;
}
.ss-facts dt { color: var(--text-muted); font-size: 0.8rem; }
.ss-facts dd { margin: 0.15rem 0 0 0; }

@media (max-width: 600px) {
  .table.ss-table,
  .table.ss-table tbody,
  .table.ss-table tr,
  .table.ss-table td,
  .table-scroll > table.table.ss-table { display: block; width: 100%; min-width: 0; }
  .table.ss-table thead { display: none; }
  .table.ss-table tr { padding: 0.6rem 0; border-bottom: 1px solid var(--border-subtle); }
  .table.ss-table tbody tr:last-child { border-bottom: none; }
  /* Подпись — в левом поле ячейки, значение — сколько угодно элементов справа */
  .table.ss-table td {
    position: relative;
    padding: 0.3rem 0 0.3rem 7.5rem;
    border-bottom: none;
  }
  .table.ss-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 0.3rem;
    width: 7rem;
    color: var(--text-muted);
    font-size: 0.8rem;
  }
  .ss-num { white-space: normal; }
  .ss-pair .ss-sub { display: block; }
}
