/*
 * Основные стили сайта: шрифты, каркас, формы, таблицы, матрица и модальные окна.
 * Фирменные цвета: #3C5CB4, #75B1DE, #BF0F3D.
 * Мобильные дополнения находятся в mobile.css, запасные правила — в compatibility.css.
 * Печатное оформление Excel задаётся отдельно в app/spreadsheets/exporter.py.
 */
html {
    background: #e0f2fc;
}

body {
    margin: 0;
    color: #1b2c49;
    background: #e0f2fc;
    /* Системные шрифты с полноценной кириллицей и обычным начертанием на Windows 7. */
    font: 400 14px/1.5 Tahoma,Arial,sans-serif;
}

*,*:before,*:after {
    box-sizing: border-box;
}

a {
    color: #3C5CB4;
    text-decoration: none;
}

a:hover {
    color: #284891;
}

.route-name-link {
    color: #3C5CB4;
    font-weight: 700;
}

.route-name-link:hover, .route-name-link:focus {
    text-decoration: underline;
}

button,input,select,textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

img {
    max-width: 100%;
}

h1 {
    font-size: 23px;
    line-height: 1.3;
    margin: 0 0 12px;
    font-weight: 700;
    color: #182a49;
}

h2 {
    font-size: 17px;
    line-height: 1.4;
    margin: 0 0 14px;
    font-weight: 700;
    color: #182a49;
}

p {
    margin: 8px 0 14px;
}

.muted {
    color: #52647e;
}

.small {
    font-size: 12px;
}

.required {
    color: #BF0F3D;
}

.inline-form {
    display: inline-block;
    vertical-align: middle;
    margin: 0;
}

/* Каркас приложения и верхняя панель. Фиксация на компьютере и запасное оформление для старых браузеров. */

.app-shell {
    min-height: 100vh;
    padding-top: 84px;
}

.topbar-brand {
    display: block;
    flex-shrink: 0;
}

.topbar-logo {
    display: block;
    width: 150px;
    height: 56px;
    object-fit: contain;
    object-position: left center;
}

.topbar-logout {
    margin: 0 0 0 18px;
}

.app-main {
    min-width: 0;
}

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 84px;
    background: #fff;
    border-bottom: 1px solid #bddff3;
    padding: 0 32px;
    overflow: hidden;
}

.topbar .topbar-title {
    float: none;
    flex: 1;
    min-width: 0;
    max-width: none;
}

.topbar .topbar-user {
    display: flex;
    align-items: center;
    gap: 6px;
    float: none;
    flex-shrink: 0;
    margin-left: auto;
    line-height: normal;
}

.topbar-title {
    float: left;
    font-size: 25px;
    font-weight: 700;
    line-height: 84px;
    color: #182a49;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-user {
    float: right;
    line-height: 84px;
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    vertical-align: middle;
    text-align: center;
}

.user-avatar img {
    display: inline-block;
    width: 20px;
    height: 20px;
    vertical-align: middle;
}

.user-name {
    font-size: 14px;
    vertical-align: middle;
}

.content-area {
    width: 100%;
    padding: 30px 32px 44px;
    margin: 0 auto;
}

/* Заголовки и карточки содержимого */

.headline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.headline h1 {
    margin-bottom: 4px;
}

.route-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.route-actions form {
    margin: 0;
}

.headline p {
    margin-bottom: 0;
}

.panel {
    background: #fff;
    border: 1px solid #bddff3;
    border-radius: 12px;
    padding: 26px;
    margin-bottom: 20px;
    box-shadow: 0 3px 18px rgba(23,47,86,.025);
}

.panel.compact,.panel-form {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.technical-error-card {
    width: 100%;
    max-width: 640px;
    margin: 0;
    text-align: center;
}

.panel-table {
    padding: 0;
    overflow: hidden;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 15px;
    margin-bottom: 17px;
}

.section-heading h2,.section-heading h1 {
    margin-bottom: 4px;
}

.stage-heading { align-items: flex-start; }
.stage-heading > div, .stage-heading > h1 { min-width: 0; flex: 1 1 auto; }
.stage-home-link { flex: 0 0 auto; margin-left: auto; }
.leave-stage-buttons { display: grid; gap: 10px; margin-top: 22px; }
.leave-stage-notice { font-size: 13px; color: #5d7190; }

.form-section {
    border-top: 1px solid #d1eafa;
    padding-top: 22px;
    margin-top: 22px;
}

.form-section h2 {
    margin-bottom: 16px;
}

/* Кнопки и их состояния */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 19px;
    border: 1px solid transparent;
    border-radius: 9px;
    min-height: 46px;
    font-size: 15px;
    line-height: 1.25;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    white-space: normal;
}

.btn-primary {
    background: #3C5CB4;
    border-color: #3C5CB4;
    color: #fff;
}

.btn-primary:hover {
    background: #314f9f;
    border-color: #314f9f;
    color: #fff;
}

.btn-light {
    background: #fff;
    border-color: #cad9ee;
    color: #3C5CB4;
}

.btn-light:hover {
    background: #d9effc;
    color: #314f9f;
}

.btn-secondary {
    background: #d9effc;
    border-color: #cedff8;
    color: #3557a5;
}

.btn-secondary:hover {
    background: #cce9fa;
}

/* Кнопка выхода */
.btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    min-height: 44px;
    padding: 9px 16px;

    background-color: #3C5CB4;
    border: 1px solid #3C5CB4;
    border-radius: 10px;

    color: #FFFFFF;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;

    transition: background-color 0.2s ease;
}

