* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        sans-serif;

    background: #f4f6f8;
    color: #17202a;
}


/* Layout */

.app-layout {
    display: flex;
    min-height: 100vh;
}


/* Sidebar */

.sidebar {
    width: 260px;
    min-width: 260px;

    background: #18222f;
    color: white;

    padding: 20px 14px;

    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    align-self: flex-start;
    overflow-y: auto;
}


.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 5px 8px 25px;
}


.logo-icon {
    width: 42px;
    height: 42px;

    border-radius: 12px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #ffffff;
    color: #18222f;

    font-weight: 800;
}


.logo-title {
    font-weight: 700;
    font-size: 17px;
}


.logo-subtitle {
    margin-top: 3px;

    font-size: 11px;

    color: #aeb9c5;
}


.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}


.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 11px 12px;

    border-radius: 9px;

    color: #dfe6ed;
    text-decoration: none;

    font-size: 14px;

    transition: 0.15s ease;
}


.nav-link:hover {
    background: #253344;
    color: white;
}

.nav-link[aria-current] {
    background: #253344;
    color: white;
}


.nav-icon {
    width: 20px;
    text-align: center;
}


.nav-section {
    margin:
        20px 12px
        8px;

    color: #7f8c9b;

    font-size: 10px;
    font-weight: 700;

    letter-spacing: 0.08em;
}


/* Main */

.main-content {
    flex: 1;
    min-width: 0;
}


.topbar {
    height: 76px;

    padding: 0 30px;

    background: white;

    border-bottom: 1px solid #e8ebef;

    display: flex;
    align-items: center;
    justify-content: space-between;
}


.topbar-company {
    font-size: 15px;
    font-weight: 700;
}


.topbar-date {
    margin-top: 3px;

    color: #89929c;
    font-size: 12px;
}


.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}


.user-data {
    display: flex;
    flex-direction: column;
    text-align: right;

    font-size: 13px;
}


.user-data span {
    color: #8b949e;
    font-size: 11px;

    margin-top: 2px;
}


.user-avatar {
    width: 38px;
    height: 38px;

    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #edf1f5;

    font-weight: 700;
}


.logout-button {
    border: 0;
    background: none;
    cursor: pointer;

    color: #7a8490;
}


.page-content {
    padding: 30px;
}


/* Heading */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;
    flex-wrap: wrap;

    margin-bottom: 24px;
}


.page-header h1 {
    margin: 0;

    font-size: 27px;
    line-height: 1.2;
}


.page-header p {
    margin: 7px 0 0;

    color: #7c8794;

    font-size: 14px;
}


/* Statistics */

.stats-grid {
    display: grid;

    grid-template-columns:
        repeat(
            5,
            minmax(150px, 1fr)
        );

    gap: 16px;

    margin-bottom: 24px;
}


.stat-card {
    background: white;

    border: 1px solid #e7ebef;
    border-radius: 14px;

    padding: 20px;

    box-shadow:
        0 2px 8px
        rgba(20, 30, 40, 0.03);
}


.stat-label {
    color: #74808c;

    font-size: 12px;
    font-weight: 600;
}


.stat-value {
    margin-top: 10px;

    font-size: 32px;
    font-weight: 750;
}


.stat-footer {
    margin-top: 8px;

    color: #a0a8b1;

    font-size: 11px;
}


/* Cards */

.content-card {
    min-width: 0;
    background: white;

    border:
        1px solid
        #e7ebef;

    border-radius: 14px;

    overflow: hidden;

    box-shadow:
        0 2px 8px
        rgba(20, 30, 40, 0.03);
}


.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;

    padding: 20px 22px;

    border-bottom: 1px solid #eef0f2;
}


.card-header h2 {
    margin: 0;

    font-size: 17px;
}


.card-header p {
    margin: 5px 0 0;

    color: #87919c;

    font-size: 12px;
}


/* Tables */

.table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}


table {
    width: 100%;

    border-collapse: collapse;
}


th {
    padding: 13px 17px;

    background: #f8f9fa;

    text-align: left;

    color: #707b87;

    font-size: 11px;
    font-weight: 700;

    text-transform: uppercase;

    letter-spacing: 0.03em;

    border-bottom: 1px solid #e8ebef;
}


