/* ==========================================================================
   EPIC CHARGING — Analytics Dashboard
   Brand: Urbanist font, Primary #79B4B7 / #353535 / #FFFFFF
   Secondary: #EA5A6E #34C759 #764FA9 #FFF50A #E9E9E9 #ABABAB
   ========================================================================== */

/* ===== VARIABLES ===== */
:root {
    --font: 'Urbanist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* ---- Light theme (default — matches epiccharging.com) ---- */
    --bg-body: #f5f6f8;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8f9fb;
    --bg-input: #eef0f4;
    --border: #e2e5ea;
    --border-hover: #c5c9d2;
    --text-primary: #353535;
    --text-secondary: #5f6a78;
    --text-muted: #9aa3b0;

    /* Brand primary */
    --accent: #79B4B7;
    --accent-hover: #79B4B7;
    --accent-glow: rgba(121, 180, 183, 0.12);

    /* Brand secondary */
    --green: #34C759;
    --green-bg: rgba(52, 199, 89, 0.10);
    --red: #EA5A6E;
    --red-bg: rgba(234, 90, 110, 0.10);
    --yellow: #FFF50A;
    --yellow-bg: rgba(255, 245, 10, 0.10);
    --purple: #764FA9;
    --purple-bg: rgba(118, 79, 169, 0.08);
    --blue: #79B4B7;
    --blue-bg: rgba(121, 180, 183, 0.08);
    --gray-mid: #ABABAB;
    --gray-light: #E9E9E9;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 240px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Dark theme ---- */
[data-theme="dark"] {
    --bg-body: #1a1e24;
    --bg-sidebar: #21262e;
    --bg-card: #272d37;
    --bg-card-hover: #2e3542;
    --bg-input: #313845;
    --border: #3a4150;
    --border-hover: #4d5668;
    --text-primary: #f0f2f5;
    --text-secondary: #a0a8b8;
    --text-muted: #6b7485;

    --accent-glow: rgba(121, 180, 183, 0.14);

    --green-bg: rgba(52, 199, 89, 0.12);
    --red-bg: rgba(234, 90, 110, 0.12);
    --yellow-bg: rgba(255, 245, 10, 0.10);
    --purple-bg: rgba(118, 79, 169, 0.12);
    --blue-bg: rgba(121, 180, 183, 0.12);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.35);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.45);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    font-weight: 400;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--text-primary); }

h1, h2, h3 { font-weight: 600; letter-spacing: -0.03em; }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 22px 20px 18px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.01em;
}
.sidebar-brand .ec-logo {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
    background: #353535;
    color: #fff;
}
[data-theme="dark"] .sidebar-brand .ec-logo {
    background: var(--accent);
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    transition: all var(--transition);
}
.nav-item:hover {
    background: var(--accent-glow);
    color: var(--text-primary);
}
.nav-item.active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}
.nav-item.active svg { color: #fff; }
.nav-item.active:hover {
    background: var(--accent);
    color: #fff;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    color: var(--text-muted);
}
.pulse {
    width: 7px; height: 7px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse-ring 2s ease infinite;
}
@keyframes pulse-ring {
    0%  { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(52, 199, 89, 0); }
    100%{ box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}
.live-text { color: var(--green); font-weight: 600; }

.theme-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: none; }

/* ===== MOBILE MENU ===== */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 12px; left: 12px;
    z-index: 200;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    align-items: center;
    justify-content: center;
}

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 99;
    backdrop-filter: blur(2px);
}
.mobile-overlay.visible { display: block; }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    padding: 32px 36px 56px;
}

.page-container { max-width: 1400px; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 1.65rem;
    font-weight: 700;
}
.page-header .subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 2px;
    font-weight: 400;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}
.last-updated-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 500;
}