.btn-logout:hover {
    background-color: #304A97;
    border-color: #304A97;
    color: #FFFFFF;
}

.btn-logout:active {
    background-color: #263E83;
    border-color: #263E83;
}

/* Иконка выхода */
.logout-icon {
    display: block;
    width: 20px;
    height: 20px;
    object-fit: contain;

    /* Чёрную PNG-иконку делаем белой */
    filter: brightness(0) invert(1);
}

.btn-danger {
    background: #BF0F3D;
    color: #fff;
    border-color: #BF0F3D;
}

.btn-danger:hover {
    background: #9f0b30;
    color: #fff;
}

.btn-small {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 15px;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    object-fit: contain;
    vertical-align: middle;
}

.btn[disabled],button[disabled] {
    opacity: .45;
    cursor: default;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.actions-end {
    justify-content: flex-end;
}

.actions-between {
    justify-content: space-between;
    border-top: 1px solid #edf1f7;
    padding-top: 22px;
}

.action-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.link-button {
    display: inline-block;
    border: 0;
    background: none;
    color: #3C5CB4;
    padding: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 15px;
}

.link-button:hover {
    text-decoration: underline;
}

/* Поля ввода, подписи и галочки */

.field {
    margin: 0 0 20px;
}

.field label {
    display: block;
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: #293c59;
}

input[type=text],input[type=password],input[type=file],input:not([type]),select,textarea {
    display: block;
    width: 100%;
    padding: 11px 13px;
    min-height: 46px;
    border: 1px solid #a9d2ec;
    border-radius: 8px;
    background: #fff;
    color: #1e3150;
    outline: none;
}

input::placeholder,textarea::placeholder {
    color: #9aa8bb;
}

input:focus,select:focus,textarea:focus {
    border-color: #3C5CB4;
    box-shadow: 0 0 0 2px #c4e6fa;
}

input[type=checkbox],input[type=radio] {
    accent-color: #3C5CB4;
    width: auto;
}

input[readonly] {
    background: #e0f2fc;
    color: #667b95;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.form-grid {
    display: flex;
    gap: 22px;
    flex-wrap: wrap;
}

.form-grid .field {
    flex: 1 1 240px;
    min-width: 190px;
}

.field.medium {
    max-width: 360px;
}

.check-grid {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.check-grid label {
    cursor: pointer;
}

.choice-item {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: 170px;
    min-height: 62px;
    padding: 12px 17px;
    border: 1px solid #d9e3f0;
    border-radius: 9px;
    background: #fff;
    font-weight: 600;
}

.choice-item span small {
    display: block;
    font-size: 11px;
    color: #8997aa;
    font-weight: 400;
    margin-top: 1px;
}

.choice-item input {
    margin: 0;
}

.option-list {
    display: block;
}

.checkbox-line {
    display: inline-block;
    padding: 5px 24px 5px 0;
    font-weight: 500;
    color: #293c59;
}

.checkbox-line input {
    vertical-align: middle;
    margin-right: 6px;
}

.read-only-grid {
    width: 100%;
}

.readonly-field {
    min-height: 46px;
    padding: 11px 13px;
    border: 1px solid #e5eaf2;
    border-radius: 8px;
    background: #e0f2fc;
    color: #52647e;
}

.hint-bar {
    padding: 13px 16px;
    border: 1px solid #d9e5f6;
    border-radius: 8px;
    background: #d9effc;
    color: #526d9e;
    font-size: 12px;
}

/* Списки и таблицы */

.table-scroll {
    max-width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 15px 15px;
    background: #3C5CB4;
    border-bottom: 1px solid #e2e9f2;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
}

.data-table td {
    background: #fff;
    padding: 13px 15px;
    border-bottom: 1px solid #ecf0f5;
    vertical-align: middle;
    font-size: 13px;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table td input {
    min-width: 160px;
}

.data-table td .km-field {
    min-width: 80px;
    width: 100px;
    max-width: 120px;
    text-align: center;
}

.compact-table td input {
    min-width: 65px;
}

.empty-cell {
    padding: 28px !important;
    color: #8a98aa;
    text-align: center;
}

.filters-row {
    display: flex;
    gap: 14px;
    margin-bottom: 18px;
    align-items: center;
}

.search-wrapper {
    position: relative;
    flex: 1 1 440px;
    max-width: 650px;
}

.search-wrapper input {
    padding-left: 41px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 13px;
    width: 20px;
    height: 20px;
}

.filters-row select {
    width: 230px;
    max-width: 40%;
}

.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 30px;
    background: #e0f2fc;
    color: #50658d;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-boundary {
    background: #d9effc;
}

.badge-boundary {
    color: #3157a0;
}

.route-actions {
    white-space: nowrap;
}

#grids-table .route-actions-cell {
    width: 1%;
    text-align: right;
}

#grids-table .route-actions-cell .route-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.action-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 0;
    background: transparent;
    color: #3C5CB4;
    font-size: 15px;
    cursor: pointer;
    margin: 2px 7px 2px 0;
    padding: 3px;
    vertical-align: middle;
}

