/* Переменные */
:root {
  --color-bg: #f4f6f8;
  --color-panel: #ffffff;
  --color-border: #d3d8dd;
  --color-border-strong: #bdc8d8;
  --color-text: #1d1d1b;
  --color-muted: #797979;
  --color-primary: #1c3e83;
  --color-accent: #fab400;
  --color-danger: #a32929;
  --color-table-border: #d7dde5;
  --color-table-head-bg: #e9f0f8;
  --color-table-head-text: #17356e;
  --color-table-head-border: #9fb0c6;
  --color-table-hover: #dcecff;
  --color-selection-table-hover: #d8eaff;
  --radius-control: 4px;
  --radius-panel: 6px;
  --shadow-tooltip: 0 8px 18px rgba(29, 29, 27, 0.14);
  --shadow-modal: 0 22px 48px rgba(29, 29, 27, 0.2);
  --layout-max-width: 1840px;
}

/* База */
* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  height: 100%;
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

a {
  color: var(--color-primary);
}

/* Каркас страницы */
.page-header {
  flex: 0 0 auto;
  background: var(--color-panel);
  border-bottom: 1px solid var(--color-border);
}

.page-header__inner,
.page-main {
  width: min(var(--layout-max-width), calc(100% - 32px));
  margin: 0 auto;
}

.page-header__inner {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  text-decoration: none;
  color: var(--color-text);
}

.brand__logo {
  display: block;
  flex: 0 0 auto;
  width: 196px;
  height: auto;
  max-height: 68px;
}

