:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #17202a;
  --muted: #6b7280;
  --border: #d9dee6;
  --primary: #1457d9;
  --primary-dark: #0f42a6;
  --danger: #b42318;
  --table-row-height: 32px;
  --table-header-height: 40px;
  --category-tabs-height: 28px;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

input,
select,
button,
.button {
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  padding: 9px 12px;
}

input,
select {
  background: #fff;
  width: 100%;
}

button,
.button {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button:hover,
.button:hover {
  background: var(--primary-dark);
  color: #fff;
}

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

.secondary:hover {
  background: #eef4ff;
  color: var(--primary-dark);
}

.topbar {
  background: #111827;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 58px;
  padding: 0 22px;
}

.topbar a {
  color: #fff;
}

.topbar nav {
  display: flex;
  flex: 1;
  gap: 14px;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

/* Плавающая «таблетка» со счётчиком выделенных строк — как сводка в углу
   Google Таблиц: закреплена на экране, поверх таблицы, справа снизу. */
.selection-counter {
  align-items: center;
  background: #fff;
  border: 1px solid #d2e3fc;
  border-radius: 999px;
  bottom: 28px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18);
  color: #1967d2;
  display: inline-flex;
  font-size: 0.875rem;
  font-weight: 600;
  gap: 4px;
  padding: 6px 6px 6px 14px;
  position: fixed;
  right: 24px;
  white-space: nowrap;
  z-index: 40;
}

.selection-counter[hidden] {
  display: none;
}

.selection-counter-clear {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: #1967d2;
  cursor: pointer;
  font-size: 16px;
  height: 22px;
  line-height: 1;
  padding: 0;
  width: 22px;
}

.selection-counter-clear .material-symbols-outlined {
  font-size: 18px;
  vertical-align: middle;
}

.selection-counter-clear:hover {
  background: #e8f0fe;
}

.topbar-logout-form {
  flex-shrink: 0;
  margin: 0;
}

/* Часы в шапке: один индикатор + меню выбора точки отсчёта «на сегодня». */
.tz-clock {
  position: relative;
  flex-shrink: 0;
}
.tz-toggle {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.05;
  background: #22406e;
  border: 1px solid #3f6098;
  border-radius: 8px;
  padding: 4px 10px;
  color: #fff;
  cursor: pointer;
  font-family: Roboto, system-ui, sans-serif;
}
.tz-toggle:hover {
  background: #2a4d82;
  border-color: #4f74ad;
}
.tz-toggle:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}
.tz-toggle[aria-expanded="true"] {
  background: #2a4d82;
  border-color: rgba(255, 255, 255, 0.55);
}
.tz-toggle .tz-name {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #a9c6ee;
}
.tz-toggle .tz-name::after {
  content: " · отсчёт";
  color: #7fd1a0;
}
/* Переключатель клиента (суперадмин/демо) — та же плашка, без пометки «· отсчёт». */
.client-switch .tz-toggle .tz-name::after {
  content: none;
}
.client-switch form {
  margin: 0;
}
.client-switch a.tz-option {
  /* Ссылка в меню — цвет пункта меню, а не светлый цвет ссылок шапки. */
  color: #1f2733;
  text-decoration: none;
}
.tz-toggle .tz-time {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.tz-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #fff;
  color: #1f2733;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}
.tz-menu[hidden] {
  display: none;
}
.tz-menu-title {
  font-weight: 600;
  font-size: 0.9rem;
}
.tz-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #f5f7fb;
  color: #1f2733;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-family: Roboto, system-ui, sans-serif;
}
.tz-option:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.tz-option.is-active {
  background: #eef3fe;
  border-color: var(--primary);
}
.tz-option-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tz-option-name {
  font-size: 0.85rem;
  font-weight: 600;
}
.tz-option-time {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: #5b6573;
}
.tz-option.is-active .tz-option-time {
  color: var(--primary-dark);
}
.tz-option-mark {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #1f7a4d;
}
.tz-option-mark[hidden] {
  display: none;
}
@media (max-width: 760px) {
  .tz-toggle .tz-name { display: none; }
}

/* Переключатель языка заголовков общей таблицы. Стоит слева от часов и повторяет
   их геометрию и цвета, чтобы шапка читалась одной группой контролов. */
.lang-switch {
  position: relative;
  flex-shrink: 0;
}
.lang-toggle {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.05;
  background: #22406e;
  border: 1px solid #3f6098;
  border-radius: 8px;
  padding: 4px 10px;
  color: #fff;
  cursor: pointer;
  font-family: Roboto, system-ui, sans-serif;
}
.lang-toggle:hover {
  background: #2a4d82;
  border-color: #4f74ad;
}
.lang-toggle:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}
.lang-toggle[aria-expanded="true"] {
  background: #2a4d82;
  border-color: rgba(255, 255, 255, 0.55);
}
.lang-switch-caption {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #a9c6ee;
}
.lang-switch-current {
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}
.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #fff;
  color: #1f2733;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}
