/* Clean Dispatch V3.60 mobile PWA stability + driver/partner app styling */
html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}
body.clean-dispatch-mobile-lock {
    position: relative;
}
.app-shell, .main-panel, .content, .topbar, .card, .public-card, .public-document, .table-wrap {
    max-width: 100%;
}
img, video, canvas, svg, iframe { max-width: 100%; }
input, select, textarea, button { max-width: 100%; }
.table-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
table { min-width: 760px; }
td, th { word-break: break-word; }

@media (display-mode: standalone) {
    body { min-height: 100vh; min-height: 100dvh; }
    .topbar { padding-top: calc(16px + env(safe-area-inset-top)); }
}

@media (max-width: 760px) {
    .app-shell { width: 100%; overflow-x: hidden; }
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 50;
        width: 100%;
        max-width: 100%;
        padding: 12px;
        gap: 12px;
        box-shadow: 0 8px 24px rgba(15,23,42,.18);
    }
    .brand { justify-content: space-between; }
    .brand-icon { width: 38px; height: 38px; border-radius: 12px; }
    .sidebar nav {
        display: flex !important;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
    }
    .sidebar nav a {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 10px 12px;
        scroll-snap-align: start;
    }
    .sidebar-footer { display: none; }
    .topbar {
        position: sticky;
        top: 0;
        z-index: 45;
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 14px 12px;
        background: rgba(243,246,251,.96);
        backdrop-filter: blur(10px);
    }
    .topbar h1 { font-size: 22px; line-height: 1.1; }
    .topbar p { font-size: 13px; }
    .topbar .btn { width: 100%; min-height: 44px; }
    .content { padding: 12px 10px 80px; overflow-x: hidden; }
    .card { padding: 14px; border-radius: 16px; margin-bottom: 14px; }
    .card-header { display: grid; gap: 10px; align-items: stretch; }
    .card-header .btn, .action-grid .btn, .action-grid form, .action-grid button { width: 100%; }
    .form-actions {
        position: sticky;
        bottom: 0;
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 10px;
        margin: 12px -14px -14px;
        background: rgba(255,255,255,.96);
        border-top: 1px solid var(--line);
        z-index: 20;
    }
    .filter-row { display: grid; grid-template-columns: 1fr; }
    .filter-row .btn, .filter-row input, .filter-row select { width: 100%; max-width: 100%; }
    .stats-grid, .detail-grid, .form-grid.two, .form-grid.three, .form-grid.four { grid-template-columns: 1fr !important; }
    .table-wrap { margin-left: -6px; margin-right: -6px; border-radius: 14px; }
}

.v360-app-body {
    margin: 0;
    background: #eef4ff;
    color: #0f172a;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}
.v360-app-shell {
    width: min(760px, 100%);
    margin: 0 auto;
    padding: 12px 12px 96px;
}
.v360-app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    margin: -12px -12px 14px;
    padding: calc(16px + env(safe-area-inset-top)) 14px 14px;
    background: linear-gradient(135deg,#0f172a,#155EEF);
    color: white;
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
    box-shadow: 0 14px 34px rgba(15,23,42,.22);
}
.v360-app-header.partner { background: linear-gradient(135deg,#581c87,#7c3aed); }
.v360-eyebrow { display: inline-block; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; opacity: .8; font-weight: 900; }
.v360-app-header h1 { margin: 4px 0; font-size: 25px; line-height: 1.1; }
.v360-app-header p { margin: 0; opacity: .9; }
.v360-status-card, .v360-job-card, .v360-empty-card, .v360-map-card {
    background: white;
    border: 1px solid #dbe3ef;
    border-radius: 20px;
    box-shadow: 0 14px 36px rgba(15,23,42,.08);
    padding: 16px;
    margin: 0 0 14px;
}
.v360-duty-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.v360-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    border: 0;
    border-radius: 14px;
    padding: 12px 14px;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
    background: #e2e8f0;
    color: #0f172a;
    font-size: 15px;
}
.v360-btn.primary { background: #155EEF; color: white; }
.v360-btn.success { background: #16a34a; color: white; }
.v360-btn.warn { background: #f59e0b; color: #111827; }
.v360-btn.danger { background: #dc2626; color: white; }
.v360-btn.dark { background: #0f172a; color: white; }
.v360-btn.full { width: 100%; }
.v360-btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.v360-btn-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.v360-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 6px 10px;
    background: #e2e8f0;
    font-weight: 900;
    font-size: 12px;
}
.v360-pill.on { background: #dcfce7; color: #166534; }
.v360-pill.off { background: #fee2e2; color: #991b1b; }
.v360-pill.job { background: #dbeafe; color: #1d4ed8; }
.v360-job-card h2 { margin: 8px 0 4px; font-size: 20px; }
.v360-job-meta { display: grid; gap: 8px; margin-top: 12px; }
.v360-job-meta div { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 14px; padding: 10px; }
.v360-job-meta strong { display: block; font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.v360-tracker-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    background: rgba(15,23,42,.96);
    color: white;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -12px 32px rgba(15,23,42,.22);
}
.v360-tracker-inner { width: min(760px, 100%); margin: 0 auto; display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.v360-tracker-inner small { color: #cbd5e1; display: block; margin-top: 2px; }
.v360-location-dot { width: 10px; height: 10px; border-radius: 999px; background: #94a3b8; display: inline-block; margin-right: 6px; }
.v360-location-dot.active { background: #22c55e; box-shadow: 0 0 0 6px rgba(34,197,94,.18); }
.v360-help { color: #64748b; font-size: 13px; line-height: 1.45; }
.v360-map { width: 100%; height: min(68vh, 620px); min-height: 430px; border-radius: 18px; border: 1px solid #dbe3ef; overflow: hidden; }
.v360-live-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.v360-list-item { border-bottom: 1px solid #e2e8f0; padding: 11px 0; }
.v360-list-item:last-child { border-bottom: 0; }
.v360-list-item strong { display: block; }
@media (max-width: 760px) {
    .v360-btn-grid, .v360-btn-grid.three, .v360-duty-row, .v360-live-grid { grid-template-columns: 1fr; }
    .v360-app-shell { padding: 10px 10px 104px; }
    .v360-app-header { border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; }
    .v360-map { height: 58vh; min-height: 360px; }
    .v360-tracker-inner { grid-template-columns: 1fr; }
}
