/* ============================================================
   Каркас и компоненты прототипа «Феникс Оил · Контроль качества»
   ============================================================ */

/* ---------- каркас ---------- */

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

/* ---------- сайдбар ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 14px 18px;
  background: var(--ink);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: linear-gradient(140deg, var(--plum), var(--plum-dim));
  color: var(--on-dark);
  font-weight: 400;
  font-size: 15px;
  font-family: var(--font-display);
}

.brand-name {
  color: var(--on-dark);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.brand-sub {
  color: var(--on-dark-3);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  margin-top: 3px;
}

.nav { display: grid; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--on-dark-2);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--on-dark); }

.nav-item[aria-current="page"] {
  background: var(--plum-016);
  color: var(--on-dark);
  font-weight: 700;
  box-shadow: inset 2px 0 0 var(--accent);
}

.nav-item .ico { flex: none; opacity: 0.9; }

.nav-item .nav-count {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--on-dark);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.nav-item .nav-count.hot { background: var(--accent); color: #fff; }

.nav-sep {
  margin: 12px 8px 6px;
  color: var(--on-dark-3);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.demo-note {
  margin-top: 12px;
  padding: 10px 11px;
  border-radius: 7px;
  background: var(--amber-010);
  border: 1px solid rgba(255, 184, 41, 0.26);
  color: var(--on-dark-2);
  font-size: 11.5px;
  line-height: 1.45;
}

.demo-note strong { display: block; color: var(--accent-2); margin-bottom: 3px; }

/* ---------- верхняя панель ---------- */

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--header-h);
  padding: 0 24px;
  background: var(--ink-2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.search {
  position: relative;
  flex: 1;
  max-width: 460px;
}

.search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--on-dark);
  font: inherit;
  font-size: 13.5px;
}

.search input::placeholder { color: var(--on-dark-3); }
.search input:focus { border-color: var(--accent); background: rgba(255, 255, 255, 0.1); }

.search .ico {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--on-dark-3);
  pointer-events: none;
}

.topbar-spacer { flex: 1; }

.role-switch {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.role-switch:hover { background: rgba(255, 255, 255, 0.1); }

.role-switch select {
  border: 0;
  background: transparent;
  color: var(--on-dark);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  max-width: 210px;
}

.role-switch select option { color: var(--ink); background: var(--paper-2); }

.avatar {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--plum), var(--plum-dim));
  color: var(--on-dark);
  font-size: 11px;
  font-weight: 800;
}

.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }

.topbar-label {
  color: var(--on-dark-3);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ---------- рабочая область ---------- */

.view {
  flex: 1;
  width: 100%;
  max-width: 1400px;
  padding: 26px 24px 64px;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.view-head h1 {
  font-family: var(--font-display);
  font-size: clamp(24px, 2.7vw, 32px);
  line-height: 1.12;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.view-head .lead {
  margin-top: 8px;
  max-width: 780px;
  color: var(--text-2);
  font-size: 14.5px;
}

/* margin-left:auto — чтобы блок оставался справа и после переноса на новую строку:
   при wrap флекс-элемент прижимается к левому краю, и text-align:right внутри
   него перестаёт что-либо значить. */
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }

/* Показатель в шапке раздела (часы SLA на карточке претензии). */
.head-metric {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  box-shadow: var(--shadow-1);
  text-align: right;
}

.head-metric .eyebrow { margin-bottom: 3px; }
.head-metric .v { font-size: 18px; }

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}

.btn:hover { background: var(--paper-3); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover { background: var(--accent-hover); }

.btn.dark {
  background: var(--ink-2);
  border-color: var(--ink-2);
  color: var(--on-dark);
}

.btn.dark:hover { background: var(--graphite); }

.btn.danger { color: var(--red); border-color: rgba(201, 49, 74, 0.35); background: var(--red-soft); }
.btn.danger:hover { background: #f7d9df; }

.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--paper-3); }

.btn.sm { padding: 6px 11px; font-size: 12.5px; }

.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

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

/* переключатель вариантов */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  max-width: 100%;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2);
  gap: 2px;
}

