/* Бічна панель: шапка, розмова, заявка, результат тесту, історія. */

.panel__head {
  padding: 10px 14px 12px 20px;
  border-bottom: 1px solid #0A2A19;
  flex: none; /* не стискати: overflow: hidden інакше дозволяє шапці схлопнутися */
  position: relative;
  overflow: hidden;
  color: #FFFFFF;
  background: linear-gradient(135deg, #0B2E1B, #14532D);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.panel__row { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 32px; }
.panel__number {
  font-size: 12px;
  color: #B7D5C4;
  font-family: var(--font-mono);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Кнопки шапки «⋯» і «✕»: прозорі, лише значок; підсвічуються при наведенні. */
.panel__tools { margin-left: auto; flex: none; display: flex; align-items: center; gap: 2px; margin-right: -4px; }
.panel__menu { position: relative; flex: none; }
.panel__icon-button {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #CFE8D8;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color .15s, color .15s;
}
.panel__icon-button:hover { background: rgba(255, 255, 255, .14); color: #FFFFFF; }
.panel__icon-button:active { background: rgba(255, 255, 255, .22); }
.panel__icon-button:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 0; }
.panel__icon-button .icon, .panel__icon-button svg { display: block; width: 20px; height: 20px; }
/* Ціль кліку — завжди сама кнопка, а не значок усередині (точки «⋯» дрібні). */
.panel__icon-button > * { pointer-events: none; }
.panel__menu-list {
  position: fixed; z-index: 50; /* top/right — з JS під кнопкою «⋯» */
  min-width: 200px; padding: 6px; display: grid;
  background: var(--surface); border: 1px solid var(--border-input); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(22, 32, 46, .18);
}
.panel__menu-list[hidden] { display: none; }
.panel__menu-item {
  padding: 10px 12px; border: 0; border-radius: 6px; background: transparent;
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.panel__menu-item:hover, .panel__menu-item:focus-visible { background: rgba(22, 32, 46, .06); }
.panel__menu-item--danger { color: var(--danger); }
.panel__menu-item--danger:hover, .panel__menu-item--danger:focus-visible { background: var(--danger-soft); }
.panel__person { font-family: var(--font-display); font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
.panel__contract { font-family: var(--font); font-size: 15px; font-weight: 500; color: #B7D5C4; }
.panel__sub { font-size: 12px; color: #B7D5C4; }
/* Логотип водяним знаком у шапці. */
.panel__head::after {
  content: "";
  position: absolute;
  right: 72px;
  bottom: -14px;
  width: 150px;
  height: 62px;
  background: url("/app/img/logo.png") center / contain no-repeat;
  filter: brightness(0) invert(1);
  opacity: .12;
  pointer-events: none;
}
.panel__head > * { position: relative; z-index: 1; }
/* Keep the fixed action menu above the person and subtitle within the header. */
.panel__head > .panel__row { z-index: 2; }

.panel__strip { flex: none; }
.panel__strip:empty { display: none; }
/* Присутність користувача: контрастна стрічка одразу під шапкою. */
.strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
  padding: 7px 20px; background: #16202E; color: #E6EDF7; font-size: 13px; font-weight: 600;
}
.strip__text:empty { display: none; }
.strip__text::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px; margin-right: 8px;
  border-radius: 50%;
  background: #8A94A3;
}
.strip__text.is-online::before { background: #4ADE80; }
.strip__text.is-urgent { color: #FBBF77; }
.strip__text.is-urgent::before { background: #FBBF77; }
/* «Чекає відповіді»: до 1 хв — нейтрально, >1 хв — помаранчевий, >2 хв — червоний. */
.strip__wait { margin-left: auto; font-variant-numeric: tabular-nums; }
.strip__wait::before { background: #CBD5E1; }
.strip__wait.is-late { color: #FDBA74; }
.strip__wait.is-late::before { background: #FB923C; }
.strip__wait.is-overdue { color: #FCA5A5; }
.strip__wait.is-overdue::before { background: #F87171; animation: strip-pulse 1.2s ease-in-out infinite; }
@keyframes strip-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .strip__wait.is-overdue::before { animation: none; } }
.panel__body { flex: 1; padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 20px; }
.panel__notices { display: flex; flex-direction: column; gap: 8px; }
.panel__notices:empty, .panel__content:empty { display: none; }

/* Блок: темна шапка зі світлим заголовком і біле тіло. */
.section {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.section > :not(.section__title):not(.section__head) { margin: 14px 16px 0; }
.section > :last-child { margin-bottom: 14px; }
.section--wide > :not(.section__title):not(.section__head) { margin-top: 16px; }
.section__title, .section__head {
  background: #16202E;
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.section__title { padding: 10px 16px; }
.section__head { display: flex; align-items: center; justify-content: space-between; padding-right: 8px; }
.section__head .section__title { padding-right: 0; }
/* У панелі блоки йдуть смугами на всю ширину, один під одним — без рамки-картки й бокових відступів. */
.panel__content .section { margin: 0 -24px; border-radius: 0; border-left: 0; border-right: 0; }
.panel__content .section + .section { margin-top: -20px; border-top: 0; } /* без проміжку між блоками */
.panel__content .section > .tiles { margin: 0; }
.panel__content .section > .tiles:last-child { margin-bottom: 0; }
.panel__content .section .tile-group__title, .panel__content .section .tile-group__lead { padding: 0 16px; }
.section__menu {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 28px; border: 0; border-radius: 6px;
  background: transparent; color: #FFFFFF; cursor: pointer;
}
.section__menu:hover { background: rgba(255, 255, 255, .18); }
.section__menu:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 1px; }
.section__menu svg { width: 20px; height: 20px; }

/* Модальне вікно зміни даних. */
.modal {
  width: min(640px, 92vw);
  max-height: 90vh;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(22, 32, 46, .35);
}
.modal::backdrop { background: rgba(22, 32, 46, .55); }
/* Дії із заявкою: темна шапка, прокручуваний вміст зі спойлерами, кнопки внизу. */
.modal--request { width: min(680px, 94vw); }
.modal--request[open] { display: flex; flex-direction: column; }
.modal__head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 8px 16px; background: #16202E; color: #FFFFFF;
}
.modal__title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.modal__scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.modal__foot { flex: none; display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }
.modal__foot .action__buttons { justify-content: flex-end; }
.spoiler { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.spoiler[open] { border-color: var(--accent-border); background: var(--action-bg); }
.spoiler__summary {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  font-weight: 700; cursor: pointer; list-style: none; border-radius: 10px;
}
.spoiler__summary::-webkit-details-marker { display: none; }
.spoiler__summary::before {
  content: ""; flex: none; width: 8px; height: 8px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s;
}
.spoiler[open] > .spoiler__summary::before { transform: rotate(45deg); }
.spoiler__summary:hover { background: rgba(22, 32, 46, .04); }
.spoiler__body { display: flex; flex-direction: column; gap: 12px; padding: 0 14px 14px; }
/* Перемикач дій під шапкою: обрана дія — біла «таблетка», скасування — червоним. Зберігає лише нижня кнопка. */
.modal__bar { flex: none; padding: 12px 16px 0; }
.segmented { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--track); }
.segmented__item {
  flex: 1 1 0; min-width: 0; min-height: 36px; padding: 6px 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text-2);
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1.25; text-align: center; cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.segmented__item:hover:not(:disabled):not(.is-active) { background: rgba(255, 255, 255, .6); color: var(--text); }
.segmented__item.is-active {
  background: var(--surface); color: var(--accent-text);
  box-shadow: 0 0 0 1px var(--accent-border), 0 1px 3px rgba(22, 32, 46, .12);
}
.segmented__item--danger { color: var(--danger); }
.segmented__item--danger:hover:not(:disabled):not(.is-active) { color: var(--danger); }
.segmented__item--danger.is-active {
  background: var(--danger-soft); color: var(--danger);
  box-shadow: 0 0 0 1px rgba(180, 35, 24, .35), 0 1px 3px rgba(22, 32, 46, .12);
}
.segmented__item:disabled { color: var(--muted); opacity: .55; cursor: not-allowed; }
.segmented__item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Поля обраної дії. */
.action-box {
  display: flex; flex-direction: column; gap: 12px; padding: 14px;
  border: 1px solid var(--accent-border); border-radius: 10px; background: var(--action-bg);
}
.modal__foot .form__message { margin-right: auto; }
/* Історія звернення */
.modal--history { width: min(520px, 92vw); }
.modal--history[open] { display: flex; flex-direction: column; }
/* Блок історії займає все вікно: його темна шапка слугує заголовком вікна. */
.modal__body { overflow-y: auto; }
.modal__body .section { border: 0; border-radius: 0; padding-bottom: 16px; }
.modal__body .section__title { padding: 14px 52px 14px 16px; position: sticky; top: 0; }
.modal__close { position: absolute; top: 8px; right: 8px; z-index: 1; font-size: 14px; }

/* Розмова: займає всю висоту панелі (клас panel--chat з panel.js) — шапка й статуси нагорі,
   повідомлення прокручуються без окремої рамки, поле відповіді завжди внизу. */
.panel--chat { overflow: hidden; }
.panel--chat .panel__body { min-height: 0; padding: 12px 20px 0; gap: 10px; }
.panel--chat .panel__notices { flex: none; }
.panel--chat .panel__content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel--chat .chat { flex: 1; min-height: 0; }
.chat { display: flex; flex-direction: column; gap: 8px; }
.chat__owner { font-size: 13px; color: var(--text-2); }
.chat__owner:empty { display: none; }
.chat__messages {
  flex: 1;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 -20px;
  padding: 8px 20px 12px;
  overflow-y: auto;
}
.chat__empty { margin: auto; color: var(--muted); }
.chat__footer {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 -20px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat__buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.chat__finish { display: flex; align-items: center; gap: 12px; }
.chat__finish-text { flex: 1; min-width: 0; }
.chat__finish .button { flex: none; margin-left: 0; }
.chat__close { display: flex; flex-direction: column; gap: 10px; }

/* Поле відповіді на три рядки з кнопкою-«літачком» праворуч. */
.composer { position: relative; }
.composer__input.input {
  display: block;
  height: calc(3 * 1.45em + 22px);
  padding-right: 60px;
  resize: none;
  border-radius: 12px;
}
.composer__input.input:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-soft); }
.composer__send {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(36, 87, 214, .3);
  transition: background-color .15s, transform .15s;
}
.composer__send:hover { background: var(--accent-text); }
.composer__send:active { transform: scale(.94); }
.composer__send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.composer__send .icon, .composer__send svg { display: block; width: 18px; height: 18px; }

.message {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--border);
  background: var(--bg);
  align-self: flex-start;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.message--operator { border-color: var(--accent-border); background: var(--accent-soft); align-self: flex-end; }
.message--system {
  align-self: center;
  max-width: 100%;
  border: 0;
  background: none;
  padding: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.message.is-pending { opacity: .65; }
.message__meta { font-size: 12px; color: var(--muted); }
.message__sender { font-weight: 600; }

/* Заявка */
.request { display: flex; flex-direction: column; gap: 20px; }
/* Статуси — стрілки-кроки: > > >. Кожен крок заходить на попередній на (tip − 2px);
   відступ контейнера на ту саму величину вирівнює перший крок кожного рядка по лівому краю. */
.steps { --tip: 10px; display: flex; flex-wrap: wrap; row-gap: 6px; padding-left: calc(var(--tip) - 2px); }
.step {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 calc(var(--tip) + 6px) 0 calc(var(--tip) + 8px);
  margin-left: calc(2px - var(--tip));
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: #E6EAF0;
  color: var(--text);
  clip-path: polygon(0 0, calc(100% - var(--tip)) 0, 100% 50%, calc(100% - var(--tip)) 100%, 0 100%, var(--tip) 50%);
}
.step:first-child {
  padding-left: 14px;
  clip-path: polygon(0 0, calc(100% - var(--tip)) 0, 100% 50%, calc(100% - var(--tip)) 100%, 0 100%);
}
.step.is-current { background: #16202E; color: #FFFFFF; }
.step.is-target { background: var(--accent-soft); color: var(--accent-text); }

.take {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--warn-border);
  background: var(--warn-soft);
}
.take__text { flex: 1; color: var(--text-2); }
.take .button { flex: none; }

/* Дані заявки — плитки впритул: шапка з назвою — темно-зелена з білим текстом,
   значення — темно-сіре зі світлим текстом. Сусідні рамки накладаються (margin −1px). */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); padding: 0 1px 1px 0; }
.tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0 -1px -1px 0;
  background: #27303B;
  border: 1px solid #3B4654;
}
.tile--wide { grid-column: 1 / -1; }
.tile__label {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #FFFFFF;
  background: #14532D;
}
.tile__value { flex: 1; padding: 8px 10px; font-weight: 600; color: #F1F5F9; overflow-wrap: anywhere; white-space: pre-wrap; }
/* Позначка в шапці плитки: ✓ — підтвердив застрахований, годинник — чекаємо на його відповідь. */
.tile__label { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.tile__mark { flex: none; display: inline-flex; }
.tile__mark svg { width: 15px; height: 15px; stroke-width: 2.5; }
.tile__mark--confirmed { color: #86EFAC; }
.tile__mark--pending { color: #FCD34D; }
.tile-group__title { display: flex; align-items: center; gap: 6px; }
.tile-group--confirmed > .tile-group__title { color: var(--ok); }
.tile-group--confirmed > .tile-group__title .tile__mark { color: var(--ok); }
.tile-group--pending > .tile-group__title .tile__mark { color: #B45309; }
/* Варіант, який застрахований не обрав: без кольору, як вимкнений — лише для довідки. */
.tile-group--declined > .tile-group__title { color: var(--muted); font-weight: 500; }
.tile--declined { background: #F3F4F6; border-color: #D9DDE3; }
.tile--declined .tile__label { background: #E2E5EA; color: #6B7280; }
.tile--declined .tile__value { color: #6B7280; font-weight: 500; }
.tile-group { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; padding: 12px 0 8px; margin-right: -1px; }
.tile-group__title { font-weight: 600; font-size: 13px; color: var(--text-2); }
.tile-group__lead { color: var(--text-2); }

.action {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--accent-border);
  background: var(--action-bg);
  border-radius: 12px;
  padding: 16px;
}
.action__title { font-size: 15px; }

/* Вибір застрахованого: прийняти його заклад або запропонувати інше. */
.choice {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  background: var(--surface);
}
.pick { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.pick input { margin-top: 3px; }
.action__buttons { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.form { display: flex; flex-direction: column; gap: 12px; }
.form:empty { display: none; }
.form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form__grid > .form__group, .form__grid > .form__options, .field--wide { grid-column: 1 / -1; }
.form__group {
  margin: 0;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 8px;
}
.form__group > legend { font-size: 12px; color: var(--muted); padding: 0 6px; }
.form__group.is-invalid, .form__options.is-invalid > .form__group { border-color: var(--danger); }
.form__options { display: flex; flex-direction: column; gap: 10px; }
.form__options > .button { align-self: flex-start; }
.form__more { border-top: 1px solid var(--accent-border); padding-top: 10px; }
.form__more > summary { cursor: pointer; color: var(--accent-text); font-weight: 600; margin-bottom: 10px; }
.form__errors {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #E5A29B;
  background: var(--danger-soft);
  color: #8F1D1D;
}
.form__errors ul { margin-top: 4px; padding-left: 18px; list-style: disc; }
.form__message { font-size: 13px; color: var(--muted); }
.form__message.is-ok { color: var(--ok); font-weight: 600; }
.form__message.is-error { color: var(--danger); font-weight: 600; }

/* Результат тесту */
.score { display: flex; flex-direction: column; gap: 6px; }
.score__line { display: flex; align-items: baseline; gap: 8px; }
.score__name { font-weight: 600; }
.score__level { color: var(--text-2); }
.score__value { margin-left: auto; font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.score__track { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.score__bar { height: 100%; border-radius: 4px; background: var(--accent); }
.score__bar.is-elevated { background: #B45309; }

/* Історія */
.timeline { display: flex; flex-direction: column; gap: 8px; }
.timeline__entry { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.timeline__at { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
/* Текст, який застрахований надіслав листом, коли чат не працював. */
.timeline__message { flex-basis: 100%; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Відкрита розмова: тости не перекривають поле відповіді й кнопку «надіслати». */
body:has(.panel--chat:not([hidden])) .toasts { bottom: 140px; }

/* Спільний блок ІСС для заявок та чатів. Форма відкривається в окремому діалозі. */
.panel__cases { flex: none; min-height: 0; }
.panel__cases:empty { display: none; }
.cases__body { max-height: 34vh; overflow-y: auto; padding: 0 14px 14px; }
.cases__buttons { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.cases__case { padding: 10px 0; border-top: 1px solid var(--border); }
.cases__case > summary { cursor: pointer; font-weight: 600; }
.cases__case p { font-size: 13px; margin-top: 6px; overflow-wrap: anywhere; }
.cases__operations { display: grid; gap: 8px; }
.cases__operation { display: grid; gap: 6px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.cases__operation--linked { border-left: 3px solid #166534; }
.cases__operation .button { justify-self: start; }
.cases__link-status { margin: 8px 14px; color: var(--ok); overflow-wrap: anywhere; }
.modal--cases .cases__operations:not(:empty) { margin-bottom: 14px; }
.cases__form { display: flex; flex-direction: column; max-height: 86vh; }
.cases__fields { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; min-width: 0; }
.cases__fields .field { display: grid; gap: 5px; }