td {
    padding: 14px 17px;

    font-size: 13px;

    border-bottom: 1px solid #eef0f2;

    white-space: nowrap;
}


tbody tr:hover {
    background: #fafbfc;
}


.strong-cell {
    font-weight: 700;
}


.table-link {
    color: #1e5c96;
    text-decoration: none;
}


.table-link:hover {
    text-decoration: underline;
}


.empty-state {
    text-align: center;

    color: #8c959f;

    padding: 50px;
}


/* Status */

.status-badge {
    display: inline-flex;

    align-items: center;

    border-radius: 999px;

    padding: 5px 9px;

    background: #edf1f5;

    color: #4a5662;

    font-size: 11px;
    font-weight: 650;
}


.status-planned {
    background: #e9f1ff;
    color: #2463a6;
}


.status-in_transit {
    background: #fff2d9;
    color: #946400;
}


.status-completed {
    background: #e3f6ea;
    color: #267044;
}


.status-cancelled {
    background: #f5e6e6;
    color: #944141;
}


/* Buttons */

.button {
    display: inline-flex;

    justify-content: center;
    align-items: center;

    min-height: 40px;
    max-width: 100%;

    padding: 10px 16px;
    line-height: 1.35;
    text-align: center;
    overflow-wrap: anywhere;

    border-radius: 9px;

    border: 1px solid transparent;

    text-decoration: none;

    font-size: 13px;
    font-weight: 650;

    cursor: pointer;
}


.primary-button {
    background: #1f5d93;
    color: white;
}


.primary-button:hover {
    background: #184d7b;
}


.secondary-button {
    background: white;

    border-color: #dce1e6;

    color: #44515e;
}


/* Filters */

.filters-card {
    margin-bottom: 18px;

    padding: 18px;
}


.filters {
    display: flex;

    align-items: flex-end;

    gap: 12px;

    flex-wrap: wrap;
}


.field {
    display: flex;
    flex-direction: column;

    gap: 6px;
}


.field label {
    font-size: 11px;

    font-weight: 700;

    color: #68737f;
}


.field input,
.field select {
    height: 40px;

    min-width: 190px;

    padding: 0 11px;

    border: 1px solid #d9dee4;

    border-radius: 8px;

    background: white;

    outline: none;

    font: inherit;
    font-size: 13px;
}


.field input:focus,
.field select:focus {
    border-color: #1f5d93;

    box-shadow:
        0 0 0 3px
        rgba(31, 93, 147, 0.08);
}


.search-field input {
    width: 300px;
}


.filter-buttons {
    display: flex;
    gap: 8px;
}


/* Pagination */

.pagination {
    padding: 16px 20px;

    display: flex;
    justify-content: center;
    align-items: center;

    gap: 18px;
    flex-wrap: wrap;

    border-top: 1px solid #eef0f2;

    font-size: 12px;
}


.pagination a {
    color: #1f5d93;
    text-decoration: none;
}


/* Login */

.login-body {
    background: #eef2f5;

    min-height: 100vh;
}


.login-wrapper {
    min-height: 100vh;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;
}


.login-card {
    width: 100%;
    max-width: 410px;

    padding: 38px;

    background: white;

    border: 1px solid #e1e6ea;

    border-radius: 18px;

    box-shadow:
        0 10px 35px
        rgba(20, 30, 40, 0.08);
}


.login-logo {
    width: 52px;
    height: 52px;

    margin-bottom: 22px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 14px;

    background: #18222f;
    color: white;

    font-weight: 800;
}


.login-card h1 {
    margin: 0;

    font-size: 23px;
}


.login-card > p {
    margin:
        8px 0
        26px;

    color: #7c8793;

    font-size: 13px;
}


.login-card .field {
    margin-bottom: 16px;
}


.login-card input {
    width: 100%;
}


.login-button {
    width: 100%;

    margin-top: 6px;
}


.login-error {
    padding: 10px 12px;

    margin-bottom: 16px;

    border-radius: 8px;

    background: #fcecec;

    color: #a34242;

    font-size: 12px;
}


/* Adaptive */

@media (max-width: 1200px) {

    .stats-grid {
        grid-template-columns:
            repeat(3, 1fr);
    }

}