.segmented button {
  padding: 6px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}

.segmented button[aria-pressed="true"] { background: var(--ink-2); color: var(--on-dark); }

.segmented button .cnt {
  margin-left: 6px;
  opacity: 0.65;
  font-weight: 700;
}

/* ---------- панели и сетки ---------- */

.panel {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-1);
}

.panel + .panel { margin-top: var(--gap); }

/* overflow: clip, а не hidden: hidden делает панель скролл-контейнером
   и убивает position:sticky у шапки таблицы внутри неё. */
.panel.flush { padding: 0; overflow: clip; }

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.panel.flush .panel-head { margin: 0; padding: 16px 20px 12px; }

.panel-head h2 {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.panel-head h3 { font-size: 15px; font-weight: 800; }

.panel-head .sub { margin-top: 4px; color: var(--text-3); font-size: 12.5px; }

.grid { display: grid; gap: var(--gap); }
/* start, а не stretch: иначе панель с графиком растягивается по высоте соседа
   и под svg остаётся пустая полоса в треть панели. */
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.85fr); align-items: start; }
.grid.tight { gap: 10px; }

.stack { display: grid; gap: var(--gap); }
.stack.tight { gap: 10px; }

/* Элемент грида по умолчанию не уже своего содержимого: без min-width:0
   широкая таблица растягивает панель за пределы колонки и ломает страницу. */
.grid > *, .stack > * { min-width: 0; }

/* Быстрые действия: сколько влезет, без дыры в последнем ряду при трёх кнопках. */
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }

/* ---------- полоса счётчиков ---------- */

.summary-strip {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 13px 18px;
  margin-bottom: var(--gap);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-2);
}

.summary-strip b { color: var(--text); font-size: 17px; font-weight: 800; margin-right: 5px; }
.summary-strip .dot { color: var(--line); }
.summary-strip .hot b { color: var(--accent); }

/* ---------- KPI-плитки ---------- */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: var(--gap);
}

/* Число колонок задаётся числом плиток, а не auto-fit: иначе шесть плиток
   раскладываются 5+1 и последняя висит одна во всю ширину. */