.brand__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand__organization {
  overflow: hidden;
  color: var(--color-primary);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand__title {
  overflow: hidden;
  color: var(--color-muted);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-panel {
  display: flex;
  align-items: center;
  max-width: 100%;
  gap: 14px;
  flex-wrap: wrap;
}

.control-panel__body {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.control-panel__group,
.control-panel__session {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.control-panel__session {
  margin-left: 4px;
  padding-left: 18px;
  border-left: 2px solid #c7d0dc;
}

.logout-form {
  display: inline-flex;
  margin: 0;
}

.page-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 0;
}

.page-footer {
  flex: 0 0 auto;
  width: min(var(--layout-max-width), calc(100% - 32px));
  margin: 0 auto;
  padding: 4px 0 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1;
}

.page-footer__copyright {
  opacity: 0.7;
}

.page-footer__copyright a {
  color: inherit;
  text-decoration: none;
}

.page-footer__copyright a:hover,
.page-footer__copyright a:focus-visible {
  color: var(--color-primary);
}

.page-footer__separator {
  opacity: 0.55;
}

.developer-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1;
  text-decoration: none;
  opacity: 0.58;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.developer-link:hover,
.developer-link:focus-visible {
  color: var(--color-primary);
  opacity: 0.9;
}

.developer-link__logo {
  display: block;
  width: 18px;
  height: 29px;
  object-fit: contain;
  transform-origin: center;
  transition: transform 0.16s ease;
}

.developer-link:hover .developer-link__logo,
.developer-link:focus-visible .developer-link__logo {
  transform: scale(1.15);
}

/* Панели и сетки */
.panel {
  flex: 0 0 auto;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  padding: 24px;
}

.panel--compact {
  padding: 14px 16px;
}

.panel--primary {
  border-top: 5px solid var(--color-primary);
}

.panel + .panel {
  margin-top: 20px;
}

.panel--narrow {
  max-width: 760px;
}

.panel h1,
.panel h2 {
  margin: 0 0 18px;
}

.panel--compact h1,
.panel--compact h2 {
  margin-bottom: 10px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
  border-left: 4px solid var(--color-accent);
  padding: 8px 0 8px 14px;
}

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

.metric__value {
  font-size: 22px;
  font-weight: 700;
}

.metric__value--small {
  font-size: 16px;
  overflow-wrap: anywhere;
}

.summary-list {
  margin-top: 20px;
  border-top: 1px solid var(--color-border);
}

.summary-list__row {
  display: grid;
  grid-template-columns: minmax(160px, 240px) minmax(0, 1fr);
  gap: 18px;
  border-bottom: 1px solid var(--color-border);
  padding: 10px 0;
}

.summary-list__row span {
  color: var(--color-muted);
}

.summary-list__row strong {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.summary-list--compact {
  max-width: 760px;
  margin-top: 12px;
}

.summary-list--compact .summary-list__row {
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
  padding: 7px 0;
}

.form-row {
  margin-bottom: 16px;
}

.form-alert-slot {
  min-height: 48px;
  margin-bottom: 12px;
}

.form-alert {
  border: 1px solid #e0b5b5;
  border-left: 4px solid #a32929;
  background: #fff7f7;
  padding: 10px 12px;
  color: #5f1717;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

/* Поля формы */
input,
select {
  width: 100%;
  max-width: 420px;
  min-height: 40px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  padding: 8px 10px;
  font: inherit;
}

textarea {
  width: 100%;
  max-width: 620px;
  min-height: 86px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  padding: 8px 10px;
  font: inherit;
  resize: vertical;
}

.dropzone {
  width: min(620px, 100%);
  min-height: 128px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed var(--color-border);
  background: #fff;
  padding: 20px;
  cursor: pointer;
  text-align: center;
}

.dropzone input {
  width: auto;
  max-width: 100%;
  min-height: auto;
  border: 0;
  padding: 0;
}

.dropzone__title {
  font-weight: 700;
}

.dropzone__meta {
  color: var(--color-muted);
  overflow-wrap: anywhere;
}

.dropzone--selected {
  border-color: var(--color-primary);
  background: #f4f8ff;
}

.dropzone--selected .dropzone__meta {
  max-width: 100%;
  border: 1px solid #c8d6e8;
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--color-text);
  padding: 7px 10px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.dropzone--active {
  border-color: var(--color-primary);
  background: #eef4ff;
}

.dropzone--error {
  border-color: #a32929;
}

.info-note--warning {
  border-color: #e0b44f;
  background: #fff8e7;
  color: #5b4100;
}

.confirmation-control {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.confirmation-control input {
  width: auto;
  min-height: auto;
  margin-top: 3px;
}

/* Кнопки */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-control);
  padding: 6px 12px;
  background: var(--color-primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button:disabled {
  border-color: #b6c0cb;
  background: #d8dee7;
  color: #697584;
  cursor: not-allowed;
}

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

.button--active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text);
}

.button--logout {
  background: transparent;
  border-color: #b8c0ca;
  color: #4f5d6f;
}

.button--logout:hover {
  background: #f3f6fa;
  border-color: #8f9bab;
  color: var(--color-text);
}

.button--wide {
  width: 100%;
  max-width: 420px;
}

.button--small {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}

.button--table {
  min-height: 34px;
  padding: 5px 9px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-control);
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.icon-button--secondary,
.icon-button--ghost {
  background: #fff;
  color: var(--color-primary);
}

.icon-button--ghost {
  border-color: transparent;
}

.icon-button--ghost:hover {
  border-color: var(--color-border);
  background: #f4f8ff;
}

.messages {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.messages li {
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  background: #fff;
  padding: 10px 12px;
}

/* Таблицы */
.table {
  width: 100%;
  border-collapse: collapse;
}

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

.table--compact th,
.table--compact td {
  padding: 6px 8px;
  vertical-align: top;
}

.selection-results-table,
.data-items-table,
.users-table {
  width: 100%;
  table-layout: fixed;
  font-size: 13px;
}

.selection-results-table th,
.selection-results-table td,
.data-items-table th,
.data-items-table td,
.users-table th,
.users-table td {
  border-right: 1px solid var(--color-table-border);
  padding: 6px 8px;
  text-align: center;
  white-space: nowrap;
}

.selection-results-table th:first-child,
.selection-results-table td:first-child,
.data-items-table th:first-child,
.data-items-table td:first-child,
.users-table th:first-child,
.users-table td:first-child {
  border-left: 1px solid var(--color-table-border);
}

.selection-results-table thead th,
.data-items-table thead th,
.users-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--color-table-head-bg);
  border-right: 1px solid var(--color-border-strong);
  border-bottom: 2px solid var(--color-table-head-border);
  color: var(--color-table-head-text);
  font-weight: 700;
}

.data-items-table tbody tr:hover,
.users-table tbody tr:hover {
  background: var(--color-table-hover);
}

/* Подбор */
.selection-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.selection-workspace {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.selection-workspace--with-results {
  flex: 1 1 auto;
  min-height: 0;
}

.selection-workspace__header {
  display: grid;
  grid-template-columns: minmax(620px, 1fr);
  grid-template-areas:
    "form";
  gap: 0;
  align-items: end;
}

.selection-workspace__form {
  grid-area: form;
  min-width: 0;
}

.selection-workspace__form .selection-bar {
  flex-wrap: nowrap;
}

.selection-workspace .selection-results-wrap {
  min-height: 0;
}

.selection-results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -2px 0 0;
}

.selection-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

.selection-summary strong {
  color: var(--color-text);
}

.selection-summary span + span::before {
  content: "·";
  margin-right: 8px;
  color: var(--color-border);
}

.selection-highlight-toggle {
  min-height: 34px;
  white-space: nowrap;
}

.selection-group-filter {
  position: relative;
  min-width: 150px;
}

.selection-field--explosion {
  width: 86px;
  margin-right: 8px;
}

.selection-field--explosion .selection-field__control--checkbox {
  justify-content: center;
  min-height: 34px;
  height: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.selection-field--explosion .selection-field__control--checkbox input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  flex: 0 0 16px;
}

.selection-field--groups {
  min-width: 150px;
}

.selection-field--groups .selection-group-filter {
  width: 100%;
}

.selection-group-filter__button {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--color-text);
  cursor: pointer;
  font: inherit;
  line-height: 1.2;
  padding: 6px 28px 6px 10px;
  position: relative;
  text-align: left;
  white-space: nowrap;
  list-style: none;
}

.selection-group-filter__button::-webkit-details-marker {
  display: none;
}

.selection-group-filter__button::after {
  content: "▾";
  position: absolute;
  right: 10px;
  top: 50%;
  color: var(--color-muted);
  font-size: 11px;
  transform: translateY(-50%);
}

.selection-group-filter[open] .selection-group-filter__button::after {
  content: "▴";
}

.selection-group-filter__menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  right: 0;
  width: max-content;
  min-width: 240px;
  max-width: 320px;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: #fff;
  box-shadow: var(--shadow-tooltip);
  padding: 6px;
}

.selection-group-filter:not([open]) .selection-group-filter__menu {
  display: none;
}

.selection-group-filter__option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  border-radius: var(--radius-control);
  color: var(--color-text);
  cursor: pointer;
  font-size: 13px;
  padding: 5px 7px;
  user-select: none;
}