/* ===== STAT CARDS ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-grid.four-col {
    grid-template-columns: repeat(4, 1fr);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.stat-card.accent::before { background: var(--accent); }
.stat-card.green::before  { background: var(--green); }
.stat-card.red::before    { background: var(--red); }
.stat-card.yellow::before { background: var(--yellow); }
.stat-card.blue::before   { background: var(--accent); }
.stat-card.purple::before { background: var(--purple); }

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    background: var(--accent-glow);
    color: var(--accent);
}
.stat-icon.green  { background: var(--green-bg); color: var(--green); }
.stat-icon.red    { background: var(--red-bg); color: var(--red); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }

.stat-label {
    font-size: 0.73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.03em;
}
.stat-value.green  { color: var(--green); }
.stat-value.red    { color: var(--red); }
.stat-value.yellow { color: var(--yellow); }
.stat-value.blue   { color: var(--accent); }
.stat-value.purple { color: var(--purple); }
.stat-sub {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}
.stat-badge.green { background: var(--green-bg); color: var(--green); }
.stat-badge.red   { background: var(--red-bg); color: var(--red); }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}
.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 8px;
}
.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.card-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Headline number inside a chart card — pairs the metric's current
   value (utilization%, success rate, etc.) with the trend chart that
   visualises it over time. Sits between the card-header and chart-wrap. */
.card-headline {
    margin: -4px 0 14px 0;
}
.card-headline-num {
    font-size: 1.95rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.02em;
}
.card-headline-num.green { color: var(--green, #34c759); }
.card-headline-num.red   { color: var(--red, #EA5A6E); }
.card-headline-num.teal  { color: var(--accent, #79b4b7); }
.card-headline-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== EMPTY STATE ===== */
.card.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 260px;
    text-align: center;
}
.card.empty-state p {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.card.empty-state span {
    font-size: 0.84rem;
    color: var(--text-muted);
}

/* ===== GRID LAYOUTS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* ===== TABLES ===== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    position: relative;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.84rem;
}
thead th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-input);
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}
thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
thead th:hover { color: var(--accent); }
thead th .sort-arrow { margin-left: 4px; opacity: 0.35; font-size: 0.8em; }
thead th.sorted .sort-arrow { opacity: 1; color: var(--accent); }

tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

/* Keep the session timestamp visible when the diagnostic table is scrolled
   horizontally. Without this, a retained scrollLeft made START appear as
   "RT" and clipped the month/day from every row. */
.zero-sessions-table thead th:first-child,
.zero-sessions-table tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg-card);
    box-shadow: 1px 0 0 var(--border);
}
.zero-sessions-table thead th:first-child {
    background: var(--bg-input);
    z-index: 4;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--bg-card-hover); }
tbody tr:last-child td { border-bottom: none; }

.cell-right { text-align: right; font-variant-numeric: tabular-nums; }
.cell-link { color: var(--accent); font-weight: 500; }
.cell-link:hover { text-decoration: underline; }

/* percentage bar in cells */
.pct-bar-cell { position: relative; min-width: 110px; }
.pct-bar-bg {
    position: absolute;
    top: 4px; bottom: 4px; left: 4px;
    border-radius: 4px;
    opacity: 0.18;
    transition: width 0.6s ease;
}
.pct-bar-bg.green { background: var(--green); }
.pct-bar-bg.red   { background: var(--red); }
.pct-bar-bg.teal  { background: var(--accent); }
.pct-bar-text {
    position: relative;
    z-index: 1;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Compact pill for percentage values (uptime, success rate, etc.).
   One pill style across the dashboard so all rates read the same way.
   Default = green (positive rates); .red / .teal / .muted variants
   for offline rates, utilization, and no-data. */
.pct-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.8rem;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    background: var(--green-bg);
    color: var(--green);
    white-space: nowrap;
}
.pct-pill.red   { background: var(--red-bg);    color: var(--red); }
.pct-pill.teal  { background: var(--accent-glow); color: var(--accent); }
.pct-pill.muted { background: rgba(160,160,160,0.14); color: var(--text-muted); }

/* ===== SEARCH ===== */
.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    transition: border-color var(--transition), box-shadow var(--transition);
    max-width: 320px;
    width: 100%;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.84rem;
    width: 100%;
    font-family: var(--font);
}
.search-box input::placeholder { color: var(--text-muted); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all var(--transition);
    white-space: nowrap;
    min-height: 36px;
}
.btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: var(--shadow-sm); }
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: #353535; border-color: #353535; color: #fff; }

.btn-group {
    display: flex;
    gap: 0;
}
.btn-group .btn { border-radius: 0; min-height: 34px; padding: 6px 14px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn + .btn { border-left: none; }
.btn-group .btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ===== CHART CONTAINERS ===== */
.chart-wrap {
    position: relative;
    width: 100%;
}
.chart-wrap canvas { max-height: 340px; }
.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 500;
}

/* ===== BADGE / TAG ===== */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.tag.available { background: var(--green-bg); color: var(--green); }
.tag.charging  { background: var(--blue-bg); color: var(--accent); }
.tag.offline   { background: var(--red-bg); color: var(--red); }
.tag.faulted   { background: var(--purple-bg); color: var(--purple); }
.tag.standby   { background: rgba(171,171,171,0.12); color: var(--gray-mid); }

/* Failure-category pill — used in Sessions Explorer "Failure Reason" column
   and in the filter dropdown. Four colour buckets matching the `kind` field
   on FAILURE_CATEGORY_LABEL_MAP: ok / neutral / user / operator / warn. */
.failcat-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    cursor: default;
}
.failcat-ok       { background: var(--green-bg); color: var(--green); }
.failcat-neutral  { background: rgba(171,171,171,0.14); color: var(--gray-mid); }
.failcat-user     { background: rgba(255,170,0,0.13); color: #b87800; }
.failcat-operator { background: var(--red-bg); color: var(--red); }
.failcat-warn     { background: var(--purple-bg); color: var(--purple); }
.ms-option .failcat-pill { padding: 1px 8px; font-size: 0.68rem; }

/* Failure Reason Breakdown table — the first column packs the pill
   AND a long description into one cell. The default `tbody td`
   `white-space: nowrap` rule (set above) made every long description
   force the table wider than its container, producing horizontal
   scroll. Allow the first cell to wrap so the description re-flows
   on narrow viewports; the pill itself keeps `white-space: nowrap`
   from `.failcat-pill` so the badge text stays on one line. The
   `vertical-align: top` keeps the pill aligned with the first line
   of the description when the row's height grows. */
#failureBreakdownTable { table-layout: fixed; width: 100%; }
#failureBreakdownTable tbody td:first-child {
    white-space: normal;
    word-break: normal;
    overflow-wrap: anywhere;
    vertical-align: top;
    line-height: 1.5;
}
#failureBreakdownTable thead th:nth-child(2),
#failureBreakdownTable tbody  td:nth-child(2),
#failureBreakdownTable thead th:nth-child(3),
#failureBreakdownTable tbody  td:nth-child(3) { width: 110px; }

