:root {
            --rmutl-blue: var(--brand-secondary);
            --rmutl-blue-dark: var(--brand-primary);
            --rmutl-gold: var(--brand-secondary);
            --rmutl-gold-light: var(--background-light);
            --ink: var(--text-primary);
            --muted: var(--text-secondary);
            --line: var(--border-default);
            --surface: var(--background-main);
        }

        body {
            font-family: var(--e-service-font-family, 'Noto Sans Thai', sans-serif);
            color: var(--ink);
            background: linear-gradient(135deg, var(--background-soft) 0%, var(--background-main) 55%, var(--background-light) 100%);
            margin: 0;
            padding: 0;
            min-height: 100vh;
            width: 100%;
            box-sizing: border-box;
            overflow-x: hidden;
        }

        body::before {
            content: '';
            display: block;
            height: 6px;
            position: fixed;
            inset: 0 0 auto;
            background: linear-gradient(90deg, var(--rmutl-blue-dark) 0 72%, var(--rmutl-gold) 72% 100%);
            z-index: 2;
        }

        .header-title {
            position: relative;
            text-align: center;
            color: var(--rmutl-blue-dark);
            margin: 6px 0 20px;
            padding: 22px 24px;
            background: var(--surface);
            border: 1px solid var(--line);
            border-top: 4px solid var(--rmutl-gold);
            border-radius: 0;
            box-shadow: 0 8px 24px rgba(63, 52, 42, 0.08);
            width: 100%;
            box-sizing: border-box;
        }

        .header-title h2 {
            margin: 0;
            font-size: clamp(1.25rem, 2.5vw, 1.8rem);
            font-weight: 700;
        }

        .dashboard-title-icon {
            margin-right: 8px;
            color: var(--rmutl-gold);
            vertical-align: -0.1em;
        }

        .header-title .platform-tagline .ti {
            margin-right: 5px;
            color: var(--brand-secondary);
        }

        .header-title .department-name {
            margin: 8px 0 0;
            color: var(--rmutl-blue);
            font-size: clamp(1.25rem, 2.5vw, 1.8rem);
            font-weight: 600;
        }

        .header-title .service-name {
            margin: 6px 0 0;
            color: var(--text-primary);
            font-size: clamp(1rem, 2vw, 1.3rem);
            font-weight: 600;
        }

        .header-title .platform-tagline {
            margin: 8px 0 0;
            color: var(--muted);
            font-size: clamp(0.9rem, 1.6vw, 1.1rem);
            font-weight: 500;
        }

        .dashboard-page-switch {
            position: absolute;
            top: 18px;
            right: 20px;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            margin: 0;
            padding: 7px 12px;
            color: #fff;
            background: var(--brand-primary);
            border: 1px solid var(--brand-primary);
            border-radius: 4px;
            font-size: .875rem;
            font-weight: 600;
            text-decoration: none;
        }

        .dashboard-page-switch:hover,
        .dashboard-page-switch:focus-visible {
            color: #fff;
            background: var(--brand-accent);
            border-color: var(--brand-accent);
        }

        @media (max-width: 700px) {
            .dashboard-page-switch {
                position: static;
                margin-top: 14px;
            }
        }

        .container {
            display: flex;
            gap: 20px;
            width: 100%;
            box-sizing: border-box;
            margin: 0;
            padding: 0 20px 20px;
            align-items: stretch;
        }
        .left-panel {
            width: min(450px, 38%);
            display: flex;
            flex-direction: column;
            gap: 10px;
            align-self: stretch;
        }
        .main-panel {
            flex: 1;
            box-sizing: border-box;
            align-self: stretch;
            background: var(--surface);
            border: 1px solid var(--line);
            border-top: 4px solid var(--rmutl-blue);
            border-radius: 4px;
            padding: 8px 24px 24px;
            box-shadow: 0 8px 24px rgba(63, 52, 42, 0.08);
            min-height: calc(100vh - 150px);
        }
        .box {
            background: var(--surface);
            padding: 14px;
            border: 1px solid var(--line);
            border-left: 4px solid var(--rmutl-gold);
            border-radius: 4px;
            box-shadow: 0 8px 24px rgba(63, 52, 42, 0.08);
        }
        .box h3 {
            margin-top: 0;
            color: var(--rmutl-blue-dark);
            border-bottom: 2px solid var(--rmutl-gold);
            padding-bottom: 10px;
        }

        .dashboard-heading-icon {
            margin-right: 7px;
            color: var(--brand-secondary);
            font-size: 1.1em;
            vertical-align: -0.12em;
        }

        .department-list-heading {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 10px;
            margin-bottom: 10px;
            border-bottom: 2px solid var(--rmutl-gold);
        }

        .department-list-heading h3 {
            margin: 0;
            padding-bottom: 10px;
            border-bottom: 0;
        }

        ul.dept-list {
            list-style: none;
            padding: 0;
            line-height: 1.35;
            font-size: 0.85rem;
            max-height: 250px;
            overflow-y: auto; /* เผื่อหน่วยงานมีจำนวนมากให้สามารถเลื่อนดูได้ */
        }

        .dept-list li {
            margin: 0;
            display: flex;
            align-items: center;
        }

        .dept-list label {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 2px 8px;
            border-radius: 3px;
            cursor: pointer;
        }

        .department-dashboard-link {
            color: var(--ink);
            text-decoration: none;
            padding: 2px 4px;
            border-radius: 3px;
        }

        .department-dashboard-link:hover {
            color: var(--rmutl-blue);
            background: var(--rmutl-gold-light);
            text-decoration: underline;
        }

        .dept-list label:hover {
            background: var(--rmutl-gold-light);
        }

        .dept-list input[type="checkbox"] {
            accent-color: var(--rmutl-blue);
            width: 16px;
            height: 16px;
            flex: 0 0 auto;
        }

        .selection-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            justify-content: flex-end;
            margin: 0 0 8px;
        }

        .selection-actions button {
            border: 1px solid var(--rmutl-blue);
            border-radius: 3px;
            background: white;
            color: var(--rmutl-blue-dark);
            cursor: pointer;
            font: inherit;
            padding: 2px 8px;
            font-size: 0.78rem;
            font-weight: 400;
        }

        .selection-actions button:hover {
            background: var(--rmutl-blue);
            color: white;
        }

        .selection-actions button.is-all {
            color: white;
            background: var(--rmutl-blue-dark);
            border-color: var(--rmutl-blue-dark);
        }

        table.table-stats {
            width: 100%;
            border-collapse: collapse;
            margin-top: 4px;
            font-size: 0.85rem;
            line-height: 1.15;
        }

        .left-panel > .box:nth-child(2) h3 {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 0.85rem;
            margin-bottom: 6px;
            padding-bottom: 6px;
        }

        .table-stats th, .table-stats td {
            border: 1px solid var(--line);
            padding: 4px 6px;
            text-align: left;
        }

        .table-stats td:nth-child(2),
        .table-stats td:nth-child(3),
        .table-stats td:nth-child(4) {
            text-align: right;
        }

        .table-stats .year-row {
            background-color: #f1e9de;
            font-weight: 700;
            cursor: pointer;
        }

        .table-stats .month-row td:first-child {
            padding-left: 22px;
            cursor: pointer;
        }

        .table-stats .year-row.selected-row,
        .table-stats .month-row.selected-row {
            background-color: #ead9bd;
            outline: 2px solid var(--rmutl-gold);
            outline-offset: -2px;
        }

        .table-stats .month-row.in-range {
            background-color: #f8f1e7;
        }

        .period-reset-button {
            margin-left: auto;
            padding: 2px 8px;
            border: 1px solid var(--rmutl-blue);
            border-radius: 3px;
            background: white;
            color: var(--rmutl-blue-dark);
            cursor: pointer;
            font: inherit;
            font-size: 0.78rem;
            font-weight: 400;
            vertical-align: middle;
        }

        .period-reset-button:hover {
            background: var(--rmutl-blue);
            color: white;
        }

        .period-reset-button.is-all {
            color: white;
            background: var(--rmutl-blue-dark);
            border-color: var(--rmutl-blue-dark);
        }

        .table-stats .total-row {
            background-color: var(--rmutl-blue-dark);
            color: white;
            font-weight: 700;
        }

        .table-stats th {
            background-color: var(--rmutl-blue-dark);
            color: white;
            position: sticky;
            top: 0;
        }

        .table-stats tbody tr:nth-child(even) {
            background-color: var(--background-light);
        }

        .table-stats tbody tr:hover {
            background-color: var(--rmutl-gold-light);
        }

        .table-container {
            max-height: 600px;
            overflow-y: auto; /* หากมีหลายเดือนสามารถเลื่อนลงได้ */
        }

        .single-department .left-panel {
            gap: 0;
        }

        .single-department .left-panel > .box:first-child {
            display: none;
        }

        .single-department .left-panel > .box:nth-child(2) {
            flex: 1;
        }

        .single-department .left-panel > .box:nth-child(2) .table-container {
            max-height: calc(100vh - 30px);
        }

        .main-panel h3 {
            color: var(--muted) !important;
            font-weight: 500;
        }

        .dashboard-summary {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 14px;
        }

        .summary-card {
            background: var(--surface);
            border: 1px solid var(--line);
            border-top: 4px solid var(--rmutl-blue);
            padding: 16px;
            text-align: center;
            box-shadow: 0 6px 16px rgba(63, 52, 42, 0.1);
        }

        .summary-card strong {
            display: block;
            color: var(--rmutl-blue-dark);
            font-size: clamp(1.35rem, 3vw, 2rem);
            line-height: 1.1;
        }

        .summary-card span {
            color: var(--muted);
            font-size: 0.85rem;
        }

        .dashboard-lower {
            display: grid;
            grid-template-columns: minmax(400px, 1.05fr) minmax(260px, 0.95fr);
            gap: 18px;
            margin-top: 0;
        }

        .usage-chart-section {
            margin-top: 22px;
            border-top: 3px solid var(--rmutl-blue);
            padding-top: 12px;
        }

        .usage-chart-section h3 {
            margin: 0 0 10px;
            color: var(--rmutl-blue-dark) !important;
            font-size: 1rem;
            font-weight: 700;
        }

        .usage-chart-wrap {
            position: relative;
            width: 100%;
            height: 210px;
        }

        .usage-chart-legend {
            display: flex;
            flex-wrap: wrap;
            gap: 6px 14px;
            margin: 0 0 8px 56px;
            color: var(--muted);
            font-size: 0.76rem;
        }

        .usage-legend-item {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            max-width: 260px;
        }

        .usage-legend-color {
            width: 18px;
            height: 3px;
            flex: 0 0 auto;
            background: var(--legend-color);
        }

        .usage-chart-tooltip {
            position: absolute;
            display: none;
            z-index: 3;
            pointer-events: none;
            max-width: 260px;
            padding: 7px 9px;
            border-radius: 3px;
            background: rgba(63, 52, 42, 0.96);
            color: white;
            font-size: 0.76rem;
            line-height: 1.45;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
        }

        #usage-line-chart {
            display: block;
            width: 100%;
            height: 100%;
        }

        .usage-chart-note {
            margin: 5px 0 0;
            color: var(--muted);
            font-size: 0.75rem;
            text-align: center;
        }

        .dashboard-section {
            padding-top: 12px;
        }

        .dashboard-section:first-child {
            padding-top: 2px;
        }

        .dashboard-section:first-child h3 {
            font-size: 1.15rem;
        }

        .dashboard-section h3 {
            margin: 0 0 12px;
            color: var(--rmutl-blue-dark) !important;
            font-size: 1rem;
            font-weight: 700;
        }

        .pie-chart-layout {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 14px;
        }

        .pie-chart {
            width: min(230px, 100%);
            flex: 0 1 230px;
            aspect-ratio: 1;
            margin: 8px 0;
            border-radius: 50%;
            background: conic-gradient(var(--rmutl-blue-dark) 0deg 360deg);
            position: relative;
        }

        .pie-chart::after {
            content: '';
            position: absolute;
            inset: 26%;
            background: var(--surface);
            border-radius: 50%;
        }

        .pie-chart-total {
            position: absolute;
            inset: 30%;
            z-index: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: var(--muted);
            font-size: 0.95rem;
            line-height: 1.2;
            text-align: center;
        }

        .pie-chart-total strong {
            display: block;
            color: var(--rmutl-blue-dark);
            font-size: 1.3rem;
        }

        .pie-chart-label {
            position: absolute;
            z-index: 1;
            display: none;
            width: 70px;
            color: #fff;
            font-size: 0.95rem;
            font-weight: 700;
            line-height: 1.1;
            text-align: center;
            transform: translate(-50%, -50%);
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
            pointer-events: none;
        }

        .pie-chart-tooltip {
            position: absolute;
            display: none;
            z-index: 2;
            pointer-events: none;
            min-width: 120px;
            padding: 6px 9px;
            border-radius: 3px;
            background: rgba(63, 52, 42, 0.96);
            color: white;
            font-size: 0.9rem;
            line-height: 1.4;
            text-align: center;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
            transform: translate(-50%, -110%);
        }

        .chart-legend {
            display: flex;
            flex: 0 1 auto;
            flex-direction: column;
            align-items: flex-start;
            justify-content: center;
            gap: 10px;
            color: var(--muted);
            font-size: 0.92rem;
            font-weight: 600;
            text-align: left;
        }

        .legend-item {
            display: block;
        }

        .legend-item::before {
            content: '';
            display: inline-block;
            width: 11px;
            height: 11px;
            margin-right: 5px;
            border-radius: 50%;
            background: var(--legend-color);
        }

        @media (max-width: 1180px) {
            .dashboard-lower {
                grid-template-columns: 1fr;
            }
        }

        .top-services {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .top-services li {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto auto;
            gap: 8px;
            padding: 9px 0;
            border-bottom: 1px solid var(--line);
            font-size: 0.85rem;
        }

        .top-services li > :first-child {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .top-services li span:nth-child(2) {
            color: var(--muted);
            white-space: nowrap;
        }

        .top-services li strong {
            color: var(--rmutl-blue-dark);
            text-align: right;
        }

        .service-dashboard-link {
            color: var(--brand-primary);
            font-weight: 600;
            text-decoration: none;
        }

        .service-dashboard-link:hover,
        .service-dashboard-link:focus-visible {
            color: var(--brand-accent);
            text-decoration: underline;
        }

        .service-detail-section {
            margin-top: 22px;
            border-top: 3px solid var(--rmutl-gold);
            padding-top: 12px;
        }

        .service-detail-section h3 {
            margin: 0 0 10px;
            color: var(--rmutl-blue-dark) !important;
            font-size: 1rem;
            font-weight: 700;
        }

        .service-detail-container {
            max-height: 330px;
            overflow: auto;
        }

        .service-detail-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.82rem;
        }

        .service-detail-table th,
        .service-detail-table td {
            border-bottom: 1px solid var(--line);
            padding: 7px 8px;
        }

        .service-detail-table th {
            position: sticky;
            top: 0;
            z-index: 1;
            background: var(--rmutl-blue-dark);
            color: white;
            text-align: left;
        }

        .service-detail-table th:last-child,
        .service-detail-table td:last-child {
            text-align: right;
            white-space: nowrap;
        }

        .service-detail-table tbody tr:nth-child(even) {
            background: var(--background-light);
        }

        .service-detail-table tbody tr:hover {
            background: var(--rmutl-gold-light);
        }

        .service-detail-table tfoot {
            position: sticky;
            bottom: 0;
            background: var(--rmutl-blue-dark);
            color: white;
            font-weight: 700;
        }

        .empty-row {
            text-align: center !important;
            color: var(--muted);
        }

        @media (max-width: 800px) {
            body {
                padding: 0;
            }

            .container {
                flex-direction: column;
                padding: 0 10px 10px;
            }

            .left-panel {
                width: 100%;
            }

            .main-panel {
                width: 100%;
                box-sizing: border-box;
                min-height: 240px;
            }

            .dashboard-lower {
                grid-template-columns: 1fr;
            }

            .pie-chart-layout {
                justify-content: flex-start;
            }
        }

        @media (max-width: 420px) {
            .pie-chart-layout {
                flex-direction: column;
                align-items: center;
            }

            .chart-legend {
                align-items: center;
                text-align: center;
            }
        }