#grids-table .action-link {
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
    border-radius: 9px;
    background: #3C5CB4;
    color: #fff;
    text-decoration: none;
}

#grids-table .action-link:hover {
    background: #314f9f;
}

#grids-table .action-link:focus-visible {
    outline: 2px solid #3C5CB4;
    outline-offset: 3px;
}

#grids-table .action-icon {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
}

.action-icon {
    display: inline-block;
    width: 17px;
    height: 17px;
    object-fit: contain;
    vertical-align: middle;
}

.danger-link {
    color: #BF0F3D;
}

.danger-link:hover {
    color: #a20b32;
}

.number-col {
    width: 54px;
}

.stop-list td input {
    min-height: 38px;
    padding: 7px 10px;
}

.stop-list td input[name^=name_],.stop-list td #new_stop {
    min-width: 220px;
}

.stop-list th:nth-child(2),
.stop-list td:nth-child(2) {
    width: 100%;
}

.stop-list th:not(:nth-child(2)),
.stop-list td:not(:nth-child(2)) {
    width: 1%;
    white-space: nowrap;
}

.stop-list th:last-child {
    text-align: left;
}

.stop-list td:last-child {
    text-align: right;
}

.stop-list td .km-field {
    max-width: 110px;
    min-width: 90px;
}

.action-cell {
    white-space: nowrap;
}

.boundary-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.boundary-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    color: inherit;
    background: transparent;
    font-size: 18px;
}

.boundary-reset:hover {
    background: #cce9fa;
}

.boundary-reset:focus-visible {
    outline: 2px solid #3C5CB4;
    outline-offset: 2px;
}

.mini-button {
    min-width: 31px;
    height: 32px;
    margin: 0 2px 2px 0;
    border: 1px solid #d7e0ee;
    border-radius: 7px;
    background: #e9f6fd;
    color: #3C5CB4;
    font-size: 15px;
    line-height: 1;
}

.mini-button.danger {
    color: #BF0F3D;
}

.stop-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    width: 100%;
}

.stop-list .action-cell .mini-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    flex: 0 0 36px;
    height: 36px;
    margin: 0;
    vertical-align: middle;
}

.stop-list .action-cell .btn {
    flex: 0 0 auto;
    margin-right: 12px;
    white-space: nowrap;
}

.city-insert-option {
    display: block;
    margin: 17px 0 8px;
    color: #38506f;
    font-size: 13px;
}

/* Навигация по этапам; возможность перехода не зависит от заполненности соседних этапов */

.wizard-steps {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid #bddff3;
    border-radius: 11px;
    padding: 14px 18px;
    margin-bottom: 15px;
}

.wizard-step {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 38px;
    padding: 2px 8px;
    color: #7a899e;
    font-weight: 500;
    font-size: 15px;
    border-radius: 7px;
}

.wizard-step:hover {
    background: #cce9fa;
    color: #3C5CB4;
}

.wizard-step-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    line-height: 32px;
    border: 1px solid #d7e1ef;
    background: #e0f2fc;
    border-radius: 50%;
    text-align: center;
    font-weight: 700;
    flex-shrink: 0;
}

.wizard-step.active {
    color: #3C5CB4;
    font-weight: 700;
}

.wizard-step.active .wizard-step-circle {
    background: #3C5CB4;
    border-color: #3C5CB4;
    color: #fff;
}

.steps-hint {
    font-size: 11px;
    color: #8190a5;
    margin: 0 0 19px 3px;
}

/* Редактор матрицы в браузере; оформление XLSX задаётся экспортёром */

.matrix-section-heading {
    margin-top: 25px;
}

.km-view-control {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin: 0 0 20px;
}

.km-view-label {
    font-size: 17px;
    line-height: 1.4;
    font-weight: 700;
    color: #182a49;
    cursor: pointer;
}

