/* ========================================================================== */
/* BRAND TOKENS */
/* ========================================================================== */

:root {
    --brand-gradient: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    --brand-gradient-svg-start: #E8F5E9;
    --brand-gradient-svg-end:   #C8E6C9;
}

/* ========================================================================== */
/* BODY AND LAYOUT V-1.1.6 */
/* ========================================================================== */

body {
    margin: 0;
    padding: 0;
    font-family: Tahoma, Geneva, sans-serif;
    background-image: url('/images/op-back.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    display: flex;
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 40px;
    border-radius: 12px;
    margin: 40px 0 0 0;
    pointer-events: auto;
}


.loading-spinner-overlay {
    position: fixed;
    top: 106px;
    left: 180px;
    width: calc(100% - 180px);
    height: calc(100% - 106px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    animation: fadeIn 300ms ease-in 50ms forwards;
}

.loading-spinner-icon {
    width: 160px;
    height: 160px;
    margin: 0 auto;
    position: relative;
}

.loading-spinner-icon .spinner-outer {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    animation: spin 1.33s linear infinite;
}

.loading-spinner-icon .spinner-inner {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.loading-spinner-icon img {
    width: 100%;
    height: 100%;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner-text {
    font-size: 24px;
    color: #7bdec0;
    margin-top: 15px;
    font-weight: bold;
    font-family: Tahoma, Geneva, sans-serif;
}

.loading-dots {
    display: inline-block;
    width: 60px;
    text-align: left;
}

.loading-status {
    font-size: 14px;
    color: #7bdec0;
    margin-top: 20px;
    font-family: Tahoma, Geneva, sans-serif;
    font-style: italic;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.dashboard-content {
    display: none;
}

.dashboard-content.loaded {
    display: block;
}

/* Sidebar */
.sidebar {
    width: 180px;
    min-width: 180px;
    background-color: #e8f5e9;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    z-index: 200;
    box-sizing: border-box;
}

.sidebar-header {
    padding: 0 20px 20px 20px;
    border-bottom: 1px solid #c8e6c9;
}

.sidebar-logo {
    width: 100%;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 0;
    margin-top: 8px;
}

.sidebar.has-row2 .sidebar-nav {
    margin-top: 43px;
}

.sidebar-nav a {
    display: block;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav a:hover {
    background-color: #c8e6c9;
}

.sidebar-nav a.active {
    background-color: #2E7D32;
    color: white;
    font-weight: bold;
}

.sidebar-footer {
    padding: 0 20px 20px 20px;
}

.cache-button {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: white;
    background: #2E7D32;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

.cache-button:hover {
    background: #388E3C;
}

/* Main Content Area */
.main-content {
    margin-left: 180px;
    padding: 20px;
    width: calc(100% - 180px);
}

.content-wrapper {
    max-width: 1200px;
}

.footer-info {
    margin-top: 20px;
    padding: 10px;
    font-size: 11px;
    color: #666;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 5px;
}

/* ========================================================================== */
/* PAGE LAYOUT STYLES */
/* ========================================================================== */

/* Page Header */
.header-container {
    display: flex;
    align-items: flex-end;
    justify-content: left;
    padding: 0px 0;
    margin-bottom: 10px;
}
.header-container img {
    height: 60px;
    margin-right: 20px;
}
.header-container h1 {
    font-family: Tahoma, Geneva, sans-serif;
    color: #333;
    margin: 0;
    margin-bottom: -5px;
}

/* Shared header style for display elements */
.header-style {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 14px;
    font-weight: bold;
    color: #2E7D32;
    background: var(--brand-gradient);
    border-bottom: 1px solid #ccc;
}

/* Welcome Page Styles */
.welcome-content {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.welcome-content h2 {
    color: #2E7D32;
    margin-top: 0;
}

.dashboard-list {
    font-size: 16px;
    line-height: 2;
}

.footer-text {
    color: #666;
    font-size: 14px;
}

/* ========================================================================== */
/* DISPLAY ELEMENT: KPI_BADGES */
/* ========================================================================== */

.kpi-badges-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 0 0 20px 0;
    justify-content: left;
}

/* ── Shared badge shell ── */
.kpi-badge {
    border: 2px solid #ddd;
    border-radius: 12px;
    background-color: white;
    padding: 0;
    flex: 0 0 auto;
    width: fit-content;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}
.kpi-badge-title {
    text-align: center;
    padding: 7px 16px;
    border-radius: 10px 10px 0 0;
    white-space: nowrap;
}

/* ── Badge: single centered value ── */
.kpi-badge:not(.kpi-badge-extended):not(.kpi-badge-multi) .kpi-badge-rows {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 20px;
    background-color: white;
}
.kpi-badge:not(.kpi-badge-extended):not(.kpi-badge-multi) .kpi-badge-value {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    text-align: center;
}

/* ── Multi badge: value-only rows, alternating bg ── */
.kpi-badge-multi .kpi-badge-rows {
    display: flex;
    flex-direction: column;
}
.kpi-badge-multi .kpi-badge-row {
    display: flex;
    justify-content: center;
    align-items: center;
}
.kpi-badge-multi .kpi-badge-row.kpi-badge-cell-odd  { background-color: white; }
.kpi-badge-multi .kpi-badge-row.kpi-badge-cell-even { background-color: #f5f5f5; }
.kpi-badge-multi .kpi-badge-value {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    text-align: center;
    white-space: nowrap;
    padding: 6px 20px;
}

/* ── Extended-multi badge: label+value rows, alternating bg ── */
.kpi-badge-extended .kpi-badge-rows {
    display: flex;
    flex-direction: column;
}
.kpi-badge-extended .kpi-badge-row {
    display: flex;
    flex-direction: row;
    align-items: center;
}
.kpi-badge-extended .kpi-badge-row.kpi-badge-cell-odd  { background-color: white; }
.kpi-badge-extended .kpi-badge-row.kpi-badge-cell-even { background-color: #f5f5f5; }
.kpi-badge-extended .kpi-badge-label {
    font-size: 14px;
    color: #666;
    text-align: right;
    white-space: nowrap;
    padding: 8px 6px 8px 6px;
    flex-shrink: 0;
}
.kpi-badge-extended .kpi-badge-value {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    text-align: right;
    white-space: nowrap;
    padding: 6px 8px 6px 2px;
    flex-shrink: 0;
    min-width: 60px;
}
.kpi-badge-extended .kpi-badge-extra {
    font-size: 14px;
    color: #555;
    text-align: right;
    white-space: nowrap;
    padding: 8px 8px 8px 4px;
    flex-shrink: 0;
}
.kpi-badge-extended .kpi-badge-extra:last-child {
    text-align: left;
    padding-right: 12px;
}

/* ========================================================================== */
/* DISPLAY ELEMENT: KPI_TABLE */
/* ========================================================================== */

.kpi-table-wrapper {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
    max-width: 380px;
    margin: 20px 0;
    border: 2px solid #ddd;
}

.kpi-table-header {
    background: var(--brand-gradient);
    border-bottom: 1px solid #ccc;
    padding: 10px 10px 10px 20px;
    display: flex;
    align-items: center;
}

.kpi-table-header-spacer {
    flex: 0 0 auto;
    width: 110px;
}

.kpi-table-header-columns {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.kpi-table-header-cell {
    color: #2E7D32;
    font-family: Tahoma, Geneva, sans-serif;
    font-weight: bold;
    text-align: center;
    font-size: 18px;
}

.kpi-table {
    width: 100%;
    border-collapse: collapse;
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
}

.kpi-table tbody tr {
    border-bottom: 1px solid #eee;
}

.kpi-table tbody tr:nth-child(odd) td {
    background-color: white;
}

.kpi-table tbody tr:nth-child(even) td {
    background-color: #f9f9f9;
}

.kpi-table tbody tr:hover td {
    background-color: #e8f5e9;
}

.kpi-table tbody td {
    padding: 10px 12px;
    color: #333;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
}

.kpi-table tbody td:first-child {
    text-align: right;
    font-size: 10px;
    color: #666;
    font-weight: bold;
    padding-right: 10px;
    border-right: 1px solid #ddd;
    white-space: nowrap;
    width: 85px;
}

.kpi-table tbody td:nth-child(2) {
    border-right: 1px solid #ddd;
    width: 90px;
}

.kpi-table tbody td:nth-child(3) {
    width: 90px;
}

/* ========================================================================== */
/* DISPLAY ELEMENT: TREND_CHART */
/* ========================================================================== */

.trend-chart-wrapper {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 20px 0;
    max-width: 850px;
    border: 2px solid #ddd;
    overflow: hidden;
}
.trend-chart-header {
    text-align: left;
    padding: 10px 10px 10px 20px;
}
.trend-chart-body {
    padding: 10px 20px 20px 20px;
}

/* ========================================================================== */
/* DISPLAY ELEMENT: DISTRIBUTION_CHART */
/* ========================================================================== */

.distribution-chart-wrapper {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 20px 0;
    max-width: 850px;
    border: 2px solid #ddd;
    overflow: hidden;
}
.distribution-chart-header {
    text-align: left;
    padding: 10px 10px 10px 20px;
}
.distribution-chart-body {
    padding: 10px 20px 20px 20px;
}

/* ========================================================================== */
/* DISPLAY ELEMENT: DETAIL_TABLE (Games table from Unhandled Input) */
/* ========================================================================== */

.detail-table-wrapper {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
    max-width: 850px;
    margin: 20px 0;
    border: 2px solid #ddd;
}

.detail-table-header {
    text-align: left;
    padding: 10px 10px 10px 20px;
}

.detail-table-body {
    padding: 0;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 11px;
}

.detail-table thead th {
    background-color: #f5f5f5;
    color: #333;
    font-weight: bold;
    padding: 6px 8px;
    border-bottom: 2px solid #ddd;
}

.detail-table tbody tr {
    border-bottom: 1px solid #eee;
}

.detail-table tbody tr:nth-child(odd) {
    background-color: white;
}

.detail-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.detail-table tbody tr:hover {
    background-color: #e8f5e9;
}

.detail-table td {
    padding: 4px 8px;
    color: #333;
}

.detail-table details {
    margin-top: 10px;
    padding: 0 20px 20px 20px;
}

.detail-table summary {
    cursor: pointer;
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 11px;
    color: #333;
    padding: 8px 10px;
    background-color: #f5f5f5;
    border-radius: 5px;
    font-weight: bold;
}

.detail-table summary:hover {
    background-color: #e0e0e0;
}

/* ═══════════════════════════════════════════════════════════════
   PAGE HEADER & FILTER BAR
   Add this block to the bottom of dashboard.css
   ═══════════════════════════════════════════════════════════════ */

/* ── Sidebar positioning (below fixed header) ──────────────── */

.sidebar {
    top: 106px;
    height: calc(100vh - 106px);
    transition: transform 0.25s ease;
    z-index: 200;
}

body.sidebar-hidden .sidebar {
    transform: translateX(-180px);
}

.main-content {
    transition: margin-left 0.25s ease;
}

body.sidebar-hidden .main-content {
    margin-left: 0;
    width: 100%;
}

body.sidebar-hidden .loading-spinner-overlay {
    width: 100%;
    left: 0;
}

/* ── White top bar ─────────────────────────────────────────── */

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: white;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    padding: 6px 16px 0 16px;
    z-index: 300;
}

.top-bar-left {
    width: 220px;
    display: flex;
    align-items: flex-end;
}

.top-bar-center {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
}

.top-bar-center img {
    height: 38px;
}

.top-bar-center h1 {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 20px;
    font-weight: bold;
    color: #333;
    margin: 0;
    line-height: 1;
}

.top-bar-right {
    width: 220px;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Header buttons (Menu + Compare) ──────────────────────── */

.btn-header {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: white;
    background: #2E7D32;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-header:hover  { background: #388E3C; }
.btn-header.active { background: #1B5E20; box-shadow: inset 0 1px 3px rgba(0,0,0,0.2); }

.btn-icon {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 14px;
    flex-shrink: 0;
}

.btn-icon span {
    display: block;
    height: 2px;
    background: white;
    border-radius: 1px;
}

/* ── Green filter bar ──────────────────────────────────────── */

.filter-bar-outer {
    position: fixed;
    top: 71px;
    left: 0;
    right: 0;
    background: var(--brand-gradient);
    border-bottom: 2px solid #A5D6A7;
    z-index: 299;
}

.filter-bar-inner {
    display: flex;
    align-items: center;
    padding: 6px 10px 6px 10px;
    margin-left: 180px;
    transition: margin-left 0.25s ease;
}

.filter-bar-inner-row2 {
    padding-top: 6px;
    padding-bottom: 6px;
    border-top: 1px solid #B2DFDB;
    align-items: center;
}

body.sidebar-hidden .filter-bar-inner {
    margin-left: 0;
}

.filter-group-set {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.filter-group-set + .filter-group-set {
    border-left: 1px solid #A5D6A7;
    padding-left: 10px;
    margin-left: 10px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.filter-label {
    font-size: 12px;
    font-weight: bold;
    color: #2E7D32;
    white-space: nowrap;
}

.filter-select {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    color: #333;
    background: white;
    border: 1px solid #A5D6A7;
    border-radius: 4px;
    padding: 4px 16px 4px 5px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%232E7D32'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    min-width: 90px;
}

.filter-select.narrow {
    min-width: 0;
    width: 54px;
}

.filter-select:focus {
    outline: none;
    border-color: #2E7D32;
    box-shadow: 0 0 0 2px rgba(46,125,50,0.15);
}

.filter-date-range {
    font-size: 12px;
    color: #666;
    font-style: italic;
    white-space: nowrap;
}

.filter-divider {
    width: 1px;
    height: 20px;
    background: #A5D6A7;
    flex-shrink: 0;
    margin: 0 2px;
}

/* ── Page body (reserves space for fixed header) ───────────── */

.page-body {
    padding-top: 93px; /* single filter row: top-bar ~71px + filter-bar ~42px - main-content padding 20px */
}

.page-body.has-row2 {
    padding-top: 128px; /* row2 adds ~35px to filter bar height */
}


/* ── Compare panels ────────────────────────────────────────── */

.panels-wrapper {
    display: flex;
}

.panel {
    flex: 1;
    min-width: 0;
    position: relative;
}

.panel + .panel {
    border-left: 2px solid #C8E6C9;
}

.panel-content {
    padding: 16px 20px 20px 20px;
}

/* ── Trend chart component ─────────────────────────────────── */

.trend-chart-wrapper {
    background: white;
    border: 2px solid #ddd;
    border-radius: 12px;
    padding: 16px 20px 12px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;
    min-width: 300px;
    box-sizing: border-box;
}

.trend-chart-title {
    margin: -16px -20px 12px -20px;
    padding: 8px 14px;
    border-radius: 11px 11px 0 0;
    border-bottom: 1px solid #ccc;
}

.trend-chart-plot {
    min-height: 300px;
}

/* In compare mode, charts shrink to fit their panel */
.panel .trend-chart-wrapper {
    width: 90%;
    max-width: none;
}

/* ── Custom Date Picker Popover ──────────────────────────────── */

.date-picker-popover {
    position: absolute;
    z-index: 1000;
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    width: 520px;
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 13px;
}

.dp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 8px;
    border-bottom: 1px solid #e8e8e8;
}

.dp-title {
    font-weight: bold;
    color: #2E7D32;
    font-size: 13px;
}

.dp-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
}
.dp-close:hover { color: #333; }

.dp-two-calendars {
    display: flex;
    gap: 0;
    padding: 12px 12px 8px;
}

.dp-cal-panel {
    flex: 1;
    min-width: 0;
}

.dp-cal-divider {
    width: 1px;
    background: #eee;
    margin: 0 12px;
}

.dp-cal-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.dp-month-label {
    font-weight: bold;
    color: #333;
    font-size: 13px;
    text-align: center;
    flex: 1;
}

.dp-nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #2E7D32;
    font-size: 22px;
    line-height: 1;
    padding: 0 4px;
    border-radius: 4px;
}
.dp-nav-btn:hover:not(:disabled) { background: #e8f5e9; }
.dp-nav-btn:disabled { color: #ccc; cursor: default; }

.dp-picking-label {
    text-align: center;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 6px;
    padding: 3px 0;
    border-radius: 3px;
}
.dp-picking-start { color: white; background: #2E7D32; }
.dp-picking-end   { color: white; background: #1565C0; }

.dp-day-labels {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 2px;
}
.dp-day-labels span {
    font-size: 10px;
    color: #999;
    padding: 2px 0;
}

.dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}

.dp-day {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    color: #333;
    transition: background 0.1s;
    user-select: none;
}
.dp-day:not(.dp-disabled):not(.dp-empty):hover { background: #e8f5e9; }
.dp-empty   { cursor: default; }
.dp-disabled { color: #ddd; cursor: not-allowed; }

.dp-sel-start {
    background: #2E7D32 !important;
    color: white !important;
    border-radius: 4px 0 0 4px;
}
.dp-sel-end {
    background: #1565C0 !important;
    color: white !important;
    border-radius: 0 4px 4px 0;
}
.dp-sel-start.dp-sel-end {
    background: #2E7D32 !important;
    border-radius: 4px;
}
.dp-in-range {
    background: #e0e0e0 !important;
    color: #444;
    border-radius: 0;
}

.dp-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 12px;
    border-top: 1px solid #e8e8e8;
}

.dp-range-label {
    font-size: 12px;
    color: #555;
}

.dp-apply {
    background: #2E7D32;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 6px 18px;
    font-size: 13px;
    cursor: pointer;
    font-family: Tahoma, Geneva, sans-serif;
}
.dp-apply:hover { background: #1b5e20; }

/* ── Panel Loading Scrim ─────────────────────────────────── */

.panel-scrim {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    z-index: 10;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
}

.panel-scrim.visible {
    display: flex;
}

.panel-scrim-spinner {
    width: 56px;
    height: 56px;
    position: relative;
}

.panel-scrim-spinner .scrim-spinner-outer {
    width: 56px;
    height: 56px;
    position: absolute;
    top: 0;
    left: 0;
    animation: spin 1.33s linear infinite;
}

.panel-scrim-spinner .scrim-spinner-inner {
    width: 56px;
    height: 56px;
    position: absolute;
    top: 0;
    left: 0;
}
