/* =====================================================================
   Data Dashboard Pro v6 — Front-end CSS
   Design matches Image 1: chips + horizontal bar chart + dark table
   ===================================================================== */

.mdd6 {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: #111827;
    max-width: 1400px;
    margin: 0 auto 48px;
    background: #F9FAFB;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,.07), 0 10px 30px -5px rgba(0,0,0,.1);
}
.mdd6 *, .mdd6 *::before, .mdd6 *::after { box-sizing: border-box; }

/* ── Header Strip ──────────────────────────────────────────────────── */
.mdd6-strip {
    padding: 20px 28px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.mdd6-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 4px;
    letter-spacing: -0.02em;
}
.mdd6-sub { font-size: .85rem; margin: 0; opacity: .75; }
.mdd6-sub strong { opacity: 1; }

/* ── Summary Chips (Image 1 top cards) ─────────────────────────────── */
.mdd6-chips {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    background: #fff;
    border-bottom: 1px solid #E5E7EB;
}
@media(max-width:900px){ .mdd6-chips { grid-template-columns: repeat(3,1fr); } }
@media(max-width:600px){ .mdd6-chips { grid-template-columns: repeat(2,1fr); } }

.mdd6-chip {
    padding: 18px 20px;
    border-right: 1px solid #E5E7EB;
    background: #fff;
}
.mdd6-chip:last-child { border-right: none; }
.mdd6-chip-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #6B7280; margin-bottom: 6px; }
.mdd6-chip-val   { font-size: 2rem; font-weight: 900; line-height: 1; margin-bottom: 8px; letter-spacing: -0.02em; }
.mdd6-chip-bar   { height: 4px; background: #E5E7EB; border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.mdd6-chip-fill  { height: 100%; border-radius: 2px; transition: width .8s ease; }
.mdd6-chip-sub   { font-size: .72rem; color: #9CA3AF; }

/* ── Tabs ───────────────────────────────────────────────────────────── */
.mdd6-tabs {
    display: flex;
    background: #fff;
    border-bottom: 2px solid #E5E7EB;
    padding: 0 24px;
    gap: 4px;
}
.mdd6-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 12px 18px;
    border: none;
    background: transparent;
    font-size: .88rem;
    font-weight: 600;
    color: #6B7280;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all .2s;
}
.mdd6-tab:hover { color: #111827; }
.mdd6-tab--active { color: #2563EB; border-bottom-color: #2563EB; }
.mdd6-tab-badge {
    background: #EFF6FF;
    color: #2563EB;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: .72rem;
    font-weight: 700;
}
.mdd6-tab--active .mdd6-tab-badge { background: #2563EB; color: #fff; }

/* ── Panels ─────────────────────────────────────────────────────────── */
.mdd6-panel { display: none; }
.mdd6-panel--open { display: block; }

/* ── District Chart Panel ───────────────────────────────────────────── */
.mdd6-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 20px;
    background: #0D1526;
    border-bottom: 1px solid rgba(255,255,255,.06);
    font-size: .78rem;
    color: #CBD5E1;
}
.mdd6-legend-item { display: flex; align-items: center; gap: 6px; }
.mdd6-legend-dot  { width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0; }
.mdd6-legend-line { display: inline-block; width: 0; height: 16px; margin: 0 2px; }
.mdd6-chart-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 10px;
    background: #0D1526;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.mdd6-chart-title-main {
    font-size: .95rem;
    font-weight: 700;
    color: #E2E8F0;
}
.mdd6-chart-title-sub {
    font-size: .75rem;
    color: #4B5563;
    font-style: italic;
}
.mdd6-chart-wrap  { background: #0D1526; padding: 20px 16px 16px 12px; position: relative; }

/* ── Facility Rankings Panel ─────────────────────────────────────────── */
.mdd6-fhdr {
    background: #0D1526;
    color: #E2E8F0;
    padding: 18px 24px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.mdd6-fhdr-title strong { display: block; font-size: 1rem; font-weight: 800; color: #60A5FA; margin-bottom: 3px; }
.mdd6-fhdr-title span   { font-size: .8rem; color: #475569; }
.mdd6-fhdr-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.mdd6-fc {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 10px;
    padding: 9px 16px;
    min-width: 68px;
}
.mdd6-fc span  { font-size: 1.35rem; font-weight: 800; }
.mdd6-fc small { font-size: .63rem; color: #475569; text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }

/* ── Instant Filters (horizontal single line — Image 2 style) ────────── */
.mdd6-filters {
    background: #0A0F1E;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid #1E3A5F;
}
.mdd6-search-wrap {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1 1 200px;
    max-width: 280px;
    background: rgba(255,255,255,.07);
    border: 1px solid #2D4A6A;
    border-radius: 8px;
    padding: 0 12px;
}
.mdd6-search-icon { width: 13px; height: 13px; color: #475569; flex-shrink: 0; }
.mdd6-search {
    flex: 1;
    background: transparent;
    border: none;
    color: #E2E8F0;
    padding: 9px 0;
    font-size: .82rem;
    outline: none;
    font-family: inherit;
}
.mdd6-search::placeholder { color: #94A3B8; }
.mdd6-filter-stack {
    display: contents; /* children flow directly into flex row */
}
.mdd6-sel {
    background: #111827;
    border: 1px solid #2D4A6A;
    border-radius: 7px;
    color: #CBD5E1;
    padding: 9px 10px;
    font-size: .8rem;
    cursor: pointer;
    font-family: inherit;
    flex: 1 1 130px;
    min-width: 120px;
}
.mdd6-sel--full { flex: 1 1 130px; }
.mdd6-sel:focus { outline: none; border-color: #60A5FA; }
.mdd6-sel:hover { border-color: #3B82F6; }
.mdd6-count { font-size: .75rem; color: #4B5563; white-space: nowrap; margin-left: auto; }

/* ── Table ───────────────────────────────────────────────────────────── */
.mdd6-tbl-wrap { overflow-x: auto; background: #0F1629; max-height: 600px; overflow-y: auto; }
.mdd6-tbl { width: 100%; border-collapse: collapse; font-size: .83rem; }
.mdd6-tbl thead { position: sticky; top: 0; z-index: 5; }
.mdd6-tbl th {
    background: #080D1A;
    color: #4B5563;
    font-size: .66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid #1E3A5F;
    white-space: nowrap;
}
.mdd6-row { border-bottom: 1px solid rgba(255,255,255,.04); cursor: pointer; transition: background .12s; }
.mdd6-row:hover { background: rgba(96,165,250,.07); }
.mdd6-row.mdd6-row--active { background: rgba(96,165,250,.13); border-left: 3px solid #60A5FA; }
.mdd6-row.mdd6-row--hidden { display: none; }
.mdd6-row td { padding: 11px 14px; color: #CBD5E1; vertical-align: middle; }
.mdd6-rank  { font-size: .76rem; font-weight: 800; color: #374151; }
.mdd6-fname { font-weight: 600; color: #E2E8F0; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.mdd6-fgrp  { font-size: .82rem; color: #6B7280; }
.mdd6-fbase { font-size: .82rem; color: #6B7280; }
.mdd6-pill  { background: rgba(255,255,255,.08); border-radius: 5px; padding: 3px 8px; font-size: .72rem; color: #9CA3AF; }
.mdd6-score { display: flex; flex-direction: column; gap: 4px; min-width: 90px; }
.mdd6-sbar  { height: 4px; background: rgba(255,255,255,.1); border-radius: 2px; overflow: hidden; }
.mdd6-sbar div { height: 100%; border-radius: 2px; transition: width .5s; }
.mdd6-spark { display: block; }

/* ── Pagination ──────────────────────────────────────────────────────── */
.mdd6-pg {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 14px 20px;
    background: #0A0F1E;
    border-top: 1px solid #1E3A5F;
    flex-wrap: wrap;
}
.mdd6-pg-btn {
    min-width: 34px;
    height: 34px;
    border: 1px solid #1E3A5F;
    border-radius: 7px;
    background: rgba(255,255,255,.05);
    color: #9CA3AF;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    font-family: inherit;
    transition: all .15s;
}
.mdd6-pg-btn:hover { background: rgba(96,165,250,.15); color: #60A5FA; border-color: #2D4A6A; }
.mdd6-pg-btn.on    { background: #2563EB; color: #fff; border-color: #2563EB; }
.mdd6-pg-btn:disabled { opacity: .3; cursor: default; }
.mdd6-pg-info { font-size: .75rem; color: #4B5563; padding: 0 6px; }

/* ── Drawer ──────────────────────────────────────────────────────────── */
.mdd6-drawer {
    position: fixed;
    top: 0; right: -440px;
    width: 420px; max-width: 100vw;
    height: 100vh;
    background: #0A0F1E;
    border-left: 1px solid #1E3A5F;
    z-index: 99999;
    transition: right .3s cubic-bezier(.4,0,.2,1);
    box-shadow: -8px 0 40px rgba(0,0,0,.5);
    overflow-y: auto;
}
.mdd6-drawer.open { right: 0; }
.mdd6-drawer-body { padding: 22px; }
.mdd6-drawer-x {
    position: absolute; top: 14px; right: 14px;
    background: rgba(255,255,255,.07);
    border: 1px solid #1E3A5F; border-radius: 50%;
    width: 30px; height: 30px;
    color: #9CA3AF; font-size: .85rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s;
}
.mdd6-drawer-x:hover { background: rgba(239,68,68,.25); color: #EF4444; }
/* Drawer content styles (built by JS) */
.mdd6-dr-rank { font-size: .68rem; font-weight: 700; color: #374151; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 4px; }
.mdd6-dr-name { font-size: 1.2rem; font-weight: 800; color: #E2E8F0; margin-bottom: 3px; line-height: 1.2; }
.mdd6-dr-sub  { font-size: .8rem; color: #4B5563; margin-bottom: 18px; }
.mdd6-dr-score{ font-size: 2.8rem; font-weight: 900; letter-spacing: -0.04em; margin-bottom: 2px; }
.mdd6-dr-slbl { font-size: .68rem; color: #4B5563; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 18px; }
.mdd6-dr-sec  { margin-bottom: 16px; }
.mdd6-dr-stitle { font-size: .67rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: #374151; margin-bottom: 7px; padding-bottom: 5px; border-bottom: 1px solid #1E3A5F; }
.mdd6-dr-row  { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.mdd6-dr-key  { font-size: .76rem; color: #4B5563; }
.mdd6-dr-val  { font-size: .8rem; font-weight: 600; color: #E2E8F0; }
.mdd6-dr-mgrid{ display: grid; grid-template-columns: repeat(auto-fill,minmax(72px,1fr)); gap: 7px; }
.mdd6-dr-mc   { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07); border-radius: 6px; padding: 7px; text-align: center; }
.mdd6-dr-mlbl { font-size: .6rem; color: #4B5563; display: block; margin-bottom: 3px; }
.mdd6-dr-mval { font-size: .9rem; font-weight: 700; }
.mdd6-dr-cwrap{ height: 130px; position: relative; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media(max-width:768px){
    .mdd6-strip { padding: 16px 18px; }
    .mdd6-title { font-size: 1.2rem; }
    .mdd6-chip  { padding: 14px 14px; }
    .mdd6-chip-val { font-size: 1.5rem; }
    .mdd6-tabs  { padding: 0 12px; }
    .mdd6-tab   { padding: 10px 12px; font-size: .82rem; }
    .mdd6-filters { padding: 10px 14px; flex-direction: column; }
    .mdd6-search-wrap { width: 100%; }
    .mdd6-filter-stack { width: 100%; }
    .mdd6-sel   { flex: 1 1 45%; }
    .mdd6-count { width: 100%; text-align: center; margin-left: 0; }
    .mdd6-drawer{ width: 100%; right: -100%; }
    /* Hide some table cols on mobile */
    .mdd6-tbl th:nth-child(3), .mdd6-tbl td:nth-child(3) { display: none; }
}
@media(max-width:480px){
    .mdd6-chips { grid-template-columns: 1fr 1fr; }
    .mdd6-chip:nth-child(5) { display: none; }
    .mdd6-legend { padding: 10px 14px; font-size: .7rem; gap: 10px; }
    .mdd6-tbl th:nth-child(n+5):nth-child(-n+6),
    .mdd6-tbl td:nth-child(n+5):nth-child(-n+6) { display: none; }
    .mdd6-pg-btn { min-width: 28px; height: 28px; font-size: .75rem; }
}

.mdd6-row.mdd6-row--nv { opacity: .6; }
.mdd6-row.mdd6-row--nv:hover { opacity: .8; }
.mdd6-nv-badge { background: rgba(107,114,128,.15); color: #6B7280; border: 1px solid rgba(107,114,128,.3); border-radius: 5px; padding: 3px 8px; font-size: .72rem; }

/* ── Trajectory Chart ────────────────────────────────────────────────────── */
.mdd6-traj-wrap {
    background: #0D1526;
    border-top: 1px solid #1E3A5F;
    padding: 24px;
}
.mdd6-traj-kpis {
    display: grid;
    grid-template-columns: repeat(4,1fr);
    gap: 1px;
    background: #1E3A5F;
    border: 1px solid #1E3A5F;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 24px;
}
@media(max-width:768px){ .mdd6-traj-kpis{ grid-template-columns:1fr 1fr; } }
@media(max-width:480px){ .mdd6-traj-kpis{ grid-template-columns:1fr; } }
.mdd6-traj-kpi {
    background: #0D1526;
    padding: 20px 22px;
}
.mdd6-traj-kpi--current { background: #0A1A0A; }
.mdd6-traj-kpi-label {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #4B5563;
    margin-bottom: 8px;
}
.mdd6-traj-kpi-val {
    font-size: 2rem;
    font-weight: 900;
    color: #E2E8F0;
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 6px;
}
.mdd6-traj-kpi-sub {
    font-size: .72rem;
    color: #4B5563;
}
.mdd6-traj-chart-box {
    background: #0D1526;
    border: 1px solid #1E3A5F;
    border-radius: 12px;
    padding: 20px 20px 14px;
}
.mdd6-traj-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.mdd6-traj-chart-title {
    font-size: .9rem;
    font-weight: 700;
    color: #E2E8F0;
}
.mdd6-traj-legend {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .78rem;
    color: #6B7280;
}
.mdd6-traj-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3B82F6;
    flex-shrink: 0;
}
.mdd6-traj-canvas-wrap {
    height: 300px;
    position: relative;
}

/* ── Misc ─────────────────────────────────────────────────────────────── */
.mdd-no-data { background: #FFF5F5; border: 1px solid #FCA5A5; border-radius: 10px; padding: 20px; color: #B91C1C; font-weight: 600; }
