.perf-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.perf-nav a {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}
.perf-nav a:hover {
    color: var(--text);
    border-color: var(--accent);
}
.perf-nav a.active {
    background: var(--accent-soft);
    color: var(--text);
    border-color: var(--accent);
}

.entity-panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: auto;
    max-height: min(720px, calc(100vh - 220px));
}
.entity-table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 100%;
}
.entity-table th,
.entity-table td {
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 8px 10px;
    white-space: nowrap;
    font-size: 12px;
}
.entity-table th {
    position: sticky;
    top: 0;
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    z-index: 2;
}
.entity-table thead tr.avg-row th {
    top: 33px;
    background: #1e293b;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    border-bottom: 2px solid var(--border);
    z-index: 2;
}
.entity-table thead tr.avg-row th.entity-col {
    z-index: 5;
    background: #1e293b;
    color: var(--accent);
}
.entity-table .check-col {
    position: sticky;
    left: 0;
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    padding: 8px 6px;
    text-align: center;
    background: var(--bg-elevated);
    z-index: 3;
}
.entity-table th.check-col {
    z-index: 4;
    background: var(--bg-muted);
}
.entity-table thead tr.avg-row th.check-col {
    z-index: 5;
    background: #1e293b;
}
.entity-table .entity-col {
    position: sticky;
    left: 36px;
    background: var(--bg-elevated);
    z-index: 3;
    min-width: 180px;
    max-width: 220px;
    font-weight: 700;
    color: var(--text);
}
.entity-table th.entity-col {
    z-index: 4;
    background: var(--bg-muted);
}
.entity-table .row-check {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--accent);
}
.entity-sub {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 2px;
}
.entity-table .num {
    text-align: right;
    font-family: var(--font-mono);
    color: var(--text);
}
.entity-table td.metric-above {
    background: rgba(22, 163, 74, 0.55);
    color: #f0fdf4;
    font-weight: 700;
}
.entity-table td.metric-below {
    background: rgba(220, 38, 38, 0.55);
    color: #fef2f2;
    font-weight: 700;
}
.entity-table tr.row-dimmed td {
    opacity: 0.38;
    background: transparent !important;
    color: var(--text-muted) !important;
    font-weight: 500 !important;
}
.entity-table tr.row-dimmed td.check-col,
.entity-table tr.row-dimmed td.entity-col {
    opacity: 0.55;
    background: var(--bg-elevated) !important;
}
.entity-table tr.row-dimmed:hover td {
    opacity: 0.55;
    background: rgba(59, 130, 246, 0.04) !important;
}
.entity-table tr:hover td {
    background: rgba(59, 130, 246, 0.06);
}
.entity-table tr:hover td.metric-above {
    background: rgba(22, 163, 74, 0.7);
}
.entity-table tr:hover td.metric-below {
    background: rgba(220, 38, 38, 0.7);
}
.entity-table tr:hover td.entity-col,
.entity-table tr:hover td.check-col {
    background: #1a2332;
}
.entity-table th.sortable {
    cursor: pointer;
    user-select: none;
}
.entity-table th.sortable:hover {
    color: var(--text);
    background: #243044;
}
.entity-table .sort-ind {
    display: inline-block;
    margin-left: 4px;
    opacity: 0.35;
    font-size: 10px;
}
.entity-table .sort-ind.active {
    opacity: 1;
    color: var(--accent);
}

