/* ═══════════════════════════════════════════════════════════════════
   Fleet Status — PnL Owner  (.fpn- prefix)  FEAT-042
   ═══════════════════════════════════════════════════════════════════ */

/* ── Page ─────────────────────────────────────────────────────────── */
.fpn-page {
    min-height: 100vh;
    padding-bottom: 40px;
    font-family: inherit;
}

/* ── Header ───────────────────────────────────────────────────────── */
.fpn-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px 14px;
    border-bottom: 1px solid #2d3548;
    background: #1e2537;
}

.fpn-page-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #e4e8f0;
    letter-spacing: 0.02em;
}

body[data-theme="light"] .fpn-header {
    background: #f0f4ff;
    border-bottom-color: #cdd5e0;
}

body[data-theme="light"] .fpn-page-title {
    color: #1a2540;
}

/* ── Content area ─────────────────────────────────────────────────── */
.fpn-content {
    padding: 20px 24px;
}

/* ── Region section ───────────────────────────────────────────────── */
.fpn-region-section {
    margin-bottom: 28px;
}

.fpn-region-header {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #6b7899;
    padding: 4px 0 8px;
    border-bottom: 1px solid #2d3548;
    margin-bottom: 12px;
    text-transform: uppercase;
}

body[data-theme="light"] .fpn-region-header {
    color: #7a8aaa;
    border-bottom-color: #cdd5e0;
}

/* ── Cards grid ───────────────────────────────────────────────────── */
.fpn-owner-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* ── Owner card ───────────────────────────────────────────────────── */
.fpn-owner-card {
    background: #252c3e;
    border: 1px solid #2d3548;
    border-radius: 8px;
    padding: 14px 16px;
    min-width: 280px;
    flex: 1 1 280px;
    max-width: 420px;
    transition: border-color 0.15s;
}

.fpn-owner-card:hover {
    border-color: #4a9eff;
}

body[data-theme="light"] .fpn-owner-card {
    background: #fff;
    border-color: #d0d8ea;
}

body[data-theme="light"] .fpn-owner-card:hover {
    border-color: #4a9eff;
}

/* ── Card header ──────────────────────────────────────────────────── */
.fpn-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    gap: 8px;
}

.fpn-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #c8d0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body[data-theme="light"] .fpn-card-title {
    color: #1a2540;
}

.fpn-card-total {
    font-size: 0.8rem;
    font-weight: 700;
    color: #7eb3f7;
    white-space: nowrap;
    flex-shrink: 0;
}

body[data-theme="light"] .fpn-card-total {
    color: #2c6fbf;
}

/* ── Stats row ────────────────────────────────────────────────────── */
.fpn-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.fpn-stat {
    font-size: 0.78rem;
    color: #8a96b0;
}

body[data-theme="light"] .fpn-stat {
    color: #5a6a88;
}

.fpn-stat-active {
    color: #4bcc8a;
    font-weight: 600;
}

body[data-theme="light"] .fpn-stat-active {
    color: #1a8f52;
}

.fpn-stat-inactive {
    color: #f0a04a;
}

body[data-theme="light"] .fpn-stat-inactive {
    color: #c0620c;
}

.fpn-stat-overdue {
    color: #f06060;
    font-weight: 600;
}

body[data-theme="light"] .fpn-stat-overdue {
    color: #c42020;
}

.fpn-stat-dim {
    color: #6b7899;
}

body[data-theme="light"] .fpn-stat-dim {
    color: #8a96b0;
}

/* ── Progress bar ─────────────────────────────────────────────────── */
.fpn-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fpn-bar-track {
    flex: 1;
    height: 6px;
    background: #2d3548;
    border-radius: 3px;
    overflow: hidden;
}

body[data-theme="light"] .fpn-bar-track {
    background: #d0d8ea;
}

.fpn-bar-fill {
    height: 100%;
    background: #4bcc8a;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.fpn-bar-label {
    font-size: 0.72rem;
    color: #6b7899;
    white-space: nowrap;
    min-width: 62px;
}

body[data-theme="light"] .fpn-bar-label {
    color: #7a8aaa;
}

/* ── Empty / Error states ─────────────────────────────────────────── */
.fpn-empty-state {
    padding: 48px 24px;
    text-align: center;
    color: #6b7899;
    font-size: 0.9rem;
}

body[data-theme="light"] .fpn-empty-state {
    color: #8a96b0;
}

.fpn-error-state {
    padding: 32px 24px;
    text-align: center;
}

.fpn-state-title {
    color: #f06060;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.fpn-state-detail {
    color: #8a96b0;
    font-size: 0.82rem;
}