/* ===== BREADCRUMB ===== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { opacity: 0.4; }

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.pagination .page-btns { display: flex; gap: 4px; }
.pagination .page-btn {
    width: 34px; height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font);
    transition: all var(--transition);
}
.pagination .page-btn:hover { border-color: var(--accent); color: var(--accent); }
.pagination .page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 0.4s ease forwards; }
/* The slide-up animation leaves a residual transform on the element which
   creates a new stacking context — that traps the multi-select dropdowns
   inside the filter toolbar card. Disable the animation here so dropdowns
   can layer above adjacent cards. */
.filter-toolbar.animate-in { animation: none; }
.animate-in:nth-child(2) { animation-delay: 0.05s; }
.animate-in:nth-child(3) { animation-delay: 0.10s; }
.animate-in:nth-child(4) { animation-delay: 0.15s; }
.animate-in:nth-child(5) { animation-delay: 0.20s; }

/* ===== TOOLTIP ===== */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: #353535;
    color: #fff;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.73rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-md);
    z-index: 50;
}
[data-tooltip]:hover::after { opacity: 1; transform: translateX(-50%) scale(1); }

/* ===== LOADING SKELETON ===== */
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--bg-input) 25%, var(--border) 37%, var(--bg-input) 63%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: 4px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.counter { transition: none; }

/* ===== OVERVIEW TOP GRID (Gauge + KPIs + Doughnut) ===== */
.grid-overview-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    margin-bottom: 20px;
    align-items: stretch;
}
.grid-overview-top > .card {
    margin-bottom: 0;
}
.kpi-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 150px;
}
/* Option-B style KPI cards */
.kpi-card-b {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    overflow: hidden;
    flex: 1;
    transition: all var(--transition);
}
.kpi-card-b:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}
.kpi-card-b::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
}
.kpi-card-b.red::before { background: var(--red); }
.kpi-card-b.teal::before { background: var(--accent); }
.kpi-card-b.green::before { background: var(--green); }
.kpi-card-b.yellow::before { background: var(--yellow); }
.kpi-card-link { text-decoration: none; color: inherit; cursor: pointer; }
.kpi-card-link:hover { transform: translateY(-1px); border-color: var(--red); }