@media (min-width: 1181px) {
  .kpi-strip[data-n="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .kpi-strip[data-n="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-strip[data-n="7"],
  .kpi-strip[data-n="8"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi-strip[data-n="9"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.kpi {
  padding: 15px 16px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-top: 3px solid var(--ink-3);
  border-radius: var(--radius);
}

.kpi.good { border-top-color: var(--green); }
.kpi.warn { border-top-color: var(--accent-2); }
.kpi.bad { border-top-color: var(--red); }
.kpi.key { border-top-color: var(--accent); }

.kpi-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.kpi-value {
  margin: 10px 0 4px;
  font-family: var(--font-display);
  font-size: 27px;
  line-height: 1.05;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.kpi-value .unit { font-family: var(--font-sans); font-size: 14px; font-weight: 700; color: var(--text-3); }

.kpi-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-3); }

.kpi-foot .delta { font-weight: 700; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--text-3); }

.kpi-def { margin-top: 8px; font-size: 11.5px; line-height: 1.4; color: var(--text-3); }

/* ---------- таблицы ---------- */

.tbl { width: 100%; }

.tbl-scroll { overflow-x: auto; }

.trow {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 12px;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--line-2);
  min-width: 0;
}

/* Светлая шапка, а не чёрная плашка: на «Работе сегодня» четыре очереди подряд,
   и четыре чёрные полосы спорят с чёрным сайдбаром и шапкой. */
.tbl-head {
  position: sticky;
  top: var(--header-h);
  z-index: 5;
  background: var(--paper-3);
  color: var(--text-3);
  border: 0;
  border-bottom: 1px solid var(--line);
  padding-top: 9px;
  padding-bottom: 9px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

button.trow {
  width: 100%;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

button.trow:hover { background: var(--paper-3); }
button.trow[aria-expanded="true"] { background: var(--paper-3); box-shadow: inset 3px 0 0 var(--accent); }

.trow > * { min-width: 0; }
.trow .status { max-width: 100%; overflow: hidden; }
.trow .cell-main strong { display: block; font-weight: 700; font-size: 13.5px; }
.trow .cell-main span { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; }
.trow .num { font-variant-numeric: tabular-nums; }

.who { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tbl-empty { padding: 30px 20px; text-align: center; color: var(--text-3); font-size: 13.5px; }

/* раскрытая строка */
.row-detail {
  padding: 16px 20px 18px;
  background: var(--paper);
  border-top: 1px solid var(--line-2);
}

/* ---------- значки и статусы ---------- */

.prio {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 850;
  letter-spacing: 0.03em;
}

.prio.P1 { background: var(--p1-bg); color: var(--p1); }
.prio.P2 { background: var(--p2-bg); color: var(--p2); }
.prio.P3 { background: var(--p3-bg); color: var(--p3); }
.prio.P4 { background: var(--p4-bg); color: var(--p4); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* Текст статуса — отдельным элементом, иначе в узкой ячейке он обрезается
   без многоточия: text-overflow не работает на анонимном флекс-элементе. */
.status > span { overflow: hidden; text-overflow: ellipsis; }

.status.ok { background: var(--green-soft); color: var(--green); }
.status.warn { background: var(--amber-soft); color: #8a5c00; }
.status.bad { background: var(--red-soft); color: var(--red); }
.status.info { background: var(--blue-soft); color: var(--blue); }
.status.wait { background: var(--paper-3); color: var(--text-3); }
.status.hot { background: var(--accent-soft); color: #5b34c7; }

.status.plain::before { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-3);
  font-size: 12px;
  font-weight: 650;
  color: var(--text-2);
}

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }

.sla {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  font-size: 13px;
}

.sla.danger { color: var(--red); }
.sla.soon { color: #8a5c00; }
.sla.paused { color: var(--text-3); font-weight: 600; font-size: 12px; }

/* «в разработке» / «не подключено» */
.stub {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px dashed rgba(115, 119, 130, 0.5);
  border-radius: 999px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ---------- шаговый трек ---------- */

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 0;
}

.steps li {
  position: relative;
  flex: 1 1 110px;
  min-width: 104px;
  padding: 9px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  font-size: 12px;
  line-height: 1.3;
}

.steps li .n {
  display: grid;
  place-items: center;
  width: 18px; height: 18px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--paper-3);
  border: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 800;
  color: var(--text-3);
}

.steps li.done { background: var(--green-soft); border-color: rgba(21, 132, 110, 0.30); }
.steps li.done .n { background: var(--green); border-color: var(--green); color: #fff; }
.steps li.current { background: var(--accent-soft); border-color: rgba(128, 82, 255, 0.40); font-weight: 700; }
.steps li.current .n { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- факты (dt/dd) ---------- */

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

.facts > div { min-width: 0; }

.facts dt {
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.facts dd { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.3; }
.facts dd small { display: block; margin-top: 3px; font-size: 12px; font-weight: 500; color: var(--text-3); }

/* ---------- ворота приёмки ---------- */

.gates { display: grid; gap: 8px; }

.gate {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}

.gate:hover { background: var(--paper-3); }
.gate[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.gate .g {
  display: grid;
  place-items: center;
  height: 30px;
  border-radius: 6px;
  background: var(--ink-2);
  color: var(--on-dark);
  font-size: 12px;
  font-weight: 850;
}

.gate.passed .g { background: var(--green); }
.gate.issue .g { background: var(--accent-2); color: #4a3200; }
.gate.blocked .g { background: var(--red); }
.gate.waiting .g { background: var(--paper-3); color: var(--text-3); }

.gate strong { display: block; font-size: 13.5px; }
.gate .meta { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; }

/* ---------- графики ---------- */

.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }

.bars { display: grid; gap: 9px; }

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) minmax(0, 3fr) auto;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--paper-3);
  overflow: hidden;
}

.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.bar-fill.alt { background: var(--blue); }
.bar-fill.g { background: var(--green); }
.bar-fill.r { background: var(--red); }
.bar-fill.a { background: var(--accent-2); }

.bar-row .val { font-variant-numeric: tabular-nums; font-weight: 750; white-space: nowrap; }
.bar-row .cum { color: var(--text-3); font-size: 11.5px; font-weight: 600; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 12.5px;
}

.data-table caption {
  text-align: left;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding-bottom: 7px;
}

.data-table th, .data-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-2);
  text-align: left;
}

.data-table th { color: var(--text-3); font-weight: 700; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

details.data-details summary {
  cursor: pointer;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 650;
  padding: 8px 0 0;
}

details.data-details summary:hover { color: var(--accent); }

/* ---------- прочее ---------- */

.callout {
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--paper-2);
  font-size: 13.5px;
  line-height: 1.5;
}

.callout.warn { border-left-color: var(--accent-2); background: var(--amber-soft); }
.callout.bad { border-left-color: var(--red); background: var(--red-soft); }
.callout.info { border-left-color: var(--blue); background: var(--blue-soft); }
.callout strong { display: block; margin-bottom: 3px; }

.hint {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: var(--gap);
  border: 1px solid rgba(128, 82, 255, 0.28);
  border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(128, 82, 255, 0.09), rgba(255, 184, 41, 0.10));
}

.hint .ico { flex: none; color: var(--accent); margin-top: 2px; }
.hint-body { flex: 1; min-width: 0; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.hint-body strong { display: block; font-size: 13.5px; color: var(--text); margin-bottom: 3px; }
.hint-body .tag { color: var(--accent); font-size: 10.5px; font-weight: 850; letter-spacing: 0.1em; text-transform: uppercase; display: block; margin-bottom: 4px; }

.note { color: var(--text-3); font-size: 12px; line-height: 1.45; }

.timeline { display: grid; gap: 0; }

.timeline li {
  position: relative;
  padding: 0 0 14px 20px;
  border-left: 2px solid var(--line);
  font-size: 13px;
}

.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }

.timeline li::before {
  content: "";
  position: absolute;
  left: -6px; top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--paper-2);
  border: 2px solid var(--accent);
}

.timeline strong { display: block; font-size: 13px; }
.timeline .when { color: var(--text-3); font-size: 11.5px; }

.linked { display: grid; gap: 8px; }

.linked button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}

.linked button:hover { background: var(--paper-3); border-color: var(--accent); }
.linked .lbl { color: var(--text-3); font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.linked strong { display: block; font-size: 13.5px; margin-top: 2px; }

.money-rows { display: grid; gap: 8px; }

.money-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}

.money-row strong { font-weight: 650; }
.money-row .m { font-variant-numeric: tabular-nums; font-weight: 750; white-space: nowrap; }
.money-row small { display: block; color: var(--text-3); font-size: 11.5px; font-weight: 400; }

.money-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--ink);
}