.lang-menu[hidden] {
  display: none;
}
.lang-menu-title {
  font-weight: 600;
  font-size: 0.9rem;
}
.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #f5f7fb;
  color: #1f2733;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-family: Roboto, system-ui, sans-serif;
}
.lang-option:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.lang-option.is-active {
  background: #eef3fe;
  border-color: var(--primary);
}
.lang-option-name {
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 0;
}
.lang-option-mark {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #1f7a4d;
}
.lang-option-mark[hidden] {
  display: none;
}
.lang-menu-hint {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: #5b6573;
}
@media (max-width: 760px) {
  .lang-switch-caption { display: none; }
}

/* Текст заголовка колонки. В режиме «два языка» он вдвое длиннее, поэтому режем
   многоточием по ширине колонки — полный текст скрипт кладёт в title. */
.th-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mui-button {
  align-items: center;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  font-family: Roboto, system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  gap: 6px;
  letter-spacing: 0.02857em;
  line-height: 1.75;
  min-height: 36px;
  padding: 6px 16px;
  text-transform: none;
  transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 250ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.mui-button .material-symbols-outlined {
  font-size: 20px;
  line-height: 1;
}

.mui-button-outlined {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
}

.mui-button-outlined:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: #fff;
  color: #fff;
}

.mui-button-outlined:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}

.mui-button-icon {
  justify-content: center;
  min-width: 40px;
  padding: 8px;
  width: 40px;
}

.topbar .mui-button-icon {
  text-decoration: none;
}

.brand-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.1;
}

/* Вся область бренда (логотип + версия + дата) кликабельна — открывает «Что нового». */
.brand-clickable {
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 8px;
  margin: -4px -8px;
}

.brand-clickable:hover {
  background: rgba(255, 255, 255, 0.08);
}

.brand-clickable:hover .brand-version {
  color: #93c5fd;
  text-decoration: underline;
}

.brand-clickable:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

.brand {
  font-size: 20px;
  font-weight: 700;
}

.brand-version {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.2px;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.brand-version:hover {
  color: #2563eb;
  text-decoration: underline;
}

.changelog-modal {
  max-width: 720px;
  width: min(720px, 100%);
}

.changelog-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.changelog-main {
  flex: 1 1 auto;
  min-width: 0;
}

.changelog-versions {
  flex: 0 0 148px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 1px solid var(--border, #e5e7eb);
  padding-left: 16px;
}

.changelog-versions-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #6b7280;
  margin-bottom: 4px;
}

.changelog-version-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
}

.changelog-version-item:hover {
  background: #f3f4f6;
}

.changelog-version-item.is-active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.changelog-version-item .cv-num {
  font-weight: 600;
  font-size: 13px;
  color: #111827;
}

.changelog-version-item .cv-date {
  font-size: 11px;
  color: #6b7280;
}

.changelog-date {
  color: #6b7280;
  font-size: 12px;
  margin: 0 0 14px;
}

@media (max-width: 620px) {
  .changelog-layout {
    flex-direction: column;
  }
  .changelog-versions {
    position: static;
    flex: none;
    width: 100%;
    border-left: 0;
    padding-left: 0;
    border-top: 1px solid var(--border, #e5e7eb);
    padding-top: 12px;
    margin-top: 4px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  .changelog-versions-title {
    width: 100%;
    margin-bottom: 0;
  }
}

.changelog-body p {
  margin: 0 0 10px;
  line-height: 1.5;
}

.changelog-body h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 18px 0 8px;
}

.changelog-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

.changelog-list li {
  line-height: 1.5;
}

.changelog-wagons {
  font-family: 'Roboto Mono', ui-monospace, monospace;
  font-size: 13px;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.8;
  word-spacing: 2px;
}

.brand-version-date {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.2px;
}

.link-button {
  background: transparent;
  border: 0;
  padding: 0;
}

.container {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

.container.table-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 58px);
  max-width: none;
  min-height: 0;
  padding: 6px 10px 10px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  margin-bottom: 22px;
  padding: 18px;
}

.narrow {
  max-width: 480px;
  margin: 60px auto;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.table-title {
  margin-bottom: 10px;
}

.table-title h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

.table-title p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.mapping-column-picker {
  position: relative;
}

.mapping-picker-button {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
  justify-content: space-between;
  line-height: 1.35;
  min-height: 41px;
  text-align: left;
  width: 100%;
}

.mapping-picker-button::after {
  color: var(--muted);
  content: "▾";
  flex-shrink: 0;
}

.mapping-picker-button:hover {
  background: #fff;
  border-color: var(--primary);
  color: var(--text);
}

.mapping-picker-menu {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.16);
  left: 0;
  max-height: 340px;
  overflow: hidden;
  padding: 8px;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
}

.mapping-column-search {
  margin-bottom: 8px;
}

.mapping-picker-options {
  display: grid;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.mapping-picker-option {
  background: #fff;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  display: block;
  justify-content: flex-start;
  line-height: 1.35;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}

.mapping-picker-option:hover,
.mapping-picker-option.selected {
  background: #eef4ff;
  color: var(--primary-dark);
}

.mapping-picker-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 10px;
}

.mapping-template-panel {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 12px 0 16px;
  padding: 12px;
}

.mapping-template-panel h3 {
  font-size: 15px;
  margin: 0 0 8px;
}

.mapping-template-panel p {
  margin: 6px 0;
}