.kpi-b-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.kpi-b-icon.red { background: var(--red-bg); color: var(--red); }
.kpi-b-icon.teal { background: var(--blue-bg); color: var(--accent); }
.kpi-b-icon.green { background: var(--green-bg); color: var(--green); }
.kpi-b-icon.yellow { background: var(--yellow-bg); color: #b8860b; }

.kpi-b-text {}
.kpi-b-num {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}
.kpi-b-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== DATA EXPLORER ===== */
.filter-toolbar {
    padding: 18px 22px;
    margin-bottom: 16px;
}
.filter-top-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
.filter-dropdowns {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
}
.filter-period {
    flex-shrink: 0;
}
.filter-bottom-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}
.explorer-filters .filter-row {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}
.filter-group.grow { flex: 1; min-width: 200px; }
.filter-group label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.filter-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa3b0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 32px 8px 12px;
    font-size: 0.84rem;
    font-family: var(--font);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color var(--transition);
    min-height: 38px;
}
.filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding-bottom: 1px;
}

.explorer-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 8px;
}
.active-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-glow);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}
.filter-chip a {
    color: var(--accent);
    font-size: 1em;
    line-height: 1;
    opacity: 0.7;
}
.filter-chip a:hover { opacity: 1; }

/* ===== MULTI-SELECT DROPDOWN ===== */
.multi-select {
    position: relative;
    min-width: 160px;
}
.ms-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.84rem;
    font-family: var(--font);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color var(--transition);
    min-height: 38px;
}
.ms-trigger:hover { border-color: var(--border-hover); }
.multi-select.open .ms-trigger {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.ms-display {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}
.ms-display.ms-has-value {
    color: var(--text-primary);
    font-weight: 500;
}
.ms-trigger svg {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform var(--transition);
}
.multi-select.open .ms-trigger svg { transform: rotate(180deg); }

.ms-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    min-width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    max-height: 280px;
    overflow: hidden;
    display: none;
    flex-direction: column;
}
.multi-select.open .ms-dropdown {
    display: flex;
}
.ms-search-wrap {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}
.ms-search {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-family: var(--font);
    color: var(--text-primary);
    outline: none;
}
.ms-search:focus {
    border-color: var(--accent);
}
.ms-search::placeholder { color: var(--text-muted); }
.ms-options {
    overflow-y: auto;
    max-height: 220px;
    padding: 4px 0;
}
.ms-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-primary);
    transition: background var(--transition);
}
.ms-option:hover { background: var(--bg-card-hover); }
.ms-option input[type="checkbox"] {
    width: 15px; height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.ms-option span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.explorer-table table { font-size: 0.8rem; }
.explorer-table tbody td { padding: 7px 12px; }
.explorer-table thead th { padding: 8px 12px; }

.cell-mono {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.75rem;
    letter-spacing: -0.02em;
}
.cell-addr {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.explorer-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.explorer-pagination .page-btns {
    display: flex;
    gap: 4px;
}
.explorer-pagination .btn {
    min-height: 34px;
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ===== SESSION TABS ===== */
.session-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}
.session-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    text-decoration: none;
}
.session-tab:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.session-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.session-tab svg { opacity: 0.7; }
.session-tab.active svg { opacity: 1; }

/* ===== DATE RANGE & SELECT INPUTS ===== */
.date-range-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.date-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.84rem;
    font-family: var(--font);
    color: var(--text-primary);
    min-height: 38px;
    transition: border-color var(--transition);
}
.date-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.date-sep {
    color: var(--text-muted);
    font-size: 0.9rem;
}
.select-input {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa3b0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 32px 8px 12px;
    font-size: 0.84rem;
    font-family: var(--font);
    color: var(--text-primary);
    cursor: pointer;
    min-height: 38px;
    transition: border-color var(--transition);
}
.select-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.84rem;
    color: var(--text-primary);
    min-height: 38px;
    white-space: nowrap;
}
.checkbox-label input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}
.text-red { color: var(--red) !important; }

/* ===== PERCENTAGE BAR (shared) ===== */
.pct-bar-cell {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}
.pct-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease-out;
}

/* ==========================================================================
   RESPONSIVE — Tablets
   ========================================================================== */
@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-overview-top { grid-template-columns: 1fr 1fr; }
    .kpi-stack { flex-direction: row; min-width: 0; }
    .kpi-stack .stat-card { min-width: 0; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-grid.four-col { grid-template-columns: repeat(2, 1fr); }
    .explorer-filters .filter-row { flex-direction: column; align-items: stretch; }
    .filter-top-row { flex-direction: column; }
    .filter-dropdowns { flex-direction: column; }
    .filter-bottom-row { flex-direction: column; align-items: stretch; }
    .filter-group.grow { min-width: 0; }
    .filter-actions { justify-content: flex-start; }
}