.km-toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
    cursor: pointer;
}

.km-toggle input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.km-toggle-track {
    display: block;
    width: 52px;
    height: 30px;
    border-radius: 20px;
    background: #bddff3;
    transition: background-color .18s ease;
}

.km-toggle-track::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(27, 44, 73, .18);
    transition: transform .18s ease;
}

.km-toggle input:checked + .km-toggle-track {
    background: #3C5CB4;
}

.km-toggle input:checked + .km-toggle-track::before {
    transform: translateX(22px);
}

.km-toggle input:focus-visible + .km-toggle-track {
    outline: 2px solid #3C5CB4;
    outline-offset: 3px;
}

.matrix-km-inline {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-top: 10px;
    font-size: 12px;
    font-weight: 500;
}

.matrix-km-inline[hidden],
#km-summary[hidden] {
    display: none;
}

.matrix-table th .matrix-km-inline {
    align-items: center;
}

.matrix-km-inline .km-field {
    width: 110px;
    max-width: 100%;
    min-height: 36px;
    padding: 6px 9px;
    text-align: center;
    font-size: 13px;
}

.matrix-table {
    min-width: 760px;
    width: 100%;
    border-collapse: collapse;
}

.matrix-table th {
    background: #3C5CB4;
    border: 1px solid #dee7f1;
    color: #fff;
    padding: 12px 11px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
}

.matrix-table td {
    background: #fff;
    border: 1px solid #e0e8f3;
    padding: 5px 6px;
    text-align: center;
    min-width: 90px;
}

.matrix-table td.stop-name-cell {
    min-width: 135px;
    max-width: 220px;
    border: 0;
    text-align: left;
    vertical-align: top;
    font-weight: 600;
    padding: 10px;
    background: #fff;
    color: #24385b;
}

.matrix-table td.tariff-kind {
    min-width: 90px;
    background: #fff;
    color: #526989;
    font-size: 12px;
}

.matrix-table td.matrix-empty {
    border: 1px solid #ecf0f6;
}

.matrix-table td.matrix-header-empty {
    border: 0;
    background: #fff;
}

.matrix-table th.matrix-diagonal {
    padding: 8px 11px;
}

.matrix-table td.fare-cell,
.matrix-table th {
    border-color: #284891;
}

.matrix-table .stop-group-end td.fare-cell,
.matrix-table .stop-group-end td.tariff-kind,
.matrix-table .stop-group-end th.matrix-diagonal,
.matrix-table td.stop-name-cell {
    border-bottom: 3px solid #284891;
}

.matrix-table tbody tr td.fare-cell.imported,
.legend-swatch.imported {
    background: #fff5d9;
}

.matrix-table tbody tr td.fare-cell.manual,
.legend-swatch.manual {
    background: #fbe6e7;
}

.matrix-table tbody tr td.fare-cell.calculated,
.legend-swatch.calc {
    background: #d9effc;
}

.matrix-table td.fare-cell input {
    display: block;
    width: 100%;
    min-width: 55px;
    text-align: center;
    border: 1px solid transparent;
    border-radius: 5px;
    min-height: 36px;
    padding: 5px 2px;
    background: transparent;
    font-size: 12px;
}

.matrix-table td.fare-cell input:focus {
    border-color: #75B1DE;
}

.matrix-table td.fare-cell input:focus::-webkit-input-placeholder {
    color: transparent;
}

.matrix-table td.fare-cell input:focus::-moz-placeholder {
    color: transparent;
}

.matrix-table td.fare-cell input:focus:-ms-input-placeholder {
    color: transparent;
}

.matrix-table td.fare-cell input:focus::placeholder {
    color: transparent;
}

.matrix-table td.fare-cell.manual input {
    font-weight: 600;
}

.km-table-area .data-table {
    min-width: 650px;
}

.km-table-area .data-table th,
.km-table-area .data-table td {
    text-align: center;
    vertical-align: middle;
}

.km-table-area .data-table .km-field {
    margin-left: auto;
    margin-right: auto;
}