/* Entity performance: grouped header, totals row, best / worst ranks */
.entity-table thead tr.group-row th {
    top: 0;
    height: 26px;
    box-sizing: border-box;
    padding: 4px 10px;
    text-align: center;
    font-size: 10px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.entity-table thead tr.metric-row th {
    white-space: normal;
    min-width: 76px;
    max-width: 110px;
    line-height: 1.25;
    vertical-align: bottom;
    text-transform: none;
    letter-spacing: 0;
}
.entity-table thead tr.total-row th {
    background: #1e293b;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    border-bottom: 2px solid var(--accent);
}
.entity-table thead tr.total-row th.entity-col,
.entity-table thead tr.total-row th.check-col {
    z-index: 5;
    background: #1e293b;
    color: var(--accent);
}
.entity-table th.group-head.g-base { background: linear-gradient(rgba(59, 130, 246, 0.22), rgba(59, 130, 246, 0.22)), var(--bg-muted); }
.entity-table th.group-head.g-time { background: linear-gradient(rgba(168, 85, 247, 0.2), rgba(168, 85, 247, 0.2)), var(--bg-muted); }
.entity-table th.group-head.g-trips { background: linear-gradient(rgba(14, 165, 233, 0.2), rgba(14, 165, 233, 0.2)), var(--bg-muted); }
.entity-table th.group-head.g-revenue { background: linear-gradient(rgba(34, 197, 94, 0.18), rgba(34, 197, 94, 0.18)), var(--bg-muted); }
.entity-table th.group-head.g-mileage { background: linear-gradient(rgba(245, 158, 11, 0.18), rgba(245, 158, 11, 0.18)), var(--bg-muted); }
.entity-table th.group-head.g-energy { background: linear-gradient(rgba(239, 68, 68, 0.18), rgba(239, 68, 68, 0.18)), var(--bg-muted); }
.entity-table .group-start { border-left: 2px solid #334155; }
.entity-table td.rank-best {
    background: rgba(34, 197, 94, 0.22);
    color: #86efac;
    font-weight: 700;
}
.entity-table td.rank-worst {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    font-weight: 700;
}
.entity-table tr:hover td.rank-best { background: rgba(34, 197, 94, 0.32); }
.entity-table tr:hover td.rank-worst { background: rgba(239, 68, 68, 0.3); }
.entity-table .low-sample {
    color: #fbbf24;
    font-weight: 600;
}
.entity-table .sort-ind {
    opacity: 1;
    color: var(--accent);
}

.shift-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}
.shift-filter .toggles-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-right: 2px;
}
.shift-btn {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.shift-btn span {
    font-weight: 500;
    opacity: 0.7;
    margin-left: 4px;
}
.shift-btn.on {
    background: var(--accent);
    border-color: var(--accent);
    color: #0b1220;
}
.shift-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 8px;
}
.shift-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.shift-badge.st-single { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.shift-badge.st-pair { background: rgba(168, 85, 247, 0.22); color: #d8b4fe; }
.shift-badge.st-mix { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.shift-badge.st-unplanned { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; }
.leader-line i {
    font-style: normal;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.leaders {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}
.leader-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
}
.leader-title {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.leader-fleet {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    margin: 4px 0 6px;
    font-family: var(--font-mono);
}
.leader-fleet span {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 6px;
    font-family: inherit;
}
.leader-line {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.6;
}
.leader-line.best { color: #86efac; }
.leader-line.worst { color: #fca5a5; }
.leader-line b { font-family: var(--font-mono); }

.group-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-left: auto;
}
.group-toggles .toggles-label {
    font-size: 12px;
    color: var(--text-muted);
}
.group-toggle {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    text-decoration: line-through;
}
.group-toggle.on {
    color: var(--text);
    border-color: var(--accent);
    text-decoration: none;
}

.metric-help {
    margin-top: 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text-muted);
}
.metric-help summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text);
}
.metric-help .help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 8px 24px;
    margin-top: 10px;
}
.metric-help h4 {
    margin: 6px 0;
    color: var(--text);
    font-size: 12px;
}
.metric-help dl { margin: 0; }
.metric-help dt {
    color: var(--text);
    font-weight: 600;
    margin-top: 6px;
}
.metric-help dt .dir {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 11px;
    margin-left: 6px;
}
.metric-help dd { margin: 2px 0 0; }
.metric-help .help-note { margin: 12px 0 2px; }

.selection-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}
.selection-bar button {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.selection-bar button:hover {
    color: var(--text);
    border-color: var(--accent);
}
.selection-bar .chip {
    font-size: 12px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 10px;
}
