:root {
    --app-bg: #f4f6f8;
    --app-surface: #ffffff;
    --app-sidebar: #111827;
    --app-sidebar-muted: #94a3b8;
    --app-sidebar-hover: rgba(255, 255, 255, .07);
    --app-sidebar-active: #ffffff;
    --app-sidebar-active-text: #111827;
    --app-border: #e5e7eb;
    --app-text: #1f2937;
    --app-muted: #6b7280;
    --app-radius: 14px;
    --app-sidebar-width: 276px;
    --app-topbar-height: 68px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--app-bg);
}

body {
    margin: 0;
    background: var(--app-bg);
    color: var(--app-text);
    overflow-x: hidden;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

.min-w-0 {
    min-width: 0 !important;
}

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

.app-sidebar {
    position: sticky;
    top: 0;
    flex: 0 0 var(--app-sidebar-width);
    width: var(--app-sidebar-width);
    height: 100vh;
    height: 100dvh;
    padding: 20px 14px 16px;
    background: var(--app-sidebar);
    color: #fff;
    flex-direction: column;
    z-index: 1030;
    overflow: hidden;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    padding: 4px 8px 20px;
    color: #fff;
    text-decoration: none;
}

.app-brand:hover {
    color: #fff;
}

.app-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #fff;
    color: #111827;
    font-weight: 850;
    letter-spacing: -.04em;
}

.app-brand strong,
.app-brand small {
    display: block;
}

.app-brand strong {
    font-size: 1.02rem;
    line-height: 1.15;
}

.app-brand small {
    margin-top: 3px;
    color: var(--app-sidebar-muted);
    font-size: .72rem;
}

.app-sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 4px 18px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
}

.app-nav-section + .app-nav-section {
    margin-top: 18px;
}

.app-nav-title {
    padding: 0 10px 7px;
    color: var(--app-sidebar-muted);
    font-size: .68rem;
    font-weight: 750;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.app-nav-list {
    display: grid;
    gap: 3px;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 44px;
    padding: 9px 11px;
    border-radius: 10px;
    color: #dbe2ea;
    text-decoration: none;
    font-size: .91rem;
    font-weight: 590;
    transition: background-color .15s ease, color .15s ease, transform .15s ease;
}

.app-nav-link:hover {
    color: #fff;
    background: var(--app-sidebar-hover);
}

.app-nav-link.is-active {
    color: var(--app-sidebar-active-text);
    background: var(--app-sidebar-active);
    box-shadow: 0 5px 16px rgba(0, 0, 0, .18);
}

.app-nav-icon {
    flex: 0 0 20px;
    width: 20px;
    font-size: 1.05rem;
    text-align: center;
}

.app-nav-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-sidebar-footer {
    flex: 0 0 auto;
    padding: 14px 4px 0;
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.app-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 6px 8px 12px;
}

.app-user-card strong {
    color: #fff;
    font-size: .87rem;
}

.app-user-card small {
    color: var(--app-sidebar-muted);
    font-size: .75rem;
}

.app-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #e9edf2;
    color: #111827;
    font-size: .82rem;
    font-weight: 800;
}

.app-user-avatar-sm {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: .72rem;
}

.app-logout-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 8px 10px;
    border-radius: 10px;
    color: #fca5a5;
    text-decoration: none;
    font-size: .88rem;
    font-weight: 600;
}

.app-logout-link:hover {
    color: #fff;
    background: rgba(220, 53, 69, .18);
}

.app-content {
    flex: 1 1 auto;
    min-width: 0;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: var(--app-topbar-height);
    padding: 10px clamp(14px, 2.2vw, 30px);
    padding-top: max(10px, env(safe-area-inset-top));
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--app-border);
    backdrop-filter: blur(12px);
}

.app-topbar-heading {
    display: flex;
    flex-direction: column;
}

.app-topbar-brand {
    color: #111827;
    font-size: .78rem;
    font-weight: 800;
    line-height: 1.1;
}

.app-topbar-title {
    max-width: min(42vw, 520px);
    color: #374151;
    font-size: .9rem;
    font-weight: 650;
}

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

.app-menu-button,
.app-icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--app-border);
    border-radius: 11px;
    background: #fff;
    color: #374151;
}

.app-menu-button {
    font-size: 1.35rem;
}

.app-icon-action:hover,
.app-menu-button:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
    color: #111827;
}

.app-icon-action.is-success {
    color: #15803d;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.app-icon-action.is-warning {
    color: #a16207;
    background: #fffbeb;
    border-color: #fde68a;
}

.app-profile-button {
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: 260px;
    min-height: 44px;
    padding: 4px 9px 4px 5px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
}