.matrix-legend {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin: 14px 0;
    color: #293c59;
    font-size: 15px;
    font-weight: 400;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.matrix-legend[hidden],
.legend-item[hidden] {
    display: none;
}

.legend-swatch {
    display: inline-block;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border: 1px solid #91abc6;
    border-radius: 4px;
    vertical-align: middle;
    margin: 0;
}

.pagination {
    padding: 16px 0 0;
    color: #74839a;
    font-size: 12px;
}

.page-link {
    display: inline-block;
    padding: 6px 10px;
    border: 1px solid #dce5f1;
    border-radius: 5px;
    margin-left: 5px;
}

.page-link.chosen {
    background: #3C5CB4;
    color: #fff;
    border-color: #3C5CB4;
}

/* Форма выбора файла для импорта */

.import-panel {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.upload-area {
    border: 1px dashed #bdd0ed;
    border-radius: 11px;
    padding: 32px 28px;
    background: #e9f6fd;
    text-align: center;
}

.upload-area h2 {
    margin: 8px 0;
}

.upload-icon {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.upload-file-field {
    max-width: 540px;
    margin: 21px auto 0;
    text-align: left;
}

/* Область загрузки Excel */
.upload-dropzone {
    position: relative;
    width: 100%;
}

/* Скрытый, но доступный через клавиатуру input */
.upload-native-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    clip: rect(0, 0, 0, 0);
}

/* Кликабельная область */
.upload-dropzone .upload-area {
    display: block;
    padding: 42px 28px;

    background-color: #e9f6fd;
    border: 2px dashed #a6cdeb;
    border-radius: 12px;

    text-align: center;
    cursor: pointer;

    transition:
        background-color 0.2s ease,
        border-color 0.2s ease;
}

.upload-dropzone .upload-area:hover {
    background-color: #d9effc;
    border-color: #3C5CB4;
}

/* Подсветка при перетаскивании */
.upload-dropzone .upload-area.is-dragover {
    background-color: #cce9fa;
    border-color: #3C5CB4;
}

/* Выделение при навигации с клавиатуры */
.upload-native-input:focus + .upload-area {
    outline: 2px solid #3C5CB4;
    outline-offset: 3px;
}

.upload-dropzone .upload-icon {
    display: block;
    width: 52px;
    height: 52px;
    margin: 0 auto 18px;
    object-fit: contain;
}

.upload-dropzone .upload-area h2 {
    margin: 0 0 10px;
    color: #182A49;
    font-size: 20px;
    overflow-wrap: anywhere;
}

.upload-description {
    margin: 0 0 22px;
    color: #7184AA;
    font-size: 14px;
}

/* Визуальная кнопка внутри зоны */
.upload-select-button {
    display: inline-block;
    padding: 11px 22px;

    background-color: #3C5CB4;
    border-radius: 9px;

    color: #FFFFFF;
    font-size: 15px;
    font-weight: 600;
}

/* Название выбранного файла */
.upload-file-name {
    display: block;
    margin-top: 17px;

    color: #7184AA;
    font-size: 12px;
    overflow-wrap: break-word;
}

/* Файл выбран */
.upload-dropzone .upload-area.has-file {
    background-color: #bddff5;
    border-color: #3C5CB4;
}

.upload-area.has-file .upload-description,
.upload-area.has-file .upload-file-name {
    display: none;
}

/* Неподходящий файл */
.upload-dropzone .upload-area.has-error {
    border-color: #BF0F3D;
}

.upload-area.has-error .upload-file-name {
    color: #BF0F3D;
}

/* Адаптация */
@media (max-width: 600px) {
    .upload-dropzone .upload-area {
        padding: 28px 16px;
    }

    .upload-dropzone .upload-area h2 {
        font-size: 17px;
    }
}

/* Реквизиты и поясняющие блоки */

.details {
    margin: 12px 0;
}

.details dt {
    float: left;
    clear: left;
    width: 230px;
    font-size: 12px;
    font-weight: 600;
    color: #77859a;
    margin: 0 0 12px;
}

.details dd {
    margin: 0 0 12px 240px;
    font-weight: 600;
    color: #293d5a;
    min-height: 20px;
}

.import-comment {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.import-result .panel {
    margin-bottom: 0;
    min-width: 0;
    padding: 20px;
}

.import-result .import-overview {
    margin-bottom: 16px;
}

.import-overview-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.import-overview-heading > div:first-child {
    min-width: 0;
    flex: 1 1 320px;
}

.import-complete {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #3C5CB4;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

.import-complete > span {
    display: inline-flex;
    width: 23px;
    height: 23px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #d9effc;
}

.import-overview h1 {
    margin: 0;
    font-size: 21px;
    overflow-wrap: anywhere;
}

.import-route-divider {
    color: #75B1DE;
    margin: 0 6px;
    font-weight: 400;
}

.import-primary-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.import-file-info {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(100px, 1fr) minmax(0, 1fr);
    gap: 24px;
    padding-top: 12px;
    margin: 14px 0 0;
    border-top: 1px solid #d9e9f5;
}

.import-file-info dt,
.import-price-grid dt {
    color: #5d7190;
    font-size: 12px;
    margin-bottom: 5px;
}

.import-file-info dd {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.import-result-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 16px;
    align-items: start;
}

.import-result-main {
    min-width: 0;
}

.import-tabs {
    display: flex;
    gap: 4px;
    background: #e1f1fd;
    border-radius: 9px;
    padding: 4px;
    margin-bottom: 18px;
    overflow-x: auto;
}

.import-tabs[hidden], .import-tab-panel[hidden] {
    display: none;
}

.import-tabs button {
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: #425f89;
    padding: 8px 14px;
    white-space: nowrap;
    font-size: 15px;
}

.import-tabs button[aria-selected="true"] {
    background: #3C5CB4;
    color: #fff;
}

.import-tabs button:focus-visible,
.import-tab-panel:focus-visible,
.import-stop-list:focus-visible {
    outline: 2px solid #3C5CB4;
    outline-offset: 2px;
}

.import-result-main.has-tabs .import-tab-panel {
    max-height: 390px;
    min-height: 300px;
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-color: #a8cfee #f0f7fd;
}

.import-result-main.has-tabs .import-tab-panel > h2 {
    display: none;
}

.import-result h3 {
    font-size: 13px;
    font-weight: 600;
    color: #5d7190;
    margin: 0 0 10px;
}

.import-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    margin-top: 18px;
}

.import-options {
    margin: 0;
}

.import-options > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid #e6eff7;
}

.import-options > div:last-child {
    border-bottom: 0;
}

.import-options dt {
    min-width: 0;
    overflow-wrap: anywhere;
}

.import-options dd {
    margin: 0;
    flex-shrink: 0;
}

.import-state {
    display: inline-block;
    min-width: 42px;
    padding: 3px 9px;
    border-radius: 6px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
}

.import-state.is-on {
    background: #d9effc;
    color: #284891;
}

.import-state.is-off {
    background: #f3f6fa;
    color: #64748b;
}

.import-price-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
}

.import-price-grid > div {
    border: 1px solid #9dcff0;
    background: #cce9fc;
    border-radius: 10px;
    padding: 12px 14px;
}

.import-price-grid dd {
    font-size: 23px;
    font-weight: 600;
    margin: 0;
    overflow-wrap: anywhere;
}

.import-price-grid dd > span {
    font-size: 15px;
    font-weight: 400;
    color: #5d7190;
}

.import-requisites > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.import-requisites dd {
    overflow-wrap: anywhere;
}

.import-comment-box {
    margin-top: 16px;
    border-left: 3px solid #75B1DE;
    padding: 4px 0 4px 16px;
}

.import-comment-box p {
    margin: 0;
}

.import-source-description {
    color: #5d7190;
    font-size: 12px;
    margin: 16px 0 10px;
}

.import-card-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.import-card-heading h2 {
    margin: 0;
}

.import-count {
    border-radius: 8px;
    padding: 4px 10px;
    color: #284891;
    background: #d9effc;
    font-size: 13px;
    font-weight: 600;
}

.import-stop-list {
    list-style: none;
    margin: 0;
    padding: 0 8px 0 0;
    max-height: 410px;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-color: #a8cfee #f0f7fd;
}

.import-stop-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    position: relative;
    font-size: 13px;
}

