/*
  КТ Амур · рабочее место смены.
  Графитовая нейтральная гамма, один акцент цвета контейнера, линия маршрута как главный рисунок экрана.
  Шаг сетки 4 px. Шрифты IBM Plex (OFL) лежат в /fonts.
*/
@font-face { font-family: 'IBM Plex Sans'; font-weight: 400; font-display: swap; src: url('/fonts/ibm-plex-sans-cyrillic-400-normal.woff2') format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 500; font-display: swap; src: url('/fonts/ibm-plex-sans-cyrillic-500-normal.woff2') format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 600; font-display: swap; src: url('/fonts/ibm-plex-sans-cyrillic-600-normal.woff2') format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 400; font-display: swap; src: url('/fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 500; font-display: swap; src: url('/fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 600; font-display: swap; src: url('/fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 400; font-display: swap; src: url('/fonts/ibm-plex-sans-latin-ext-400-normal.woff2') format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1E00-1E9F,U+20A0-20AB,U+20AD-20C0,U+2113,U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 500; font-display: swap; src: url('/fonts/ibm-plex-sans-latin-ext-500-normal.woff2') format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1E00-1E9F,U+20A0-20AB,U+20AD-20C0,U+2113,U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url('/fonts/ibm-plex-mono-cyrillic-400-normal.woff2') format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap; src: url('/fonts/ibm-plex-mono-cyrillic-500-normal.woff2') format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url('/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap; src: url('/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url('/fonts/ibm-plex-mono-latin-ext-400-normal.woff2') format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1E00-1E9F,U+20A0-20AB,U+20AD-20C0,U+2113,U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap; src: url('/fonts/ibm-plex-mono-latin-ext-500-normal.woff2') format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1E00-1E9F,U+20A0-20AB,U+20AD-20C0,U+2113,U+A720-A7FF; }

:root {
  color-scheme: light;
  /* Нейтральная гамма */
  --page: #f6f7f8;
  --panel: #ffffff;
  --raised: #eef0f2;
  --ink: #16181b;
  --text: #474d55;
  --muted: #636972;
  --line: rgba(22, 24, 27, 0.09);
  --line-strong: rgba(22, 24, 27, 0.18);
  /* Боковая панель */
  --side: #17181b;
  --side-raised: #26282d;
  --side-text: #c8cbd0;
  --side-muted: #8d929a;
  /* Один акцент: синий контейнер с фотографии площадки */
  --accent: #1f5fae;
  --accent-hover: #1a5096;
  --accent-soft: #e9f0f9;
  /* Смысловые цвета */
  --risk: #b42318;
  --risk-soft: #fcefee;
  --warn: #8a5300;
  --warn-dot: #d08a1c;
  --warn-soft: #fbf3e4;
  --ok: #18733d;
  --ok-dot: #2f9e5b;
  /* Скругления и движение */
  --r-small: 6px;
  --r-control: 8px;
  --r-card: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ui: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  font: 400 14px/20px var(--ui);
  font-variant-numeric: tabular-nums;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
a,
input,
textarea,
select {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
a {
  color: var(--accent);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled {
  cursor: default;
  opacity: 0.5;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1,
.title {
  font: 500 26px/32px var(--ui);
  letter-spacing: -0.01em;
}
h2 {
  font: 500 16px/24px var(--ui);
}
h3 {
  font: 600 14px/20px var(--ui);
}
strong,
b {
  font-weight: 500;
}
.muted,
small,
.meta {
  color: var(--muted);
}
small,
.meta {
  font-size: 12px;
  line-height: 16px;
}
.mono,
.code {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0;
}

/* Служебное */
.skip {
  position: fixed;
  top: -80px;
  left: 12px;
  z-index: 12;
  background: var(--panel);
  padding: 8px 12px;
  border-radius: var(--r-control);
}
.skip:focus-visible {
  top: 8px;
}
.startup,
.screen-message {
  padding: 48px;
  color: var(--text);
}

/* Каркас */
.layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  background: var(--side);
  color: var(--side-text);
  padding: 20px 12px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #3a3d43 transparent;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 600 16px/20px var(--ui);
  letter-spacing: 0.01em;
  color: #f2f3f5;
}
.brand small {
  display: block;
  color: var(--side-muted);
  font: 400 12px/16px var(--ui);
  letter-spacing: 0;
  margin-top: 2px;
}
.sidebar .brand {
  padding: 0 8px 8px;
}
/* Знак: торец контейнера с дверными штангами */
.brand-mark {
  width: 28px;
  height: 20px;
  display: inline-grid;
  grid-template-columns: repeat(3, 2px);
  gap: 4px;
  align-items: center;
  justify-content: center;
  color: #f2f3f5;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  flex: none;
}
.brand-mark i {
  height: 10px;
  display: block;
  background: currentColor;
  border-radius: 1px;
}
.nav-group {
  padding-top: 20px;
}
.nav-caption {
  font-size: 12px;
  line-height: 16px;
  color: var(--side-muted);
  padding: 0 12px 8px;
}
.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  min-height: 34px;
  margin-bottom: 2px;
  border: 0;
  background: transparent;
  color: var(--side-text);
  border-radius: var(--r-control);
  text-align: left;
  text-decoration: none;
  font-size: 14px;
  line-height: 18px;
}
.nav-item .icon {
  color: var(--side-muted);
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f2f3f5;
}
.nav-item.active {
  background: var(--side-raised);
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.nav-item.active .icon {
  color: #ffffff;
}
.icon {
  width: 16px;
  height: 16px;
  flex: none;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-bottom {
  margin-top: auto;
  padding-top: 24px;
}
.user-block {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px 4px 0 8px;
  min-width: 0;
  color: #f2f3f5;
}
.user-block small {
  display: block;
  color: var(--side-muted);
}
.user-block .identity {
  min-width: 0;
  overflow-wrap: break-word;
  hyphens: auto;
}
.initials {
  width: 32px;
  height: 32px;
  border-radius: var(--r-control);
  background: var(--side-raised);
  color: #f2f3f5;
  display: grid;
  place-items: center;
  font: 500 12px/1 var(--mono);
  flex: none;
}
.logout {
  margin-left: auto;
  background: transparent;
  color: var(--side-muted);
  border: 0;
  padding: 6px;
  border-radius: var(--r-control);
}
.logout:hover {
  color: #f2f3f5;
  background: rgba(255, 255, 255, 0.05);
}
.logout + .logout {
  margin-left: -6px;
}
.workspace {
  min-width: 0;
}
.topbar {
  padding: 0 40px;
  height: 48px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--page);
  font-size: 13px;
}
.topbar-title {
  display: none;
  color: var(--ink);
  font-weight: 500;
}
.environment-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.environment-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn-dot);
}
.time-zone {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
}
.menu-toggle {
  display: none;
}
.menu-scrim {
  display: none;
}
.content {
  padding: 32px 40px 64px;
  max-width: 1600px;
  margin: 0 auto;
}

/* Заголовок страницы */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-head p,
.page-head small {
  color: var(--muted);
  margin-top: 4px;
}
.toolbar,
.actions,
.form-actions,
.title-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.actions {
  gap: 8px;
}
.toolbar.align-end {
  align-items: flex-end;
}
.toolbar.align-end > p {
  padding-bottom: 8px;
}
.push-end {
  margin-left: auto;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 96px;
}
/* Срок договора читается одной строкой: «с 25.11.2026». */
.term-cell > * { white-space: nowrap; }

/* Кнопки */
.btn,
.text-button,
.icon-button,
.tab {
  min-height: 36px;
  border-radius: var(--r-control);
  font-weight: 500;
  line-height: 20px;
}
.btn {
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  white-space: nowrap;
}
.btn:hover {
  background: var(--raised);
}
.btn:active:not(:disabled) {
  transform: scale(0.98);
}
.btn.primary,
.primary.btn {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn.danger {
  color: var(--risk);
}
.btn.small {
  min-height: 28px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: var(--r-small);
}
.text-button,
.link {
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--accent);
  text-align: left;
  font-weight: 500;
  min-height: 0;
}
.text-button:hover,
.link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link.code {
  font-weight: 500;
}
.icon-button {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  display: inline-grid;
  place-items: center;
  width: 36px;
  padding: 0;
  font-size: 18px;
  color: var(--text);
}
.icon-button:hover {
  background: var(--raised);
}
.btn .icon {
  width: 16px;
  height: 16px;
}
/* Переключатели вида: один сегментированный блок */
.tab {
  border: 0;
  background: transparent;
  padding: 0 12px;
  min-height: 32px;
  color: var(--text);
  border-radius: var(--r-small);
}
.tab:hover {
  color: var(--ink);
}
.tab.active,
.tab[aria-pressed='true'] {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(22, 24, 27, 0.08), 0 0 0 1px var(--line);
}
.segments {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--raised);
  border-radius: var(--r-control);
}

/* Показатели: число, подпись */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  margin-bottom: 20px;
}
.metric {
  padding: 16px 20px 20px;
  border-right: 1px solid var(--line);
  min-width: 0;
}
.metric:last-child {
  border-right: 0;
}
.metric .meta {
  display: block;
  font-size: 13px;
  line-height: 20px;
  color: var(--text);
}
.metric .value {
  display: block;
  margin-top: 8px;
  font: 500 28px/32px var(--ui);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.metric.attn .value {
  color: var(--risk);
}

/* Панели */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  margin-bottom: 20px;
  min-width: 0;
  overflow: hidden;
}
.section-head {
  padding: 16px 20px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.section-head small {
  display: block;
  margin-top: 2px;
}
.panel-body {
  padding: 20px;
}
.panel > .toolbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.panel > ul.panel-body {
  margin: 0;
  padding-left: 40px;
}
.panel > ul.panel-body li + li {
  margin-top: 4px;
}
.empty {
  padding: 20px;
  color: var(--muted);
}
.panel-note {
  margin: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
}
.panel-note.warn {
  color: var(--warn);
  background: var(--warn-soft);
}
.metrics.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.doc-list {
  display: grid;
  gap: 2px;
}
.doc-list span {
  font: 400 12px/16px var(--mono);
  white-space: nowrap;
}
.doc-list small {
  color: var(--muted);
  font-size: 12px;
}

/* Временный пароль: показывается один раз */
.credential {
  display: grid;
  gap: 4px;
  padding: 0 24px 8px;
}
.credential .dialog-description {
  margin-bottom: 12px;
}
.credential .meta {
  margin-top: 8px;
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}
.secret {
  display: block;
  padding: 12px 16px;
  border-radius: var(--r-control);
  background: var(--raised);
  font: 500 18px/24px var(--mono);
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
  user-select: all;
}
.credential + .form-actions {
  padding: 0 24px 24px;
  margin-top: 16px;
}
.login-form .text-button {
  display: block;
  margin: 12px auto 0;
}
.count {
  font: 400 12px/16px var(--mono);
  color: var(--muted);
}
.small-note {
  font-size: 12px;
  color: var(--muted);
}

/* Таблицы */
.table-wrap {
  max-width: 100%;
  overflow: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}
.data-table th {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  white-space: nowrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.data-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table td:first-child,
.data-table th:first-child {
  padding-left: 20px;
}
.data-table td:last-child,
.data-table th:last-child {
  padding-right: 20px;
}
.data-table tbody tr:last-child td {
  border-bottom: 0;
}
.data-table tbody tr:hover {
  background: #fafbfb;
}
.data-table td small {
  display: block;
  margin-top: 2px;
}
.history-list {
  display: grid;
  gap: 6px;
}
.history-list p {
  margin: 0;
}
/* Новые сделки из Bitrix24 на главном экране менеджера */
.inbox-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
}
.inbox-note {
  box-shadow: inset 3px 0 0 var(--accent);
}
.inbox-line strong {
  font-weight: 500;
}
.inbox-line small {
  display: block;
  margin-top: 2px;
}
@media (max-width: 620px) {
  .inbox-line {
    flex-direction: column;
    align-items: stretch;
  }
}
/* Подключение Bitrix24: короткие факты о состоянии автозагрузки */
.facts {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0 0 16px;
}
.facts dt {
  color: var(--muted);
}
.facts dd {
  margin: 0;
  color: var(--ink);
}
.facts dd.error {
  color: var(--risk);
}
@media (max-width: 620px) {
  .facts {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
  .facts dd {
    margin-bottom: 8px;
  }
}
/* Кнопка «?» в верхней строке и короткая подсказка справа */
.topbar .help-button {
  width: 28px;
  height: 28px;
  min-height: 28px;
  border-radius: 50%;
  font: 500 14px/1 var(--ui);
  color: var(--ink);
  flex: none;
}
dialog.guide-sheet {
  margin: 0 0 0 auto;
  width: min(440px, 100%);
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
}
.guide-body {
  display: grid;
  gap: 24px;
  padding: 0 24px 32px;
}
.guide-role {
  color: var(--text);
}
.guide-block h3 {
  font: 500 12px/16px var(--ui);
  color: var(--muted);
  margin-bottom: 8px;
}
.guide-list,
.guide-legend,
.guide-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}
.guide-list {
  gap: 8px;
  margin-top: 10px;
}
.guide-list li,
.guide-legend li {
  position: relative;
  padding-left: 16px;
  color: var(--text);
}
.guide-list li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
}
.guide-legend {
  gap: 6px;
}
.guide-legend li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 3px;
  width: 3px;
  height: 14px;
  border-radius: 2px;
}
.guide-legend .tone-bad::before {
  background: var(--risk);
}
.guide-legend .tone-warn::before {
  background: var(--warn-dot);
}
.guide-legend .tone-good::before {
  top: 7px;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok-dot);
}
.guide-flow {
  font-weight: 500;
  margin-bottom: 4px;
}
.guide-links {
  gap: 2px;
  margin: 0 -12px;
}
.guide-links a {
  display: grid;
  gap: 2px;
  padding: 8px 12px;
  border-radius: var(--r-control);
  color: var(--ink);
  text-decoration: none;
}
.guide-links a span {
  color: var(--muted);
  font-size: 13px;
}
.guide-links a:hover,
.guide-links a.active {
  background: var(--page);
}
/* Карточка заявки: стадия, контроль срока и срок доставки одной строкой */
.order-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.order-status-cell {
  display: grid;
  gap: 6px;
  padding: 16px 20px;
  border-right: 1px solid var(--line);
}
.order-status-cell:last-child {
  border-right: 0;
}
.order-status-cell .meta {
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}
.order-status-cell small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}
.order-status.row-late {
  box-shadow: inset 3px 0 0 var(--risk);
}
.order-status.row-risk {
  box-shadow: inset 3px 0 0 var(--warn-dot);
}
/* Срочность строки: красная полоса у просроченных, жёлтая там, где до срока меньше суток */
.data-table tr.row-late td:first-child {
  box-shadow: inset 3px 0 0 var(--risk);
}
.data-table tr.row-risk td:first-child {
  box-shadow: inset 3px 0 0 var(--warn-dot);
}
.num {
  text-align: right;
  white-space: nowrap;
}

