:root {
    --color-bg: #dbe7f5;
    --color-surface: #ffffff;
    --color-surface-soft: #f8fbff;
    --color-text: #1e293b;
    --color-muted: #64748b;
    --color-border: #dbe4f0;
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-secondary: #475569;
    --color-danger: #dc2626;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --shadow-sm: 0 10px 30px rgba(15, 23, 42, 0.05);
    --header-offset: 92px;
}

* { box-sizing: border-box; }

body {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
}

body {
    padding-top: var(--header-offset);
}


body.login-page {
    padding-top: 0;
    min-height: 100vh;
}

body.login-page .page-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 3vw, 32px);
}

body.login-page .page-card {
    width: min(100%, 760px);
}

.header {
    background: linear-gradient(90deg, #1e40af, #1d4ed8 60%, #2563eb);
    color: #fff;
    padding: 16px clamp(14px, 3vw, 32px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 8px 20px rgba(30, 64, 175, 0.22);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1050;
}

.page-container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: clamp(14px, 2.4vw, 32px);
    background: transparent;
}

.page-card {
    width: 100%;
    background: var(--color-surface);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: clamp(14px, 2.5vw, 28px);
}

.nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nav a { color: #fff; text-decoration: none; font-weight: 600; opacity: .95; }
.nav a:hover { opacity: 1; text-decoration: underline; }
.nav .dropdown {
    margin-left: auto;
}

.nav-toggle {
    display: none;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.16);
    box-shadow: none;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
}


.dropdown-item-form {
    margin: 0;
}

.btn,
button:not(.dropdown-item):not(.btn-close) {
    border: none;
    border-radius: 12px;
    padding: 10px 16px;
    background: linear-gradient(180deg, #3b82f6, var(--color-primary));
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}
.btn:hover,
button:not(.dropdown-item):not(.btn-close):hover { transform: translateY(-1px); filter: brightness(1.03); }
.btn:active,
button:not(.dropdown-item):not(.btn-close):active { transform: translateY(0); }
.btn-secondary { background: linear-gradient(180deg, #64748b, var(--color-secondary)); box-shadow: 0 8px 16px rgba(71, 85, 105, .28); }
.btn-danger { background: linear-gradient(180deg, #ef4444, var(--color-danger)); box-shadow: 0 8px 16px rgba(220, 38, 38, .28); }
.btn-outline-secondary {
    background: #fff;
    border: 1px solid #cbd5e1;
    color: #334155;
    box-shadow: 0 6px 14px rgba(51, 65, 85, .16);
}
.btn-outline-secondary:hover {
    background: #f8fafc;
    color: #1e293b;
}

.dropdown-menu {
    min-width: 0;
    width: max-content;
    max-width: calc(100vw - 24px);
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    padding: 10px 0;
    background: #ffffff;
    box-shadow: 0 20px 35px rgba(15, 23, 42, .18);
}

.profile-menu {
    text-align: center;
}

.profile-menu .dropdown-header {
    justify-content: center;
}

.profile-menu.show {
    position: absolute !important;
    top: calc(100% + 8px) !important;
    right: 0 !important;
    left: auto !important;
    transform: none !important;
}

.dropdown-header {
    font-size: 1.35rem;
    font-weight: 500;
    color: #4b5563;
    white-space: normal;
}

.dropdown-item-text {
    color: #1f2937;
    font-size: 1rem;
}

.dropdown-item {
    color: #1f2937;
    padding-top: 10px;
    padding-bottom: 10px;
}

.dropdown-item:hover,
.dropdown-item:focus {
    color: #0f172a;
    background: #eef2ff;
}


.profile-menu > li {
    margin: 0;
}

.profile-menu > li + li {
    border-top: none;
}

.profile-menu .dropdown-item,
.profile-menu .dropdown-item-text {
    display: block;
    width: 100%;
    font-size: 1.1rem;
    color: #1f2937;
}

.profile-menu .dropdown-item {
    font-weight: 500;
}
.dropdown-divider {
    margin: 0;
    border-top: 1px solid #d1d5db;
}

.form-row { margin-bottom: 14px; }
label { display: block; margin-bottom: 6px; font-weight: 600; }
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.2);
}

/* Выбор месяца должен оставаться хорошо читаемым в нативном меню браузера. */
.month-select {
    min-height: 48px;
    font-size: 1.125rem;
    line-height: 1.5;
    font-weight: 500;
}

.month-select option {
    font-size: 1.125rem;
    line-height: 1.5;
    color: var(--color-text);
    background: #fff;
}

textarea { min-height: 110px; }

.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { border: 1px solid #e5e7eb; padding: 10px; text-align: left; vertical-align: top; }

th { background: var(--color-surface-soft); font-weight: 700; text-align: center; }

table .btn,
table button {
    text-align: center;
    justify-content: center;
}

.error, .flash { border-radius: var(--radius-sm); margin-bottom: 16px; padding: 12px 14px; }
.error, .flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-success { background: #ecfdf3; color: #027a48; border: 1px solid #abefc6; }
.flash-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #93c5fd; }
.muted { color: var(--color-muted); }
.actions form { display: inline-block; margin: 0; }
.role-badge { font-size: 12px; background: rgba(255,255,255,.18); padding: 6px 10px; border-radius: 999px; }
.filter-box { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; margin-bottom: 20px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; align-items: end; }
.block-offset-top { margin-top: 20px; }
.block-offset-bottom { margin-bottom: 20px; }
.pager { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }


.page-card th {
    color: #334155;
}



@media (max-width: 768px) {
    :root {
        --header-offset: 78px;
    }

    body.login-page {
        padding-top: 0;
    }

    .header { padding: 12px; }
    .header.nav-mobile {
        align-items: flex-start;
    }
    .header-brand {
        width: 100%;
        text-align: center;
    }
    .header-brand strong {
        display: block;
        font-size: 1.5rem;
        line-height: 1.05;
        white-space: nowrap;
    }
    .page-container { padding: 10px; }
    .page-card { border-radius: 14px; padding: 14px; }
    .nav-toggle {
        display: inline-flex;
        flex: 0 0 100%;
        margin: 0 auto;
    }
    .header.nav-mobile .nav {
        display: none;
        width: 100%;
        gap: 10px;
        flex-direction: column;
        align-items: center;
    }
    .header.nav-mobile .nav.nav-open {
        display: flex;
    }
    .nav a { font-size: 16px; line-height: 1.2; }
    .header.nav-mobile .nav a,
    .header.nav-mobile .nav .dropdown {
        width: 100%;
    }
    .role-badge { font-size: 11px; padding: 4px 8px; }
    .btn, button { width: auto; max-width: 100%; }
    .nav .actions { margin-left: 0; width: 100%; }
    .nav .actions button { width: 100%; justify-content: center; }
    .filter-grid { grid-template-columns: 1fr; }
    table { min-width: 640px; }

    .cabinet-title {
        text-align: center;
    }

    .cabinet-filter-row {
        justify-content: center;
    }

    .cabinet-filter-form {
        justify-content: center;
    }


    .users-title {
        text-align: center;
    }

    .users-action-row {
        display: flex;
        justify-content: center;
    }

    .trip-reports-title {
        text-align: center;
    }

    .trip-reports-controls {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .trip-reports-controls .filter-box {
        width: 100%;
    }

    .trip-reports-controls #notReportedLine {
        text-align: center;
    }

    .trip-reports-controls .filter-grid > div:last-child {
        display: flex;
        justify-content: center;
    }

    .trip-reports-controls .filter-grid > div:last-child .btn {
        margin: 0 auto;
    }

    .header.nav-mobile .nav a {
        text-align: center;
        font-size: 1.2rem;
        font-weight: 700;
    }

    .header.nav-mobile .nav .dropdown {
        display: flex;
        justify-content: center;
    }

    .header.nav-mobile .nav .dropdown .btn {
        width: auto;
        min-width: 0;
        max-width: fit-content;
        margin: 0 auto;
        font-size: 1rem;
    }

    .header.nav-mobile .profile-menu {
        font-size: 1rem;
        text-align: center;
    }

    .header.nav-mobile .profile-menu .dropdown-item,
    .header.nav-mobile .profile-menu .dropdown-item-text,
    .header.nav-mobile .profile-menu .dropdown-header {
        font-size: 1rem;
        text-align: center;
    }
}


/* Стек уведомлений: Bootstrap складывает тосты в одном контейнере сверху вниз. */
.toast-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    /*gap: 0px;*/
}

/* Внутри фиксированного контейнера каждый тост должен жить в потоке, а не перекрывать соседей. */
.toast-container .toast {
    position: static !important;
    pointer-events: auto;
}

.toast-stack-item + .toast-stack-item {
    /*margin-top: 0px;*/
}
.trip-reports-table th,
.trip-reports-table td {
    vertical-align: middle;
}

.trip-reports-table tbody tr {
    height: 64px;
}

.trip-reports-table tbody tr.trip-row-non-work {
    background-color: #b1d7ef;
}

.trip-reports-table .add-col,
.trip-reports-table .add-cell {
    width: 80px;
    text-align: center;
}

.trip-reports-table .add-trip-btn {
    min-width: 42px;
    padding: 8px 12px;
}

.trip-reports-table .add-cell {
    white-space: nowrap;
}

.trip-reports-table .trip-report-indicator {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

.trip-reports-table .trip-report-indicator--red {
    background-color: #dc3545;
}

.trip-reports-table .trip-report-indicator--green {
    background-color: #198754;
}
/* Таблица статистики пользователя: должна полностью помещаться на мобильном экране. */
.user-stats-table {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.user-stats-table .user-stats-label,
.user-stats-table .user-stats-value {
    max-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.user-stats-table .user-stats-label {
    width: 65%;
}

.user-stats-table .user-stats-value {
    width: 35%;
    text-align: center;
}

@media (max-width: 768px) {
    .user-stats-table {
        min-width: 0 !important;
    }
}

/* Модальное окно доп. информации по рейсу: делаем поля заметно контрастнее фона окна */
#tripExtraModal .modal-content {
    background: #f8fafc;
}

#tripExtraModal .form-control {
    background: #eef2f7;
    border-color: #cbd5e1;
}

#tripExtraModal .form-control:focus {
    background: #ffffff;
    border-color: #60a5fa;
}
/*
 * Нативное раскрытое меню select оформляется операционной системой и на части
 * мобильных устройств игнорирует CSS. После загрузки JS оставляем select в форме,
 * но показываем поверх него управляемое браузером читаемое меню.
 */
.readable-select {
    position: relative;
    width: 100%;
    min-width: 220px;
}

.readable-select--enhanced .month-select {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.readable-select button.readable-select__trigger:not(.dropdown-item):not(.btn-close) {
    position: relative;
    width: 100%;
    min-height: 52px;
    padding: 12px 44px 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    background: #fff;
    box-shadow: none;
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    justify-content: flex-start;
}

.readable-select button.readable-select__trigger:not(.dropdown-item):not(.btn-close)::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 16px;
    width: 10px;
    height: 10px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-70%) rotate(45deg);
}

.readable-select button.readable-select__trigger:not(.dropdown-item):not(.btn-close):focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.2);
    outline: none;
}

.readable-select__menu {
    position: absolute;
    z-index: 1100;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    min-width: max-content;
    max-height: min(360px, 60vh);
    overflow-y: auto;
    padding: 6px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    background: #fff;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.2);
}

.readable-select button.readable-select__option:not(.dropdown-item):not(.btn-close) {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    color: var(--color-text);
    background: #fff;
    box-shadow: none;
    font-size: 1.125rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
}

.readable-select button.readable-select__option:not(.dropdown-item):not(.btn-close):hover,
.readable-select button.readable-select__option:not(.dropdown-item):not(.btn-close):focus {
    color: #0f172a;
    background: #eff6ff;
    outline: none;
}

.readable-select button.readable-select__option--selected:not(.dropdown-item):not(.btn-close) {
    color: #fff;
    background: var(--color-primary);
}