@media (max-width: 850px) {

    .app-layout {
        display: block;
    }


    .sidebar {
        width: 100%;
        min-width: 0;
        min-height: auto;
        position: static;
        height: auto;
        overflow-y: visible;
    }


    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
    }


    .nav-section {
        display: none;
    }


    .nav-link {
        white-space: nowrap;
    }


    .topbar {
        padding: 0 16px;
    }


    .user-data {
        display: none;
    }


    .page-content {
        padding: 18px;
    }


    .stats-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }

}


@media (max-width: 520px) {

    .stats-grid {
        grid-template-columns: 1fr;
    }


    .page-header {
        align-items: flex-start;
        flex-direction: column;
    }


    .search-field,
    .search-field input,
    .field,
    .field input,
    .field select {
        width: 100%;
    }

}
/* =========================================
   Trip forms
========================================= */

.trip-section {
    margin-bottom: 20px;
    padding: 22px;
}


.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;

    margin-bottom: 20px;
}


.section-heading h2 {
    margin: 0;

    font-size: 17px;
}


.section-heading p {
    margin: 5px 0 0;

    color: #87919c;
    font-size: 12px;
}


.form-grid {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            minmax(0, 1fr)
        );

    gap: 18px;
}


.form-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}


.form-field label {
    color: #65717d;

    font-size: 11px;
    font-weight: 700;
}


.form-field input,
.form-field select,
.form-field textarea {

    width: 100%;

    padding: 10px 11px;

    border: 1px solid #d9dee4;
    border-radius: 8px;

    background: white;

    font: inherit;
    font-size: 13px;

    outline: none;
}


.form-field input,
.form-field select {
    min-height: 40px;
}


.form-field textarea {
    resize: vertical;
}


.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {

    border-color: #1f5d93;

    box-shadow:
        0 0 0 3px
        rgba(31, 93, 147, 0.08);
}


.errorlist {
    margin: 0;
    padding: 0;

    list-style: none;

    color: #ad3e3e;

    font-size: 11px;
}


.form-error-box {
    margin-bottom: 18px;
    padding: 12px 14px;

    border-radius: 8px;

    background: #fcecec;

    color: #9c3939;

    font-size: 12px;
}


.odometer-check {
    margin-top: 20px;

    padding-top: 20px;

    border-top: 1px solid #eef0f2;
}


.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;

    margin-bottom: 15px;

    font-size: 13px;
}


.checkbox-row input {
    width: auto;
}


.formset-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}


.subform-row {
    display: grid;

    grid-template-columns:
        minmax(180px, 1fr)
        minmax(160px, 220px)
        minmax(200px, 1.5fr)
        auto;

    gap: 12px;

    align-items: end;

    padding: 15px;

    background: #f8f9fa;

    border: 1px solid #e9ecef;
    border-radius: 10px;
}


.cargo-row {
    grid-template-columns:
        1.3fr
        1.5fr
        110px
        110px
        90px
        1.5fr
        auto;
}


.point-row {
    grid-template-columns:
        60px
        130px
        1fr
        1fr
        2fr
        170px
        170px
        1fr
        auto;
}


.small-field {
    min-width: 0;
}


.wide-field {
    min-width: 220px;
}


.delete-check {
    display: flex;
    align-items: center;
    gap: 5px;

    padding-bottom: 10px;

    color: #a14b4b;

    font-size: 11px;
}


.trip-actions {
    position: sticky;

    bottom: 0;

    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    z-index: 2;

    padding: 15px 0;

    background:
        linear-gradient(
            to top,
            #f4f6f8 75%,
            rgba(244, 246, 248, 0)
        );
}


.large-button {
    min-width: 160px;
}


/* Trip detail */

.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}


.detail-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 20px;
}


.detail-list {
    display: grid;
    gap: 13px;
}


.detail-list > div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    min-width: 0;

    padding-bottom: 11px;

    border-bottom:
        1px solid
        #eef0f2;
}


.detail-list span {
    color: #7c8792;

    font-size: 12px;
}


.detail-list strong {
    text-align: right;

    font-size: 13px;
    min-width: 0;
    overflow-wrap: anywhere;
}


.trip-total {
    font-size: 20px;
}


.route-timeline {
    display: flex;
    flex-direction: column;
}