/* Поля ввода */
.search,
.control,
input,
select,
textarea {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  padding: 8px 12px;
  min-height: 36px;
  line-height: 18px;
}
input:hover,
select:hover,
textarea:hover {
  border-color: rgba(22, 24, 27, 0.28);
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}
.search {
  min-width: 180px;
  flex: 1;
  max-width: 368px;
}
input::placeholder,
textarea::placeholder {
  color: #8a9098;
}

/* Состояние: тихая подпись с точкой, цвет только у отклонений */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  color: var(--text);
  font-size: 13px;
  line-height: 20px;
}
.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a3a8af;
  flex: none;
}
.pill.good::before {
  background: var(--ok-dot);
}
.pill.warn {
  color: var(--warn);
}
.pill.warn::before {
  background: var(--warn-dot);
}
.pill.bad {
  color: var(--risk);
  font-weight: 500;
}
.pill.bad::before {
  background: var(--risk);
}

/* Раскладки */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
  gap: 20px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px 24px;
  margin: 0;
}
.detail-grid dt {
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}
.detail-grid dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}
.row-list {
  padding: 4px 20px;
}
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child {
  border: 0;
}
.list-row small {
  display: block;
}
.ledger-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.ledger-row:last-child {
  border-bottom: 0;
}
.ledger-row strong {
  display: block;
  margin-bottom: 4px;
}
.order-tool {
  display: flex;
  gap: 8px;
  align-items: center;
}
details > summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--ink);
  padding: 4px 0;
}
details > summary::marker {
  color: var(--muted);
}
details[open] > summary {
  margin-bottom: 8px;
}
details .row-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 16px;
  padding: 8px 0 4px;
  margin: 0;
}
details .row-list dd {
  margin: 0;
}