.import-stop-list li:not(:last-child)::after {
    content: '';
    position: absolute;
    width: 1px;
    background: #bddff3;
    left: 13px;
    top: 34px;
    bottom: -6px;
}

.import-stop-list li:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.import-stop-list li > span:last-child {
    overflow-wrap: anywhere;
    min-width: 0;
}

.import-stop-number {
    flex-shrink: 0;
    min-width: 26px;
    text-align: center;
    color: #3C5CB4;
    font-size: 12px;
    font-weight: 600;
    background: #e1f1fd;
    border-radius: 50%;
    line-height: 26px;
}

@media (max-width: 800px) {
    .import-result-layout { grid-template-columns: minmax(0, 1fr); }
    .import-settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .import-file-info, .import-price-grid, .import-settings-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .import-primary-actions, .import-primary-actions .btn { width: 100%; }
    .import-primary-actions .btn { text-align: center; }
    .import-requisites > div { grid-template-columns: minmax(0, 1fr); gap: 5px; }
    .import-result-main.has-tabs .import-tab-panel { min-height: 0; max-height: 430px; }
    .import-stop-list { max-height: 280px; }
}

.notice {
    padding: 13px 15px;
    border-radius: 8px;
    margin: 0 0 18px;
    background: #e0f2fc;
    border: 1px solid #d3e3f7;
    color: #47618d;
    font-size: 12px;
}

.notice-error {
    background: #fff3f6;
    border-color: #f4cbd5;
    color: #a22344;
}

.notice-success {
    background: #edf8f1;
    border-color: #cfe7d9;
    color: #2c7152;
}

.notice ul {
    padding-left: 18px;
    margin: 9px 0;
}

/* Страница входа */

.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 18px;
}

.auth-shell .notice {
    max-width: 490px;
    margin: 0 auto 15px;
}

.login-card {
    width: 100%;
    max-width: 490px;
    margin: auto;
    background: #fff;
    border: 1px solid #e0e7f1;
    border-radius: 16px;
    padding: 42px;
    box-shadow: 0 9px 30px rgba(31,55,100,.07);
}

