/* =====================================================
   SERVICE BOOKING  (all rules scoped to .svc-page)
   ===================================================== */

/* reset global button/input styles inside this page */
.svc-page button {
    background: transparent;
    border: none;
    width: auto;
    padding: 0;
    margin-bottom: 0;
    font-size: 13px;
    color: #8892a4;
}
.svc-page input[type="text"] {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 0;
    width: 100%;
    box-sizing: border-box;
}

/* page shell */
.svc-page {
    background: #1a1f2e;
    min-height: 100vh;
    color: #e8eaf0;
    font-family: 'Segoe UI', sans-serif;
}

/* header */
.svc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: #252b3b;
    border-bottom: 1px solid #2d3548;
}
.svc-page-title {
    color: #e8eaf0;
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}
.svc-header-right {
    display: flex;
    gap: 10px;
    align-items: center;
}
.svc-branch-chip {
    background: #2d3548;
    color: #e8eaf0;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.svc-branch-chip:hover { background: #3a4258; color: #4a9eff; text-decoration: none; }
.svc-sync-btn {
    background: #2a5bd7 !important;
    color: white !important;
    border-radius: 6px !important;
    padding: 7px 16px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    width: auto !important;
    margin-bottom: 0 !important;
    border: none !important;
}
.svc-sync-btn:hover { background: #3a6be7 !important; }
.svc-sync-btn:active { transform: scale(0.97); }


.svc-sync-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}
.svc-last-synced {
    font-size: 10px;
    color: #8892a4;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.svc-server-clock {
    font-size: 12px;
    color: #8892a4;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
    white-space: nowrap;
    align-self: center;
}

/* tabs */
.svc-tabs {
    display: flex;
    background: #1a1f2e;
    padding: 0 24px;
    border-bottom: 1px solid #2d3548;
}
.svc-tab {
    background: transparent !important;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    color: #8892a4 !important;
    padding: 11px 18px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    border-radius: 0 !important;
    width: auto !important;
    margin-bottom: 0 !important;
    transition: color 0.15s, border-color 0.15s;
}
.svc-tab:hover { color: #e8eaf0 !important; background: transparent !important; }
.svc-tab-active { color: #e8eaf0 !important; border-bottom-color: #4a9eff !important; }
.svc-tab-badge {
    background: #2a5bd7;
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 12px;
    margin-left: 4px;
}
.svc-tab-badge:empty { display: none; }

/* body layout */
.svc-body {
    display: flex;
    height: calc(100vh - 116px);
    overflow: hidden;
}
.svc-left-panel {
    width: 255px;
    min-width: 255px;
    background: #1a1f2e;
    border-right: 1px solid #2d3548;
    padding: 14px 16px;
    overflow-y: auto;
}
.svc-right-panel {
    flex: 1;
    background: #1a1f2e;
    padding: 16px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* calendar */
.svc-calendar { margin-bottom: 10px; }
.svc-cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.svc-cal-title { font-size: 14px; font-weight: 600; color: #e8eaf0; }
.svc-cal-nav {
    background: transparent !important;
    border: none !important;
    color: #8892a4 !important;
    cursor: pointer !important;
    font-size: 16px !important;
    padding: 3px 8px !important;
    border-radius: 4px !important;
    width: auto !important;
    margin-bottom: 0 !important;
    line-height: 1;
}
.svc-cal-nav:hover { background: #2d3548 !important; color: #e8eaf0 !important; }
.svc-cal-daynames {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 3px;
}
.svc-cal-daynames span { font-size: 11px; color: #8892a4; padding: 3px 0; }
.svc-cal-grid { display: flex; flex-direction: column; gap: 2px; }
.svc-cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.svc-cal-cell {
    text-align: center;
    padding: 5px 2px;
    font-size: 12px;
    color: #8892a4;
    cursor: pointer;
    border-radius: 4px;
    user-select: none;
    background: transparent !important;
    border: none !important;
    width: auto !important;
    margin-bottom: 0 !important;
    font-weight: normal !important;
}
.svc-cal-empty { cursor: default !important; }
.svc-cal-cell:not(.svc-cal-empty):hover { background: #2d3548 !important; color: #e8eaf0 !important; }
.svc-cal-has-booking { color: #e8eaf0; position: relative; }
.svc-cal-has-booking::after {
    content: '';
    display: block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #4a9eff;
    margin: 0 auto;
    margin-top: 1px;
}
.svc-cal-selected { background: #2a5bd7 !important; color: white !important; }
.svc-cal-today { color: #4a9eff !important; font-weight: 700 !important; }
.svc-cal-selected.svc-cal-today { color: white !important; }

/* calendar legend */
.svc-cal-legend { display: flex; gap: 14px; margin-bottom: 14px; }
.svc-legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #8892a4; }
.svc-legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.svc-legend-booking  { background: rgba(74,158,255,0.5); }
.svc-legend-selected { background: #2a5bd7; }

/* left KPI stats */
.svc-left-kpi { background: #252b3b; border-radius: 8px; padding: 12px; }
.svc-left-date { font-size: 11px; color: #8892a4; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.svc-kpi-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid #2d3548;
}
.svc-kpi-row:last-child { border-bottom: none; padding-bottom: 0; }
.svc-kpi-label { font-size: 13px; color: #8892a4; }
.svc-kpi-value { font-size: 20px; font-weight: 700; color: #e8eaf0; }
.svc-kpi-green { color: #4caf7d; }
.svc-kpi-red   { color: #e8734a; }
.svc-kpi-blue  { color: #4a9eff; }
.svc-kpi-teal  { color: #20c997; }
.svc-kpi-divider { height: 1px; background: #2d3548; margin: 6px 0; }

/* top KPI cards */
.svc-kpi-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.svc-top-card { background: #252b3b; border-radius: 8px; padding: 14px 16px; border-left: 3px solid #2d3548; }
.svc-top-card-green { border-left-color: #4caf7d; }
.svc-top-card-red   { border-left-color: #e8734a; }
.svc-top-card-label { font-size: 13px; color: #8892a4; margin-bottom: 6px; }
.svc-top-card-value { font-size: 28px; font-weight: 700; color: #e8eaf0; }
.svc-top-card-clickable { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.svc-top-card-clickable:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.35); }
.svc-top-card-clickable:active { transform: translateY(0); }

/* filters — 2-column grid so all 4 dropdowns have proper room */
.svc-filters {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}
.svc-filter-dropdown { min-width: 0; width: 100%; }
.svc-filter-dropdown > div,
.svc-filter-dropdown .dash-dropdown,
.svc-page .svc-filter-dropdown .Select { width: 100% !important; }

/* Dash dropdown dark theme — react-select v1 class names */
.svc-page .svc-filter-dropdown .Select,
.svc-page .svc-filter-dropdown .Select--single { min-width: 0; }
.svc-page .svc-filter-dropdown .Select-control {
    background: #252b3b !important;
    border: 1px solid #3a4258 !important;
    border-radius: 6px !important;
    color: #e8eaf0 !important;
    height: 38px !important;
    box-shadow: none !important;
    cursor: pointer !important;
}
.svc-page .svc-filter-dropdown .Select-control:hover { border-color: #4a9eff !important; }
.svc-page .svc-filter-dropdown .is-open > .Select-control {
    border-color: #4a9eff !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}
.svc-page .svc-filter-dropdown .Select-multi-value-wrapper { display: flex; align-items: center; height: 36px; overflow: hidden; }
.svc-page .svc-filter-dropdown .Select-value,
.svc-page .svc-filter-dropdown .Select-placeholder {
    color: #c5cad6 !important;
    line-height: 36px !important;
    padding-left: 10px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.svc-page .svc-filter-dropdown .Select-value-label { color: #e8eaf0 !important; font-size: 13px; }
.svc-page .svc-filter-dropdown .Select-arrow-zone { padding-right: 8px !important; }
.svc-page .svc-filter-dropdown .Select-arrow-zone .Select-arrow { border-top-color: #8892a4 !important; }
.svc-page .svc-filter-dropdown .is-open .Select-arrow { border-bottom-color: #8892a4 !important; border-top-color: transparent !important; }
.svc-page .svc-filter-dropdown .Select-clear-zone { display: none !important; }
.svc-page .svc-filter-dropdown .Select-menu-outer {
    background: #1e2535 !important;
    border: 1px solid #3a4258 !important;
    border-top: none !important;
    border-radius: 0 0 6px 6px !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.55) !important;
    z-index: 9999 !important;
    min-width: 100% !important;
    width: max-content !important;
}
.svc-page .svc-filter-dropdown .Select-option {
    background: #1e2535 !important;
    color: #c5cad6 !important;
    font-size: 13px !important;
    padding: 9px 14px !important;
    white-space: nowrap !important;
    cursor: pointer !important;
}
.svc-page .svc-filter-dropdown .Select-option.is-focused { background: #2d3548 !important; color: #e8eaf0 !important; }
.svc-page .svc-filter-dropdown .Select-option.is-selected { background: #1e4a8a !important; color: #4a9eff !important; font-weight: 600 !important; }
.svc-page .svc-filter-dropdown .Select-input > input { color: #e8eaf0 !important; background: transparent !important; caret-color: #4a9eff; }
.svc-page .svc-filter-dropdown .VirtualizedSelectOption { background: #1e2535 !important; color: #c5cad6 !important; font-size: 13px !important; padding: 9px 14px !important; white-space: nowrap !important; }
.svc-page .svc-filter-dropdown .VirtualizedSelectFocusedOption { background: #2d3548 !important; color: #e8eaf0 !important; }
.svc-page .svc-filter-dropdown .VirtualizedSelectSelectedOption { background: #1e4a8a !important; color: #4a9eff !important; }
.svc-search-input {
    background: #252b3b !important;
    border: 1px solid #2d3548 !important;
    border-radius: 6px !important;
    color: #e8eaf0 !important;
    outline: none;
}
.svc-search-input::placeholder { color: #8892a4; }
.svc-search-input:focus { border-color: #4a9eff !important; box-shadow: none !important; }

/* ── Sort bar ──────────────────────────────────────────────── */
.svc-sort-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.svc-sort-label {
    font-size: 11px;
    color: #8892a4;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.svc-sort-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.svc-sort-chip {
    padding: 7px 14px;
    border-radius: 6px;
    border: 1px solid #3a4258;
    background: #252b3b;
    color: #c5cad6;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    width: auto !important;
    margin-bottom: 0 !important;
    white-space: nowrap;
}
.svc-sort-chip:hover {
    border-color: #4a9eff !important;
    color: #e8eaf0 !important;
    background: #2d3548 !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4) !important;
}
.svc-sort-chip:active { transform: translateY(1px); box-shadow: none !important; }
.svc-sort-chip-active {
    border-color: #4a9eff !important;
    color: #4a9eff !important;
    background: rgba(74,158,255,0.15) !important;
    box-shadow: 0 0 0 1px #4a9eff !important;
}

/* ── Date group dividers (All records tab) ──────────────────── */
.svc-date-group-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 8px 0 4px;
    margin-top: 6px;
    border-bottom: 1px solid #2d3548;
}
.svc-date-group-header:first-child { margin-top: 0; }
.svc-date-group-label {
    font-size: 12px;
    font-weight: 700;
    color: #e8eaf0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.svc-date-group-count {
    font-size: 11px;
    color: #8892a4;
}

/* booking date header */
.svc-booking-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #2d3548;
}
.svc-date-label   { font-size: 13px; font-weight: 600; color: #e8eaf0; }
.svc-record-count { font-size: 12px; color: #8892a4; }

/* booking list */
.svc-booking-list { display: flex; flex-direction: column; gap: 8px; }

/* booking card */
.svc-booking-card {
    background: #252b3b;
    border-radius: 8px;
    padding: 14px 18px;
    border: 1px solid #2d3548;
    border-left: 3px solid #4a9eff;
}
.svc-card-done     { opacity: 0.6; border-left-color: #4caf7d !important; }
.svc-card-overdue  { border-left-color: #f04e4e !important; }
.svc-card-dispatch { border-left-color: #20c997 !important; background: rgba(32,201,151,0.04); }

/* ── View toggle button ──────────────────────────────────────────────────── */
.svc-view-toggle-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid #3a4258;
    border-radius: 6px;
    color: #8892a4;
    font-size: 13px;
    padding: 5px 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    margin-left: auto;
    flex-shrink: 0;
}
.svc-view-toggle-btn:hover { background: rgba(255,255,255,0.10); color: #c5cad6; }

/* ── KDS Grid container ──────────────────────────────────────────────────── */
.svc-grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(162px, 1fr));
    gap: 10px;
    padding: 2px 0;
}

/* ── KDS Tile ────────────────────────────────────────────────────────────── */
.svc-tile {
    background: #252b3b;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid #2d3548;
    transition: transform 0.12s, box-shadow 0.12s;
}
.svc-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.40); }
.svc-tile-done    { opacity: 0.60; }
.svc-tile-overdue { border-color: rgba(240,78,78,0.35); }

.svc-tile-header {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 34px;
}
.svc-tile-header-done    { background: rgba(76,175,125,0.18); }
.svc-tile-header-overdue { background: rgba(240,78,78,0.22); }
.svc-tile-header-pending { background: rgba(74,158,255,0.10); }

.svc-tile-body {
    flex: 1;
    padding: 10px 12px 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.svc-tile-plate {
    font-size: 17px;
    font-weight: 800;
    color: #e8eaf0;
    letter-spacing: 0.04em;
    line-height: 1.15;
}
.svc-tile-odo {
    font-size: 12px;
    color: #8892a4;
    font-variant-numeric: tabular-nums;
}
.svc-tile-meta {
    font-size: 11px;
    color: #6b7588;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.svc-tile-footer {
    padding: 6px 10px;
    border-top: 1px solid #2d3548;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.svc-tile-date { font-size: 11px; color: #6b7588; }
.svc-tile-history-btn {
    background: none;
    border: none;
    color: #4a9eff;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.svc-tile-history-btn:hover { color: #7db8ff; }
.svc-card-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.svc-card-left { display: flex; flex-direction: column; gap: 2px; min-width: 110px; }
.svc-vehicle-id { font-size: 16px; font-weight: 700; color: #e8eaf0; }
.svc-vehicle-model,
.svc-vehicle-location { font-size: 13px; color: #8892a4; }
.svc-vehicle-location { text-transform: uppercase; letter-spacing: 0.4px; }
.svc-card-middle { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.svc-odo, .svc-svc-odo, .svc-bk-odo { font-size: 13px; color: #8892a4; white-space: nowrap; }
.svc-bk-odo { font-style: italic; opacity: 0.75; }
.svc-delta { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 10px; white-space: nowrap; }
.svc-delta-positive { background: rgba(232,115,74,0.18);  color: #e8734a; } /* odo past target = overdue = red  */
.svc-delta-negative { background: rgba(136,146,164,0.12); color: #8892a4; } /* not yet due = neutral             */
.svc-card-right { flex-shrink: 0; }
.svc-badge { padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.svc-badge-pending     { background: rgba(245,166,35,0.20);  color: #f5a623; }
.svc-badge-overdue     { background: rgba(240,78,78,0.20);   color: #f04e4e; }
.svc-badge-done        { background: rgba(76,175,125,0.15);  color: #4caf7d; }
.svc-badge-inprogress  { background: rgba(74,158,255,0.18);  color: #4a9eff; }
.svc-badge-cancelled   { background: rgba(136,146,164,0.18); color: #8892a4; }
.svc-badge-group       { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.svc-card-meta-row { display: flex; gap: 14px; margin-top: 7px; flex-wrap: wrap; }
.svc-card-meta    { font-size: 13px; color: #8892a4; }
.svc-card-remarks { font-size: 13px; color: #6b7585; font-style: italic; }
.svc-no-data { text-align: center; color: #8892a4; padding: 40px; font-size: 14px; }

/* ── Card redesign ───────────────────────────────────────────────────────── */
.svc-card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}
.svc-card-sub-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.svc-card-odo-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: rgba(45, 53, 72, 0.55);
    border-radius: 6px;
    padding: 6px 10px;
    margin-bottom: 6px;
}
.svc-card-info-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 4px;
}
.svc-card-remarks-row {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #2d3548;
}
.svc-sep         { color: #4a5568; font-size: 11px; }
.svc-booking-id  { font-size: 13px; color: #4a9eff; font-family: monospace; font-weight: 600; }
.svc-card-creator { font-size: 13px; color: #63b3ed; font-weight: 500; }

/* ── Loading overlay dark theme ──────────────────────────────────────────── */
/* Fallback for Dash versions that don't support overlay_style prop */
._dash-loading-callback { background-color: rgba(26, 31, 46, 0.88) !important; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .svc-body {
        flex-direction: column;
        height: auto;
        overflow-y: visible;
    }
    .svc-left-panel {
        width: 100% !important;
        min-width: unset !important;
        border-right: none;
        border-bottom: 1px solid #2d3548;
    }
    .svc-right-panel { overflow-y: visible; }
    .svc-kpi-cards   { grid-template-columns: repeat(2, 1fr); }
    .svc-filters     { grid-template-columns: 1fr; }
    .svc-header      { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
    .svc-branch-chip { font-size: 12px; padding: 5px 10px; }
    .svc-page-title  { font-size: 15px; }
    .svc-top-card-value { font-size: 22px; }
    .svc-card-odo-row   { gap: 8px; }
}

@media (max-width: 480px) {
    .svc-kpi-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .svc-top-card  { padding: 10px 12px; }
    .svc-top-card-value { font-size: 18px; }
    .svc-tab  { padding: 8px 10px !important; font-size: 12px !important; }
    .svc-tabs { padding: 0 10px; overflow-x: auto; }
    .svc-right-panel { padding: 12px 14px; }
    .svc-booking-card { padding: 10px 12px; }
}

/* ── At-Risk tab badge (red tint, distinct from Today's blue) ───────── */
.svc-tab-badge-risk { background: rgba(232, 115, 74, 0.25); color: #e8734a; }

/* ── At-Risk tab content ────────────────────────────────────────────── */
.svc-risk-group-label {
    font-size: 10px; font-weight: 700; padding: 2px 8px;
    border-radius: 8px; text-transform: uppercase;
}
.svc-risk-group-count { font-size: 12px; color: #8892a4; }

.svc-risk-chip {
    font-size: 11px; color: #c5cad6;
    background: rgba(255,255,255,0.06);
    padding: 2px 8px; border-radius: 8px; white-space: nowrap;
}
.svc-risk-chip-days { color: #8892a4; }

/* Re-use priority colours from badge system */
.svc-risk-critical { background: rgba(220,50,50,0.22);  color: #ff6b6b; }
.svc-risk-high     { background: rgba(232,115,74,0.22); color: #e8734a; }
.svc-risk-medium   { background: rgba(255,193,7,0.18);  color: #ffc107; }

/* ── History button on each booking card ────────────────────────────── */
.svc-card-history-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.svc-history-btn {
    background: none;
    border: 1px solid #3a4258;
    color: #8892a4;
    padding: 5px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
    width: auto;
    margin-bottom: 0;
}
.svc-history-btn:hover { background: #252b3b; color: #4a9eff; border-color: #4a9eff; }

/* ── Option 2: inline accordion history ─────────────────────────────── */
.svc-inline-btn {
    background: none;
    border: 1px solid #3a4258;
    color: #8892a4;
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.15s;
    margin-left: 8px;
    width: auto;
    margin-bottom: 0;
}
.svc-inline-btn:hover { background: #252b3b; color: #4a9eff; border-color: #4a9eff; }

/* Loading state — Dash sets data-dash-is-loading while the MATCH callback runs */
.svc-inline-btn[data-dash-is-loading="true"] {
    color: #4a9eff;
    border-color: #4a9eff;
    cursor: wait;
    opacity: 0.7;
}
.svc-inline-panel[data-dash-is-loading="true"] {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: #4a9eff;
    font-size: 13px;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 10px;
}
.svc-inline-panel[data-dash-is-loading="true"]::after {
    content: "Loading history…";
}

.svc-inline-panel:empty { border: none; margin: 0; padding: 0; min-height: 0; }
.svc-inline-panel:not(:empty) {
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 10px;
    padding-top: 10px;
    max-height: 320px;
    overflow-y: auto;
}
.svc-inline-panel .svc-history-summary { margin-bottom: 8px; }
.svc-inline-panel .svc-history-list    { display: flex; flex-direction: column; gap: 6px; }
.svc-inline-panel .svc-history-event   { padding: 8px 10px; border-radius: 4px; }

/* ── History modal overlay ──────────────────────────────────────────── */
.svc-history-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 14, 26, 0.82);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.svc-history-modal {
    background: #1a1f2e;
    border: 1px solid #2e3549;
    border-radius: 12px;
    width: 100%;
    max-width: 680px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.svc-history-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #2e3549;
    flex-shrink: 0;
}
.svc-history-modal-title { font-size: 16px; font-weight: 700; color: #d0d7e8; }
.svc-history-close-btn {
    background: none;
    border: 1px solid #3a4258;
    color: #8892a4;
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s;
    width: auto;
    margin-bottom: 0;
}
.svc-history-close-btn:hover { background: #252b3b; color: #d0d7e8; border-color: #4a9eff; }

/* svc-history-body is the scroll container.
   dcc.Loading inserts an unstyled wrapper div between body and content,
   breaking the flex height chain — so we scroll here, not on .svc-history-content. */
.svc-history-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.svc-history-content {
    padding: 16px 20px;
}
.svc-history-summary {
    font-size: 12px; color: #8892a4;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #252b3b;
}
.svc-history-count { color: #c5cad6; font-weight: 600; }
.svc-history-meta  { font-size: 11px; color: #8892a4; }

.svc-history-list  { display: flex; flex-direction: column; gap: 7px; }
.svc-history-event {
    background: #1e2538;
    border-radius: 8px;
    padding: 10px 14px;
    border-left: 3px solid transparent;
}
.svc-history-sb { border-left-color: #4a9eff; }
.svc-history-ro { border-left-color: #a78bfa; }

.svc-history-event-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.svc-history-date  { font-size: 11px; color: #8892a4; min-width: 88px; }
.svc-history-info  { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

.svc-history-source-label {
    font-size: 10px; font-weight: 700;
    padding: 2px 7px; border-radius: 8px; text-transform: uppercase;
}
.svc-history-sb-source       { background: rgba(74,158,255,0.18);  color: #4a9eff; }
.svc-history-ro-source       { background: rgba(167,139,250,0.18); color: #a78bfa; }
.svc-history-dispatch-source { background: rgba(32,201,151,0.18);  color: #20c997; }
.svc-history-dispatch        { border-left-color: #20c997; }
.svc-history-dispatch-times  { font-size: 11px; color: #8892a4; font-variant-numeric: tabular-nums; }
.svc-badge-dispatch          { background: rgba(32,201,151,0.18);  color: #20c997; }
.svc-history-ro-badge  { background: rgba(167,139,250,0.15); color: #a78bfa; }

.svc-history-top-row  { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.svc-history-meta-row { display: flex; align-items: center; flex-wrap: wrap; font-size: 12px; color: #8892a4; }

/* ── Collapsible month groups inside history ─────────────────── */
.svc-history-month-group {
    border: 1px solid #2a3048;
    border-radius: 7px;
    overflow: hidden;
    margin-bottom: 6px;
}
.svc-history-month-group:last-child { margin-bottom: 0; }

.svc-history-month-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    background: #252b3b;
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.svc-history-month-summary::-webkit-details-marker,
.svc-history-month-summary::marker { display: none; }
.svc-history-month-summary:hover { background: #2c3347; }

.svc-history-month-label {
    font-size: 12px; font-weight: 700;
    color: #d0d7e8; text-transform: uppercase; letter-spacing: 0.5px;
}
.svc-history-month-count { font-size: 11px; color: #8892a4; }
.svc-history-month-toggle {
    margin-left: auto;
    font-size: 9px;
    color: #8892a4;
    transition: transform 0.2s ease;
}
details[open] .svc-history-month-toggle { transform: rotate(90deg); }

/* Inner body — darker layer so event cards visually "sit inside" */
.svc-history-month-body {
    background: #181d2c;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
/* Event cards inside body stay at their normal shade, creating depth */
.svc-history-month-body .svc-history-event {
    background: #1e2538;
}

.svc-history-event-detail {
    margin-top: 7px; padding-top: 7px;
    border-top: 1px solid rgba(255,255,255,0.05);
    font-size: 12px; display: flex; flex-direction: column; gap: 3px;
}
.svc-history-description { color: #b0b8cc; }
.svc-history-notes       { color: #8892a4; font-style: italic; }
.svc-history-completed   { color: #4caf7d; font-weight: 600; }
.svc-history-empty       { color: #8892a4; text-align: center; padding: 40px 20px; font-size: 13px; }

@media (max-width: 600px) {
    .svc-history-modal   { max-height: 92vh; border-radius: 10px; }
    .svc-history-content { padding: 12px 14px; }
}

/* ── Enhancement A: booking card age label ───────────────────── */
.svc-card-age { font-size: 12px; color: #6b7585; font-style: italic; }

/* ── Enhancement B: at-risk card priority borders ────────────── */
.svc-card-risk-critical { border-left-color: #ff6b6b !important; background: rgba(220,50,50,0.06); }
.svc-card-risk-high     { border-left-color: #e8734a !important; background: rgba(232,115,74,0.05); }
.svc-card-risk-medium   { border-left-color: #ffc107 !important; }
.svc-risk-group-header-critical { border-bottom-color: rgba(255,107,107,0.3); }
.svc-risk-group-header-high     { border-bottom-color: rgba(232,115,74,0.3); }
.svc-risk-group-header-medium   { border-bottom-color: rgba(255,193,7,0.3); }
.svc-risk-chip-critical { color: #ff6b6b; background: rgba(220,50,50,0.18); }
.svc-risk-chip-high     { color: #e8734a; background: rgba(232,115,74,0.18); }

/* ── Enhancement C/F: date header subtitle ───────────────────── */
.svc-date-subtitle {
    font-size: 11px;
    color: #6b7585;
    padding: 4px 0 6px;
    font-style: italic;
}

/* ── Enhancement E: Vehicle 360° summary panel ───────────────── */
.svc-v360-panel {
    background: #1e2538;
    border: 1px solid #2d3548;
    border-left: 3px solid #a78bfa;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 14px;
}
.svc-v360-title {
    font-size: 12px;
    font-weight: 700;
    color: #a78bfa;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 10px;
}
.svc-v360-body { display: flex; gap: 20px; flex-wrap: wrap; }
.svc-v360-section { flex: 1; min-width: 160px; }
.svc-v360-section-label {
    font-size: 10px;
    font-weight: 700;
    color: #8892a4;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.svc-v360-section-body { display: flex; flex-direction: column; gap: 4px; }
.svc-v360-stat { font-size: 13px; color: #c5cad6; }
.svc-v360-faults { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.svc-v360-faults-label { font-size: 11px; color: #8892a4; }
.svc-v360-fault {
    font-size: 11px;
    background: rgba(167,139,250,0.12);
    color: #a78bfa;
    padding: 2px 8px;
    border-radius: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   Document expiry chips  (shared by service-booking + dispatching)
   ══════════════════════════════════════════════════════════════ */
.svc-doc-row    { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.svc-doc-chip   { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 8px; white-space: nowrap; }
.svc-doc-chip-expired { background: rgba(240,78,78,0.22);   color: #f04e4e; }
.svc-doc-chip-warning { background: rgba(232,115,74,0.22);  color: #e8734a; }
.svc-doc-chip-caution { background: rgba(245,166,35,0.18);  color: #f5a623; }

/* Vehicle profile chips inside 360 panel */
.svc-v360-profile-row  { display: flex; flex-wrap: wrap; gap: 5px; }
.svc-v360-profile-chip { font-size: 11px; padding: 2px 8px; border-radius: 8px;
                          background: rgba(255,255,255,0.08); color: #c5cad6; }
.svc-v360-profile-active   { background: rgba(76,175,125,0.18); color: #4caf7d; }
.svc-v360-profile-inactive { background: rgba(136,146,164,0.15); color: #8892a4; }
