:root {
    --navy: #2677fe;
    --navy-2: #2677fe;
    --blue: #2677fe;
    --blue-soft: #dceaf5;
    --sky: #8dbbd8;
    --bg: #f5f7fa;
    --panel: #ffffff;
    --line: #dde3ea;
    --line-soft: #edf1f5;
    --text: #172033;
    --muted: #6c788a;
    --muted-2: #9aa5b5;
    --danger: #c94040;
    --success: #237a57;
    --warning: #c87519;
    --purple: #5661a8;
    --shadow: 0 18px 45px rgba(38, 119, 254, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    color: var(--text);
    background: var(--bg);
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

img {
    max-width: 100%;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: 240px;
    display: flex;
    flex-direction: column;
    background: #fbfcfd;
    border-right: 1px solid var(--line);
    transition: transform 0.2s ease;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 22px 18px;
    border-bottom: 1px solid var(--line-soft);
    background: #fff;
}

.brand-logo-wrap {
    width: 54px;
    min-width: 54px;
    height: 44px;
    display: grid;
    place-items: center;
    background: #fff;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    overflow: hidden;
}

.brand-logo-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
    background: #fff;
}

.brand strong {
    display: block;
    font-size: 15px;
    color: var(--navy);
}

.brand span {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--muted);
}

.side-nav {
    padding: 14px 12px;
    overflow-y: auto;
}

.side-link {
    position: relative;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px 10px 14px;
    margin-bottom: 4px;
    color: #39475d;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
}

.side-link:hover {
    background: #f0f3f7;
}

.side-link.active {
    background: #eef2f6;
    color: var(--navy);
}

.side-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 4px;
    border-radius: 6px;
    background: var(--navy);
}

.sidebar-bottom {
    margin-top: auto;
    padding: 14px;
    border-top: 1px solid var(--line-soft);
}

.module-switcher {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--navy);
    font-size: 13px;
    font-weight: 700;
}

.app-main {
    width: 100%;
    min-width: 0;
    margin-left: 240px;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 28px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 28px;
    min-width: 0;
}

.topbar h1 {
    margin: 0;
    font-size: 20px;
    color: var(--navy);
    white-space: nowrap;
}

.top-nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

.top-nav a {
    position: relative;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.top-nav a.active {
    color: var(--text);
}

.top-nav a.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 6px;
    height: 2px;
    background: #2677fe;
    border-radius: 10px;
}

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

.content {
    flex: 1;
    padding: 24px 28px 28px;
}

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

.page-head h2 {
    margin: 0;
    color: var(--navy);
    font-size: 24px;
}

.page-head p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.filters-bar,
.button-row,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.filters-bar {
    padding: 12px;
    margin-bottom: 18px;
    background: #fff;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
}

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

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

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

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