.mapping-template-name {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.mapping-template-save-choice {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
}

.mapping-template-save-choice label {
  align-items: center;
  display: flex;
  gap: 8px;
}

.mapping-template-save-choice input[type="radio"] {
  width: auto;
}

.mapping-field-group {
  border-top: 2px solid var(--border);
}

.mapping-group-card {
  border-left: 4px solid var(--mapping-group-accent, var(--accent));
}

.mapping-group-card--repair {
  --mapping-group-accent: #2563eb;
}

.mapping-group-card--condition {
  --mapping-group-accent: #059669;
}

.mapping-group-card--wagon-id {
  --mapping-group-accent: #4f46e5;
}

.mapping-group-card--status-park {
  --mapping-group-accent: #7c3aed;
}

.mapping-group-card--route {
  --mapping-group-accent: #0891b2;
}

.mapping-group-card--dislocation {
  --mapping-group-accent: #0d9488;
}

.mapping-group-card--movement {
  --mapping-group-accent: #ca8a04;
}

.mapping-group-card--cargo {
  --mapping-group-accent: #ea580c;
}

.mapping-group-card--other {
  --mapping-group-accent: #64748b;
}

.mapping-form-meta {
  padding-bottom: 14px;
  padding-top: 14px;
}

.mapping-group-card-desc {
  font-size: 13px;
  margin: 4px 0 0;
}

.mapping-group-card-header {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.mapping-group-card-header h2 {
  margin: 0;
}

.mapping-group-card-count {
  color: var(--muted);
  font-size: 13px;
}

.mapping-fields-table {
  margin-top: 4px;
}

.mapping-save-card {
  padding-bottom: 16px;
  padding-top: 16px;
}

.mapping-save-card .mapping-save-actions {
  margin-top: 0;
}

.mapping-form > .card:last-child {
  margin-bottom: 22px;
}

.mapping-save-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.column-samples {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 6px;
}

.column-samples.empty {
  color: #9ca3af;
}

.dashboard-sources-table {
  table-layout: fixed;
}

.archive-files-table {
  table-layout: fixed;
}

.archive-files-table th:nth-child(2),
.archive-files-table td:nth-child(2) {
  width: 120px;
  white-space: nowrap;
}

.archive-files-table th:nth-child(3),
.archive-files-table td:nth-child(3) {
  width: 190px;
  white-space: nowrap;
}

.dashboard-sources-table .truncate-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-files-table .truncate-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-sources-table th.compact-col,
.dashboard-sources-table td.compact-col {
  text-align: center;
  white-space: nowrap;
  width: 78px;
}

.dashboard-sources-table th.size-col,
.dashboard-sources-table td.size-col {
  text-align: right;
  white-space: nowrap;
  width: 88px;
}

.dashboard-sources-table th.order-col,
.dashboard-sources-table td.order-col {
  text-align: center;
  white-space: nowrap;
  width: 118px;
}

.dashboard-sources-table th.select-col,
.dashboard-sources-table td.select-col {
  text-align: center;
  width: 40px;
}

.dashboard-sources-table .select-col input {
  cursor: pointer;
  width: auto;
}

/* Пока действует сортировка или фильтр, ручной порядок (перетаскивание, ↑/↓) выключен. */
.dashboard-sources-table.is-reorder-locked .source-order-cell > * {
  opacity: 0.35;
  pointer-events: none;
}

.source-order-cell {
  align-items: center;
  display: flex;
  gap: 4px;
  justify-content: center;
}

.source-drag-handle,
.drag-handle {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: grab;
  font-size: 13px;
  letter-spacing: -2px;
  line-height: 1;
  padding: 6px 2px;
  touch-action: none;
  user-select: none;
}

.source-drag-handle:active,
.drag-handle:active {
  cursor: grabbing;
}

.dashboard-sources-table tr.source-row-dragging {
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
  opacity: 0.92;
  position: relative;
  z-index: 2;
}

.dashboard-sources-table tr.source-row-drop-target td {
  box-shadow: inset 0 3px 0 var(--primary);
}

.source-order-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.source-order-actions form {
  margin: 0;
}

.source-order-actions .mini-button {
  min-width: 34px;
  padding: 6px 8px;
}

.dashboard-sources-table th.compact-col,
.dashboard-sources-table td.compact-col,
.dashboard-sources-table th.uploaded-col,
.dashboard-sources-table td.uploaded-col {
  padding-left: 6px;
  padding-right: 6px;
}

.dashboard-sources-table th.tracking-date-col,
.dashboard-sources-table td.tracking-date-col {
  white-space: nowrap;
  width: 148px;
}

.tracking-date-input {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  max-width: 100%;
  padding: 6px 8px;
}

.tracking-date-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.dashboard-sources-table th.uploaded-col,
.dashboard-sources-table td.uploaded-col {
  white-space: nowrap;
  width: 142px;
}

.dashboard-sources-table th.owner-col,
.dashboard-sources-table td.owner-col {
  white-space: nowrap;
  width: 132px;
}

.owner-combo {
  position: relative;
}

.owner-input {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 6px 26px 6px 8px;
  width: 100%;
}

.owner-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.owner-combo-toggle {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 4px;
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
}

.owner-combo-toggle:hover {
  background: #e8eef8;
  color: var(--text);
}

.owner-combo .owner-combo-menu {
  display: none;
  left: 0;
  max-height: 220px;
  min-width: 200px;
  overflow: auto;
  right: auto;
  top: calc(100% + 4px);
  z-index: 30;
}

.dashboard-sources-table .owner-combo-menu.open {
  display: grid;
  gap: 2px;
}

.owner-combo-option {
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  overflow: hidden;
  padding: 7px 8px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.owner-combo-option:hover {
  background: #eef4ff;
  color: var(--text);
}

.owner-combo-option.is-active {
  background: #e8eef8;
  color: var(--text);
  font-weight: 600;
}

.dashboard-sources-table th.actions-col,
.dashboard-sources-table td.actions-col {
  background: #fff;
  position: sticky;
  right: 0;
  width: 152px;
  z-index: 2;
}

.dashboard-sources-table th.actions-col {
  z-index: 3;
}

.source-row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.source-row-actions form {
  margin: 0;
}

.source-row-actions .icon-button {
  text-decoration: none;
}

.source-row-actions .icon-button .material-symbols-outlined {
  font-size: 20px;
  line-height: 1;
}

.alert {
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 8px;
  color: var(--danger);
  margin-bottom: 16px;
  padding: 12px;
}

.duplicate-alert {
  color: #78350f;
  background: #fffbeb;
  border-color: #fde68a;
}

.duplicate-alert p {
  margin: 8px 0 0;
}

.inline-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.inline-actions form {
  margin: 0;
}

.stack {
  display: grid;
  gap: 14px;
}

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

.metric span,
label {
  display: grid;
  gap: 6px;
}

.metric strong {
  display: block;
  font-size: 34px;
  margin-top: 8px;
}

.inline-form,
.actions,
.pagination,
.tabs {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.compact-form {
  margin-bottom: 0;
}

.compact-form label {
  align-items: center;
  display: flex;
  gap: 8px;
}

.compact-form select {
  min-width: 140px;
}

.filters {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  align-items: end;
}

.small-input {
  max-width: 90px;
}

.table-card {
  overflow: auto;
  max-height: 70vh;
}

.table-container .table-card {
  overscroll-behavior-y: contain;
}

.table-container .table-shell {
  display: grid;
  flex: 1;
  gap: 6px;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.horizontal-scrollbar-shell {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.top-scrollbar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 18px;
  overflow-x: auto;
  overflow-y: hidden;
}

.top-scrollbar-track {
  height: 1px;
  min-width: 100%;
}

.scroll-step-button {
  background: #fff;
  border-color: var(--border);
  color: var(--primary);
  font-size: 18px;
  height: 18px;
  line-height: 1;
  min-width: 28px;
  padding: 0 8px;
}

.scroll-step-button:hover {
  background: #eef4ff;
  color: var(--primary-dark);
}

.table-container .full-table {
  border-radius: 10px;
  height: 100%;
  margin-bottom: 0;
  max-height: none;
  min-height: 0;
  padding: 0;
}

.data-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: max-content;
  table-layout: auto;
}

.data-table th,
.data-table td {
  background: #fff;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  max-width: 280px;
  min-width: 130px;
  padding: 6px 8px;
  white-space: nowrap;
}

.data-table th[data-field-id],
.data-table td[data-field-id],
.data-table th[data-column-key],
.data-table td[data-column-key] {
  max-width: none;
  min-width: 0;
}

.data-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table th {
  background: #f8fafc;
  overflow: visible;
  top: 0;
  z-index: 3;
}

.data-table tbody tr {
  height: var(--table-row-height);
}

.data-table tbody td {
  box-sizing: border-box;
  height: var(--table-row-height);
  max-height: var(--table-row-height);
  padding-bottom: 4px;
  padding-top: 4px;
  vertical-align: middle;
}

.data-table tbody tr:hover td {
  background: #f8fbff;
}

.data-table tbody tr.lazy-spacer-row {
  height: auto;
}

.data-table tbody tr.lazy-spacer-row td {
  border: 0;
  height: auto;
  max-height: none;
  padding: 0;
}

.data-table tbody tr.lazy-spacer-row:hover td {
  background: transparent;
}

/* Колонка «Инструкция» всегда есть в разметке — кнопка в тулбаре только прячет её,
   чтобы не перерисовывать таблицу целиком ради одной колонки. */
.data-table.instruction-column-hidden [data-column-role="instruction"] {
  display: none;
}

.operation-cell {
  cursor: help;
  text-decoration: underline dotted #94a3b8;
  text-underline-offset: 3px;
}

.instruction-cell {
  padding-left: 6px;
  padding-right: 6px;
}

.instruction-select {
  width: 100%;
  min-width: 0;
  padding: 2px 4px;
  border-radius: 6px;
  background: #fff;
  font-size: 0.92rem;
}

.instruction-select:disabled {
  opacity: 0.7;
}

.data-table tbody td[data-column-key="source"] {
  background: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table th.row-col {
  min-width: 0;
}

.sheet-row-number {
  background: #f1f5f9 !important;
  color: #64748b;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  left: 0;
  line-height: 1.1;
  min-width: 54px !important;
  padding: 4px 2px;
  position: sticky;
  text-align: center;
  width: 54px !important;
  z-index: 5;
}

tbody .sheet-row-number {
  font-weight: 600;
  z-index: 3;
}

/* Выделение строк по колонке номеров. Скоуп row-select-enabled вешает JS
   только на /table, чтобы не задеть таблицы вагонов и источников. */
.data-table.row-select-enabled tbody td.sheet-row-number {
  cursor: pointer;
  user-select: none;
}

.data-table.row-select-enabled th.sheet-corner {
  cursor: pointer;
}

.data-table.is-row-dragging {
  user-select: none;
}

/* !important — иначе не перебить фон .sheet-row-number и правило hover. */
.data-table tbody tr.is-row-selected td {
  background: #e8f0fe !important;
}

.data-table tbody tr.is-row-selected td.sheet-row-number {
  background: #d2e3fc !important;
  color: #1967d2;
}

.data-table th.sheet-corner {
  height: var(--table-header-height);
  left: 0;
  padding: 0 2px 4px;
  position: sticky;
  top: 0;
  vertical-align: bottom;
  z-index: 6;
}

.data-table--category-tabs thead {
  position: sticky;
  top: 0;
  z-index: 6;
}

.data-table--category-tabs thead th {
  position: relative;
  top: auto;
  z-index: auto;
}

.data-table--category-tabs thead .category-tabs-row th {
  background: #e8eaed;
  border-bottom: none;
  padding: 0;
  vertical-align: bottom;
}

.data-table--category-tabs .category-tab-corner {
  background: #e8eaed !important;
  left: 0;
  position: sticky;
  top: auto;
  vertical-align: bottom;
  z-index: 8;
}

.data-table--category-tabs .category-tab-gutter {
  background: #e8eaed !important;
  border-bottom: none;
  max-width: none;
  min-width: 0;
  padding: 0;
  width: auto;
}

.data-table--category-tabs .category-tab {
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  box-shadow: none;
  color: #3c4043;
  cursor: grab;
  font-size: 12px;
  font-weight: 500;
  height: 28px;
  line-height: 28px;
  max-width: none;
  min-width: 0;
  padding: 0 14px;
  text-align: left;
  vertical-align: bottom;
  white-space: nowrap;
}

.data-table--category-tabs .category-tab.dragging {
  cursor: grabbing;
  opacity: 0.85;
}

.data-table--category-tabs .category-tab-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table--category-tabs .category-tab--wagon-id {
  --category-tab-accent: #4f46e5;
}

.data-table--category-tabs .category-tab--status-park {
  --category-tab-accent: #7c3aed;
}

.data-table--category-tabs .category-tab--route {
  --category-tab-accent: #0891b2;
}

.data-table--category-tabs .category-tab--dislocation {
  --category-tab-accent: #0d9488;
}

.data-table--category-tabs .category-tab--movement {
  --category-tab-accent: #ca8a04;
}

.data-table--category-tabs .category-tab--cargo {
  --category-tab-accent: #ea580c;
}

.data-table--category-tabs .category-tab--repair {
  --category-tab-accent: #2563eb;
}

.data-table--category-tabs .category-tab--condition {
  --category-tab-accent: #059669;
}

.data-table--category-tabs .category-tab--other {
  --category-tab-accent: #64748b;
}

.data-table--category-tabs .category-tab[class*='category-tab--'] {
  border-bottom: 2px solid var(--category-tab-accent, #94a3b8);
}

.data-table--category-tabs .field-headers-row th {
  background: #f8fafc;
}

.category-bands-toggle-form .mui-button-icon.is-active {
  background: #e8f0fe;
  border-color: #1457d9;
  color: #1457d9;
}

.settings-block-group {
  margin-top: 12px;
}

.settings-block-group h3 {
  font-size: 15px;
  margin: 0;
}

.sheet-corner {
  cursor: help;
}

.sheet-corner-inner {
  align-items: flex-end;
  display: flex;
  height: 100%;
  justify-content: center;
  min-height: 36px;
  width: 100%;
}

.sheet-count-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-col {
  min-width: 76px !important;
  width: 76px;
}

.th-menu {
  position: relative;
}

.th-button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  display: flex;
  font-weight: 650;
  justify-content: space-between;
  line-height: 1.2;
  padding: 5px 6px;
  text-align: left;
  width: 100%;
}

.th-button:hover {
  background: #e8eef8;
  color: var(--text);
}

.drag-handle {
  color: var(--muted);
  cursor: grab;
  font-size: 13px;
  margin-right: 5px;
}

th.dragging {
  opacity: 0.55;
}

.column-menu {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.16);
  display: none;
  left: 0;
  min-width: 240px;
  padding: 10px;
  position: absolute;
  top: calc(100% + 6px);
  z-index: 20;
}

.column-menu.open {
  display: grid;
  gap: 8px;
}

.column-menu.is-floating {
  bottom: auto;
  left: 0;
  max-width: calc(100vw - 16px);
  overflow: auto;
  position: fixed;
  right: auto;
  top: 0;
  z-index: 1000;
}

.column-menu a {
  border-radius: 7px;
  color: var(--text);
  padding: 7px 8px;
}

.column-menu a:hover {
  background: #eef4ff;
}

.column-menu form {
  display: grid;
  gap: 8px;
}

.menu-label {
  color: var(--muted);
  font-size: 13px;
}

.filter-toolbar {
  display: flex;
  gap: 6px;
}

.mini-button {
  font-size: 12px;
  padding: 5px 8px !important;
}

.filter-values {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 2px;
  max-height: 190px;
  overflow: auto;
  padding: 6px;
}

.value-search {
  position: relative;
}

.value-search input {
  padding-right: 26px;
  width: 100%;
}

.value-search-clear {
  align-items: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  font-size: 16px;
  height: 20px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
}

.value-search-clear:hover {
  background: #eef4ff;
  color: var(--text);
}

.filter-values-compact {
  max-height: 132px;
}

.source-tracking-date-filter {
  display: grid;
  gap: 8px;
}

.menu-hint {
  font-size: 13px;
  margin: 0;
}

.tracking-date-option,
button.tracking-date-option {
  align-items: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 6px 8px;
  text-align: left;
  width: 100%;
}

.tracking-date-option:hover,
.tracking-date-option.is-active {
  background: #eef4ff;
}

.tracking-date-option.is-active {
  font-weight: 600;
}

.tracking-date-option small {
  color: var(--muted);
}

.source-tracking-date-picker-wrap {
  position: relative;
}

.source-tracking-date-picker {
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.source-tracking-date-display {
  background: #fff;
  color: var(--text);
  cursor: pointer;
  min-height: 34px;
  padding: 7px 10px;
}

.source-tracking-date-display::placeholder {
  color: var(--muted);
}

.source-tracking-date-open {
  min-width: 38px;
  padding-left: 10px !important;
  padding-right: 10px !important;
}

.source-tracking-date-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stc-popover {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
  left: 0;
  padding: 10px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
}

.stc-popover[hidden] {
  display: none;
}

#source-menu [data-source-tracking-calendar] {
  width: 100%;
}

#source-menu .stc-toolbar {
  align-items: center;
  display: grid;
  gap: 4px;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  margin-bottom: 8px;
}

#source-menu .stc-nav,
#source-menu .stc-title,
#source-menu .stc-day,
#source-menu .stc-month {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  min-height: 32px;
}

#source-menu .stc-nav {
  color: var(--muted);
  font-size: 1.2rem;
  padding: 0;
}

#source-menu .stc-title {
  font-weight: 600;
  padding: 6px 8px;
}