/* Линия маршрута: план назад от срока доставки, факт по точкам */
.rail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 20px 20px 24px;
  overflow: hidden;
  margin-bottom: 20px;
}
.rail-panel .section-head {
  padding: 0 0 16px;
  min-height: 0;
  border: 0;
  align-items: flex-start;
}
.rail-panel h2 {
  font: 500 20px/28px var(--ui);
  margin-top: 4px;
}
.rail-panel .subtitle {
  color: var(--text);
  font-size: 13px;
  margin-top: 2px;
}
.rail-strip {
  display: flex;
  overflow-x: auto;
  padding: 12px 4px 4px;
  margin: 0 -4px;
  scrollbar-width: thin;
}
.rail-stop {
  flex: 1;
  min-width: 128px;
  position: relative;
  padding: 20px 16px 0 0;
  border-top: 2px dashed #c4c8ce;
  font-size: 13px;
  line-height: 18px;
}
.rail-stop strong {
  display: block;
  font-weight: 500;
  color: var(--ink);
}
.rail-stop::before {
  position: absolute;
  content: '';
  top: -7px;
  left: 0;
  width: 12px;
  height: 12px;
  background: var(--panel);
  border: 2px solid #9aa0a8;
  border-radius: 50%;
}
.rail-stop.done {
  border-top-style: solid;
  border-top-color: var(--accent);
}
.rail-stop.done::before {
  background: var(--accent);
  border-color: var(--accent);
}
.rail-stop.current::before {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.rail-stop.late:not(.done)::before {
  border-color: var(--risk);
}
.rail-stop.late.current::before {
  box-shadow: 0 0 0 4px var(--risk-soft);
}
.rail-stop.late:not(.done) small {
  color: var(--risk);
}
.rail-stop:last-child {
  border-top-color: transparent;
}
.rail-stop small {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 12px;
}
.rail-compact {
  padding: 16px 20px;
}
.inline-note {
  display: block;
  padding: 12px 16px;
  margin-top: 16px;
  background: var(--warn-soft);
  color: #5c3a05;
  border-radius: var(--r-control);
}
.rail-panel .inline-note {
  margin-top: 20px;
}

/* Формы и диалоги */
.field {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 4px;
}
.field label {
  font-size: 13px;
  line-height: 18px;
  color: var(--text);
  font-weight: 500;
}
.field input,
.field select,
.field textarea {
  width: 100%;
}
.field textarea {
  min-height: 80px;
  resize: vertical;
}
.field[hidden] {
  display: none;
}
.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.field.wide,
.fields .field:only-child {
  grid-column: 1/-1;
}
.form-group {
  grid-column: 1 / -1;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font: 500 14px/20px var(--ui);
}
.form-group:first-child {
  border-top: 0;
  padding-top: 0;
}
dialog {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  max-width: min(640px, calc(100% - 24px));
  width: 100%;
  max-height: 90dvh;
  overflow: auto;
  box-shadow: 0 24px 64px rgba(16, 18, 22, 0.18);
}
dialog::backdrop {
  background: rgba(16, 18, 22, 0.4);
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  gap: 12px;
}
.dialog-head h2 {
  font: 500 18px/24px var(--ui);
}
.dialog-head .icon-button {
  border-color: transparent;
}
dialog form {
  padding: 0 24px 24px;
}
.dialog-description {
  color: var(--text);
  margin-bottom: 20px;
}
.form-actions {
  justify-content: flex-end;
  margin-top: 24px;
}
.error:empty {
  display: none;
}
.error {
  color: var(--risk);
  background: var(--risk-soft);
  border-radius: var(--r-control);
  padding: 12px 16px;
  margin: 12px 0;
  overflow-wrap: anywhere;
}
.content > .error {
  margin-top: 0;
}
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 16px;
  max-width: min(90vw, 480px);
  z-index: 10;
  color: #f2f3f5;
  background: var(--ink);
  box-shadow: 0 8px 24px rgba(16, 18, 22, 0.16);
  border-radius: var(--r-control);
}
#toast:empty {
  display: none;
}

/* Звенья маршрута в форме */
.leg-editor {
  min-width: 0;
  border: 0;
  border-top: 1px solid var(--line);
  margin: 8px 0 0;
  padding: 16px 0 0;
}
.leg-editor > legend,
.leg-row > legend {
  font-weight: 500;
  padding-right: 8px;
}
.leg-editor > .btn {
  align-self: start;
}
.leg-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  margin: 0 0 12px;
  padding: 12px;
}
.leg-row > legend {
  padding: 0 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.leg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.leg-row > .text-button {
  margin-top: 8px;
  font-size: 13px;
}
.leg-row > .meta {
  display: block;
  margin-top: 8px;
}

/* Вход */
.login {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.1fr);
  background: var(--panel);
}
.login-main {
  width: min(100%, 400px);
  padding: 48px 32px;
  align-self: center;
  justify-self: center;
}
.login-visual {
  min-height: 0;
  background: #3a4350 url('/images/terminal-login.jpg') center / cover no-repeat;
}
.login-main .brand {
  color: var(--ink);
}
.login-main .brand small {
  color: var(--muted);
}
.login-main .brand-mark {
  color: var(--accent);
}
.login-form {
  margin-top: 48px;
}
.login-form h1 {
  margin-bottom: 8px;
}
.login-form > .muted {
  margin-bottom: 8px;
}
.login-form .field {
  margin: 16px 0;
}
.login-form .btn {
  width: 100%;
  margin-top: 8px;
  min-height: 40px;
}

/* Журнал и события */
.journal-filters {
  align-items: end;
  gap: 12px;
}
.filter-field {
  display: grid;
  gap: 4px;
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
  min-width: 140px;
}
.filter-field .search,
.filter-field .control {
  width: 100%;
  min-width: 0;
  max-width: none;
  font-size: 14px;
  color: var(--ink);
}
.journal-filters .filter-field:first-child {
  flex: 1;
  min-width: 180px;
}
.journal-filters .count {
  margin-left: auto;
  align-self: center;
}
.journal-pages {
  justify-content: flex-end;
}
.journal-pages .count {
  margin-right: auto;
}
.event-list {
  margin: 0;
  list-style: none;
  padding: 0;
}
.event-list li {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr 1.7fr;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.event-list li:last-child {
  border-bottom: 0;
}
.event-reference {
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .nav-item,
  .tab,
  .logout,
  input,
  select,
  textarea {
    transition:
      background-color 140ms var(--ease),
      border-color 140ms var(--ease),
      color 140ms var(--ease),
      transform 140ms var(--ease);
  }
  .content {
    animation: enter 320ms var(--ease);
  }
  @keyframes enter {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
  }
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 216px minmax(0, 1fr);
  }
  .content {
    padding: 24px 24px 48px;
  }
  .topbar {
    padding: 0 24px;
  }
  .data-table td,
  .data-table th {
    padding-left: 12px;
    padding-right: 12px;
  }
  .split {
    grid-template-columns: 1fr;
  }
  .metric {
    padding: 12px 16px 16px;
  }
}
@media (max-width: 780px) {
  .layout {
    display: block;
  }
  .sidebar {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    z-index: 5;
    width: 264px;
    height: calc(100dvh - 52px);
    box-shadow: 8px 0 32px rgba(16, 18, 22, 0.2);
  }
  .sidebar.show {
    display: flex;
  }
  .nav-open .menu-scrim {
    display: block;
    position: fixed;
    inset: 52px 0 0;
    z-index: 4;
    border: 0;
    padding: 0;
    border-radius: 0;
    background: rgba(16, 18, 22, 0.32);
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 4;
    height: 52px;
    padding: 0 16px;
  }
  .topbar-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .environment-label,
  .tz-offset {
    display: none;
  }
  .menu-toggle {
    display: inline-grid;
  }
  .content {
    padding: 20px 12px 40px;
  }
  h1,
  .title {
    font-size: 22px;
    line-height: 28px;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metric:nth-child(2) {
    border-right: 0;
  }
  .metric:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
  .metrics.three .metric {
    border-bottom: 0;
  }
  .metrics.three .metric:nth-child(2) {
    border-right: 1px solid var(--line);
  }
  .metric .value {
    font-size: 24px;
    line-height: 28px;
  }
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .panel > .toolbar,
  .section-head {
    padding: 12px 16px;
  }
  .rail-panel {
    padding: 16px;
  }
  .nav-item {
    min-height: 40px;
  }
  .fields {
    grid-template-columns: 1fr;
  }
  .page-head {
    margin-bottom: 16px;
  }
  .event-list li {
    grid-template-columns: 1fr 1fr;
    padding: 12px 16px;
    gap: 4px 12px;
  }
  .event-reference {
    grid-column: 1 / -1;
  }
  .login {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }
  .login-visual {
    grid-row: 1;
    height: 200px;
    background-position: center 56%;
  }
  .login-main {
    padding: 32px 20px;
    align-self: start;
  }
  .login-form {
    margin-top: 32px;
  }
}
@media (min-width: 781px) {
  .icon-button.menu-toggle {
    display: none;
  }
}
@media (max-width: 620px) {
  .journal-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .journal-filters .filter-field,
  .journal-filters .filter-field:first-child {
    min-width: 0;
  }
  .journal-filters .filter-field:first-child {
    grid-column: 1 / -1;
  }
  .journal-filters .count {
    grid-column: auto;
    margin-left: 0;
    overflow-wrap: anywhere;
  }
  .order-journal .data-table thead {
    position: absolute;
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
  }
  .order-journal .data-table,
  .order-journal tbody {
    display: block;
  }
  .order-journal tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
  }
  .order-status {
    grid-template-columns: minmax(0, 1fr);
  }
  .order-status-cell {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .order-status-cell:last-child {
    border-bottom: 0;
  }
  .order-journal tr.row-late {
    box-shadow: inset 3px 0 0 var(--risk);
  }
  .order-journal tr.row-risk {
    box-shadow: inset 3px 0 0 var(--warn-dot);
  }
  .order-journal tr.row-late td:first-child,
  .order-journal tr.row-risk td:first-child {
    box-shadow: none;
  }
  .order-journal td,
  .order-journal td:first-child,
  .order-journal td:last-child {
    display: block;
    padding: 4px 0;
    border-bottom: 0;
    overflow-wrap: anywhere;
  }
  .order-journal td:first-child {
    grid-column: 1 / -1;
  }
  .order-journal td::before {
    display: block;
    content: attr(data-label);
    font-size: 12px;
    color: var(--muted);
    padding-bottom: 2px;
  }
  .order-journal td .pill {
    white-space: normal;
  }
  .order-journal td .actions {
    gap: 4px;
  }
  .order-journal td .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .order-journal td:has(> .row-actions) {
    grid-column: 1 / -1;
    padding-top: 8px;
  }
  .order-journal td:has(> .row-actions)::before {
    display: none;
  }
  .page-head > .primary {
    min-height: 40px;
  }
}
@media (max-width: 480px) {
  .leg-grid {
    grid-template-columns: 1fr;
  }
  .metrics .metric {
    padding: 12px;
  }
}

/* ===== Ведущая цепочка заявки ===== */

/* Путь заявки: семь шагов и одна главная кнопка */
.lead {
  overflow: hidden;
}
.path {
  list-style: none;
  margin: 0;
  padding: 20px 24px 16px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
}
.path li {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 16px;
  text-align: center;
}
/* Линия между шагами */
.path li + li::before {
  content: '';
  position: absolute;
  top: 13px;
  right: calc(50% + 18px);
  width: calc(100% - 36px);
  height: 2px;
  background: var(--line-strong);
}
.path li.done + li::before {
  background: var(--ink);
}
.path-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 500 13px/1 var(--ui);
  background: var(--panel);
  border: 2px solid var(--line-strong);
  color: var(--muted);
}
.path li.done .path-dot {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.path li.done {
  color: var(--ink);
}
.path li.now .path-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.path li.now {
  color: var(--ink);
  font-weight: 500;
}
.lead-now {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px;
  border-top: 1px solid var(--line);
}
.lead-words {
  display: grid;
  gap: 6px;
  max-width: 760px;
}
.lead-kicker {
  font: 500 12px/16px var(--ui);
  color: var(--accent);
}
.lead-kicker.hold {
  color: var(--risk);
}
.lead-text {
  margin: 0;
  font: 400 17px/26px var(--ui);
  color: var(--ink);
}
.lead-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
  flex: none;
}
.lead-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 16px;
}
.btn.large {
  min-height: 44px;
  padding: 0 22px;
  font-size: 15px;
  font-weight: 500;
}
.lead-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 40px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--page);
}
.lead-facts > div {
  display: grid;
  gap: 2px;
}
.lead-facts .meta {
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}
.batch-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.batch-links a {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 13px;
}
.batch-links a.active {
  color: var(--ink);
  font-weight: 500;
}
.warn-text {
  color: var(--warn);
}