.login-card input[type="text"],
.login-card input[type="password"] {
    background-color: #d9effc;
}

.login-card input:autofill {
    background-color: #d9effc;
    box-shadow: inset 0 0 0 1000px #d9effc;
    color: #1e3150;
}

.login-card input:-webkit-autofill {
    -webkit-box-shadow: inset 0 0 0 1000px #d9effc;
    box-shadow: inset 0 0 0 1000px #d9effc;
    -webkit-text-fill-color: #1e3150;
    caret-color: #1e3150;
}

.login-card input:autofill:focus {
    box-shadow: inset 0 0 0 1000px #d9effc, 0 0 0 2px #c4e6fa;
}

.login-card input:-webkit-autofill:focus {
    -webkit-box-shadow: inset 0 0 0 1000px #d9effc, 0 0 0 2px #c4e6fa;
    box-shadow: inset 0 0 0 1000px #d9effc, 0 0 0 2px #c4e6fa;
}

.login-logo {
    display: block;
    width: 220px;
    height: 72px;
    object-fit: contain;
    margin: 0 auto 26px;
}

.login-title {
    font-size: 23px;
    text-align: center;
    margin-bottom: 5px;
}

.login-subtitle {
    text-align: center;
    margin-bottom: 28px;
}

.login-help {
    font-size: 11px;
    text-align: center;
    margin-top: 22px;
    margin-bottom: 0;
}

/* Модальное подтверждение удаления */

.modal-overlay {
    position: fixed;
    z-index: 999;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(23,35,57,.56);
}

.modal-window {
    width: 92%;
    max-width: 455px;
    margin: 12vh auto 0;
    background: #fff;
    border: 1px solid #dce4f0;
    border-radius: 13px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 17px 45px rgba(0,0,0,.15);
}

.modal-window.matrix-validation-window {
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    margin: 24px auto;
}

.matrix-validation-window ul {
    text-align: left;
    padding-left: 22px;
    overflow-wrap: anywhere;
}

.matrix-validation-window li {
    margin: 8px 0;
}

.modal-window.stop-delete-window {
    max-width: 380px;
    margin: max(24px, 20vh) auto 0;
    padding: 24px;
}

.stop-delete-window p {
    overflow-wrap: anywhere;
}

.modal-symbol {
    width: 62px;
    height: 62px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: #fcedf1;
    line-height: 62px;
}

.modal-symbol img {
    width: 25px;
    height: 25px;
    vertical-align: middle;
}

.modal-window h2 {
    font-size: 19px;
    margin: 0 0 12px;
}

.modal-window p {
    margin: 9px 0;
    color: #475875;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 11px;
    align-items: center;
    margin-top: 24px;
}

.modal-buttons .btn {
    flex: 1 1 50%;
}

/* Дополнительные правила узких экранов */

@media (max-width:1200px) {

    .content-area {
        padding: 24px 20px;
    }

    .topbar {
        padding: 0 20px;
    }


    .data-table td,.data-table th {
        padding: 11px 9px;
    }

}

@media (max-width:900px) {

    .topbar-logo {
        width: 110px;
        height: 46px;
    }



    .topbar-title {
        font-size: 21px;
    }

    .form-grid .field {
        min-width: 190px;
    }

}