#source-menu .stc-day {
  align-items: center;
  border-color: transparent;
  display: flex;
  justify-content: center;
  min-height: 32px;
  padding: 0;
}

#source-menu .stc-month {
  align-items: center;
  border-color: transparent;
  display: flex;
  justify-content: center;
  padding: 0;
}

#source-menu .stc-day-stack {
  display: inline-block;
  line-height: 1;
  position: relative;
}

#source-menu .stc-day-num {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.2;
}

#source-menu .stc-day-count {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 500;
  left: calc(100% + 1px);
  line-height: 1;
  position: absolute;
  top: -1px;
}

#source-menu .stc-day.has-data .stc-day-num {
  color: var(--primary);
  font-weight: 600;
}

#source-menu .stc-title:hover,
#source-menu .stc-nav:hover,
#source-menu .stc-day:hover,
#source-menu .stc-month:hover {
  background: #f3f7ff;
  border-color: #c9d7f5;
}

#source-menu .stc-weekdays,
#source-menu .stc-days,
#source-menu .stc-months {
  display: grid;
  gap: 2px;
}

#source-menu .stc-weekdays,
#source-menu .stc-days {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

#source-menu .stc-weekday {
  color: var(--muted);
  font-size: 0.78rem;
  padding: 4px 0;
  text-align: center;
}