.money-total .m { font-family: var(--font-display); font-size: 21px; font-weight: 400; letter-spacing: -0.02em; }

.photo-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }

.photo {
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: var(--paper);
  margin: 0;
}

.photo .ph {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(45deg, var(--paper-3) 0 10px, var(--paper) 10px 20px);
  color: var(--text-3);
}

/* Кадр снимка. Отметка времени рисуется поверх, а не вжигается в пиксели —
   так она остаётся резкой и всегда совпадает с данными карточки. */
.photo-open {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--ink);
  cursor: zoom-in;
}

.photo-open img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: opacity 0.12s;
}

.photo-open:hover img { opacity: 0.88; }

.photo-open .stamp {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.92);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.photo figcaption { padding: 8px 10px; font-size: 11.5px; line-height: 1.35; }
.photo figcaption strong { display: block; font-size: 12px; }
.photo figcaption span { color: var(--text-3); }

.photo-credit { margin-top: 8px; }

/* ---------- просмотр снимка ---------- */

.lightbox { display: none; }

.lightbox[data-open] {
  display: grid;
  place-items: center;
  position: fixed;
  inset: 0;
  z-index: 200;
  padding: 24px;
  background: rgba(6, 6, 12, 0.82);
}

.lightbox-inner {
  position: relative;
  max-width: min(920px, 100%);
  max-height: 100%;
  background: var(--paper-2);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-3);
}