/* Очередь «Что сделать сейчас» */
.queue {
  list-style: none;
  margin: 0;
  padding: 0;
}
.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
.queue-item:first-child {
  border-top: 0;
}
.queue-item.late {
  box-shadow: inset 3px 0 0 var(--risk);
}
.queue-item.risk {
  box-shadow: inset 3px 0 0 var(--warn-dot);
}
.queue-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.queue-text strong {
  font-weight: 500;
}
.queue-text small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-text.clickable {
  cursor: pointer;
}
.queue-more {
  margin: 4px 20px 14px;
}

/* Переключатель вида */
.view-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-control);
  background: var(--raised);
}
.view-tab {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-small);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.view-tab.active {
  background: var(--panel);
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(22, 24, 27, 0.12);
}

/* Доска заявок */
.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(168px, 1fr);
  gap: 12px;
  padding: 16px 20px 20px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
}
.board-col {
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: start;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border-radius: var(--r-card);
  background: var(--page);
  scroll-snap-align: start;
}
.board-col > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 4px;
  font-weight: 500;
}
.board-count {
  min-width: 24px;
  padding: 0 7px;
  border-radius: 10px;
  background: var(--raised);
  color: var(--text);
  font: 500 12px/20px var(--ui);
  text-align: center;
}
.board-col.hold .board-count,
.board-col.late .board-count {
  background: var(--risk-soft);
  color: var(--risk);
}
.board-col.risk .board-count {
  background: var(--warn-soft);
  color: var(--warn);
}
.board-cards {
  display: grid;
  align-content: start;
  gap: 8px;
}
.board-empty {
  margin: 0;
  padding: 12px 4px;
  color: var(--muted);
  font-size: 13px;
}
.card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease);
}
.card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}
.card.late {
  box-shadow: inset 3px 0 0 var(--risk);
}
.card.risk {
  box-shadow: inset 3px 0 0 var(--warn-dot);
}
.card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 8px;
}
.card-top strong {
  font-weight: 500;
}
.card-top .mono {
  font-size: 12px;
  color: var(--text);
}
.card-client {
  color: var(--ink);
}
.card-route,
.card-foot {
  color: var(--muted);
  font-size: 13px;
}
.card-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 8px;
  margin-top: 4px;
}
.card-next {
  color: var(--accent);
  font-weight: 500;
}
.card-next.hold {
  color: var(--risk);
}

.page-head .row-actions {
  display: flex;
  gap: 8px;
}

/* Печатные формы */
.sheet {
  max-width: 820px;
  padding: 40px 48px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
  font-size: 15px;
  line-height: 24px;
}
.sheet h2 {
  margin: 0 0 20px;
  font: 600 19px/28px var(--ui);
}
.sheet p {
  margin: 0 0 10px;
}
.sheet-note {
  padding: 10px 14px;
  border-radius: var(--r-control);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 13px;
  line-height: 20px;
}
.sheet-total {
  margin-top: 12px !important;
  font-weight: 600;
  text-align: right;
}
.sheet-clauses {
  margin: 12px 0 20px;
  padding-left: 22px;
  display: grid;
  gap: 8px;
}
.sheet-signs {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 40px;
}
@media print {
  .sidebar,
  .topbar,
  .no-print,
  #toast {
    display: none !important;
  }
  .layout {
    display: block;
  }
  .content {
    padding: 0;
  }
  .sheet {
    border: 0;
    padding: 0;
    max-width: none;
  }
  body {
    background: #fff;
  }
}

/* Экран смены: телефон, крупные кнопки */
.shift {
  min-height: 100vh;
  background: var(--page);
}
.shift-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--side);
  color: #fff;
}
.shift-user {
  display: grid;
  line-height: 18px;
}
.shift-user small {
  color: var(--side-muted);
}
.shift-tools {
  display: flex;
  gap: 8px;
}
.shift-bar .btn {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}
.shift-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 64px;
  display: grid;
  gap: 20px;
}
.shift-head h1 {
  margin: 0;
  font: 600 24px/32px var(--ui);
}
.shift-counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.shift-count {
  display: grid;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
}
.shift-count strong {
  font: 500 26px/30px var(--ui);
}
.shift-count span {
  color: var(--muted);
  font-size: 13px;
  line-height: 16px;
}
.shift-count.go strong {
  color: var(--ok);
}
.shift-group {
  display: grid;
  gap: 10px;
}
.shift-group h2 {
  margin: 0;
  font: 500 15px/20px var(--ui);
  color: var(--text);
}
.task {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
}
.task.go {
  box-shadow: inset 4px 0 0 var(--ok-dot);
}
.task.mine {
  box-shadow: inset 4px 0 0 var(--accent);
}
.task.wait {
  background: transparent;
  border-style: dashed;
  color: var(--text);
}
.task-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.task-top .mono {
  font-size: 15px;
  font-weight: 500;
}
.task-order,
.task-nonumber {
  color: var(--muted);
}
.task h3 {
  margin: 0;
  font: 600 18px/24px var(--ui);
}
.task.wait h3 {
  font-weight: 500;
  font-size: 16px;
}
.task p {
  margin: 0;
}
.task-route,
.task-when {
  color: var(--text);
}
.task-when.late,
.task-problem {
  color: var(--risk);
}
.task-wait {
  color: var(--muted);
}
.task-actions {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.task-actions .btn.large {
  width: 100%;
  min-height: 68px;
  font-size: 17px;
}
.task-more {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 900px) {
  .lead-now {
    flex-direction: column;
    align-items: stretch;
  }
  .lead-actions {
    justify-items: stretch;
  }
  .lead-links {
    justify-content: flex-start;
  }
}
@media (max-width: 720px) {
  /* На узком экране названия остаются только у текущего шага */
  .path {
    padding: 16px 12px 12px;
  }
  .path li .path-name {
    display: none;
  }
  .path li.now .path-name {
    display: block;
    position: absolute;
    top: 34px;
    white-space: nowrap;
  }
  .path li:first-child.now .path-name {
    left: 0;
  }
  .path li:last-child.now .path-name {
    right: 0;
  }
  .path {
    padding-bottom: 34px;
  }
  .path li + li::before {
    right: calc(50% + 16px);
    width: calc(100% - 32px);
  }
  .lead-now,
  .lead-facts {
    padding-left: 16px;
    padding-right: 16px;
  }
  .lead-text {
    font-size: 16px;
    line-height: 24px;
  }
  .queue-item {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
  }
  .queue-text small {
    white-space: normal;
  }
  .board {
    grid-auto-columns: 78%;
    padding: 12px 16px 16px;
  }
  .sheet {
    padding: 20px 16px;
  }
  .sheet-signs {
    flex-direction: column;
  }
}

/* ===== Виды, фильтры и статистика ===== */

/* Цвета стадий: один цвет на стадию на всех экранах — доска, таблицы, графики.
   Набор проверен на различимость при нарушениях цветового зрения и на контраст с белым. */
:root {
  --st-contract: #d93f3e;
  --st-new: #6250d6;
  --st-offer: #e0602c;
  --st-ready: #12976a;
  --st-work: #2a78d6;
  --st-delivered: #008300;
  --st-closed: #8a9099;
  --viz: #2a78d6;
  --viz-soft: #b9d3f3;
}
.st-contract { --st: var(--st-contract); }
.st-new { --st: var(--st-new); }
.st-offer { --st: var(--st-offer); }
.st-ready { --st: var(--st-ready); }
.st-work { --st: var(--st-work); }
.st-delivered { --st: var(--st-delivered); }
.st-closed,
.st-cancelled,
.st-none { --st: var(--st-closed); }
.st-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--st, var(--st-closed));
}
.st-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