@media (max-width:600px) {
    .app-shell {
        padding-top: 66px;
    }

    .topbar {
        height: 66px;
        padding: 0 12px;
        gap: 8px;
    }

    .topbar-logo {
        width: 60px;
        height: 40px;
    }

    .topbar .topbar-user {
        gap: 6px;
    }

    .topbar-logout .btn {
        padding: 7px 8px;
    }

    .user-name {
        max-width: 65px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar-title,.topbar-user {
        line-height: 66px;
    }

    .topbar-title {
        font-size: 17px;
    }

    .user-avatar {
        display: none;
    }

    .user-name {
        font-size: 12px;
    }

    .content-area {
        padding: 18px 12px;
    }

    .panel {
        padding: 17px;
    }

    .headline,.actions-between {
        display: block;
    }

    .headline .btn {
        margin-top: 12px;
    }

    .wizard-steps {
        padding: 10px;
    }

    .wizard-step {
        font-size: 15px;
    }

    .wizard-step-circle {
        width: 29px;
        height: 29px;
        line-height: 27px;
    }

    .filters-row {
        display: block;
    }

    .filters-row select {
        display: block;
        width: 100%;
        max-width: none;
        margin-top: 10px;
    }

    .login-card {
        padding: 25px 20px;
    }

    .details dt {
        float: none;
        width: auto;
        margin-bottom: 1px;
    }

    .details dd {
        margin: 0 0 12px;
    }

    .modal-window {
        margin: 9vh auto 0;
        padding: 20px;
    }

}

/* ======================================
   ЕЦК — ВСПЛЫВАЮЩИЕ УВЕДОМЛЕНИЯ
   ====================================== */

.snackbar-container {
    position: fixed;
    top: 96px;
    right: 24px;
    width: 370px;
    z-index: 11000;
}

/* Уведомление */

.snackbar {
    position: relative;
    box-sizing: border-box;
    min-height: 70px;
    margin-bottom: 12px;
    padding: 16px 40px 16px 16px;
    background: #FFFFFF;
    color: #263551;
    border: 1px solid #D9E2EF;
    border-left: 4px solid #3C5CB4;
    border-radius: 12px;
    box-shadow: 0 8px 26px rgba(28, 49, 85, 0.13);
    -webkit-animation: eckSnackbarIn 0.3s ease-out both;
    animation: eckSnackbarIn 0.3s ease-out both;
}

/* Успех */

.snackbar-success {
    border-left-color: #3C5CB4;
}

/* Ошибка */

.snackbar-error {
    border-left-color: #BF0F3D;
}

/* Предупреждение */

.snackbar-warning {
    border-left-color: #BF0F3D;
}

/* Круглая иконка */

.snackbar-icon {
    position: absolute;
    top: 17px;
    left: 13px;
    width: 32px;
    height: 32px;
    line-height: 32px;
    border-radius: 50%;
    background: #d9effc;
    color: #3C5CB4;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
}

/* Иконка ошибки */

.snackbar-error .snackbar-icon,
.snackbar-warning .snackbar-icon {
    background: #FCE8EE;
    color: #BF0F3D;
}

/* Текст */

.snackbar-content {
    padding-left: 42px;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.snackbar-title {
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: bold;
    color: #253B60;
}

.snackbar-message {
    font-size: 13px;
    line-height: 1.5;
    color: #596A84;
}

/* Закрытие */

.snackbar-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 27px;
    height: 27px;
    padding: 0;
    border: none;
    background: transparent;
    color: #8391A6;
    cursor: pointer;
    font-size: 24px;
    line-height: 24px;
    text-align: center;
}

.snackbar-close:hover {
    color: #BF0F3D;
}

/* Исчезновение */

.snackbar-leaving {
    -webkit-animation: eckSnackbarOut 0.25s ease-in both;
    animation: eckSnackbarOut 0.25s ease-in both;
}

/* Плавное появление */

@-webkit-keyframes eckSnackbarIn {
    from {
        opacity: 0;
        -webkit-transform: translateY(-15px);
    }

    to {
        opacity: 1;
        -webkit-transform: translateY(0);
    }

}

@keyframes eckSnackbarIn {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }

}

/* Плавное исчезновение */

@-webkit-keyframes eckSnackbarOut {
    from {
        opacity: 1;
        -webkit-transform: translateY(0);
    }

    to {
        opacity: 0;
        -webkit-transform: translateY(-10px);
    }

}

@keyframes eckSnackbarOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }

}

/* Если пользователь отключил анимации */

@media (prefers-reduced-motion: reduce) {
    .snackbar,
    .snackbar-leaving {
        -webkit-animation: none;
        animation: none;
    }

}

/* Узкие экраны */

@media screen and (max-width: 480px) {
    .snackbar-container {
        top: 75px;
        left: 14px;
        right: 14px;
        width: auto;
    }

    .snackbar {
        padding-right: 38px;
    }

}

/* Не выводить уведомления на печать */

@media print {
    .snackbar-container {
        display: none;
    }

}

/* Контейнер выпадающего списка */
.filters-row .status-select-wrapper {
    position: relative;
    width: 230px;
    max-width: 40%;
    flex-shrink: 0;
}

/* Убираем системную стрелку */
.filters-row .status-select-wrapper select {
    display: block;
    width: 100%;
    max-width: 100%;
    padding-right: 50px;

    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    background: #FFFFFF;
    cursor: pointer;
}

/* Для старого Internet Explorer */
.status-select-wrapper select::-ms-expand {
    display: none;
}

/* Наша собственная стрелка */
.status-select-wrapper::after {
    content: "";
    position: absolute;

    top: 50%;
    right: 24px;

    width: 8px;
    height: 8px;

    border-right: 2px solid #1B2C49;
    border-bottom: 2px solid #1B2C49;

    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

/* Адаптация под мобильные устройства */
@media (max-width: 600px) {
    .filters-row .status-select-wrapper {
        width: 100%;
        max-width: none;
        margin-top: 10px;
    }

    .filters-row .status-select-wrapper select {
        margin-top: 0;
    }
}

/* Две независимые опции комбинированного тарифа. */
#combined-extra-options .checkbox-line {
    display: block;
    margin-bottom: 7px;
}

#combined-extra-options .muted {
    margin-top: 6px;
}