.route-point {
    position: relative;

    display: flex;
    gap: 15px;

    padding-bottom: 22px;
}


.route-point:not(:last-child)::before {
    content: "";

    position: absolute;

    left: 17px;
    top: 34px;
    bottom: 0;

    width: 2px;

    background: #dfe4e9;
}


.route-number {
    position: relative;
    z-index: 1;

    width: 36px;
    height: 36px;

    flex: 0 0 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #1f5d93;
    color: white;

    font-weight: 700;
    font-size: 12px;
}


.route-title {
    font-weight: 700;
    font-size: 13px;
}


.route-address {
    margin-top: 5px;

    color: #46515c;

    font-size: 13px;
    overflow-wrap: anywhere;
}


.route-meta {
    margin-top: 5px;

    color: #88929c;

    font-size: 11px;
}


.trip-note {
    font-size: 13px;
    line-height: 1.6;
}


/* Messages */

.messages {
    margin-bottom: 18px;
}


.message {
    padding: 12px 15px;

    border-radius: 9px;

    font-size: 13px;
}


.message-success {
    background: #e4f5ea;
    color: #276d43;
}


/* Responsive */

@media (max-width: 1600px) {

    .point-row,
    .cargo-row {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

}


@media (max-width: 1000px) {

    .form-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }


    .detail-grid {
        grid-template-columns: 1fr;
    }


    .subform-row {
        grid-template-columns:
            repeat(2, 1fr);
    }

}


@media (max-width: 650px) {

    .form-grid,
    .subform-row,
    .cargo-row,
    .point-row {
        grid-template-columns: 1fr;
    }

}
/* =========================================
   Universal model forms
========================================= */

.model-form-card {
    padding: 24px;
}


.model-form-grid {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            minmax(0, 1fr)
        );

    gap: 20px;
}


.model-form-grid .form-field:has(textarea) {
    grid-column:
        span 2;
}


.field-help {
    color: #8d97a1;
    font-size: 11px;
    line-height: 1.4;
}


.checkbox-field {
    justify-content: center;
}


.form-field ul {
    margin: 0;
    padding: 0;

    list-style: none;
}


.form-field ul li {
    margin-bottom: 7px;
}


.form-field ul label {
    display: flex;
    align-items: center;
    gap: 7px;

    font-size: 13px;
}


.form-field ul input[type="checkbox"] {
    width: auto;
    min-height: auto;
}


@media (max-width: 1000px) {

    .model-form-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }

}


@media (max-width: 650px) {

    .model-form-grid {
        grid-template-columns: 1fr;
    }


    .model-form-grid .form-field:has(textarea) {
        grid-column: span 1;
    }

}

.route-template-row {
    grid-template-columns:
        70px
        150px
        minmax(160px, 1fr)
        minmax(260px, 2fr)
        minmax(180px, 1fr)
        auto;
}


@media (max-width: 1200px) {

    .route-template-row {
        grid-template-columns:
            repeat(2, 1fr);
    }

}


@media (max-width: 650px) {

    .route-template-row {
        grid-template-columns: 1fr;
    }

}

/* =========================================
   Dispatch calendar
========================================= */

.calendar-toolbar {
    margin-bottom: 18px;

    padding: 16px 18px;

    display: flex;
    justify-content: space-between;
    align-items: center;

    gap: 20px;
}


.calendar-navigation {
    display: flex;
    align-items: center;

    gap: 14px;
}


.calendar-period {
    min-width: 190px;

    display: flex;
    flex-direction: column;

    align-items: center;

    gap: 3px;
}


.calendar-period strong {
    font-size: 14px;
}


.calendar-period span {
    color: #86919c;
    font-size: 11px;
}


.calendar-date-select form {
    display: flex;
    align-items: end;

    gap: 8px;
}


.calendar-date-select label {
    display: flex;
    flex-direction: column;

    color: #697580;

    font-size: 11px;
    font-weight: 700;
}


.calendar-date-select input {
    height: 40px;

    padding: 0 10px;

    border: 1px solid #d9dee4;
    border-radius: 8px;

    font: inherit;
}


.calendar-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;

    margin-bottom: 12px;
}


.calendar-tab {
    padding: 10px 18px;

    border: 1px solid #dce1e6;
    border-radius: 9px;

    background: white;

    color: #606c78;

    cursor: pointer;

    font-weight: 650;
}


