/* Оформлення адмінки ORIGAMI Ukraine.
 *
 * Токени взяті з макета: графіт у навігації, тепла помаранчева — тільки на
 * головній дії, робоча область світла. Інлайнові стилі з макета зведені в
 * класи: у макеті одна й та сама кнопка описана двадцять разів, і правити її
 * потім довелося б у двадцяти місцях.
 */

/* Montserrat одним variable-файлом: одна вага 100–900 замість десятка окремих
 * накреслень. Курсив в інтерфейсі не вживається, тому italic-файл не возимо.
 * Ліцензія — web/fonts/OFL.txt. */
@font-face {
  font-family: Montserrat;
  src: url("/fonts/montserrat-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --graphite: #3d3e3c;
  --graphite-soft: #45463f;
  --orange: #ffb84d;
  --orange-deep: #8a6a1f;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #2d2e2c;
  --text-secondary: #666762;
  --text-muted: #8a8a86;
  --border: #dededa;
  --divider: #ebebe8;
  --danger: #a6483c;

  /* Приглушені статуси: яскравий помаранчевий лишається за головною дією. */
  --st-neutral-bg: #ebebe8;
  --st-neutral-fg: #666762;
  --st-ok-bg: #e4ede4;
  --st-ok-fg: #3f6b45;
  --st-warn-bg: #f6ecd8;
  --st-warn-fg: #8a6a1f;
  --st-danger-bg: #f3e3e1;
  --st-danger-fg: #a6483c;
  --st-info-bg: #e6ebef;
  --st-info-fg: #4a6070;

  --radius-card: 8px;
  --radius-control: 6px;
  --radius-inner: 4px;
  --sidebar-width: 236px;
  --topbar-height: 60px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
}

body {
  font-family: Montserrat, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--orange-deep);
}

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

::selection {
  background: var(--orange);
  color: var(--text);
}

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

table {
  border-collapse: collapse;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ *
 *  Вхід
 * ------------------------------------------------------------------ */
.login {
  display: grid;
  grid-template-columns: 42% 1fr;
  min-height: 100vh;
}

.login__brand {
  background: var(--graphite);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login__form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.login__form {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand__name {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fff;
}

.brand__sub {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--orange);
}

.brand__rule {
  width: 40px;
  height: 3px;
  background: var(--orange);
}

.brand__claim {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.35;
  color: #fff;
  max-width: 380px;
}

.brand__note {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.6;
}

/* ------------------------------------------------------------------ *
 *  Каркас застосунку
 * ------------------------------------------------------------------ */
/* Висота фіксована, а прокручується лише робоча область: коли сайдбар тягнувся
 * за висотою сторінки, підвал із роллю стрибав на кожному перемиканні розділу —
 * скелетон коротший за таблицю. */
.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--graphite);
  display: flex;
  flex-direction: column;
  padding: 24px 0 16px;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar__brand {
  padding: 0 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fff;
}

.sidebar__brand-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--orange);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 20px 0 17px;
  cursor: pointer;
  border-left: 3px solid transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 500;
  background: none;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  width: 100%;
  text-align: left;
  transition: background 160ms;
}

.nav-item:hover {
  background: var(--graphite-soft);
}

/* Варіант B із DESIGN.md: тонка помаранчева лінія замість заливки —
 * на великій CRM суцільний помаранчевий пункт втомлює. */
.nav-item.is-active {
  background: var(--graphite-soft);
  border-left-color: var(--orange);
  color: #fff;
}

.nav-item__icon {
  display: flex;
  flex: 0 0 16px;
  width: 16px;
  opacity: 0.85;
}

.nav-item__icon svg {
  display: block;
}

.nav-item.is-active .nav-item__icon {
  opacity: 1;
}

.nav-item__label {
  flex: 1;
}

.badge-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--orange);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar__spacer {
  flex: 1;
}

.sidebar__footer {
  padding: 16px 20px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar__caption {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.45);
}