/* ==========================================================================
   RESPONSIVE — Mobile
   ========================================================================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .mobile-menu-btn { display: flex; }

    .main-content {
        margin-left: 0;
        padding: 60px 16px 32px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .page-header h1 { font-size: 1.3rem; }

    .stat-grid, .stat-grid.four-col {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.5rem; }
    .stat-label { font-size: 0.68rem; }
    .stat-icon { width: 32px; height: 32px; margin-bottom: 8px; }
    .stat-icon svg { width: 16px; height: 16px; }

    .card { padding: 18px 16px; margin-bottom: 16px; }
    .card-header { margin-bottom: 14px; }

    .grid-2, .grid-3 { gap: 16px; }
    .grid-overview-top { grid-template-columns: 1fr; }
    .kpi-stack { flex-direction: row; }
    .kpi-stack .stat-card { flex: 1; }
    .kpi-stack .stat-value { font-size: 1.2rem; }

    .chart-wrap canvas { max-height: 240px; }

    /* Tables: horizontal scroll on mobile with fade hint */
    .table-wrapper { margin: 0 -16px; padding: 0 16px; }
    .table-wrapper::after {
        content: '';
        position: absolute;
        top: 0; right: 0; bottom: 0;
        width: 24px;
        background: linear-gradient(to right, transparent, var(--bg-card));
        pointer-events: none;
        border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    }

    .search-box { max-width: 100%; }

    .btn-group { flex-wrap: nowrap; }
    .btn { padding: 8px 12px; font-size: 0.76rem; min-height: 40px; }

    .breadcrumb { font-size: 0.78rem; }

    .header-meta { width: 100%; }
}

@media (max-width: 420px) {
    .stat-grid, .stat-grid.four-col { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 14px 12px; }
    .stat-value { font-size: 1.25rem; }
    .stat-icon { width: 28px; height: 28px; }

    .main-content { padding: 56px 10px 24px; }

    .page-header h1 { font-size: 1.15rem; }

    .card { padding: 16px 12px; }
}

/* ===== Sessions overview widgets (v5) ===== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 28px 0 12px;
}
.section-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}
.section-header .section-sub {
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 8px;
}
.kpi-big {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 0 4px;
}
.kpi-big-num {
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--accent);
}
.kpi-big-unit {
    font-size: 1.2rem;
    font-weight: 500;
    margin-left: 2px;
    color: var(--text-muted);
}
.kpi-big-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.kpi-mini-list {
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kpi-mini-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-secondary, var(--text-primary));
}
.badge {
    background: var(--bg-subtle, rgba(121,180,183,0.12));
    color: var(--accent);
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* ===== Sessions explorer column picker ===== */
.col-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px 14px;
}
.col-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 4px 0;
    color: var(--text-primary);
}
.col-picker-item input[type="checkbox"] {
    accent-color: var(--accent);
}

/* ===== Date range picker (chips + custom range) ===== */
.date-range-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 320px;
}
.dr-chips {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
}
.dr-chips button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.dr-chips button:hover {
    color: var(--text-primary);
    background: rgba(121, 180, 183, 0.08);
}
.dr-chips button.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 3px rgba(121, 180, 183, 0.35);
}
.dr-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}
.dr-inputs input[type="date"] {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.82rem;
    color-scheme: light;
}
[data-theme="dark"] .dr-inputs input[type="date"] {
    color-scheme: dark;
}
.dr-inputs span { color: var(--text-muted); font-size: 0.85rem; }

/* ===== Server-side sortable header links ===== */
th.srv-sort a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
th.srv-sort a:hover { color: var(--accent); }
th.srv-sort .sort-ind {
    font-size: 0.7em;
    color: var(--text-muted);
    line-height: 1;
}
th.srv-sort.sorted .sort-ind { color: var(--accent); }

/* ===== Loading placeholders ===== */
.loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 120px;
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Filter-by-click icons in explorer table */
.filter-icon {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.6rem;
    color: var(--text-muted);
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.15s;
    vertical-align: middle;
    cursor: pointer;
}
.filter-icon:hover { color: var(--accent); opacity: 1 !important; }
td:hover .filter-icon { opacity: 0.6; }