/* ── Date label ───────────────────────────────────────────────────── */
.fpn-date-label { font-size:0.8rem; color:#8a96b0; white-space:nowrap; }

/* ── Region sub-header inside PnL groups ──────────────────────────── */
.flt-state-region-header {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #6c757d;
    padding: 18px 16px 4px;
}
.flt-region-section { margin-bottom: 8px; }

/* ── Clickable card header ─────────────────────────────────────────── */
.fpn-card-clickable {
    cursor: pointer;
    transition: background 0.15s;
}
.fpn-card-clickable:hover { background: rgba(255,255,255,0.04); }
.fpn-chevron { margin-right: 8px; font-size: 0.75rem; color: #6c757d; }
.fpn-card-expanded { border-color: #4a9eff !important; }

/* ── Bus detail panel ──────────────────────────────────────────────── */
.fpn-bus-panel { display: none; }
.fpn-bus-panel-open {
    display: block;
    padding: 0 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.07);
    margin-top: 4px;
}

/* ── Bus table ─────────────────────────────────────────────────────── */
.fpn-bus-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-top: 10px;
}
.fpn-th {
    text-align: left;
    padding: 6px 10px;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8a96b0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.fpn-th-right { text-align: right; }
.fpn-td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: #c8d0df;
    vertical-align: middle;
}
.fpn-td-plate { font-weight: 600; color: #e4e8f0; font-size: 0.85rem; }
.fpn-td-right { text-align: right; }

.fpn-bus-row-overdue td { background: rgba(232,115,74,0.05); }
.fpn-bus-row-due-soon td { background: rgba(244,167,36,0.05); }

/* ── PM status badges in bus table ────────────────────────────────── */
.fpn-pm-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
}
.fpn-pm-overdue  { background: rgba(232,115,74,0.2);  color: #e8734a; }
.fpn-pm-soon     { background: rgba(244,167,36,0.2);  color: #f4a724; }
.fpn-pm-ok       { background: rgba(77,212,143,0.2);  color: #4dd48f; }
.fpn-pm-unknown  { background: rgba(138,150,176,0.15); color: #8a96b0; }

/* ── Header right ──────────────────────────────────────────────────── */
.fpn-header-right { display: flex; align-items: center; gap: 10px; }
.fpn-date-label   { font-size: 0.8rem; color: #8a96b0; }
.fpn-loading      { color: #8a96b0; font-size: 0.85rem; padding: 16px; text-align: center; }
.fpn-empty-buses  { color: #6c757d; font-size: 0.85rem; padding: 12px; text-align: center; }

/* ═══════════════════════════════════════════════════════════════════
   FEAT-013B — Servicing badges + status dot + history modal
   ═══════════════════════════════════════════════════════════════════ */

/* ── Clickable bus cards ───────────────────────────────────────────── */
.fpn-bus-card {
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.fpn-bus-card:hover {
    border-color: #4a9eff !important;
    box-shadow: 0 0 0 2px rgba(74,158,255,0.18);
}

/* ── Servicing badges ──────────────────────────────────────────────── */
.fpn-svc-badge-overdue {
    font-weight: 700;
    letter-spacing: 0.03em;
}
.fpn-svc-badge-due {
    font-style: italic;
}

/* ── Workshop badge ────────────────────────────────────────────────── */
.fpn-badge-workshop {
    background: rgba(138,150,176,0.18);
    color: #8a96b0;
}

/* ── Status dot ────────────────────────────────────────────────────── */
.fpn-dot {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    letter-spacing: 0.04em;
}
.fpn-dot-active   { background: rgba(75,204,138,0.18); color: #4bcc8a; }
.fpn-dot-inactive { background: rgba(232,115,74,0.15); color: #e8734a; }
.fpn-dot-workshop { background: rgba(244,167,36,0.18); color: #f4a724; }

/* ── Route label on bus card ───────────────────────────────────────── */
.fpn-vcard-route {
    font-size: 0.72rem;
    color: #6b7899;
    margin: 2px 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
body[data-theme="light"] .fpn-vcard-route { color: #8a96b0; }

/* ── Service history modal backdrop ───────────────────────────────── */
.fpn-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.fpn-modal-hidden { display: none !important; }
.fpn-modal-open   { display: flex; }

/* ── Modal dialog ──────────────────────────────────────────────────── */
.fpn-modal-dialog {
    background: #1e2537;
    border: 1px solid #2d3548;
    border-radius: 10px;
    width: 100%;
    max-width: 680px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
body[data-theme="light"] .fpn-modal-dialog {
    background: #fff;
    border-color: #cdd5e0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

/* ── Modal header ──────────────────────────────────────────────────── */
.fpn-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #2d3548;
    flex-shrink: 0;
}
body[data-theme="light"] .fpn-modal-header { border-bottom-color: #cdd5e0; }

.fpn-modal-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e4e8f0;
}
body[data-theme="light"] .fpn-modal-title { color: #1a2540; }

.fpn-modal-close {
    background: none;
    border: none;
    color: #6b7899;
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.12s;
}
.fpn-modal-close:hover { background: rgba(255,255,255,0.08); color: #c8d0e0; }
body[data-theme="light"] .fpn-modal-close:hover { background: rgba(0,0,0,0.07); }

/* ── Modal body (scrollable) ───────────────────────────────────────── */
.fpn-modal-body {
    overflow-y: auto;
    padding: 16px 18px;
    flex: 1;
    min-height: 0;
    /* BUG-128: Dash wraps the body in plain divs, breaking the dialog's flex chain,
       so flex:1 alone never scrolls. Cap the body height directly (dialog is 80vh,
       header ~60px) so long service histories scroll instead of clipping. */
    max-height: calc(80vh - 60px);
}

/* ── History table inside modal ────────────────────────────────────── */
.fpn-bus-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.fpn-th {
    text-align: left;
    padding: 6px 10px;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8a96b0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.fpn-th-right { text-align: right; }
.fpn-td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: #c8d0df;
    vertical-align: middle;
}
.fpn-td-plate { font-weight: 600; color: #e4e8f0; }
.fpn-td-right { text-align: right; }

body[data-theme="light"] .fpn-th { color: #5a6a88; border-bottom-color: rgba(0,0,0,0.1); }
body[data-theme="light"] .fpn-td { color: #2a3a54; border-bottom-color: rgba(0,0,0,0.05); }

/* ── 390px mobile ──────────────────────────────────────────────────── */
@media (max-width: 430px) {
    .fpn-modal-dialog { max-height: 90vh; border-radius: 10px 10px 0 0; }
    .fpn-modal-body { max-height: calc(90vh - 60px); }
    .fpn-modal-backdrop { align-items: flex-end; padding: 0; }
    .fpn-bus-table { font-size: 0.72rem; }
    .fpn-th, .fpn-td { padding: 5px 6px; }
}