.sidebar__role {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.sidebar__link {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
}

.sidebar__link:hover {
  color: var(--orange);
}

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

.topbar {
  height: var(--topbar-height);
  flex: 0 0 var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
}

.topbar__search {
  flex: 1;
  max-width: 460px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
}

.topbar__spacer {
  flex: 1;
}

.topbar__alerts {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: none;
  border: 0;
  flex: 0 0 auto;
}

.topbar__alerts span:first-child {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.topbar__divider {
  width: 1px;
  height: 24px;
  background: var(--divider);
}

.topbar__user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.topbar__user-email {
  font-size: 13px;
  font-weight: 600;
}

.topbar__user-role {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ------------------------------------------------------------------ *
 *  Заголовки та картки
 * ------------------------------------------------------------------ */
.page-head {
  display: flex;
  align-items: flex-end;
  gap: 24px;
}

.page-head__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

/* Опис — звичайною вагою: напівжирний підзаголовок сперечався із заголовком. */
.page-subtitle {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.45;
}

.page-head__actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card--flush {
  padding: 0;
  overflow: hidden;
}

.card__title {
  font-size: 15px;
  font-weight: 700;
}

.card__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.grid-kpi {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.kpi {
  background: var(--surface);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kpi__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Головне в KPI — цифра, а не іконка. */
.kpi__value {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.kpi__hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Асиметрична сітка: рівні ряди однакових карток заборонені в DESIGN.md. */
.split-60-40 {
  display: grid;
  grid-template-columns: 60fr 40fr;
  gap: 20px;
  align-items: start;
}

.split-65-35 {
  display: grid;
  grid-template-columns: 65fr 35fr;
  gap: 20px;
  align-items: start;
}

.split-35-65 {
  display: grid;
  grid-template-columns: 35fr 65fr;
  gap: 20px;
  align-items: start;
}

/* ------------------------------------------------------------------ *
 *  Кнопки
 * ------------------------------------------------------------------ */
.btn {
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 160ms;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--bg);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  border: none;
  background: var(--orange);
  font-weight: 600;
}

.btn--primary:hover:not(:disabled) {
  background: #f0a833;
}

.btn--lg {
  height: 40px;
  padding: 0 18px;
  font-size: 14px;
}

.btn--sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.btn--danger {
  color: var(--danger);
}

.btn-link {
  background: none;
  border: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.btn-link:hover {
  color: var(--orange-deep);
}

/* ------------------------------------------------------------------ *
 *  Форми
 * ------------------------------------------------------------------ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.input,
.select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.input--lg,
.select--lg {
  height: 42px;
  padding: 0 12px;
  font-size: 14px;
}

.input:focus,
.select:focus {
  border-color: var(--graphite);
  outline: none;
}

textarea.input {
  height: auto;
  padding: 10px;
  resize: vertical;
  min-height: 72px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

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

.filters .input,
.filters .select {
  width: auto;
  min-width: 180px;
}

.filters__count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.form-error {
  font-size: 13px;
  font-weight: 500;
  color: var(--danger);
  line-height: 1.5;
}

/* ------------------------------------------------------------------ *
 *  Вкладки
 * ------------------------------------------------------------------ */
.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tab {
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  background: var(--bg);
}

.tab.is-active {
  background: var(--graphite);
  color: #fff;
  font-weight: 600;
}

/* ------------------------------------------------------------------ *
 *  Таблиці — критично важливі, це робочий інструмент
 * ------------------------------------------------------------------ */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  min-width: 100%;
}

.table thead th {
  text-align: left;
  padding: 0 24px;
  height: 34px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table tbody td {
  padding: 0 24px;
  height: 44px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  border-bottom: 1px solid var(--divider);
}

/* Ховер — лише зміна фону. Ні підняття, ні тіні, ні масштабу. */
.table tbody tr:hover td {
  background: #fbfbfa;
}

.table tbody tr.is-clickable {
  cursor: pointer;
}

.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table td.muted {
  font-weight: 500;
  color: var(--text-secondary);
}

.table td.wrap {
  white-space: normal;
  font-weight: 500;
  line-height: 1.45;
}

.table__foot {
  padding: 12px 24px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border-top: 1px solid var(--divider);
}

/* ------------------------------------------------------------------ *
 *  Статуси
 * ------------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--st-neutral-bg);
  color: var(--st-neutral-fg);
}

.badge--ok {
  background: var(--st-ok-bg);
  color: var(--st-ok-fg);
}

.badge--warn {
  background: var(--st-warn-bg);
  color: var(--st-warn-fg);
}

.badge--danger {
  background: var(--st-danger-bg);
  color: var(--st-danger-fg);
}

.badge--info {
  background: var(--st-info-bg);
  color: var(--st-info-fg);
}

/* ------------------------------------------------------------------ *
 *  Порожні стани та завантаження
 * ------------------------------------------------------------------ */
.empty {
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

/* Мінімалістична origami-фігура замість 3D-ілюстрації. */
.empty__mark {
  width: 34px;
  height: 34px;
  background: var(--divider);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  margin-bottom: 4px;
}

.empty__title {
  font-size: 14px;
  font-weight: 600;
}

.empty__hint {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  max-width: 380px;
}

.skeleton {
  padding: 40px 24px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
}

/* ------------------------------------------------------------------ *
 *  Діаграми
 * ------------------------------------------------------------------ */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 170px;
}

.chart__col {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 100%;
}

.chart__bar {
  width: 12px;
  border-radius: 2px 2px 0 0;
  background: var(--orange);
  min-height: 2px;
}

.chart__bar--secondary {
  background: var(--graphite);
  opacity: 0.35;
}

.chart__labels {
  display: flex;
  gap: 10px;
}

.chart__label {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.legend {
  display: flex;
  gap: 16px;
  margin-left: auto;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.legend__dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--orange);
}

.legend__dot--secondary {
  background: var(--graphite);
  opacity: 0.35;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-row__head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
}

.bar-row__value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bar-row__track {
  height: 6px;
  border-radius: 3px;
  background: var(--divider);
  overflow: hidden;
}

.bar-row__fill {
  height: 100%;
  background: var(--orange);
}

/* ------------------------------------------------------------------ *
 *  Списки, деталі, модальні вікна
 * ------------------------------------------------------------------ */

/* Ліва колонка вибору (довідники, звіти): у макеті це не таби, а рейка —
 * шістнадцять довідників горизонтальними вкладками перелазили у два ряди. */
.split-rail {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.rail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 6px 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rail__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 6px 16px 6px 13px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition:
    background 150ms,
    border-color 150ms;
}

.rail__item:hover {
  background: #fafaf8;
}

.rail__item.is-active {
  background: var(--bg);
  border-left-color: var(--orange);
  font-weight: 700;
}

.rail__label {
  flex: 1;
  min-width: 0;
}

.rail__count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.rail__item.is-active .rail__count {
  color: var(--text-secondary);
}

.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.meta__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.meta__value {
  font-size: 13px;
  font-weight: 600;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline__row {
  display: grid;
  grid-template-columns: 116px 150px 1fr;
  gap: 12px;
  font-size: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider);
}

.timeline__row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.timeline__when {
  color: var(--text-muted);
  font-weight: 500;
}

.timeline__what {
  font-weight: 600;
}

.timeline__note {
  color: var(--text-secondary);
  font-weight: 500;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(45, 46, 44, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  z-index: 50;
  animation: backdrop-in 160ms ease-out;
}

.modal-backdrop.is-closing {
  animation: backdrop-out 140ms ease-in forwards;
}

.modal-backdrop.is-closing .modal {
  animation: modal-out 140ms ease-in forwards;
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
}

@keyframes backdrop-out {
  to {
    opacity: 0;
  }
}

/* Вікно піднімається на кілька пікселів, без «пружин» і масштабування вдвічі:
 * це підказка, звідки воно взялося, а не атракціон. */
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}

@keyframes modal-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
}

.modal {
  background: var(--surface);
  animation: modal-in 200ms cubic-bezier(0.2, 0.7, 0.3, 1);
  border-radius: var(--radius-card);
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.modal--wide {
  max-width: 940px;
}

.modal__head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal__title {
  font-size: 16px;
  font-weight: 700;
}

.modal__close {
  margin-left: auto;
  background: none;
  border: 0;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.modal__close:hover {
  color: var(--text);
}

.modal__body {
  padding: 22px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal__foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
}

.modal__foot .spacer {
  flex: 1;
}

.note {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.55;
}

.note strong {
  font-weight: 700;
  color: var(--text);
}

.toast-stack {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
  max-width: 420px;
}

.toast {
  animation: modal-in 180ms cubic-bezier(0.2, 0.7, 0.3, 1);
  background: var(--graphite);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-control);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.toast--error {
  background: var(--danger);
}

.toast--ok {
  background: var(--st-ok-fg);
}

/* ------------------------------------------------------------------ *
 *  Адаптив: desktop-first, менші екрани лише згортають зайве
 * ------------------------------------------------------------------ */
@media (max-width: 1180px) {
  .grid-kpi {
    grid-template-columns: repeat(2, 1fr);
  }

  .split-rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .split-60-40,
  .split-65-35,
  .split-35-65 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: 64px;
  }

  .sidebar__brand-sub,
  .nav-item__label,
  .sidebar__footer {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 0 8px;
  }

  .content {
    padding: 18px;
  }

  .login {
    grid-template-columns: 1fr;
  }

  .login__brand {
    display: none;
  }
}

@media (max-width: 620px) {
  .grid-kpi {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------ *
 *  Форми, рядки документів, дрібні службові блоки
 * ------------------------------------------------------------------ */
.screen {
  display: block;
}

/* Кореневий блок екрана — вертикальний стос. Без цього заголовок розділу,
 * рейка вибору й картки стояли впритул: у блокових div-ів немає ані відступів,
 * ані gap. Класифіковані корені (та сама .card «немає доступу») не чіпаємо. */
.screen > div:not([class]) {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.field__hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.45;
}

.card__actions,
.chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filters__toggles {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.input--sm {
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

/* Рядки документа: підпис колонки над полем зайняв би вдвічі більше місця,
 * тому шапка одна на весь список. */
.lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.line,
.lines__head {
  display: grid;
  grid-template-columns: 1fr 130px 150px 36px;
  gap: 8px;
  align-items: center;
}

.line--4,
.lines__head--4 {
  grid-template-columns: 1fr repeat(3, 120px);
}

.lines__head {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  padding-bottom: 2px;
}

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

.pager .spacer {
  flex: 1;
}

.table__count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.num-danger {
  color: var(--danger);
  font-weight: 700;
}

/* Історія обладнання: дата ліворуч фіксованою колонкою, щоб події читалися
 * як стрічка, а не як таблиця. */
.timeline__item {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider);
}

.timeline__item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.timeline__date {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.timeline__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline__title {
  font-size: 13px;
  font-weight: 600;
}

.timeline__text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.5;
}

pre.note {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Обгортки колонок рядка: без min-width:0 довга назва в select розсуває сітку. */
.line__main,
.line__qty,
.line__unit {
  min-width: 0;
}

/* ------------------------------------------------------------------ *
 *  Менше руху — коли система про це просить
 * ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