.calendar-tab.active {
    background: #18222f;
    border-color: #18222f;

    color: white;
}


.calendar-section {
    display: none;
}


.calendar-section.active {
    display: block;
}


.calendar-section-header {
    padding: 18px 20px;

    border-bottom: 1px solid #e8ebef;
}


.calendar-section-header h2 {
    margin: 0;

    font-size: 17px;
}


.calendar-section-header p {
    margin: 5px 0 0;

    color: #87919c;
    font-size: 12px;
}


.dispatch-calendar-wrapper {
    overflow-x: auto;
}


.dispatch-calendar {
    min-width: 1250px;

    table-layout: fixed;
}


.dispatch-calendar th,
.dispatch-calendar td {
    border-right: 1px solid #edf0f2;
}


.calendar-resource-column {
    width: 210px;
}


.calendar-resource {
    width: 210px;

    vertical-align: top;

    background: #fafbfc;
}


.calendar-resource a {
    display: block;

    color: #263541;

    font-weight: 750;
    text-decoration: none;
}


.calendar-resource span {
    display: block;

    margin-top: 4px;

    color: #8a949e;
    font-size: 11px;

    white-space: normal;
}


.calendar-day-header {
    width: 150px;

    text-align: center;
}


.calendar-day-header strong,
.calendar-day-header span {
    display: block;
}


.calendar-weekday {
    margin-bottom: 3px;

    color: #929ba5;

    font-size: 10px;

    text-transform: uppercase;
}


.calendar-today {
    background: #edf5ff;
}


.calendar-cell {
    min-height: 100px;

    padding: 7px;

    vertical-align: top;

    white-space: normal;
}


.calendar-today-cell {
    background: #f8fbff;
}


.calendar-trip {
    display: block;

    margin-bottom: 6px;
    padding: 8px 9px;

    border-left: 3px solid #8898a8;
    border-radius: 7px;

    background: #f1f4f6;

    color: #263541;

    text-decoration: none;

    transition: 0.15s ease;
}


.calendar-trip:hover {
    transform: translateY(-1px);

    box-shadow:
        0 3px 10px
        rgba(20, 30, 40, 0.08);
}


.calendar-trip strong {
    display: block;

    font-size: 11px;
}


.calendar-trip span {
    display: block;

    margin-top: 3px;

    overflow: hidden;

    color: #66727e;

    font-size: 10px;

    text-overflow: ellipsis;
}


.calendar-trip-draft {
    border-left-color: #86919c;
}


.calendar-trip-planned,
.calendar-trip-assigned {
    border-left-color: #2874ba;

    background: #edf5ff;
}


.calendar-trip-departed,
.calendar-trip-loading,
.calendar-trip-in_transit,
.calendar-trip-unloaded {
    border-left-color: #d69724;

    background: #fff6e5;
}

.calendar-trip-unfinished {
    border-left-color: #d69724;
    background: #fff6e5;
}


.calendar-trip-completed,
.calendar-trip-accounting_closed {
    border-left-color: #358757;

    background: #ebf7ef;
}


.calendar-conflict-cell {
    background: #fff6f6;
}


.conflict-warning {
    margin-bottom: 6px;

    padding: 4px 6px;

    border-radius: 5px;

    background: #ffe3e3;

    color: #a83d3d;

    font-size: 9px;
    font-weight: 750;

    text-transform: uppercase;
}


@media (max-width: 1200px) {

    .calendar-toolbar {
        align-items: stretch;
        flex-direction: column;
    }


    .calendar-navigation {
        justify-content: space-between;
    }


    .calendar-date-select form {
        align-items: stretch;
        flex-direction: column;
    }

}


.conflict-override-card {
    border: 1px solid #efc36a;
    background: #fffaf0;
}


.trip-closed-card {
    border: 1px solid #8cc9a2;
    background: #f3fbf6;
}


.trip-action-form {
    display: grid;
    gap: 16px;
}


.trip-action-form .button {
    justify-self: start;
}


.form-help {
    margin: 0;
    color: #66727e;
    font-size: 13px;
}


.coordinate-hint {
    display: block;
    margin-top: 5px;
    color: #7b8793;
    font-size: 11px;
}