.selection-group-filter__option:hover {
  background: var(--color-table-hover);
}

.selection-group-filter__option input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.selection-group-filter__option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-group-filter__option--all {
  border-bottom: 1px solid var(--color-border);
  border-radius: var(--radius-control) var(--radius-control) 0 0;
  margin-bottom: 4px;
  padding-bottom: 8px;
}

.selection-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.selection-panel__header h1 {
  flex: 0 0 auto;
  margin: 0;
}

.selection-panel__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.data-freshness {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.25;
}

.data-freshness__item {
  min-width: 0;
}

.data-freshness__item + .data-freshness__item::before {
  content: "·";
  margin-right: 8px;
  color: var(--color-border);
}

.data-freshness--table {
  flex: 0 0 auto;
  margin: 0 0 4px;
}

.data-freshness strong {
  color: var(--color-text);
}

.data-table-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin: 0 0 10px;
}

.data-table-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-muted);
  font-size: 13px;
  font-weight: 700;
}

.data-table-filter select {
  min-width: 220px;
}

.selection-field {
  display: grid;
  gap: 3px;
}

.selection-field label {
  margin: 0;
  color: var(--color-muted);
  font-size: 13px;
}

.selection-field__control {
  display: flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: #fff;
  overflow: hidden;
}

.selection-field__control input {
  width: 96px;
  min-height: 32px;
  border: 0;
  border-radius: 0;
  padding: 5px 9px;
}

.selection-field__control input::-webkit-outer-spin-button,
.selection-field__control input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.selection-field__control input[type="number"] {
  appearance: textfield;
}

.selection-field__control:has(input.is-invalid) {
  border-color: var(--color-danger);
}

.selection-field__control input.is-invalid {
  background: #fff7f7;
}

.selection-field__client-error {
  color: var(--color-danger);
  font-size: 12px;
  line-height: 1.2;
}