#source-menu .stc-day--empty {
  background: transparent;
  border: none;
  min-height: 32px;
}

#source-menu .stc-day.is-selected,
#source-menu .stc-month.is-selected,
#source-menu .stc-day.is-anchor {
  background: #dbe7ff;
  border-color: #4c78d4;
  font-weight: 700;
}

#source-menu .stc-day.is-selected .stc-day-num,
#source-menu .stc-day.is-anchor .stc-day-num {
  color: #12336d;
}

#source-menu .stc-day.is-selected .stc-day-count,
#source-menu .stc-day.is-anchor .stc-day-count {
  color: #5b6f94;
}

#source-menu .stc-day.is-in-range,
#source-menu .stc-month.is-in-range {
  background: #eef4ff;
  color: var(--text);
}

#source-menu .stc-months {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#source-menu .stc-hint {
  font-size: 0.78rem;
  line-height: 1.3;
  margin: 6px 0 0;
}

.filter-option.is-source-date-hidden,
.filter-option[hidden] {
  display: none !important;
}

.filter-option {
  align-items: center;
  border-radius: 6px;
  display: grid;
  gap: 6px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 4px 5px;
}

.filter-option:hover {
  background: #f8fbff;
}

.filter-option input {
  width: auto;
}

.filter-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-option small {
  color: var(--muted);
}

