:root {
    --sidebar-width: 276px;
    --header-height: 74px;
    --app-radius: 1rem;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bs-tertiary-bg);
    font-family: Vazirmatn, Tahoma, Arial, sans-serif;
}

button,
input,
select,
textarea,
.tooltip,
.popover,
.dropdown-menu,
.modal,
.offcanvas {
    font-family: inherit;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--header-height) minmax(0, 1fr);
    grid-template-areas:
        "header"
        "main";
    direction: ltr;
}

.app-header {
    grid-area: header;
    position: sticky;
    top: 0;
    z-index: 1040;
    height: var(--header-height);
    background: color-mix(in srgb, var(--bs-body-bg) 96%, transparent);
    backdrop-filter: blur(10px);
    direction: rtl;
}

.app-sidebar {
    grid-area: sidebar;
    min-width: 0;
    background: var(--bs-body-bg);
    direction: rtl;
}

.sidebar-inner {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-footer {
    flex: 0 0 auto;
    background: var(--bs-body-bg);
}

.app-main {
    grid-area: main;
    min-width: 0;
    min-height: calc(100vh - var(--header-height));
    overflow-x: hidden;
    direction: rtl;
}

@media (min-width: 992px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
        grid-template-areas:
            "header header"
            "main sidebar";
    }

    .app-sidebar {
        display: block !important;
        position: sticky;
        top: var(--header-height);
        align-self: start;
        height: calc(100vh - var(--header-height));
        overflow: hidden;
    }
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 13px;
    background: var(--bs-primary);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 8px 20px rgba(var(--bs-primary-rgb), .2);
}

.brand-mark-lg {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
    border-radius: 16px;
    font-size: 1.25rem;
}

.user-summary {
    min-width: 150px;
}

.user-avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bs-secondary-bg);
    border: 1px solid var(--bs-border-color);
    font-weight: 700;
}

.nav-pills .nav-link {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 46px;
    padding: .7rem .9rem;
    border-radius: .8rem;
    color: var(--bs-body-color);
    white-space: nowrap;
}

.nav-pills .nav-link > i {
    flex: 0 0 1.25rem;
    text-align: center;
}

.nav-pills .nav-link > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-pills .nav-link:not(.active):not(.disabled):hover {
    background: var(--bs-secondary-bg);
}

.nav-pills .nav-link.disabled {
    opacity: .62;
    cursor: default;
}

.card {
    border-radius: var(--app-radius);
}

.stat-card .card-body {
    min-height: 118px;
}

.stat-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: 15px;
    font-size: 1.3rem;
}

.map-card {
    overflow: hidden;
}

.map-placeholder {
    min-height: 480px;
    background:
        linear-gradient(rgba(var(--bs-primary-rgb), .035), rgba(var(--bs-primary-rgb), .035)),
        var(--bs-body-bg);
}

.system-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--bs-border-color);
    font-size: .9rem;
}

.system-meta-row:last-child {
    border-bottom: 0;
}

.auth-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 10%, rgba(var(--bs-primary-rgb), .12), transparent 34%),
        radial-gradient(circle at 90% 90%, rgba(var(--bs-info-rgb), .08), transparent 30%),
        var(--bs-tertiary-bg);
}

.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-brand {
    width: min(100%, 560px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .9rem;
}

.auth-card {
    width: min(100%, 460px);
    border-radius: 1.25rem;
}

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

.auth-theme-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1050;
}

.form-control,
.form-select,
.btn {
    border-radius: .75rem;
}

.driver-avatar,
.vehicle-thumb {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: 14px;
    object-fit: cover;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-secondary-bg);
}

.driver-avatar-placeholder,
.vehicle-thumb-placeholder {
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    color: var(--bs-secondary-color);
}

.driver-mobile-card,
.vehicle-mobile-card {
    background: var(--bs-body-bg);
}

.driver-mobile-meta,
.vehicle-mobile-meta {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: .6rem 1rem;
    font-size: .875rem;
}

.driver-mobile-meta span,
.vehicle-mobile-meta span {
    color: var(--bs-secondary-color);
}

.driver-mobile-meta strong,
.vehicle-mobile-meta strong {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.driver-photo-preview,
.vehicle-photo-preview {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border: 1px dashed var(--bs-border-color);
    border-radius: 1rem;
    background: var(--bs-tertiary-bg);
}

.driver-photo-preview img,
.vehicle-photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.driver-photo-placeholder,
.vehicle-photo-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    color: var(--bs-secondary-color);
}

.driver-photo-placeholder i,
.vehicle-photo-placeholder i {
    font-size: 3rem;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin-inline: auto;
    display: grid;
    place-items: center;
    border-radius: 20px;
    background: var(--bs-secondary-bg);
    color: var(--bs-secondary-color);
    font-size: 1.75rem;
}

html[data-pwa-standalone="1"] .app-header {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--header-height) + env(safe-area-inset-top));
}

@media (max-width: 1199.98px) {
    .map-placeholder {
        min-height: 410px;
    }
}

@media (max-width: 767.98px) {
    :root {
        --header-height: 66px;
    }

    .map-placeholder {
        min-height: 330px;
    }

    .stat-card .card-body {
        min-height: 105px;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
    }

    .display-6 {
        font-size: 2rem;
    }
}