/* Загрузки */
.file-documents-panel__top {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.file-documents-panel__summary {
  min-width: 0;
}

.file-documents-panel__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.file-documents-panel__actions .button {
  white-space: nowrap;
}

.file-documents-panel__title {
  margin: 0 0 8px;
  color: var(--color-text);
  font-size: 18px;
  line-height: 1.25;
}

.table-scroll {
  width: 100%;
  min-height: 0;
  overflow: auto;
}

.selection-results-panel,
.file-documents-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.selection-results-panel h2,
.file-documents-panel h2 {
  flex: 0 0 auto;
}

.file-documents-panel__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.file-documents-panel__header h2 {
  margin: 0;
}

.file-documents-panel__header span {
  min-width: 0;
  overflow: hidden;
  color: var(--color-muted);
  font-size: 13px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-documents-tabs {
  gap: 10px;
}

.file-tabs {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.file-tabs__button.is-active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text);
}

.file-tab-panel {
  min-height: 0;
}

.file-tab-panel.is-active {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.file-tab-panel[hidden] {
  display: none;
}

.selection-results-title {
  color: var(--color-text);
  font-size: 18px;
  line-height: 1.25;
}

.selection-results-wrap,
.file-table-scroll {
  flex: 1 1 auto;
}

.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--color-muted);
  font-size: 13px;
  font-weight: 400;
  user-select: none;
}

.toggle-control input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.app-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 320px;
  border: 1px solid #9fb0c6;
  border-radius: var(--radius-control);
  background: #f7f9fc;
  color: #17356e;
  padding: 6px 9px;
  font-size: 12px;
  line-height: 1.25;
  text-align: left;
  pointer-events: none;
  box-shadow: var(--shadow-tooltip);
}

.app-tooltip__line + .app-tooltip__line {
  margin-top: 3px;
}

.selection-results-table {
  min-width: 1547px;
}

.selection-results-table--with-drive-groups {
  min-width: 1657px;
}

.selection-results-table thead th {
  line-height: 1.2;
  vertical-align: middle;
}

.selection-results-table thead button {
  position: relative;
  width: 100%;
  min-height: 28px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  padding: 0 13px 0 0;
  text-align: center;
}

.selection-results-table thead button::after {
  content: "↕";
  position: absolute;
  right: 0;
  top: 50%;
  color: #6d7f98;
  font-size: 11px;
  transform: translateY(-50%);
}

.selection-results-table thead th[aria-sort="ascending"] button::after {
  content: "↑";
  color: var(--color-primary);
}

.selection-results-table thead th[aria-sort="descending"] button::after {
  content: "↓";
  color: var(--color-primary);
}

.table-head-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 3px;
}

.selection-results-table__time-head button {
  padding-right: 13px;
}

.selection-results-table thead th:first-child {
  border-left: 1px solid var(--color-border-strong);
}

.selection-results-table .col-model {
  overflow: hidden;
  text-overflow: ellipsis;
}

.selection-results-table .cell-text {
  text-align: center;
}