/* Плитки с цифрами */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.tile {
  position: relative;
  display: grid;
  gap: 4px;
  align-content: start;
  padding: 16px 20px 16px 24px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  text-align: left;
  min-width: 0;
}
button.tile {
  cursor: pointer;
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease);
}
button.tile:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}
.tile-mark {
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--c, var(--line-strong));
}
.tile .meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}
.tile .value {
  font: 500 28px/34px var(--ui);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.tile.attn .value {
  color: var(--risk);
}
.tile-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}
.tile-hint.good {
  color: var(--ok);
}
.tile-hint.bad {
  color: var(--warn);
}

/* Карточки графиков */
.viz-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.viz-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.workspace-body > .viz-grid {
  padding: 16px 20px 20px;
  margin: 0;
}
.viz-card {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px 20px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
  min-width: 0;
}
.viz-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.viz-card h3 {
  margin: 0;
  font: 500 15px/20px var(--ui);
}
.viz-head small,
.viz-note,
.viz-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}
.viz-note,
.viz-empty {
  margin: 0;
  font-size: 13px;
  line-height: 20px;
}
.viz-tip {
  position: fixed;
  z-index: 60;
  max-width: 280px;
  padding: 6px 10px;
  border-radius: var(--r-control);
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  line-height: 16px;
  pointer-events: none;
}

/* Полосы: от общей нулевой линии, скруглён только конец */
.bars {
  display: grid;
  gap: 6px;
}
.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 42%) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
}
button.bar-row {
  cursor: pointer;
}
button.bar-row:hover .bar-name {
  color: var(--accent);
}
.bar-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
  line-height: 18px;
}
.bar-name > span:not(.st-dot):not(.bar-mark) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-mark {
  flex: none;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--raised);
  color: var(--text);
  font-size: 11px;
  line-height: 18px;
}
.bar-track {
  display: block;
  height: 12px;
  border-left: 1px solid var(--line-strong);
}
.bar-fill {
  display: block;
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--st, var(--c, var(--viz)));
}
.bar-fill.late { background: var(--risk); }
.bar-fill.risk { background: var(--warn-dot); }
.bar-fill.fine { background: var(--ok-dot); }
.bar-value {
  min-width: 56px;
  font: 500 13px/18px var(--ui);
  text-align: right;
  white-space: nowrap;
}

/* Столбики по дням */
.cols {
  display: grid;
  gap: 6px;
}
.cols-plot {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 96px;
  border-bottom: 1px solid var(--line-strong);
}
.col {
  flex: 1 1 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  min-width: 0;
}
.col-bar {
  width: 100%;
  max-width: 24px;
  border-radius: 4px 4px 0 0;
  background: var(--viz-soft);
}
.col-bar.zero {
  background: var(--line-strong);
  border-radius: 0;
}
.col.today .col-bar {
  background: var(--viz);
}
.col:hover .col-bar,
.col:focus-visible .col-bar {
  background: var(--accent);
}
.cols-avg {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px solid var(--muted);
  pointer-events: none;
}
.cols-avg small {
  position: absolute;
  right: 0;
  bottom: 2px;
  padding: 0 4px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  line-height: 14px;
}
.cols-axis {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  line-height: 14px;
}

/* Кольцо цели */
.ring-box {
  position: relative;
  width: 96px;
  height: 96px;
  flex: none;
}
.ring {
  width: 96px;
  height: 96px;
}
.ring circle {
  fill: none;
  stroke-width: 9;
}
.ring-track { stroke: var(--raised); }
.ring-fill {
  stroke: var(--viz);
  stroke-linecap: round;
}
.ring.full .ring-fill { stroke: var(--ok-dot); }
.ring-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
}
.ring-text strong {
  font: 500 26px/28px var(--ui);
}
.ring-text small {
  color: var(--muted);
  font-size: 12px;
  line-height: 14px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 2px 10px;
  border-radius: 12px;
  background: var(--raised);
  color: var(--text);
  font-size: 12px;
  line-height: 20px;
}
.chip.accent {
  background: var(--accent-soft);
  color: var(--accent);
}
.chip.good {
  background: #e6f4ec;
  color: var(--ok);
}

/* Моя работа */
.my-body {
  display: grid;
  gap: 12px;
  padding: 16px 20px 20px;
}
.my-body .viz-grid,
.my-body .tiles {
  margin: 0;
}
.my-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.3fr) minmax(0, 1.2fr);
  gap: 12px;
}
.my-goal {
  display: grid;
  justify-items: start;
  gap: 10px;
}
.my-goal-text {
  margin: 0;
  font: 500 15px/22px var(--ui);
}
.my-goal-text.good {
  color: var(--ok);
}
.my-total {
  display: grid;
}
.my-total strong {
  font: 500 40px/44px var(--ui);
  letter-spacing: -0.02em;
}
.my-total span {
  color: var(--muted);
}
.my-speed {
  display: grid;
  gap: 12px;
}
.my-speed .tiles {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.my-advice {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--r-card);
  background: var(--accent-soft);
  color: var(--ink);
}

/* Фильтры */
.filters {
  display: grid;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.filters-row[hidden] {
  display: none;
}
.filters .filter-field {
  flex: 1 1 150px;
  max-width: 240px;
}
.filters .filter-field:first-child {
  flex: 2 1 220px;
  max-width: 320px;
}
.filters .filter-field .control,
.filters .filter-field .search {
  width: 100%;
}
.filters .count {
  margin-left: auto;
  padding-bottom: 10px;
}
.filters .btn.small,
.filters .text-button {
  margin-bottom: 2px;
}

/* Сортировка по заголовку */
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.sortable::after {
  content: '↕';
  margin-left: 6px;
  color: var(--line-strong);
}
th.sortable[aria-sort='ascending']::after {
  content: '↑';
  color: var(--accent);
}
th.sortable[aria-sort='descending']::after {
  content: '↓';
  color: var(--accent);
}
th.sortable:hover {
  color: var(--ink);
}

/* Доска: цвет стадии и перетаскивание */
.board.three {
  grid-auto-columns: minmax(240px, 1fr);
}
.board-col {
  border-top: 3px solid var(--st, transparent);
}
.board-col.late { border-top-color: var(--risk); }
.board-col.risk { border-top-color: var(--warn-dot); }
.board-col.fine { border-top-color: var(--ok-dot); }
.board-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.board-col.over {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}
.card.movable {
  cursor: grab;
}
.card.dragging {
  opacity: 0.45;
}
.card .st-label {
  font-size: 12px;
  color: var(--text);
}
.queue-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Путь заявки: текущий шаг в цвете стадии */
.lead {
  border-top: 3px solid var(--st, var(--line));
}
.lead .path li.now .path-dot {
  background: var(--st, var(--accent));
  border-color: var(--st, var(--accent));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--st, var(--accent)) 18%, transparent);
}

