/* ═══════════════════════════════════════════════════════════════
   PM Analytics  (.pm-*)  — dark defaults
   ══════════════════════════════════════════════════════════════ */
.pm-page           { padding: 28px 32px; min-height: 100vh; background-color: #1a1f2e; }
.pm-header         { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.pm-page-title     { font-weight: 700; font-size: 1.15rem; color: #e8eaf0; margin: 0 0 4px; }
.pm-breadcrumb     { font-size: 0.78rem; display: flex; align-items: center; gap: 2px; }
.pm-breadcrumb-link   { color: #4a9eff; text-decoration: none; }
.pm-breadcrumb-link:hover { text-decoration: underline; }
.pm-breadcrumb-active { color: #8892a4; }
.pm-breadcrumb-sep    { color: #5a6478; padding: 0 2px; }
.pm-refresh-btn    { background: #2d3548; border: 1px solid #3a4258; color: #c5cad6;
                     padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 0.82rem; }
.pm-refresh-btn:hover { background: #3a4258; }
.pm-btn-danger     { background: #3a1a1a; border: 1px solid #8b3a2a; color: #e8734a;
                     padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 0.82rem; }
.pm-btn-danger:hover    { background: #4a2020; border-color: #e8734a; }
.pm-btn-danger:disabled { opacity: 0.45; cursor: not-allowed; }
.pm-toast          { font-size: 0.82rem; color: #20c997; background: rgba(32,201,151,0.1);
                     border: 1px solid rgba(32,201,151,0.3); border-radius: 6px;
                     padding: 7px 14px; margin-bottom: 12px; }
.pm-toast:empty    { display: none; }

/* KPI strip */
.pm-kpi-strip      { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr));
                     gap: 14px; margin-bottom: 20px; }
.pm-kpi-card       { background: #252b3b; border: 1px solid #2d3548; border-radius: 8px;
                     padding: 16px 18px; }
.pm-kpi-value      { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.pm-kpi-label      { font-size: 0.75rem; color: #8892a4; text-transform: uppercase;
                     letter-spacing: 0.8px; }

/* Cards */
.pm-card           { background: #252b3b; border: 1px solid #2d3548; border-radius: 8px;
                     padding: 18px 20px; margin-bottom: 20px; }
.pm-card-header    { display: flex; align-items: center; justify-content: space-between;
                     margin-bottom: 14px; }
.pm-card-title     { font-weight: 700; font-size: 0.95rem; color: #e8eaf0; }
.pm-card-subtitle  { font-size: 0.78rem; color: #8892a4; margin-top: 2px; }
.pm-empty          { color: #8892a4; font-size: 0.85rem; padding: 24px 0; text-align: center; }

/* Trend controls */
.pm-trend-controls   { display: flex; gap: 6px; }
.pm-trend-btn        { background: #2d3548; border: 1px solid #3a4258; color: #8892a4;
                       padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 0.78rem; }
.pm-trend-btn:hover  { background: #3a4258; color: #c5cad6; }
.pm-trend-btn-active { background: #1e4a8a; border-color: #4a9eff; color: #4a9eff; }

/* Group summary cards (overview) */
.pm-group-cards      { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 12px; }
.pm-group-card       { background: #1e2537; border: 1px solid #2d3548; border-radius: 7px;
                       padding: 14px 16px; cursor: pointer;
                       transition: transform 0.12s ease, border-color 0.12s ease; }
.pm-group-card:hover { transform: translateY(-2px); border-color: #4a5578; }
.pm-gc-name          { font-weight: 700; font-size: 0.85rem; color: #e8eaf0; margin-bottom: 6px;
                       white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-gc-overdue       { font-size: 1.1rem; font-weight: 700; }
.pm-gc-total         { font-size: 0.8rem; color: #8892a4; }
.pm-gc-pct           { font-size: 0.72rem; margin-top: 4px; font-weight: 600; }

/* Breakdown filter bar */
.pm-filter-bar       { display: flex; align-items: center; justify-content: space-between;
                       gap: 12px; margin-bottom: 16px; }
.pm-search-input     { background: #252b3b; border: 1px solid #3a4258; color: #e8eaf0;
                       padding: 8px 12px; border-radius: 6px; font-size: 0.85rem; width: 220px; }
.pm-search-input::placeholder { color: #5a6478; }
.pm-ctrl-btn         { background: #2d3548; border: 1px solid #3a4258; color: #c5cad6;
                       padding: 6px 12px; border-radius: 5px; cursor: pointer; font-size: 0.78rem; }
.pm-ctrl-btn:hover   { background: #3a4258; }
.pm-sort-btn         { background: #2d3548; border: 1px solid #3a4258; color: #c5cad6;
                       padding: 6px 13px; border-radius: 5px; cursor: pointer; font-size: 0.78rem; }
.pm-sort-btn:hover            { background: #3a4258; }
.pm-sort-btn-active           { background: #e8734a !important; border-color: #e8734a !important;
                                color: #fff !important; font-weight: 600; }
.pm-th-active                 { color: #e8734a !important; font-weight: 700; }

/* Accordion */
.pm-accordion-wrap   { display: flex; flex-direction: column; gap: 8px; }
.pm-group-section    { background: #252b3b; border: 1px solid #2d3548; border-radius: 8px;
                       overflow: hidden; }
.pm-group-header     { display: flex; align-items: center; justify-content: space-between;
                       padding: 13px 16px; cursor: pointer; user-select: none; }
.pm-group-header:hover { background: rgba(255,255,255,0.04); }
.pm-toggle-icon      { font-size: 0.7rem; color: #8892a4; width: 12px; }
.pm-group-name       { font-weight: 700; font-size: 0.9rem; color: #e8eaf0; }
.pm-group-badge      { background: #2d3548; color: #8892a4; font-size: 0.7rem;
                       padding: 2px 8px; border-radius: 10px; }
.pm-group-badge-red  { background: rgba(232,115,74,0.15); color: #e8734a; }
.pm-group-body       { padding: 0 12px 12px; }

/* Vehicle rows table */
.pm-table-header     { border-bottom: 1px solid #2d3548; margin-bottom: 4px; padding-bottom: 6px; }
.pm-th               { font-size: 0.7rem; color: #5a6478; font-weight: 600;
                       text-transform: uppercase; letter-spacing: 0.8px; }
.pm-vehicle-row      { display: grid; align-items: center; padding: 7px 4px;
                       grid-template-columns: 120px 60px 1fr 100px 80px;
                       border-bottom: 1px solid rgba(255,255,255,0.04); }
.pm-vehicle-row:last-child { border-bottom: none; }
.pm-row-cell         { font-size: 0.82rem; color: #c5cad6; }
.pm-row-plate        { font-weight: 600; }
.pm-row-days         { font-weight: 600; text-align: center; }
.pm-plate-link       { color: #4a9eff; text-decoration: none; font-weight: 700; }
.pm-plate-link:hover { text-decoration: underline; }

/* Overdue bar */
.pm-bar-track        { background: #1e2537; border-radius: 3px; height: 6px; width: 100%; }
.pm-bar-fill         { height: 6px; border-radius: 3px; transition: width 0.3s ease; }
.pm-bar-critical     { background: #e8734a; }
.pm-bar-warning      { background: #f0c060; }
.pm-bar-mild         { background: #4a9eff; }

/* Vehicle history page */
.pm-vh-summary-grid  { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr));
                       gap: 12px; background: #252b3b; border: 1px solid #2d3548;
                       border-radius: 8px; padding: 16px 20px; margin-bottom: 20px; }
.pm-vh-stat          { display: flex; flex-direction: column; gap: 3px; }
.pm-vh-lbl           { font-size: 0.7rem; color: #8892a4; text-transform: uppercase;
                       letter-spacing: 0.8px; }
.pm-vh-val           { font-size: 0.9rem; font-weight: 600; color: #e8eaf0; }
.pm-vh-badge-overdue { background: rgba(232,115,74,0.15); color: #e8734a; font-size: 0.78rem;
                       font-weight: 700; padding: 3px 10px; border-radius: 10px; }
.pm-vh-badge-ok      { background: rgba(25,135,84,0.15); color: #198754; font-size: 0.78rem;
                       font-weight: 700; padding: 3px 10px; border-radius: 10px; }

/* Missed detail panel */
.pm-missed-detail        { margin-top: 4px; }
.pm-missed-detail-header { display: flex; align-items: baseline; gap: 12px;
                            padding: 10px 14px 8px;
                            border-top: 1px solid rgba(255,255,255,0.06); }
.pm-missed-detail-date   { font-weight: 700; font-size: 0.88rem; color: #e8eaf0; }
.pm-missed-detail-count  { font-size: 0.8rem; color: #8892a4; }
.pm-missed-chips              { display: flex; flex-wrap: wrap; gap: 6px;
                               padding: 0 14px 10px; }
.pm-missed-group-label        { font-size: 0.75rem; color: #8892a4;
                               padding: 6px 14px 4px; font-style: italic; }
.pm-missed-group-label-advance{ color: #f0c060; }
.pm-missed-chip               { display: inline-flex; align-items: center; gap: 5px;
                               padding: 4px 10px; background: #2d3548;
                               border: 1px solid #3a4258; border-radius: 4px;
                               font-size: 0.8rem; color: #4a9eff;
                               text-decoration: none; transition: background 0.15s; }
.pm-missed-chip:hover         { background: #3a4258; color: #7ab8ff; }
.pm-missed-chip-advance       { border-color: #f0c060; color: #f0c060; }
.pm-missed-chip-advance:hover { background: #3a3020; color: #f5d080; }
.pm-missed-chip-bdate         { font-size: 0.7rem; opacity: 0.65; }

/* Timeline */
.pm-tl-summary       { font-size: 0.8rem; color: #8892a4; margin-bottom: 16px; }
.pm-timeline         { display: flex; flex-direction: column; gap: 0; position: relative; }
.pm-timeline::before { content: ''; position: absolute; left: 10px; top: 12px; bottom: 12px;
                       width: 2px; background: #2d3548; }
.pm-tl-event         { display: flex; gap: 16px; align-items: flex-start;
                       padding: 10px 0; position: relative; }
.pm-tl-dot           { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
                       border: 2px solid #2d3548; position: relative; z-index: 1; margin-top: 1px; }
.pm-tl-dot-done      { background: #198754; border-color: #198754; }
.pm-tl-dot-open      { background: #f0c060; border-color: #f0c060; }
.pm-tl-dot-overdue   { background: #e8734a; border-color: #e8734a; }
.pm-tl-dot-missed         { background: #2d3548; border-color: #5a6478; border-style: dashed; }
.pm-tl-dot-missed-booking { background: #6c2020; border-color: #e8734a; border-style: dashed; }
.pm-tl-content       { flex: 1; padding-bottom: 10px;
                       border-bottom: 1px solid rgba(255,255,255,0.04); }
.pm-tl-event:last-child .pm-tl-content { border-bottom: none; }
.pm-tl-top           { display: flex; gap: 12px; align-items: baseline; margin-bottom: 4px; flex-wrap: wrap; }
.pm-tl-pos           { font-weight: 700; font-size: 0.82rem; color: #e8eaf0; }
.pm-tl-odo           { font-size: 0.82rem; color: #4a9eff; font-weight: 600; }
.pm-tl-date          { font-size: 0.75rem; color: #8892a4; }
.pm-tl-desc          { font-size: 0.8rem; color: #8892a4; margin-top: 2px; }
.pm-tl-notes         { font-size: 0.75rem; color: #5a6478; margin-top: 2px; font-style: italic; }
.pm-tl-event-missed  { opacity: 0.7; }
.pm-tl-missed-label  { font-size: 0.72rem; font-weight: 700; color: #5a6478;
                       text-transform: uppercase; letter-spacing: 0.8px; display: block;
                       margin-bottom: 2px; }
.pm-tl-event-current .pm-tl-pos { color: #e8734a; }

/* Repair Order events */
.pm-tl-dot-ro-done   { background: #7c5cbf; border-color: #7c5cbf; }
.pm-tl-dot-ro-open   { background: #2d6fa8; border-color: #2d6fa8; }
.pm-tl-event-ro      { background: rgba(124,92,191,0.05); border-radius: 6px;
                       padding: 10px 10px 0; margin: 0 -10px; }
.pm-tl-ro-ref        { font-size: 0.82rem; font-weight: 700; color: #a98de8;
                       letter-spacing: 0.3px; }
.pm-tl-ro-link          { text-decoration: none; }
.pm-tl-ro-link:hover    { color: #c4b5fd; text-decoration: underline; }
.pm-tl-ro-archived      { opacity: 0.55; cursor: default; }
.pm-tl-ro-archived-icon { font-size: 9px; margin-left: 3px; vertical-align: middle; }
.pm-tl-ro-meta       { font-size: 0.75rem; color: #7c8fa8; margin-top: 3px; }
.pm-tl-ref           { display: inline-block; font-size: 0.73rem; color: #7c8fa8;
                       background: rgba(74,158,255,0.1); border: 1px solid rgba(74,158,255,0.2);
                       border-radius: 4px; padding: 1px 6px; margin: 3px 0 2px; }

.pm-timeline-wrap    { background: #252b3b; border: 1px solid #2d3548; border-radius: 8px;
                       padding: 20px 24px; }

/* ── PM light-theme overrides ──────────────────────────────── */
body[data-theme="light"] .pm-page            { background-color: #f0f2f5 !important; }
body[data-theme="light"] .pm-page-title      { color: #1a1f2e !important; }
body[data-theme="light"] .pm-kpi-card        { background: #ffffff !important; border-color: #dde1eb !important; }
body[data-theme="light"] .pm-kpi-label       { color: #6c757d !important; }
body[data-theme="light"] .pm-kpi-value { color: #1a1f2e !important; }
body[data-theme="light"] .pm-card            { background: #ffffff !important; border-color: #dde1eb !important; }
body[data-theme="light"] .pm-card-title      { color: #1a1f2e !important; }
body[data-theme="light"] .pm-card-subtitle        { color: #6c757d !important; }
body[data-theme="light"] .pm-missed-detail-header { border-color: #dee2e6 !important; }
body[data-theme="light"] .pm-missed-detail-date   { color: #1a1f2e !important; }
body[data-theme="light"] .pm-missed-detail-count  { color: #6c757d !important; }
body[data-theme="light"] .pm-missed-chip               { background: #f0f2f5 !important; border-color: #ced4da !important; color: #0d6efd !important; }
body[data-theme="light"] .pm-missed-chip:hover         { background: #e2e6ea !important; }
body[data-theme="light"] .pm-missed-chip-advance       { border-color: #e6a817 !important; color: #856404 !important; background: #fff8e6 !important; }
body[data-theme="light"] .pm-missed-group-label        { color: #6c757d !important; }
body[data-theme="light"] .pm-missed-group-label-advance{ color: #856404 !important; }
body[data-theme="light"] .pm-group-section   { background: #ffffff !important; border-color: #dde1eb !important; }
body[data-theme="light"] .pm-group-name      { color: #1a1f2e !important; }
body[data-theme="light"] .pm-group-badge     { background: #e9ecef !important; color: #6c757d !important; }
body[data-theme="light"] .pm-group-card      { background: #f8f9fa !important; border-color: #dde1eb !important; }
body[data-theme="light"] .pm-gc-name         { color: #1a1f2e !important; }
body[data-theme="light"] .pm-row-cell        { color: #2d3548 !important; }
body[data-theme="light"] .pm-th              { color: #6c757d !important; }
body[data-theme="light"] .pm-vehicle-row     { border-bottom-color: #f0f2f5 !important; }
body[data-theme="light"] .pm-bar-track       { background: #e9ecef !important; }
body[data-theme="light"] .pm-search-input    { background: #ffffff !important; border-color: #ced4da !important; color: #1a1f2e !important; }
body[data-theme="light"] .pm-vh-summary-grid { background: #ffffff !important; border-color: #dde1eb !important; }
body[data-theme="light"] .pm-vh-val          { color: #1a1f2e !important; }
body[data-theme="light"] .pm-vh-lbl          { color: #6c757d !important; }
body[data-theme="light"] .pm-timeline-wrap   { background: #ffffff !important; border-color: #dde1eb !important; }
body[data-theme="light"] .pm-tl-content      { border-bottom-color: #f0f2f5 !important; }
body[data-theme="light"] .pm-tl-pos          { color: #1a1f2e !important; }
body[data-theme="light"] .pm-tl-desc         { color: #5a6478 !important; }
body[data-theme="light"] .pm-tl-event-ro     { background: rgba(124,92,191,0.06) !important; }
body[data-theme="light"] .pm-tl-ro-ref       { color: #6941c6 !important; }
body[data-theme="light"] .pm-tl-ro-link:hover{ color: #4f30a8 !important; }
body[data-theme="light"] .pm-tl-ro-meta      { color: #6c757d !important; }
body[data-theme="light"] .pm-tl-ref          { color: #0d6efd !important; background: rgba(13,110,253,0.08) !important; border-color: rgba(13,110,253,0.2) !important; }
body[data-theme="light"] .pm-timeline::before { background: #dee2e6 !important; }
body[data-theme="light"] .pm-refresh-btn     { background: #e9ecef !important; border-color: #ced4da !important; color: #495057 !important; }
body[data-theme="light"] .pm-ctrl-btn        { background: #e9ecef !important; border-color: #ced4da !important; color: #495057 !important; }
body[data-theme="light"] .pm-sort-btn        { background: #e9ecef !important; border-color: #ced4da !important; color: #495057 !important; }
body[data-theme="light"] .pm-trend-btn       { background: #e9ecef !important; border-color: #ced4da !important; color: #495057 !important; }
body[data-theme="light"] .pm-btn-danger      { background: #fdf0ee !important; border-color: #e8734a !important; color: #c94a20 !important; }
body[data-theme="light"] .pm-toast           { background: rgba(25,135,84,0.08) !important; border-color: rgba(25,135,84,0.3) !important; color: #198754 !important; }

/* FEAT-004 — KPI card drilldown */
.kpi-card { cursor: pointer; transition: border 0.15s, box-shadow 0.15s; }
.kpi-card:hover { border: 1px solid #e8734a; }
.kpi-card-active { border: 2px solid #e8734a !important; box-shadow: 0 4px 12px rgba(232,115,74,0.25); }
.pm-kpi-detail { transition: max-height 0.3s ease; }
.pm-kpi-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.pm-kpi-panel-title  { font-weight: 700; font-size: 0.95rem; color: #e8eaf0; }
.pm-kpi-panel-count  { font-size: 0.8rem; color: #8892a4; }
.pm-kpi-panel-close  { background: none; border: none; color: #8892a4; font-size: 1.3rem;
                       cursor: pointer; padding: 0 4px; line-height: 1; flex-shrink: 0; }
.pm-kpi-panel-close:hover { color: #e8734a; }

body[data-theme="light"] .pm-kpi-panel-title { color: #1a1f2e !important; }
body[data-theme="light"] .pm-kpi-panel-count { color: #6c757d !important; }
body[data-theme="light"] .pm-kpi-panel-close { color: #6c757d !important; }
body[data-theme="light"] .pm-kpi-panel-close:hover { color: #e8734a !important; }
body[data-theme="light"] .kpi-card-active { border-color: #e8734a !important; }

/* FEAT-001 — Monthly KPI chart */
#pm-monthly-bar .js-plotly-plot,
#pm-monthly-bar .plot-container {
    height: 350px !important;
}

@media (max-width: 576px) {
    #pm-monthly-bar .js-plotly-plot,
    #pm-monthly-bar .plot-container {
        height: 220px !important;
    }
}