.app-profile-button:hover,
.app-profile-button.show {
    border-color: var(--app-border);
    background: #f8fafc;
}

.app-profile-copy {
    max-width: 170px;
    line-height: 1.05;
}

.app-profile-copy strong {
    font-size: .82rem;
}

.app-profile-copy small {
    color: var(--app-muted);
    font-size: .7rem;
}

.app-profile-menu {
    min-width: 220px;
    padding: 7px;
    border-radius: 12px;
}

.app-profile-menu .dropdown-item {
    min-height: 40px;
    padding: 9px 10px;
    border-radius: 8px;
}

.app-main {
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: clamp(16px, 2.3vw, 32px);
    padding-bottom: max(28px, env(safe-area-inset-bottom));
}

.app-mobile-nav {
    width: min(88vw, 350px) !important;
    background: var(--app-sidebar);
    color: #fff;
    border-right: 0 !important;
}

.app-mobile-nav .offcanvas-header {
    min-height: 72px;
    padding: max(12px, env(safe-area-inset-top)) 14px 8px;
}

.app-mobile-nav .btn-close {
    filter: invert(1) grayscale(1);
    opacity: .8;
}

.app-brand-mobile {
    padding: 0;
}

.app-mobile-nav .app-sidebar-nav {
    padding: 10px 14px 24px;
}

.app-mobile-nav .app-sidebar-footer {
    margin: 0 14px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
}

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

.card.shadow-sm {
    box-shadow: 0 4px 18px rgba(17, 24, 39, .06) !important;
}

.card-header {
    border-bottom-color: #edf0f3;
}

.table-responsive {
    position: relative;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.table > :not(caption) > * > * {
    vertical-align: middle;
}

.table thead th {
    color: #4b5563;
    font-size: .78rem;
    font-weight: 750;
    letter-spacing: .01em;
    white-space: nowrap;
}

.table tbody td {
    font-size: .91rem;
}

.table-scroll-hint {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 12px;
    color: var(--app-muted);
    background: #f8fafc;
    border-top: 1px solid var(--app-border);
    font-size: .75rem;
}

.page-title {
    font-weight: 750;
    letter-spacing: -.025em;
}

.form-label {
    font-weight: 650;
}

.btn {
    border-radius: 9px;
}

.form-control,
.form-select {
    min-height: 42px;
    border-radius: 9px;
}

textarea.form-control {
    min-height: auto;
}

.badge {
    font-weight: 650;
}

.action-card {
    transition: transform .15s ease, box-shadow .15s ease;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(17, 24, 39, .08) !important;
}

.metric-card .metric-value {
    font-size: 1.75rem;
    font-weight: 750;
    line-height: 1.1;
}

.section-title {
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 700;
}

.order-total-box {
    position: sticky;
    top: calc(var(--app-topbar-height) + 1rem);
}

.order-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .55rem 0;
    border-bottom: 1px solid #edf0f3;
}

.order-total-row:last-child {
    border-bottom: 0;
}

.order-total-main {
    font-size: 1.35rem;
    font-weight: 750;
}

.requirement-panel {
    padding: 1rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
}

.order-number {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 700;
}

.table-tariff input {
    min-width: 115px;
}

.required-field::after {
    content: " *";
    color: #dc3545;
}

.driver-order-card {
    border: 1px solid rgba(17, 24, 39, .06);
}

.driver-order-price {
    font-size: 1.5rem;
    font-weight: 800;
    white-space: nowrap;
}

.driver-vehicle-card {
    background: linear-gradient(135deg, #ffffff 0%, #f7f8fa 100%);
}

.notification-unread {
    background: #fff8e6;
    border-left: 4px solid #ffc107 !important;
}

.notification-list .list-group-item:first-child {
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
}

.notification-list .list-group-item:last-child {
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 14px;
}

.order-progress {
    display: grid;
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    gap: 0;
    overflow-x: auto;
    padding: 8px 0 4px;
}

.order-progress-step {
    position: relative;
    min-width: 130px;
    padding: 28px 14px 0 0;
}

.order-progress-step::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 12px;
    right: -12px;
    height: 3px;
    background: #dee2e6;
}

.order-progress-step:last-child::before {
    right: calc(100% - 12px);
}

.order-progress-dot {
    position: absolute;
    top: 3px;
    left: 4px;
    z-index: 1;
    width: 18px;
    height: 18px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #dee2e6;
    box-shadow: 0 0 0 1px #ced4da;
}

.order-progress-step.is-done::before,
.order-progress-step.is-done .order-progress-dot {
    background: #198754;
}