.card,
.panel {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.metric-card {
    position: relative;
    min-height: 128px;
    padding: 18px 18px 16px;
    overflow: hidden;
}

.metric-card.accent::before {
    content: "";
    position: absolute;
    inset: 18px auto 18px 0;
    width: 4px;
    background: var(--navy);
    border-radius: 10px;
}

.metric-label {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.metric-value {
    margin-top: 12px;
    color: var(--navy);
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
}

.metric-help {
    margin-top: 9px;
    color: var(--muted);
    font-size: 12px;
}

.metric-watermark {
    position: absolute;
    right: 16px;
    bottom: 10px;
    opacity: 0.08;
    transform: scale(2.5);
}

.panel {
    padding: 18px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-header h3 {
    margin: 0;
    color: var(--navy);
    font-size: 16px;
}

.panel-subtitle {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.chart-wrap {
    position: relative;
    height: 300px;
}

.chart-wrap.small {
    height: 230px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    padding: 12px 10px;
    text-align: left;
    color: var(--muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

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

.table-actions {
    display: flex;
    gap: 7px;
    flex-wrap: nowrap;
}

.avatar,
.initials {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: var(--blue-soft);
    color: var(--navy);
    font-size: 13px;
    font-weight: 800;
}

.person-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.person-cell small {
    display: block;
    color: var(--muted);
    margin-top: 2px;
}

.badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    justify-content: center;
    padding: 4px 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.badge-success { color: var(--success); background: #e6f4ee; }
.badge-info { color: #236a97; background: #e5f1f8; }
.badge-warning { color: var(--warning); background: #fff1de; }
.badge-danger { color: var(--danger); background: #fde8e8; }
.badge-muted { color: #667080; background: #eef1f4; }
.badge-purple { color: var(--purple); background: #eceeff; }

.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: #fff;
    color: var(--navy);
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

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

.btn-secondary {
    color: var(--navy);
    background: #fff;
    border-color: var(--line);
}

.btn-danger {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

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

.icon-button {
    position: relative;
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.notification-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    display: inline-grid;
    place-items: center;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--danger);
    color: #fff;
    border: 2px solid #fff;
    font-size: 10px;
    font-weight: 900;
}

.notification-panel {
    width: 330px;
}

.notification-head,
.notification-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 8px 10px;
    border-bottom: 1px solid var(--line-soft);
}

.notification-head span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.notification-list {
    max-height: 310px;
    overflow-y: auto;
    padding: 6px 0;
}

.notification-list a,
.notification-list p {
    display: block;
    margin: 0;
    padding: 10px 8px;
    border-radius: 6px;
}

.notification-list a:hover {
    background: #f1f4f7;
}

.notification-list strong {
    display: block;
    color: var(--navy);
    font-size: 13px;
}

.notification-list span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.notification-actions {
    border-top: 1px solid var(--line-soft);
    border-bottom: 0;
}

.select-control,
.form-control {
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    outline: none;
}

.select-control:focus,
.form-control:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(38, 119, 254, 0.12);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.field.full {
    grid-column: 1 / -1;
}

.field label {
    color: #344056;
    font-size: 13px;
    font-weight: 800;
}

.field small,
.help-text {
    color: var(--muted);
    font-size: 12px;
}

.required {
    color: var(--danger);
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(180deg, #f7f9fc 0%, #eef3f7 100%);
}

.auth-card {
    width: min(440px, 100%);
    padding: 28px;
    background: #fff;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-card img {
    display: block;
    width: 170px;
    max-height: 74px;
    object-fit: contain;
    margin-bottom: 24px;
    background: #fff;
}

.auth-card h1 {
    margin: 0 0 6px;
    color: var(--navy);
    font-size: 24px;
}

.auth-card p {
    margin: 0 0 20px;
    color: var(--muted);
}

.error-card {
    text-align: center;
}

.error-card img {
    margin-left: auto;
    margin-right: auto;
}

.error-code {
    color: var(--navy);
    font-size: 54px;
    font-weight: 900;
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
}

.alert-success { border-color: #bfe6d4; background: #effaf5; color: var(--success); }
.alert-danger { border-color: #f0b8b8; background: #fff0f0; color: var(--danger); }
.alert-warning { border-color: #f4d3a4; background: #fff8ed; color: var(--warning); }
.alert-info { border-color: #bcd8ea; background: #eef7fc; color: #236a97; }

.timeline {
    position: relative;
    display: grid;
    gap: 14px;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--line);
}

.timeline-item {
    position: relative;
    padding-left: 28px;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 5px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--blue);
}

.timeline-item strong {
    display: block;
    color: var(--navy);
    font-size: 13px;
}

.timeline-item span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.driver-info,
.calculation-box {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #f8fafc;
}

.driver-info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.mini-stat span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 800;
}

.mini-stat strong {
    display: block;
    margin-top: 3px;
    color: var(--navy);
}

.hidden {
    display: none !important;
}

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

details {
    position: relative;
}

summary {
    list-style: none;
    cursor: pointer;
}

summary::-webkit-details-marker {
    display: none;
}

.menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 60;
    width: 220px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.menu-panel.right {
    right: 0;
    left: auto;
}

.menu-panel a {
    display: block;
    padding: 10px 11px;
    color: #39475d;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
}

.menu-panel a:hover {
    background: #f1f4f7;
    color: var(--navy);
}

.profile-menu summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-name {
    max-width: 120px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--navy);
    font-size: 13px;
    font-weight: 800;
}

.app-footer {
    padding: 16px 28px 22px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
}

.mobile-menu-button {
    display: none;
    position: fixed;
    left: 14px;
    top: 14px;
    z-index: 80;
    width: 44px;
    height: 44px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 10px 24px rgba(38, 119, 254, 0.12);
}

.mobile-menu-button span {
    display: block;
    height: 2px;
    margin: 4px 0;
    background: var(--navy);
    border-radius: 4px;
}

.sidebar-backdrop {
    display: none;
}

.line-icon {
    position: relative;
    width: 19px;
    min-width: 19px;
    height: 19px;
    display: inline-block;
    color: currentColor;
}

.line-icon::before,
.line-icon::after {
    content: "";
    position: absolute;
    border: 2px solid currentColor;
    border-radius: 3px;
}

.line-icon-grid::before { inset: 2px 2px 10px 2px; box-shadow: 0 9px 0 -2px currentColor; border-width: 2px; }
.line-icon-user::before { width: 7px; height: 7px; left: 5px; top: 1px; border-radius: 50%; }
.line-icon-user::after { width: 13px; height: 7px; left: 2px; bottom: 1px; border-radius: 8px 8px 3px 3px; }
.line-icon-users::before { width: 7px; height: 7px; left: 2px; top: 2px; border-radius: 50%; box-shadow: 8px 0 0 -2px currentColor; }
.line-icon-users::after { left: 1px; right: 1px; bottom: 2px; height: 7px; border-radius: 8px 8px 3px 3px; }
.line-icon-truck::before { left: 1px; top: 5px; width: 12px; height: 7px; }
.line-icon-truck::after { right: 1px; top: 8px; width: 5px; height: 4px; box-shadow: -11px 6px 0 -2px currentColor, -2px 6px 0 -2px currentColor; }
.line-icon-box::before { inset: 2px; transform: rotate(0deg); }
.line-icon-box::after { left: 4px; right: 4px; top: 7px; border-width: 1px 0 0; }
.line-icon-chart::before { left: 2px; bottom: 2px; width: 3px; height: 8px; box-shadow: 6px -4px 0 -1px currentColor, 12px -8px 0 -1px currentColor; border: 0; background: currentColor; }
.line-icon-gear::before { inset: 3px; border-radius: 50%; }
.line-icon-gear::after { inset: 7px; border-radius: 50%; background: currentColor; }
.line-icon-shield::before { left: 3px; top: 2px; width: 11px; height: 14px; border-radius: 7px 7px 9px 9px; }
.line-icon-switch::before { left: 1px; top: 4px; width: 14px; height: 0; border-width: 2px 0 0; }
.line-icon-switch::after { left: 4px; bottom: 4px; width: 14px; height: 0; border-width: 2px 0 0; }
.line-icon-bell::before { left: 4px; top: 2px; width: 9px; height: 12px; border-radius: 8px 8px 3px 3px; }
.line-icon-bell::after { left: 7px; bottom: 1px; width: 4px; height: 2px; border-radius: 0 0 8px 8px; }
.report-brand-panel {
    margin-bottom: 18px;
    background: #fff;
}

.report-summary-grid {
    margin-bottom: 18px;
}

.report-chart-grid {
    margin-bottom: 18px;
}

.export-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.install-page {
    min-height: 100vh;
    background: var(--bg);
    padding: 30px;
}

.install-shell {
    width: min(1080px, 100%);
    margin: 0 auto;
}

.requirements {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.requirement {
    padding: 10px 12px;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid var(--line);
    font-size: 12px;
    font-weight: 800;
}

.requirement.ok { color: var(--success); }
.requirement.fail { color: var(--danger); }

@media (max-width: 1180px) {
    .grid.cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .mobile-menu-button {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 25;
        background: rgba(38, 119, 254, 0.25);
    }

    .app-main {
        margin-left: 0;
    }

    .topbar {
        padding-left: 72px;
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .topbar-left {
        width: 100%;
        flex-wrap: wrap;
        gap: 14px;
    }

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

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

@media (max-width: 720px) {
    .content {
        padding: 18px 14px;
    }

    .page-head {
        flex-direction: column;
    }

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

    .top-nav,
    .topbar-actions {
        display: none;
    }

    .topbar {
        min-height: 72px;
        justify-content: center;
    }

    .select-control,
    .module-select-form,
    .action-menu,
    .profile-menu {
        width: 100%;
    }

    .btn,
    .action-menu summary {
        width: 100%;
    }

    .icon-button {
        flex: 1;
        min-width: 44px;
    }

    .profile-menu summary {
        justify-content: center;
    }

    .driver-info-grid {
        grid-template-columns: 1fr;
    }

    .chart-wrap {
        height: 240px;
    }

    .export-stack {
        grid-template-columns: 1fr;
    }

    .data-table {
        min-width: 760px;
    }
}