.route-map-card {
    margin-top: 20px;
}


.route-map {
    width: 100%;
    height: 420px;
    overflow: hidden;
    border: 1px solid #dfe4e8;
    border-radius: 10px;
    background: #eef1f3;
}


.route-calculation-summary {
    display: flex;
    gap: 18px;
    align-items: center;
    margin-bottom: 16px;
    color: #66727e;
    font-size: 13px;
}


.route-calculation-summary strong {
    color: #263541;
    font-size: 18px;
}


.profile-stats {
    margin-bottom: 20px;
}


.profile-status-value {
    margin-top: 10px;
    color: #263541;
    font-size: 22px;
    font-weight: 750;
}


.assignment-card {
    display: grid;
    gap: 6px;
    padding: 15px 0;
    border-bottom: 1px solid #edf0f2;
}


.assignment-card:last-child {
    border-bottom: 0;
}


.assignment-card > span,
.document-card > span {
    color: #87919c;
    font-size: 12px;
}


.assignment-card small,
.document-card small {
    color: #66727e;
    font-size: 12px;
}


.assignment-link {
    color: #246da8;
    font-weight: 750;
    text-decoration: none;
}


.assignment-link:hover {
    text-decoration: underline;
}


.document-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}


.document-card {
    display: grid;
    gap: 7px;
    padding: 16px;
    border: 1px solid #e4e8eb;
    border-radius: 9px;
    background: #fafbfc;
}


.document-warning {
    border-color: #efc36a;
    background: #fffaf0;
}


.document-expired {
    border-color: #e4a0a0;
    background: #fff5f5;
}


.document-missing {
    border-style: dashed;
}


.profile-section-heading {
    padding: 18px 20px;
    border-bottom: 1px solid #edf0f2;
}


@media (max-width: 800px) {
    .document-grid {
        grid-template-columns: 1fr;
    }
}


.document-card-link {
    color: inherit;
    text-decoration: none;
    transition: 0.15s ease;
}


.document-card-link:hover {
    transform: translateY(-1px);
    border-color: #b8c5d0;
    box-shadow: 0 4px 12px rgba(20, 30, 40, 0.06);
}


.document-empty-state {
    grid-column: 1 / -1;
}


.dashboard-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}


.stat-card-danger {
    border-color: #e4a0a0;
    background: #fff7f7;
}


.dashboard-section {
    margin-bottom: 20px;
}


.dashboard-section-heading {
    padding: 18px 20px;
    border-bottom: 1px solid #edf0f2;
}


.document-alert-list {
    display: grid;
}


.document-alert {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 20px;
    border-bottom: 1px solid #edf0f2;
    color: #263541;
    text-decoration: none;
}


.document-alert:last-child {
    border-bottom: 0;
}


.document-alert:hover {
    background: #fafbfc;
}


.document-alert > div {
    display: grid;
    gap: 4px;
}


.document-alert span {
    color: #74808c;
    font-size: 12px;
}


.document-alert-date {
    text-align: right;
}


.document-alert-expired {
    border-left: 4px solid #c94d4d;
}


.document-alert-warning {
    border-left: 4px solid #d69a2d;
}


.status-in_progress {
    background: #fff1d8;
    color: #9a6512;
}

.status-pending {
    background: #fff1d8;
    color: #9a6512;
}

.status-paid {
    background: #e3f6ea;
    color: #267044;
}

.status-overdue {
    background: #f5e6e6;
    color: #944141;
}


.maintenance-line-row {
    grid-template-columns: minmax(240px, 2fr) minmax(100px, 0.6fr) minmax(140px, 1fr) auto;
}


.fuel-summary-grid {
    margin-bottom: 24px;
}


.fuel-stat-value {
    font-size: 28px;
}


.fuel-filter-form {
    margin-bottom: 24px;
}


.checkbox-filter {
    display: flex;
    align-items: center;
    align-self: end;
    gap: 8px;
    min-height: 42px;
}


.checkbox-filter input {
    width: auto;
}


.table-subtext {
    display: block;
    margin-top: 4px;
    color: #718096;
    font-size: 12px;
}


.muted-text {
    color: #8a94a6;
}


.consumption-badge {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}


.consumption-normal {
    color: #17663a;
    background: #e9f8ef;
}