.order-progress-step.is-done .order-progress-dot {
    box-shadow: 0 0 0 1px #198754;
}

.driver-trip-card {
    border-left: 5px solid #198754;
}

.pwa-notification-banner {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 680px;
    margin: 0 auto;
    padding: 14px 16px;
    color: #fff;
    background: #212529;
    border-radius: 14px;
}

.settlement-autocomplete {
    position: relative;
}

.settlement-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1080;
    max-height: 320px;
    overflow-y: auto;
    padding: .35rem;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    box-shadow: 0 .75rem 2rem rgba(0, 0, 0, .12);
}

.settlement-suggestion {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    padding: .7rem .8rem;
    border: 0;
    border-radius: var(--bs-border-radius);
    background: transparent;
    text-align: left;
}

.settlement-suggestion:hover,
.settlement-suggestion.active {
    background: var(--bs-tertiary-bg);
}

.settlement-suggestion small {
    color: var(--bs-secondary-color);
}

.settlement-suggestion-empty {
    padding: .8rem;
    color: var(--bs-secondary-color);
}

.toast-container {
    padding-top: calc(var(--app-topbar-height) + 12px) !important;
}

@media (max-width: 1199.98px) {
    .app-content {
        width: 100%;
    }

    .app-main {
        max-width: none;
    }

    .order-total-box {
        position: static;
    }
}

@media (max-width: 767.98px) {
    :root {
        --app-topbar-height: 60px;
    }

    .app-topbar {
        gap: 8px;
        min-height: var(--app-topbar-height);
        padding-right: 10px;
        padding-left: 10px;
    }

    .app-topbar-title {
        max-width: 42vw;
        font-size: .78rem;
    }

    .app-topbar-actions {
        gap: 5px;
    }

    .app-menu-button,
    .app-icon-action {
        flex-basis: 40px;
        width: 40px;
        height: 40px;
    }

    .app-profile-button {
        min-height: 40px;
        padding: 3px;
    }

    .app-profile-button::after {
        display: none;
    }

    .app-main {
        padding: 14px 12px max(24px, env(safe-area-inset-bottom));
    }

    .app-main > .d-flex.flex-wrap.justify-content-between {
        align-items: stretch !important;
        gap: 12px !important;
        margin-bottom: 16px !important;
    }

    .app-main > .d-flex.flex-wrap.justify-content-between > div:first-child {
        width: 100%;
    }

    .app-main > .d-flex.flex-wrap.justify-content-between > .btn,
    .app-main > .d-flex.flex-wrap.justify-content-between > a.btn {
        width: 100%;
    }

    .page-title,
    h1.h3 {
        font-size: 1.45rem;
    }

    .card {
        border-radius: 12px;
    }

    .card-body.p-4 {
        padding: 1rem !important;
    }

    .card-header.py-3 {
        padding-top: .8rem !important;
        padding-bottom: .8rem !important;
    }

    .table-responsive > .table {
        min-width: 700px;
    }

    .table-scroll-hint.is-visible {
        display: flex;
    }

    .table > :not(caption) > * > * {
        padding: .72rem .75rem;
    }

    .form-control,
    .form-select,
    .input-group-text {
        font-size: 16px;
    }

    .btn:not(.btn-sm):not(.btn-close) {
        min-height: 44px;
    }

    .btn-group,
    .btn-group-vertical {
        max-width: 100%;
    }

    .driver-order-price {
        font-size: 1.2rem;
    }

    .driver-order-card .btn-lg {
        min-height: 52px;
        font-size: 1rem;
    }

    .driver-order-card .d-flex.justify-content-between {
        flex-direction: column;
    }

    .driver-order-card .text-end {
        text-align: left !important;
    }

    .driver-vehicle-card .d-flex.gap-4 {
        gap: 14px !important;
    }

    .notification-list .list-group-item {
        padding: 1rem;
    }

    .text-truncate[style*="max-width"] {
        max-width: 52vw !important;
    }

    .pwa-notification-banner {
        align-items: stretch;
        flex-direction: column;
        left: 10px;
        right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
    }

    .order-progress {
        grid-template-columns: repeat(5, 140px);
    }

    .toast-container {
        left: 0 !important;
        right: 0 !important;
        width: 100%;
        padding: calc(var(--app-topbar-height) + 8px) 10px 10px !important;
    }

    .toast-container .toast {
        width: 100%;
    }
}

@media (max-width: 419.98px) {
    .app-topbar-title {
        display: none;
    }

    .app-topbar-brand {
        font-size: .84rem;
    }


    .app-user-avatar-sm {
        flex-basis: 38px;
        width: 38px;
        height: 38px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