/* Очередь смены */
.shift-queue {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sq-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.sq-row:first-child {
  border-top: 0;
}
.sq-row[draggable='true'] {
  cursor: grab;
}
.sq-row.dragging {
  opacity: 0.45;
}
.sq-row.over {
  box-shadow: inset 0 3px 0 var(--accent);
}
.sq-row.busy {
  background: var(--page);
}
.sq-row.trouble {
  box-shadow: inset 3px 0 0 var(--risk);
}
.sq-place {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--raised);
  font: 500 13px/1 var(--ui);
}
.sq-row.busy .sq-place {
  background: var(--accent-soft);
  color: var(--accent);
}
.sq-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.sq-text strong {
  font-weight: 500;
}
.sq-text small {
  color: var(--muted);
}
.sq-tools {
  display: inline-flex;
  gap: 4px;
}
.sq-tools .icon-button {
  width: 32px;
  min-height: 32px;
  font-size: 15px;
}
.sq-waiting {
  margin: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

/* Панель собственника */
.owner-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.owner-bar [hidden] {
  display: none;
}
.owner-body > .panel,
.owner-body > .viz-card {
  margin-bottom: 20px;
}

/* Экран смены: статистика */
.shift-stats .viz-card {
  gap: 14px;
}
.shift-stat-top {
  display: flex;
  align-items: center;
  gap: 16px;
}
.shift-stat-words {
  display: grid;
  gap: 4px;
}

@media (max-width: 1180px) {
  .my-grid,
  .viz-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .my-grid > :first-child {
    grid-column: 1 / -1;
  }
}
@media (max-width: 720px) {
  .tiles,
  .my-speed .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .tile {
    padding: 12px 12px 12px 18px;
  }
  .tile .value {
    font-size: 24px;
    line-height: 30px;
  }
  .viz-grid,
  .viz-grid.three,
  .my-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .my-body,
  .workspace-body > .viz-grid {
    padding: 12px 12px 16px;
  }
  .filters {
    padding: 12px 16px;
  }
  .filters .filter-field {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
    max-width: none;
  }
  .filters .filter-field:first-child {
    flex: 1 1 100%;
    max-width: none;
  }
  .view-tab {
    white-space: nowrap;
  }
  .filters .count {
    margin-left: 0;
    padding-bottom: 0;
  }
  /* На телефоне подпись полосы занимает свою строку, полоса и значение — под ней */
  .bar-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 8px;
    padding: 2px 0;
  }
  .bar-name {
    grid-column: 1 / -1;
  }
  .sq-row {
    grid-template-columns: 28px minmax(0, 1fr) auto;
    padding: 12px 16px;
  }
  .sq-row .pill {
    grid-column: 2 / -1;
    white-space: normal;
  }
  .sq-tools {
    grid-row: 1;
    grid-column: 3;
  }
  .owner-bar {
    align-items: stretch;
  }
  .view-switch {
    overflow-x: auto;
    max-width: 100%;
  }
  .board.three {
    grid-auto-columns: 78%;
  }
}

/* Вкладки раздела, собранного из двух (счета и платёжный календарь, справочники) */
.section-tabs {
  display: flex;
  gap: 4px;
  margin: -4px 0 20px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.section-tab {
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.section-tab:hover {
  color: var(--ink);
}
.section-tab.active {
  border-bottom-color: var(--accent);
  color: var(--ink);
  font-weight: 500;
}

/* Аналитика · сотрудники */
.staff-legend { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.staff-body { padding: 16px 20px 0; }
.staff-body .tiles { margin-bottom: 16px; }
.staff-body .table-wrap { margin: 0 -20px; }
.triple { font-variant-numeric: tabular-nums; white-space: nowrap; }
.late-text { color: var(--risk); }

/* Аналитика · оргструктура */
.org { display: grid; justify-items: center; padding: 8px 0 4px; }
.org-node {
  display: grid;
  gap: 4px;
  width: 100%;
  max-width: 320px;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--org, var(--accent));
  border-radius: var(--r-card);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease);
}
.org-node:hover { transform: translateY(-1px); border-color: var(--line-strong); border-top-color: var(--org, var(--accent)); }
.org-node.top { max-width: 380px; }
.org-node.role-director { --org: var(--ink); }
.org-node.role-manager { --org: var(--st-new); }
.org-node.role-dispatcher { --org: var(--st-work); }
.org-node.role-accountant { --org: var(--st-delivered); }
.org-node.role-loader { --org: var(--st-offer); }
.org-unit { color: var(--muted); font-size: 12px; line-height: 16px; }
.org-role { font-size: 15px; line-height: 20px; }
.org-people { color: var(--ink); font-size: 13px; }
.org-does { color: var(--text); font-size: 13px; line-height: 18px; }
.org-kpi { margin-top: 4px; color: var(--accent); font-size: 13px; font-weight: 500; }
.org-stem { display: block; width: 2px; height: 24px; background: var(--line-strong); }
.org-row { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; width: 100%; }
/* Горизонталь от центра первой колонки до центра последней */
.org-row::before { content: ''; position: absolute; top: 0; left: calc((100% - 40px) / 6); right: calc((100% - 40px) / 6); height: 2px; background: var(--line-strong); }
.org-col { display: grid; justify-items: center; align-content: start; }
.org-up { display: block; width: 2px; height: 24px; background: var(--line-strong); }
.org-side { display: grid; gap: 4px; max-width: 520px; margin-top: 28px; padding: 12px 16px; border: 1px dashed var(--line-strong); border-radius: var(--r-card); color: var(--text); font-size: 13px; text-align: center; }
.org-side strong { color: var(--ink); font-size: 14px; }
@media (max-width: 720px) {
  .org-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .org-row::before { display: none; }
  .org-node, .org-node.top { max-width: none; }
}

/* ---------- 24 ноября, вечер: партия из Excel, ссылка клиенту, участки смены ---------- */
.import-preview p { margin: 0 0 8px; }
.import-table { max-height: 360px; overflow: auto; }
.import-table td:last-child { min-width: 200px; }
dialog:has(.import-preview) { width: min(920px, calc(100vw - 24px)); max-width: none; }
.link-box .secret { word-break: break-all; user-select: all; }
.link-box .warn-text { margin-top: 10px; }
.task-crew { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.client-page { min-height: 100vh; background: var(--page); padding: 32px 16px 64px; }
.client-sheet { max-width: 920px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px 32px; }
.client-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.client-brand { font-weight: 600; color: var(--ink); }
.client-sheet h1 { font-size: 26px; line-height: 32px; margin: 0 0 6px; }
.client-lead { color: var(--text); margin: 0 0 18px; }
.client-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 20px; }
.client-facts dt { color: var(--muted); font-size: 12px; }
.client-facts dd { margin: 2px 0 0; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.client-decision { margin-top: 24px; padding: 20px; border-radius: 12px; background: var(--accent-soft); }
.client-decision h2 { margin: 0 0 4px; font-size: 18px; }
.client-form { display: grid; gap: 12px; margin-top: 12px; max-width: 520px; }
.client-form .field { display: grid; gap: 4px; }
.client-form input, .client-form textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--panel); }
.client-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.client-done { font-weight: 600; color: var(--ink); margin: 0 0 8px; }
.client-sheet .small { font-size: 12px; margin-top: 18px; }
@media (max-width: 640px) {
  .client-page { padding: 0; }
  .client-sheet { border-radius: 0; border: 0; padding: 20px 16px; }
  .client-facts { grid-template-columns: 1fr 1fr; }
  .client-sheet table thead { display: none; }
  .client-sheet table, .client-sheet tbody, .client-sheet tr, .client-sheet td { display: block; width: 100%; }
  .client-sheet tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .client-sheet td { border: 0; padding: 2px 0; text-align: left; }
  .client-sheet td::before { content: attr(data-label) ' · '; color: var(--muted); font-size: 12px; }
  .client-actions .btn { flex: 1 1 auto; }
}
.timing-sub { font-size: 14px; line-height: 20px; margin: 0; padding: 20px 20px 8px; }
.timing-note { padding: 12px 20px 18px; }
.timing-note p { margin: 0 0 10px; }
.client-form [hidden] { display: none; }