.consumption-warning {
    color: #9b2c2c;
    background: #fff0f0;
}


.section-footer {
    margin-top: 18px;
    text-align: right;
}


@media (max-width: 800px) {
    .dashboard-stats {
        grid-template-columns: 1fr 1fr;
    }

    .document-alert {
        align-items: flex-start;
        flex-direction: column;
    }

    .document-alert-date {
        text-align: left;
    }
}


.dispatch-date-card {
    margin-bottom: 24px;
    padding: 20px;
}

.dispatch-date-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.dispatch-date-form .form-field {
    min-width: 180px;
}

.dispatch-state-note {
    margin: 14px 0 0;
    color: #718096;
    font-size: 12px;
    line-height: 1.6;
}

.dispatch-board {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr);
    gap: 24px;
    align-items: start;
}

.dispatch-fleet-column,
.dispatch-trips-column {
    min-width: 0;
}

.dispatch-fleet-table {
    min-width: 720px;
}

.dispatch-table-item + .dispatch-table-item {
    margin-top: 12px;
}

.dispatch-trip-list {
    display: grid;
    gap: 12px;
}

.dispatch-trip-card {
    display: grid;
    gap: 6px;
    padding: 14px;
    border: 1px solid #e6ebf1;
    border-radius: 12px;
    color: #334155;
    text-decoration: none;
    font-size: 13px;
}

.dispatch-trip-card:hover {
    background: #f8fafc;
}

.dispatch-trip-card small {
    color: #718096;
    line-height: 1.5;
}