.selection-results-table .cell-number {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.selection-results-table .cell-center {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.selection-results-table .cell-time {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.selection-results-table th.cell-text,
.selection-results-table th.cell-number,
.selection-results-table th.cell-center,
.selection-results-table th.cell-time {
  text-align: center;
  vertical-align: middle;
}

.selection-results-table tbody tr {
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.selection-results-table tbody tr:hover {
  background: var(--color-selection-table-hover);
}

.selection-results-table tbody tr:hover td {
  background: var(--color-selection-table-hover) !important;
}

.selection-results-table--recommendation-highlight tbody tr.recommended-row td {
  background: #e2f7e8;
}

.selection-results-table--recommendation-highlight tbody td.price-tier--lowest {
  background: #bfeacb;
  font-weight: 700;
}

.selection-results-table--recommendation-highlight tbody td.price-tier--low {
  background: #d6f1bd;
}

.selection-results-table--recommendation-highlight tbody td.price-tier--medium {
  background: #ffe48a;
}

.selection-results-table--recommendation-highlight tbody td.price-tier--high {
  background: #ffc4b8;
}

.selection-results-table--recommendation-highlight tbody td.recommended-time-cell {
  background: #bfeacb;
  font-weight: 700;
}

.selection-results-table--recommendation-highlight tbody td.best-overall-time-cell {
  background: #ffe48a;
  font-weight: 700;
}

.selection-results-table__row-number {
  width: 50px;
}

.selection-results-table__gearbox {
  width: 230px;
}

.selection-results-table__ratio {
  width: 140px;
}

.selection-results-table__drive-group {
  width: 110px;
}

.selection-results-table__drive {
  width: auto;
}

.selection-results-table__explosion {
  width: 135px;
}

.selection-results-table__torque {
  width: 170px;
}

.selection-results-table__margin {
  width: 90px;
}

.selection-results-table__time {
  width: 112px;
}

.selection-results-table__time-margin {
  width: 115px;
}

.selection-results-table__price {
  width: 110px;
}

.selection-results-table__price:last-child {
  width: 125px;
}

.data-items-table {
  min-width: 1030px;
  border-collapse: separate;
  border-spacing: 0;
}

.data-items-table__col-row-number {
  width: 50px;
}

.data-items-table__col-model {
  width: 280px;
}

.data-items-table__col-ratios {
  width: 260px;
}

.data-items-table__col-number,
.data-items-table__col-price {
  width: 140px;
}

.data-items-table__col-flag {
  width: 130px;
}

.data-items-table__col-note {
  width: 320px;
}

.data-items-table th,
.data-items-table td {
  height: 34px;
  line-height: 1.25;
  vertical-align: middle;
  overflow: hidden;
}

.data-items-table__name,
.data-items-table__note {
  text-align: left;
  text-overflow: ellipsis;
}

.data-items-table__group-row td {
  background: #f3f6fa;
  color: var(--color-table-head-text);
  font-weight: 800;
  text-align: left;
}

.row-number-cell {
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: center;
}

/* Админка */
.admin-users-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.admin-users-panel__header,
.admin-form-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.admin-users-panel__header h1,
.admin-users-panel__header p,
.admin-form-header h1 {
  margin-bottom: 6px;
}

.admin-users-table-scroll {
  flex: 1 1 auto;
}

.users-table {
  min-width: 1180px;
}

.users-table td:nth-child(1),
.users-table td:nth-child(4),
.users-table td:nth-child(5) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.users-table th:nth-child(1),
.users-table td:nth-child(1) {
  width: 260px;
}

.users-table th:nth-child(2),
.users-table td:nth-child(2) {
  width: 150px;
}

.users-table th:nth-child(3),
.users-table td:nth-child(3) {
  width: 120px;
}

.users-table th:nth-child(4),
.users-table td:nth-child(4) {
  width: 190px;
}

.users-table th:nth-child(5),
.users-table td:nth-child(5) {
  width: 260px;
}

.users-table th:nth-child(6),
.users-table td:nth-child(6) {
  width: 85px;
}

.users-table th:nth-child(7),
.users-table td:nth-child(7) {
  width: 115px;
}

.admin-user-form {
  width: min(760px, 100%);
  margin: 0 auto;
  overflow: auto;
}

.admin-user-form input,
.admin-user-form textarea {
  max-width: none;
}

.admin-user-form input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
}

.admin-user-form__active {
  justify-content: flex-start;
  margin: 0 0 16px;
}

.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.help-text {
  max-width: 620px;
  margin-top: 5px;
  color: var(--color-muted);
  font-size: 13px;
}

.info-note {
  max-width: 620px;
  border: 1px solid #c8d6e8;
  border-left: 4px solid var(--color-primary);
  background: #f4f8ff;
  padding: 9px 11px;
  color: #244069;
  font-size: 13px;
  line-height: 1.35;
}

/* Модальные окна */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(29, 29, 27, 0.42);
  padding: 24px;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-card {
  width: min(640px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--color-border);
  border-top: 5px solid var(--color-primary);
  border-radius: var(--radius-panel);
  background: #fff;
  box-shadow: var(--shadow-modal);
  padding: 18px;
}

.modal-card--wide {
  width: min(920px, 100%);
}

.modal-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-card__header h2 {
  margin: 0;
}

.modal-card__subtitle {
  margin: 4px 0 0;
  color: var(--color-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.modal-card__close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--color-text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.modal-card .dropzone {
  position: relative;
  width: 100%;
  min-height: 150px;
}

.modal-card .dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.modal-card textarea,
.modal-card select {
  max-width: 100%;
}

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

.error-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  color: var(--color-muted);
  font-size: 13px;
}

.error-table-scroll {
  max-height: 360px;
  margin-bottom: 14px;
}

.error-table th:first-child,
.error-table td:first-child {
  width: 92px;
  white-space: nowrap;
}

.error-table td {
  vertical-align: top;
}

.error-copy-details {
  margin-bottom: 14px;
}

.error-copy-details summary {
  cursor: pointer;
  color: var(--color-primary);
  font-weight: 700;
}

.error-copy-text {
  max-height: 180px;
  margin: 10px 0 0;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: #f8f9fb;
  padding: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Утилиты */
.muted {
  color: var(--color-muted);
}

.crumb-line,
.section-kicker {
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

/* Логин */
.login-page {
  position: relative;
  min-height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 48px 0;
}

.login-page::before,
.login-page::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.login-page::before {
  inset: 42px 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border), transparent);
}

.login-page::after {
  right: 4%;
  bottom: 7%;
  width: 220px;
  height: 110px;
  border-top: 1px solid #c5c5c5;
  border-bottom: 1px solid #c5c5c5;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 13px,
      rgba(28, 62, 131, 0.14) 14px,
      rgba(28, 62, 131, 0.14) 15px
    );
  opacity: 0.55;
}

.login-frame {
  position: absolute;
  inset: 18px;
  border: 1px solid var(--color-border);
  border-left: 6px solid var(--color-accent);
  pointer-events: none;
}

.login-frame::before,
.login-frame::after {
  content: "";
  position: absolute;
  width: 170px;
  height: 76px;
  opacity: 0.8;
}

.login-frame::before {
  top: 26px;
  left: 28px;
  border-top: 2px solid var(--color-primary);
  border-left: 2px solid var(--color-primary);
}

.login-frame::after {
  right: 28px;
  bottom: 26px;
  border-right: 2px solid var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
}

.login-frame__mark {
  position: absolute;
  color: var(--color-muted);
  font-size: 12px;
  text-transform: uppercase;
}

.login-frame__mark--top {
  top: 24px;
  right: 28px;
}

.login-frame__mark--bottom {
  left: 28px;
  bottom: 22px;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  border: 1px solid var(--color-border);
  border-top: 5px solid var(--color-primary);
  background: #fff;
  box-shadow: 0 18px 40px rgba(29, 29, 27, 0.08);
  padding: 34px;
}

.login-card::before {
  content: "";
  position: absolute;
  inset: -14px;
  z-index: -1;
  border: 1px solid rgba(211, 216, 221, 0.85);
  background:
    linear-gradient(90deg, rgba(250, 180, 0, 0.12), transparent 32%),
    rgba(255, 255, 255, 0.55);
}

.login-card__header {
  margin-bottom: 26px;
}

.login-card h1 {
  margin: 14px 0 18px;
  font-size: 26px;
  line-height: 1.22;
}

.login-card input,
.login-card .button {
  max-width: none;
}

/* Адаптив */
@media (max-width: 720px) {
  .page-header__inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 0;
  }

  .brand {
    width: 100%;
    gap: 12px;
  }

  .brand__logo {
    width: 158px;
    max-height: 56px;
  }

  .brand__organization {
    font-size: 19px;
    white-space: normal;
  }

  .brand__title {
    font-size: 14px;
    white-space: normal;
  }

  .control-panel {
    align-items: stretch;
    width: 100%;
  }

  .control-panel__body {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .control-panel__session {
    margin-left: 0;
    padding-top: 8px;
    padding-left: 0;
    border-top: 1px solid #c7d0dc;
    border-left: 0;
  }

  .grid--two,
  .grid--three {
    grid-template-columns: 1fr;
  }

  .file-documents-panel__top {
    flex-direction: column;
  }

  .file-documents-panel__actions {
    justify-content: flex-start;
  }

  .file-documents-panel__header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .file-documents-panel__header span {
    max-width: 100%;
    text-align: left;
  }

  .modal-overlay {
    padding: 12px;
  }

  .modal-card {
    padding: 14px;
  }

  .selection-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .selection-workspace__header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .selection-workspace__form {
    grid-column: auto;
  }

  .selection-workspace__form .selection-bar {
    flex-wrap: wrap;
  }

  .selection-summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    white-space: normal;
  }

  .selection-summary span + span::before {
    content: none;
    margin: 0;
  }

  .selection-highlight-toggle {
    justify-self: start;
  }

  .selection-results-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .selection-panel__header,
  .selection-panel__right {
    align-items: flex-start;
    flex-direction: column;
  }

  .data-freshness {
    gap: 4px;
    white-space: normal;
  }

  .data-freshness__item + .data-freshness__item::before {
    content: none;
    margin: 0;
  }

  .selection-field__control input {
    width: 100%;
  }

  .selection-field__control {
    width: 100%;
  }

  .summary-list__row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .login-page {
    min-height: 100%;
    padding: 24px 0;
  }

  .login-frame__mark,
  .login-page::after {
    display: none;
  }

  .login-card {
    padding: 24px;
  }

  .login-card h1 {
    font-size: 22px;
  }
}
