:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #6c7486;
    --line: #e7ebf2;
    --blue: #4f86d9;
    --blue-dark: #2f6dca;
    --red: #ef6468;
    --yellow: #fbff39;
    --green: #1aa874;
    --shadow: 0 12px 34px rgba(21, 34, 64, 0.1);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    background: var(--bg);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 12px 18px;
    color: #fff;
    background: linear-gradient(135deg, #5e92dd, #3d78d4);
    box-shadow: 0 4px 16px rgba(47, 109, 202, 0.18);
}

.topbar h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0;
}

.status-dot {
    position: absolute;
    right: 16px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ffd166;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18);
}

.status-dot.online {
    background: #40d889;
}

.page-main {
    width: min(980px, 100%);
    margin: 0 auto;
    padding: 14px;
}

.user-layout {
    display: grid;
    grid-template-rows: minmax(360px, 58vh) auto;
    min-height: 100vh;
    padding-bottom: 76px;
}

#map {
    position: relative;
    width: 100%;
    min-height: 360px;
    background: #e9edf5;
}

.booking-panel {
    width: min(760px, calc(100% - 24px));
    margin: -10px auto 16px;
    padding: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.field-grid {
    display: grid;
    gap: 10px;
}

.field {
    display: grid;
    gap: 6px;
}

.field label {
    color: #4a5367;
    font-size: 13px;
    font-weight: 700;
}

.field input,
.field textarea {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #d8dee9;
    border-radius: 4px;
    outline: none;
    background: #fff;
    color: var(--text);
}

.field textarea {
    resize: vertical;
    min-height: 62px;
}

.field input:focus,
.field textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(79, 134, 217, 0.14);
}

.submit-btn {
    width: 100%;
    min-height: 54px;
    margin-top: 12px;
    color: #fff;
    background: var(--red);
    border-radius: 6px;
    font-size: 20px;
    font-weight: 900;
    box-shadow: 0 10px 22px rgba(239, 100, 104, 0.24);
}

.submit-btn:disabled {
    opacity: 0.66;
    cursor: wait;
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 18;
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 64px;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.bottom-nav button {
    display: grid;
    place-items: center;
    gap: 2px;
    color: #8a93a5;
    background: transparent;
    font-size: 12px;
    font-weight: 800;
}

.bottom-nav button.active {
    color: var(--blue-dark);
}

.nav-icon {
    font-size: 22px;
    line-height: 1;
}

.drawer {
    display: none;
    width: min(760px, calc(100% - 24px));
    margin: 0 auto 18px;
}

.drawer.active {
    display: block;
}

.tabs {
    position: sticky;
    top: 56px;
    z-index: 15;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.tabs button {
    position: relative;
    background: #fff;
    color: #222a39;
    font-size: 19px;
    font-weight: 800;
}

.tabs button.active {
    color: var(--blue-dark);
}

.tabs button.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 3px;
    background: var(--blue-dark);
}

.order-list {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.order-card {
    display: grid;
    gap: 16px;
    padding: 20px;
    background: #fff;
    border: 1px solid rgba(231, 235, 242, 0.85);
    border-radius: var(--radius);
    box-shadow: 0 8px 28px rgba(21, 34, 64, 0.06);
}

.order-card.compact {
    gap: 10px;
    padding: 14px;
}

.order-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    color: #8a6410;
    background: #fff3c4;
    font-weight: 800;
    white-space: nowrap;
}

.status-badge.ongoing {
    color: #1d5fa3;
    background: #dcecff;
}

.status-badge.completed {
    color: #13744f;
    background: #dff7eb;
}

.status-badge.cancelled {
    color: #7c3442;
    background: #ffe0e6;
}

.route-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: baseline;
}

.route-row .label {
    color: #111827;
    font-weight: 900;
    white-space: nowrap;
}

.route-row .place {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 25px;
    line-height: 1.2;
    font-weight: 950;
}

.route-row .distance {
    color: #111827;
    font-size: 18px;
    font-weight: 950;
    white-space: nowrap;
}

.address {
    margin-top: -8px;
    color: #222a39;
    font-size: 13px;
    font-weight: 700;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

.info-grid b {
    color: #2a3346;
}

.slide-action {
    --progress: 0px;
    position: relative;
    height: 56px;
    overflow: hidden;
    border-radius: 6px;
    background: var(--yellow);
    box-shadow: 0 6px 16px rgba(198, 195, 22, 0.22);
    touch-action: none;
    user-select: none;
    cursor: grab;
}

.slide-action:active {
    cursor: grabbing;
}

.slide-action.green {
    background: #2ee59d;
    box-shadow: 0 6px 16px rgba(31, 176, 120, 0.22);
}

.slide-action .slide-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: calc(var(--progress) + 56px);
    max-width: 100%;
    background: rgba(255, 255, 255, 0.28);
    pointer-events: none;
}

.slide-action .slide-thumb {
    position: absolute;
    left: var(--progress);
    top: 0;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    color: #111;
    font-size: 26px;
    font-weight: 900;
    pointer-events: none;
}

.slide-action .slide-label {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 0 62px;
    color: #111;
    font-size: 20px;
    font-weight: 950;
    pointer-events: none;
}

.slide-action.loading {
    opacity: 0.72;
}

.empty {
    display: grid;
    place-items: center;
    min-height: 160px;
    color: var(--muted);
    background: #fff;
    border: 1px dashed #d7deea;
    border-radius: var(--radius);
    font-weight: 700;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 86px;
    z-index: 100;
    transform: translateX(-50%) translateY(12px);
    max-width: min(420px, calc(100vw - 28px));
    padding: 10px 14px;
    color: #fff;
    background: rgba(23, 32, 51, 0.92);
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s ease;
    font-weight: 800;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.admin-shell {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 18px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    padding: 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(21, 34, 64, 0.05);
}

.stat-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
}

.table-wrap {
    overflow: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    font-size: 13px;
}

th {
    color: #3f4a5e;
    background: #f8fafd;
    font-size: 12px;
    font-weight: 900;
}

td {
    color: #20293a;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 12px 0;
}

.select {
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
}

.refresh-btn {
    min-height: 38px;
    padding: 0 14px;
    color: #fff;
    background: var(--blue-dark);
    border-radius: 4px;
    font-weight: 800;
}

@media (min-width: 760px) {
    .field-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .field.span-2 {
        grid-column: span 2;
    }

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

    .driver-page .order-list {
        grid-template-columns: minmax(0, 1fr);
        width: min(860px, 100%);
        margin: 0 auto;
    }
}

@media (max-width: 560px) {
    .topbar h1 {
        font-size: 17px;
    }

    .page-main,
    .order-list {
        padding: 10px;
    }

    .order-card {
        padding: 18px;
    }

    .route-row {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .route-row .distance {
        grid-column: 2;
        justify-self: end;
        font-size: 16px;
    }

    .route-row .place {
        font-size: 23px;
    }

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