.dispatch-trip-heading {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.dispatch-trip-attention {
    border-left: 4px solid #d69a2d;
}

@media (max-width: 1250px) {
    .dispatch-board {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Shared page controls and final responsive overrides. */
.topbar {
    height: auto;
    min-height: 76px;
    padding-top: 12px;
    padding-bottom: 12px;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar > div,
.page-header > div,
.section-heading > div,
.card-header > div,
.route-content,
.detail-grid > *,
.form-grid > *,
.model-form-grid > *,
.subform-row > * {
    min-width: 0;
}

.topbar-user {
    margin-left: auto;
}

.user-data,
.page-header h1,
.section-heading h2,
.stat-value,
.stat-footer,
.dispatch-trip-card,
.document-card,
.trip-note {
    overflow-wrap: anywhere;
}

.stat-value {
    line-height: 1.2;
}

.stat-footer {
    line-height: 1.5;
}

.user-avatar,
.nav-icon {
    flex-shrink: 0;
}

.form-field input,
.form-field select,
.form-field textarea,
.field input,
.field select {
    min-width: 0;
    max-width: 100%;
}

.form-field input[type="checkbox"],
.form-field input[type="radio"] {
    width: auto;
    min-height: auto;
    align-self: flex-start;
}

.form-field input:disabled,
.form-field select:disabled {
    background: #f3f5f7;
    color: #65717d;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.form-actions + .content-card,
form.content-card + .content-card {
    margin-top: 20px;
}

.form-help {
    line-height: 1.5;
}

.model-form-grid + .form-help,
.form-field + .form-help {
    margin-top: 16px;
}

.form-field .errorlist,
.subform-row > .form-error-box {
    line-height: 1.5;
}

.subform-row > .form-error-box {
    grid-column: 1 / -1;
    margin-bottom: 0;
}

.messages {
    display: grid;
    gap: 10px;
}

.message {
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.message-warning {
    background: #fff4db;
    color: #855a11;
}

.message-error {
    background: #fcecec;
    color: #9c3939;
}

.message-info {
    background: #edf5ff;
    color: #245a88;
}

.status-assigned,
.status-posted {
    background: #e9f1ff;
    color: #2463a6;
}

.status-departed,
.status-loading,
.status-unloaded,
.status-unfinished,
.status-in_trip,
.status-maintenance {
    background: #fff2d9;
    color: #946400;
}

.status-free,
.status-accounting_closed {
    background: #e3f6ea;
    color: #267044;
}

.status-repair,
.status-broken {
    background: #f5e6e6;
    color: #944141;
}

.dispatch-fleet-column .dashboard-section > .dispatch-state-note {
    margin: 0;
    padding: 16px 20px;
}

.dispatch-trips-column .dashboard-section > .section-heading {
    padding: 20px;
    margin: 0;
    border-bottom: 1px solid #edf0f2;
}

.dispatch-trips-column .dispatch-trip-list {
    padding: 16px;
}

.maintenance-part-row {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 0.6fr) minmax(0, 1fr) auto;
}

.button:focus-visible,
.nav-link:focus-visible,
.calendar-tab:focus-visible,
.table-link:focus-visible {
    outline: 3px solid #6b9dca;
    outline-offset: 3px;
}

.table-wrapper:focus-visible,
.dispatch-calendar-wrapper:focus-visible {
    outline: 3px solid #6b9dca;
    outline-offset: -3px;
}

@media (max-width: 1100px) {
    .maintenance-line-row,
    .maintenance-part-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 850px) {
    .sidebar-nav {
        padding-bottom: 8px;
        max-width: 100%;
        overscroll-behavior-x: contain;
    }
    .nav-link {
        flex-shrink: 0;
    }
    .calendar-navigation {
        flex-wrap: wrap;
        gap: 8px;
    }
    .calendar-period {
        min-width: 0;
        flex: 1 1 180px;
    }
}

@media (max-width: 650px) {
    .page-content {
        padding: 16px;
    }
    .model-form-card,
    .trip-section {
        padding: 16px;
    }
    .form-grid,
    .model-form-grid,
    .subform-row,
    .cargo-row,
    .point-row,
    .route-template-row,
    .maintenance-line-row,
    .maintenance-part-row {
        grid-template-columns: minmax(0, 1fr);
    }
    .wide-field,
    .field {
        min-width: 0;
    }
    .detail-list > div {
        flex-direction: column;
        gap: 6px;
    }
    .detail-list strong {
        text-align: left;
    }
    .card-header,
    .dashboard-section-heading,
    .profile-section-heading {
        padding: 16px;
    }
    .empty-state {
        padding: 28px 16px;
        white-space: normal;
    }
    .calendar-period {
        order: -1;
        flex-basis: 100%;
    }
    .calendar-tab {
        padding: 10px 12px;
    }
    .calendar-date-select input,
    .dispatch-date-form .form-field {
        width: 100%;
        min-width: 0;
    }
    .trip-actions {
        justify-content: flex-start;
    }
    .dispatch-date-card {
        padding: 16px;
    }
}

@media (max-width: 520px) {
    .stats-grid,
    .dashboard-stats {
        grid-template-columns: minmax(0, 1fr);
    }
    .topbar-date {
        display: none;
    }
    .login-card {
        padding: 24px;
    }
    .login-card input {
        min-width: 0;
    }
    .form-actions .button,
    .filter-buttons .button {
        flex: 1 1 auto;
    }
    .filter-buttons {
        flex-wrap: wrap;
        width: 100%;
    }
    .filters > .field,
    .calendar-navigation > .button {
        flex: 1 1 auto;
    }
}
/* Administrative preferences reuse the existing responsive forms and tables. */
.system-api-section { margin-top: 24px; }
.system-api-section .card-header { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.system-api-notice { padding: 0 24px; color: #64748b; line-height: 1.6; }
.api-name { white-space: normal; overflow-wrap: anywhere; min-width: 140px; max-width: 220px; }
.api-address { white-space: normal; overflow-wrap: anywhere; min-width: 180px; max-width: 300px; }
.api-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.api-actions form { margin: 0; }
.date-input-control { position: relative; display: inline-grid; grid-template-columns: minmax(0, 1fr) 42px; align-items: stretch; gap: 6px; width: 100%; min-width: 0; }
.date-input-control > input[data-date-kind] { width: 100%; min-width: 0; }
.date-calendar-button { padding: 0; min-height: 40px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc; color: #334155; cursor: pointer; font-size: 24px; }
.date-calendar-button:hover { background: #e2e8f0; }
.date-calendar-button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.date-calendar-button:disabled { cursor: default; opacity: .5; }
.date-input-control > .date-native-picker { position: absolute; top: 0; right: 0; width: 42px; height: 100%; opacity: 0; pointer-events: none; }
.date-input-control > .date-native-picker-fallback { position: static; grid-column: 1 / -1; width: 100%; opacity: 1; pointer-events: auto; }