.icon-button {
  min-height: 38px;
  min-width: 38px;
  padding: 8px 10px;
}

.modal-backdrop {
  align-items: center;
  background: rgba(15, 23, 42, 0.42);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 24px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 100;
}

.table-container .modal-backdrop {
  align-items: stretch;
  background: var(--bg);
  justify-content: stretch;
  padding: 0;
  top: 58px;
}

/* Модалка настроек внутри .table-container намеренно во весь экран, а диалог
   подтверждения должен остаться обычным центрированным окном. */
.table-container .modal-backdrop.confirm-backdrop {
  align-items: center;
  background: rgba(15, 23, 42, 0.42);
  justify-content: center;
  padding: 24px;
  top: 0;
}

.modal-backdrop[hidden] {
  display: none;
}

.settings-modal {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  max-height: min(720px, calc(100vh - 48px));
  max-width: 720px;
  overflow: auto;
  padding: 16px;
  width: min(720px, 100%);
}

.table-container .settings-modal {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: none;
  max-width: none;
  overflow: hidden;
  padding: 12px 14px 14px;
  width: 100%;
}

.confirm-modal {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  display: grid;
  gap: 12px;
  max-width: 420px;
  padding: 20px;
  width: min(420px, 100%);
}

.confirm-modal h2 {
  font-size: 17px;
  margin: 0;
}