.lightbox-inner img { max-height: 74vh; width: 100%; object-fit: contain; background: var(--ink); }

.lightbox-cap { padding: 12px 16px; font-size: 13px; }
.lightbox-cap strong { display: block; }
.lightbox-cap span { color: var(--text-3); font-size: 12px; }

.lightbox-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.lightbox-close:hover { background: rgba(0, 0, 0, 0.75); }

.progress {
  height: 7px;
  border-radius: 999px;
  background: var(--paper-3);
  overflow: hidden;
  min-width: 60px;
}

.progress i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.progress.g i { background: var(--green); }

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-3);
}

.empty strong { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 6px; }

.dark-band {
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--ink-2);
  color: var(--on-dark-2);
}

.dark-band h2, .dark-band h3, .dark-band strong { color: var(--on-dark); }
.dark-band .eyebrow { color: var(--accent-2); }

.role-gate {
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--paper-3);
  color: var(--text-3);
  font-size: 13px;
}

.role-gate strong { color: var(--text-2); }

/* тост демо-действий */
.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: grid;
  gap: 8px;
  max-width: 380px;
}

.toast {
  padding: 12px 15px;
  border-radius: var(--radius);
  background: var(--ink-2);
  color: var(--on-dark);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--shadow-3);
  border-left: 3px solid var(--accent-2);
  animation: toast-in 0.16s ease-out;
}

.toast strong { display: block; color: var(--accent-2); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 3px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.footer-note {
  margin-top: 28px;
  padding: 16px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.5;
}

.footer-note strong { color: var(--text-2); display: block; margin-bottom: 3px; }

/* ---------- адаптив ---------- */

@media (max-width: 1180px) {
  .grid.side, .grid.three, .grid.four { grid-template-columns: 1fr; }
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Реестры шире 1300px не помещаются рядом с сайдбаром: на промежуточных
   ширинах таблица прокручивается внутри панели. Sticky в скролл-контейнере
   всё равно не работает — честнее отключить его, чем оставить наполовину. */
@media (max-width: 1300px) {
  .panel.flush .tbl { overflow-x: auto; }
  .tbl-head { position: static; }
}

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

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    padding: 12px;
  }

  .brand { border: 0; padding: 0 8px 0 0; margin: 0; flex: none; }
  .brand-sub { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: max-content; }
  .nav-sep, .demo-note { display: none; }

  /* display:contents, а не none: иначе «Настройки» вместе со всем служебным
     блоком исчезают с мобильной ширины и раздел становится недостижимым. */
  .sidebar-foot { display: contents; }
  .nav-item { white-space: nowrap; }
  .tbl-head { top: 0; }
  .grid.two, .grid.four { grid-template-columns: 1fr; }
  .view { padding: 20px 16px 56px; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .search { max-width: none; }
  .role-switch select { max-width: 120px; }
  .trow { grid-template-columns: 1fr !important; gap: 8px; padding: 12px 14px; }
  .tbl-head { display: none; }
  .trow > * { min-width: 0; }

  /* Подписи колонок переезжают в строку: шапка на этой ширине скрыта. */
  .trow > [data-l]::before {
    content: attr(data-l);
    display: block;
    margin-bottom: 2px;
    color: var(--text-3);
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .trow > .cell-main[data-l]::before { display: none; }
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .gate { grid-template-columns: 36px 1fr; }
  .gate > :last-child { grid-column: 1 / -1; }
  .toast-host { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}