/* Сквозной процесс: схема из восьми шагов, карточка шага с документом, документы и реестр цепочек. */
.sc-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; margin-bottom: 16px; }
.sc-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.sc-pick label { color: var(--muted); font-size: 13px; }
.sc-head .row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sc-pick select { max-width: 100%; min-width: 220px; }
.sc-auto { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px; margin-bottom: 16px; border-radius: var(--r-card); background: var(--accent-soft); color: var(--ink); }
.sc-auto span { flex: 1 1 200px; color: var(--text); }
.sc-scheme { padding: 20px 12px 16px; }
.sc-line { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.sc-line li { position: relative; min-width: 0; }
.sc-line li + li::before { content: ''; position: absolute; top: 23px; right: calc(50% + 20px); width: calc(100% - 40px); height: 2px; background: var(--line-strong); }
.sc-line li.done + li::before { background: var(--ink); }
.sc-node { width: 100%; display: grid; justify-items: center; gap: 4px; padding: 8px 4px 10px; border: 0; border-radius: var(--r-control); background: none; color: var(--muted); text-align: center; font: inherit; }
.sc-node:hover { background: var(--page); }
.sc-node:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sc-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font: 500 14px/1 var(--ui); background: var(--panel); border: 2px solid var(--line-strong); color: var(--muted); position: relative; z-index: 1; }
.sc-name { font: 500 13px/16px var(--ui); margin-top: 4px; }
.sc-note { font-size: 12px; line-height: 16px; min-height: 16px; overflow-wrap: anywhere; }
.sc-line li.done .sc-dot { background: var(--ink); border-color: var(--ink); color: #fff; }
.sc-line li.done .sc-name { color: var(--ink); }
.sc-line li.nodeal .sc-dot { background: var(--panel); border-color: var(--line-strong); color: var(--muted); }
.sc-line li.nodeal .sc-name { color: var(--muted); }
.sc-line li.now .sc-dot { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.sc-line li.now .sc-name { color: var(--ink); font-weight: 600; }
.sc-line li.now .sc-note { color: var(--accent); }
.sc-line li.alert .sc-dot { border-color: var(--risk); color: var(--risk); background: var(--risk-soft); box-shadow: none; }
.sc-line li.alert .sc-note { color: var(--risk); }
.sc-line li.picked .sc-node { background: var(--page); box-shadow: inset 0 -2px 0 var(--ink); }
.sc-card { display: grid; grid-template-columns: minmax(0, 11fr) minmax(0, 9fr); gap: 0; }
.sc-card.single { grid-template-columns: minmax(0, 1fr); }
.sc-text { padding: 24px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.sc-card.single .sc-text { max-width: 860px; }
.sc-side { padding: 24px; display: grid; gap: 12px; align-content: start; background: var(--page); border-left: 1px solid var(--line); min-width: 0; }
.sc-kicker { font: 500 12px/16px var(--ui); color: var(--muted); }
.sc-kicker.now { color: var(--accent); }
.sc-card h2 { margin: 0; font: 600 22px/28px var(--ui); color: var(--ink); }
.sc-say { margin: 0; font: 400 16px/24px var(--ui); color: var(--ink); max-width: 68ch; }
.sc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-top: 4px; }
.sc-who { margin: 8px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 20px; max-width: 68ch; }
.sc-match { margin: 0; padding: 10px 14px; border-radius: var(--r-control); font: 500 15px/22px var(--ui); }
.sc-match.ok { background: #e7f4ec; color: #125c30; box-shadow: inset 4px 0 0 var(--ok-dot); }
.sc-match.bad { background: var(--risk-soft); color: var(--risk); box-shadow: inset 4px 0 0 var(--risk); }
.sc-doc { display: grid; gap: 10px; padding: 16px 18px; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--panel); min-width: 0; }
.sc-doc-kind { font: 500 12px/16px var(--ui); color: var(--muted); }
.sc-kv { display: grid; grid-template-columns: minmax(96px, max-content) minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.sc-kv dt { color: var(--muted); font-size: 13px; }
.sc-kv dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.sc-quote { margin: 0; padding-left: 12px; border-left: 2px solid var(--warn-dot); color: var(--text); font-size: 13px; line-height: 20px; }
.sc-quote mark { background: #fdeeb5; color: var(--ink); padding: 1px 2px; border-radius: 2px; }
.sc-letter-body { margin: 0; padding: 12px 14px; border-radius: var(--r-small); background: var(--page); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 21px; max-height: 320px; overflow: auto; }
.sc-sub { margin: 4px 0 0; font: 600 14px/20px var(--ui); color: var(--ink); }
.sc-parsed { display: grid; gap: 8px; }
.sc-view { display: grid; gap: 12px; }
.sc-stages table, .sc-text .table-wrap table { font-size: 13px; }
.sc-text .table-wrap td, .sc-side .table-wrap td { padding-block: 10px; }
.sc-side .table-wrap, .sc-text .table-wrap { border: 1px solid var(--line); border-radius: var(--r-control); background: var(--panel); overflow-x: auto; }
.sc-deadline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.sc-deadline label { color: var(--muted); font-size: 13px; flex-basis: 100%; }
.sc-deadline .error { flex-basis: 100%; margin: 0; }
.sc-deadline .error:empty { display: none; }
.sc-deadline input { min-height: 44px; }
.sc-phone { display: grid; gap: 10px; max-width: 340px; padding: 14px; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--panel); }
.sc-phone .task { border-color: var(--line-strong); }
.sc-fake { display: grid; place-items: center; margin-top: 8px; pointer-events: none; }
.sc-papers { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.sc-paper { display: grid; gap: 2px; align-content: start; padding: 14px 20px; background: var(--panel); box-shadow: inset 0 3px 0 transparent; min-width: 0; }
.sc-paper strong { font: 600 14px/20px var(--ui); color: var(--ink); }
.sc-paper span { color: var(--muted); font-size: 13px; line-height: 18px; overflow-wrap: anywhere; }
.sc-paper.ok { box-shadow: inset 0 3px 0 var(--ok-dot); }
.sc-paper.ok span { color: var(--text); }
.sc-paper.warn { box-shadow: inset 0 3px 0 var(--warn-dot); }
.sc-paper .text-button { justify-self: start; margin-top: 4px; }
.sc-title { margin: 8px 0 12px; font: 600 16px/24px var(--ui); color: var(--ink); }
.sheet-kv { margin: 12px 0 16px; }
.sheet .sc-quote { font-size: 14px; line-height: 22px; margin-bottom: 14px; }
dialog:has(.sc-view) { width: min(720px, calc(100vw - 24px)); max-width: none; }
@media (max-width: 1100px) {
  .sc-card { grid-template-columns: minmax(0, 1fr); }
  .sc-side { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .sc-head { align-items: stretch; }
  .sc-pick, .sc-pick select { width: 100%; min-width: 0; }
  .sc-head .row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .sc-head .row-actions .btn { width: 100%; padding-inline: 8px; }
  .sc-scheme { padding: 12px 4px 40px; }
  .sc-node { padding: 6px 0; }
  .sc-node .sc-name, .sc-node .sc-note { display: none; }
  .sc-line li.picked .sc-node { background: none; box-shadow: none; }
  .sc-line li.picked .sc-dot { outline: 2px solid var(--ink); outline-offset: 2px; }
  .sc-line li.picked .sc-name { display: block; position: absolute; top: 46px; left: 50%; transform: translateX(-50%); white-space: nowrap; color: var(--ink); font-weight: 600; margin: 0; }
  .sc-line li.picked:nth-child(-n+2) .sc-name { left: 4px; transform: none; }
  .sc-line li.picked:nth-last-child(-n+2) .sc-name { left: auto; right: 4px; transform: none; }
  .sc-line li + li::before { top: 21px; right: calc(50% + 18px); width: calc(100% - 36px); }
  .sc-dot { width: 30px; height: 30px; }
  .sc-text, .sc-side { padding: 16px; }
  .sc-card h2 { font-size: 20px; line-height: 26px; }
  .sc-actions .btn.large { width: 100%; min-height: 48px; }
  .sc-deadline input, .sc-deadline .btn { width: 100%; }
  .sc-kv { grid-template-columns: minmax(84px, max-content) minmax(0, 1fr); gap: 4px 12px; }
  .sc-papers { grid-template-columns: 1fr 1fr; }
  .sc-paper { padding: 12px 14px; }
}
@media print {
  .sc-quote mark { background: none; font-weight: 600; }
}

/* ---------- План работ и проверка заявки (plan.js) ---------- */
/* Цепочка — список по порядку: что, кто, к какому сроку. Срок стоит справа крупно, его ищут глазами первым. */
.pl { display: grid; gap: 12px; min-width: 0; }
.pl.busy .pl-list { opacity: 0.55; }
.pl-panel { display: grid; gap: 14px; }
.pl-head { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 12px; align-items: stretch; }
.pl-due { display: grid; gap: 4px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--panel); }
.pl-due input { min-height: 36px; border: 0; padding: 0; font: 600 17px/24px var(--ui); color: var(--ink); background: none; width: 100%; }
.pl-due input:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 2px; }
.pl-plate { display: grid; gap: 2px; align-content: center; padding: 10px 14px; border-radius: var(--r-control); border: 1px solid transparent; }
.pl-plate strong { font: 600 15px/22px var(--ui); color: var(--ink); }
.pl-plate span { font-size: 13px; line-height: 18px; color: var(--text); }
.pl-plate.ok { background: #e9f6ee; border-color: #b9dfc6; }
.pl-plate.warn { background: var(--warn-soft); border-color: #e9cf9c; }
.pl-plate.bad { background: var(--risk-soft); border-color: #f0c2bd; }
.pl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pl-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 4px 14px; align-items: center; padding: 10px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--panel); min-width: 0; }
.pl-row.locked, .pl-row.fixed { grid-template-columns: minmax(0, 1fr) auto; }
.pl-row.locked { background: var(--raised); border-color: var(--line); }
.pl-row.locked .pl-main strong, .pl-row.locked .pl-when strong { color: var(--text); font-weight: 500; }
.pl-row.fixed { background: var(--raised); }
.pl-row.custom { border-color: var(--accent); background: var(--accent-soft); }
.pl-row.pinned .pl-when small { color: var(--warn); font-weight: 500; }
.pl-row.dragging { opacity: 0.4; }
.pl-row.over { box-shadow: 0 -3px 0 var(--accent); }
.pl-handle { color: var(--muted); font-size: 18px; line-height: 20px; cursor: grab; user-select: none; }
.pl-main, .pl-when { display: grid; gap: 1px; min-width: 0; }
.pl-main strong { font: 600 15px/21px var(--ui); color: var(--ink); overflow-wrap: anywhere; }
.pl-main small, .pl-when small { color: var(--muted); font-size: 13px; line-height: 18px; }
.pl-when { text-align: right; white-space: nowrap; }
.pl-when strong { font: 600 15px/21px var(--ui); color: var(--ink); }
.pl-tools { display: flex; gap: 6px; align-items: center; }
.pl-tools .btn.small { min-width: 34px; }
.pl-foot { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.pl-add { border-style: dashed; }
.pl-save { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: flex-end; padding: 12px 14px; border-radius: var(--r-control); background: var(--warn-soft); }
.pl-save[hidden] { display: none; }
.pl-save .muted { margin-right: auto; color: var(--warn); }
.pl-hint { margin: 0; font-size: 13px; }
.pl-notice { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: var(--r-control);
  background: var(--risk-soft); border: 1px solid #f0c2bd; }
.pl-notice p { margin: 0; color: var(--ink); flex: 1 1 280px; }

/* Проверка заявки: слева три блока сверху вниз, справа письмо для сверки, внизу сумма и одна главная кнопка. */
.ck { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: 16px; align-items: start; }
.ck-main { display: grid; gap: 16px; min-width: 0; }
.ck-main > .sc-match { margin: 0; }
.ck-side { position: sticky; top: 72px; min-width: 0; }
.ck-letter summary { cursor: pointer; padding: 10px 2px; font: 600 14px/20px var(--ui); color: var(--ink); }
.ck-letter .sc-letter-body { max-height: 56vh; }
.ck-stop { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; justify-content: space-between; padding: 18px 20px; box-shadow: inset 4px 0 0 var(--risk); }
.ck-stop .lead-text { margin: 4px 0 0; }
.ck-check input, .ck-check select { border-color: var(--warn-dot); background: var(--warn-soft); }
.ck-check label::after { content: ' · проверьте'; color: var(--warn); font-weight: 500; }
.ck-rate { display: grid; grid-template-columns: minmax(200px, 280px) auto minmax(0, 1fr); gap: 12px 16px; align-items: end; }
.ck-rate .field { margin: 0; }
.ck-total { display: grid; gap: 1px; justify-items: end; text-align: right; }
.ck-total strong { font: 600 22px/28px var(--ui); color: var(--ink); }
.ck-total small { color: var(--muted); font-size: 13px; max-width: 46ch; }
.ck-bar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-top: 16px; padding: 12px 16px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r-card); box-shadow: 0 -6px 18px rgba(22, 24, 27, 0.08); }
.ck-bar-words { display: grid; gap: 1px; margin-right: auto; min-width: 0; }
.ck-bar-words strong { font: 600 16px/22px var(--ui); color: var(--ink); }
.ck-bar-words small { color: var(--muted); font-size: 13px; line-height: 18px; }
@media (max-width: 1100px) {
  .ck { grid-template-columns: minmax(0, 1fr); }
  .ck-side { position: static; order: -1; }
}
@media (max-width: 720px) {
  .pl-head { grid-template-columns: minmax(0, 1fr); }
  .pl-row { grid-template-columns: auto minmax(0, 1fr) auto; padding: 10px 12px; }
  .pl-row.locked, .pl-row.fixed { grid-template-columns: minmax(0, 1fr) auto; }
  .pl-tools { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
  .pl-tools .btn.small { min-height: 40px; min-width: 44px; }
  .pl-handle { display: none; }
  .pl-row:not(.locked):not(.fixed) { grid-template-columns: minmax(0, 1fr) auto; }
  .pl-save { justify-content: stretch; }
  .pl-save .btn { flex: 1 1 140px; min-height: 44px; }
  .ck-rate { grid-template-columns: minmax(0, 1fr); }
  .ck-total { justify-items: start; text-align: left; }
  .ck-bar { margin-inline: -4px; border-radius: var(--r-control); }
  .ck-bar .btn.large { width: 100%; min-height: 48px; }
  .ck-stop .btn.large { width: 100%; }
}

.pl-forecast {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}
.pl-forecast p { margin: 0; }
.pl-forecast-dates {
  display: grid;
  gap: 12px 24px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}
.pl-forecast-dates > div { display: grid; gap: 4px; }

.task-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
}
.task-filters input {
  flex: 1 0 220px;
  min-width: 0;
}
.task-match-count {
  margin: 0;
  padding: 6px 16px 12px;
  color: var(--muted);
}

.file-viewer { max-width: min(36rem, 92vw); padding: 24px; }
.file-viewer h2 { margin: 0 0 1rem; overflow-wrap: anywhere; }
.file-viewer a, .file-viewer button { margin: 0 12px 8px 0; }
.response-window .section-head { background: #edf3fa; border-inline-start: 4px solid #356597; }
.shipment-stages .section-head { background: #e9f3ef; border-inline-start: 4px solid #297359; }
.response-window td:nth-child(2), .shipment-stages .current-stage td:first-child { font-weight: 650; }
.shipment-stages .current-stage td { background: #eaf3ef; }
.shipment-stages .row-risk.current-stage td { background: #fff4df; }
.shipment-stages .row-late.current-stage td { background: #fff0ec; }
.order-actions .btn.danger { margin-inline-start: auto; }

.position-card{margin:0 0 12px;padding:12px 16px;border:1px solid var(--line,#d9dce1);border-radius:8px;min-width:0}
.position-card legend{padding:0 6px;font-weight:600}
.position-fields{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(140px,100%),1fr));gap:10px}
.position-fields input,.position-fields select{width:100%;box-sizing:border-box}
.position-card>.text-button{margin-top:8px}

.readiness-choices,.management-metrics{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.55rem;padding:.8rem 1.1rem}
.management-metrics{grid-template-columns:repeat(auto-fit,minmax(10.5rem,1fr))}
.readiness-choice,.management-metric{border:1px solid var(--line,#d0d5dc);border-radius:8px;background:var(--panel,#fff);color:inherit;padding:.75rem .85rem;text-align:left;cursor:pointer;font:inherit;display:flex;flex-direction:column;gap:.3rem;overflow-wrap:anywhere}
.management-metric strong{font-size:1.45rem;line-height:1.15}
.readiness-choice[aria-pressed="true"],.management-metric[aria-pressed="true"]{border-color:var(--accent,#2463ad);box-shadow:inset 3px 0 var(--accent,#2463ad)}
.readiness-detail,.management-list{padding:.5rem 1.1rem 1rem}.readiness-detail{display:grid;gap:.45rem}.management-list .table-wrap{max-height:29rem;overflow:auto}
.registry-menu>div{padding:.4rem 0}.registry-menu summary{cursor:pointer}
@media(max-width:680px){.readiness-choices{grid-template-columns:1fr}.management-metrics{grid-template-columns:repeat(2,minmax(0,1fr));padding:.6rem}.readiness-choice{flex-direction:row;justify-content:space-between;gap:.5rem}}

/* Terminal pickup register and the assigned driver's mobile trip. */
.road-title,.road-item {display:flex; align-items:center; gap:.8rem; flex-wrap:wrap}
.road-title {justify-content:space-between; margin-bottom:1.25rem}
.road-card {padding:1.1rem 1.25rem; margin:.8rem 0}
.road-card h2 {margin:0 0 1rem}
.road-filter {margin-bottom:1rem}
.road-item {padding:.65rem 0; border-bottom:1px solid #d9dde2}
.road-item strong {min-width:min(17rem,100%)}
.road-item:last-child {border-bottom:0}
.road-pin,.road-warning,.road-next {display:block; padding:.6rem .8rem; margin:.5rem 0}
.road-warning {background:#fff0ec; color:#962e21; border-left:3px solid #a53726}
.road-stopped td {background:#fff8f7}
.road-next,.road-pin {background:#edf3f8; color:#253a4b}
.road-table {width:100%; min-width:850px}
.road-table small {display:block}
.road-preview img {display:block; max-width:100%; max-height:65vh; object-fit:contain}
.road-card button {margin:.22rem}