.confirm-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.confirm-modal-warning {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
  padding: 8px 10px;
}

.confirm-modal-warning[hidden] {
  display: none;
}

.settings-modal-header {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.settings-modal-header h2 {
  font-size: 18px;
  margin: 0;
}

.table-settings-form {
  display: grid;
  gap: 14px;
}

.table-container .table-settings-form {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.settings-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
}

.table-container .settings-block-compact {
  flex-shrink: 0;
}

.table-container .settings-block-fields {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.table-container .settings-block-group {
  flex: 0 0 auto;
}

.table-container .settings-block-group .settings-field-list {
  flex: none;
}

.settings-block-title {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.settings-block-title h2 {
  font-size: 16px;
  margin: 0;
}

.settings-hint {
  font-size: 13px;
  margin: 0;
}

.settings-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
}

.table-container .settings-system-list {
  max-height: none;
}

.table-container .settings-field-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  max-height: none;
  min-height: 0;
  width: 100%;
}

.table-container .settings-field-list .settings-field-row {
  align-items: center;
  border-radius: 7px;
  box-sizing: border-box;
  column-gap: 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 32px;
  padding: 4px 0 4px 4px;
  width: 100%;
}

.settings-field-name {
  display: block;
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-field-toggle {
  align-items: center;
  display: flex;
  grid-column: 3;
  justify-content: flex-end;
  justify-self: end;
  width: 32px;
}

.settings-field-toggle input {
  flex-shrink: 0;
  margin: 0;
  width: auto;
}

.settings-option {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr);
}

.settings-option input {
  width: auto;
}

.settings-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-field-row.settings-field-row-dragging {
  background: #fff;
  border-radius: 7px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
  opacity: 0.92;
  position: relative;
  z-index: 2;
}

.settings-field-row.settings-field-row-drop-target {
  box-shadow: inset 0 3px 0 var(--primary);
}

.settings-row-order {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 2px;
  grid-column: 1;
}

.settings-row-order .mini-button {
  min-width: 30px;
  padding: 6px 6px;
}

.settings-field-row:hover {
  background: #f8fbff;
}

.settings-option:hover {
  background: #f8fbff;
}

.settings-move-actions,
.settings-actions {
  align-items: center;
  display: flex;
  gap: 6px;
}

.settings-actions {
  flex-wrap: wrap;
}

.table-container .settings-actions {
  flex-shrink: 0;
}

.upload-order {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.upload-order ol {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 24px;
}

.upload-order-item {
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.upload-order-item,
.upload-order-actions {
  display: flex;
}

.upload-order-actions {
  gap: 6px;
}

.column-menu button {
  padding: 7px 10px;
}

code {
  background: #f1f5f9;
  border-radius: 6px;
  padding: 2px 5px;
}

.resize-handle {
  bottom: 0;
  cursor: col-resize;
  position: absolute;
  right: -4px;
  top: 0;
  width: 8px;
  z-index: 30;
}

.resize-handle:hover {
  background: rgba(20, 87, 217, 0.18);
}

/* Период отображения общей таблицы */
.table-period-control {
  position: relative;
  flex-shrink: 0;
}

.mui-button-period {
  width: auto;
  min-width: 40px;
  max-width: 220px;
  padding: 6px 12px;
}

.mui-button-period-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mui-button-period.is-active {
  background: rgba(255, 255, 255, 0.18);
  border-color: #fff;
}

.period-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: 288px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: #fff;
  color: #1f2733;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}

.period-menu[hidden] {
  display: none;
}

.period-menu-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.period-preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.period-preset {
  border: 1px solid var(--border);
  background: #f5f7fb;
  color: #1f2733;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.period-preset:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.period-preset.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.period-custom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}

.period-custom input[type="date"] {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 6px;
  font: inherit;
}

.period-load-more {
  border: 1px solid var(--primary);
  background: #eef3fe;
  color: var(--primary-dark);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.period-load-more:hover {
  background: #e0eafd;
}

.period-search-all {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.period-hint {
  margin: 0;
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.35;
}

.period-hint[hidden] {
  display: none;
}

/* Переключатель справочников (Станции / Дороги) — тот же вид, что вкладки на
   странице оборота и в аудите инструкций. */
.reference-tabs {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  font-size: 13px;
  margin-bottom: 14px;
}

.reference-tabs .ref-tab {
  padding: 6px 18px;
  color: #374151;
  background: #fff;
  text-decoration: none;
  font-weight: 500;
}

.reference-tabs .ref-tab:hover {
  background: #f1f5f9;
}

.reference-tabs .ref-tab.on {
  background: #1f4e78;
  color: #fff;
}

/* Правка справочников (/stations, /roads): модалка формы, поля, ключевые слова
   отдельными строками и блок проверки. Общая для обоих экранов — разметку собирают
   views/stations.ejs и views/roads.ejs, поведение — public/reference-editor.js. */

.ref-modal {
  max-width: 560px;
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
}

.ref-modal .settings-modal-header {
  margin-bottom: 0;
}

.ref-modal form {
  display: grid;
  gap: 12px;
}

.ref-form-row {
  display: grid;
  gap: 4px;
}

.ref-form-row label {
  font-size: 13px;
  font-weight: 600;
}

.ref-form-row input[type="text"],
.ref-form-row select {
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  padding: 7px 10px;
  width: 100%;
}

.ref-code-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

.ref-code-row input[type="text"] {
  font-variant-numeric: tabular-nums;
  max-width: 140px;
}

.ref-code-row [data-station-tr4] {
  text-decoration: none;
  white-space: nowrap;
}

.ref-code-row [data-station-tr4].is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.ref-suggest-head {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.ref-suggest {
  display: grid;
  gap: 6px;
}

.ref-suggest[hidden] {
  display: none;
}

.ref-suggest-item {
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 13px;
  gap: 8px;
  padding: 7px 10px;
  text-align: left;
  width: 100%;
}

.ref-suggest-item:hover {
  background: #f1f5f9;
}

.ref-suggest-item .ref-suggest-code {
  font-variant-numeric: tabular-nums;
}

.ref-suggest-item .ref-suggest-src {
  margin-left: auto;
}

.ref-keys {
  display: grid;
  gap: 6px;
}

.ref-key-row {
  align-items: center;
  display: flex;
  gap: 6px;
}

.ref-key-row input {
  flex: 1;
  min-width: 0;
}

.ref-key-row.is-known input {
  background: #f8fafc;
}

.ref-key-remove {
  color: #b91c1c;
  flex: 0 0 auto;
  font-size: 15px;
  line-height: 1;
  padding: 6px 10px !important;
}

.ref-key-remove:hover {
  background: #fdecea;
  color: #b91c1c;
}

.ref-keys-actions {
  display: flex;
  justify-content: flex-start;
}

.ref-hint {
  font-size: 12px;
  margin: 0;
}

.ref-check {
  border: 1px solid var(--border);
  text-align: left;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 12px;
}

.ref-check[hidden] {
  display: none;
}

.ref-check b {
  display: block;
  margin-bottom: 3px;
}

.ref-check p,
.ref-check ul {
  margin: 6px 0 0;
}

.ref-check ul {
  padding-left: 18px;
}

.ref-check.ok {
  background: #e6f4ea;
  border-color: #b7e0c2;
  color: #1b7f37;
}

.ref-check.warn {
  background: #fff4e5;
  border-color: #f3d9ae;
  color: #8a5300;
}

.ref-check.bad {
  background: #fdecea;
  border-color: #f5c2bd;
  color: #c62828;
}

/* Глобально input {width: 100%} — радиокнопке внутри блока проверки это ломает вид. */
.ref-check input[type="radio"] {
  border: 0;
  border-radius: 0;
  flex: 0 0 auto;
  margin: 1px 0 0;
  padding: 0;
  width: auto;
}

.ref-choice {
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  margin-top: 6px;
  padding: 7px 10px;
  text-align: left;
}

.ref-choice:hover {
  background: #fff;
}

.ref-choice span {
  line-height: 1.35;
}

.stations-table td.st-actions,
.roads-table td.rd-actions {
  text-align: right;
}

.stations-table td.st-road {
  color: #37474f;
}


/* Демо-профиль (backlog/multi-client задача 07). Данные маскирует сервер, правку закрывают
   права маршрутов (403) — здесь только прячем элементы правки, чтобы демо не натыкался на отказы.
   Класс demo-view ставит header.ejs на <body> для роли demo. */
.demo-badge {
  align-self: center;
  background: #fff4e5;
  border: 1px solid #f3d9ae;
  border-radius: 999px;
  color: #8a5300;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  white-space: nowrap;
}

.demo-exit-form {
  align-self: center;
  margin: 0;
}

.demo-view form[action$="/move"],
.demo-view form[action$="/delete"],
.demo-view a[href^="/sources/"][href$="/table"],
.demo-view a[href^="/sources/"][href$="/download"],
.demo-view a[href="/upload"],
.demo-view [data-sources-selection-download],
.demo-view [data-sources-download],
.demo-view [data-owner-combo-toggle],
.demo-view [data-move-field],
.demo-view .resize-handle,
.demo-view form[action="/table/toggle-category-bands"],
.demo-view [data-toggle-instruction-column],
.demo-view [data-period-save-default],
.demo-view [data-view-name],
.demo-view [data-view-save],
.demo-view [data-view-update],
.demo-view [data-view-default],
.demo-view [data-view-delete],
.demo-view [data-revert-day],
.demo-view [data-phase-open],
.demo-view form[action="/wagons/oborot-config"] {
  display: none !important;
}

/* «Инструкция» у демо — просто значение, без выбора. */
.demo-view .instruction-select {
  appearance: none;
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}
