/* ============================================
   KWH MONITORING - ERP THEME
   Based on ERP reference design
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 56px;
    --sidebar-bg: #1a1d23;
    --sidebar-bg-hover: #2a2d35;
    --sidebar-bg-active: #0d6efd;
    --sidebar-text: #a0a4b0;
    --sidebar-text-active: #ffffff;
    --sidebar-border: #2d3039;
    --topbar-bg: #ffffff;
    --topbar-border: #e5e7eb;
    --content-bg: #f0f2f5;
    --card-bg: #ffffff;
    --primary-color: #0d6efd;
    --accent-red: #dc3545;
    --accent-blue: #0d6efd;
    --brand-red: #dc3545;
    --brand-blue: #0d6efd;
}

/* ============================================
   BASE STYLES - IMPROVED TEXT READABILITY
   ============================================ */
body {
    background-color: var(--content-bg);
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Enhanced text visibility for all text elements */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

/* Improve contrast for all text */
.text-muted {
    opacity: 0.8 !important;
}

/* Dynamic text size adjustment for better readability */
@media (max-width: 768px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.95rem; }
}

/* ============================================
   SIDEBAR
   ============================================ */
.erp-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, transform 0.3s ease;
    overflow: hidden;
}

.erp-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.erp-sidebar.collapsed .sidebar-brand .brand-banner,
.erp-sidebar.collapsed .sidebar-brand .brand-subtitle,
.erp-sidebar.collapsed .sidebar-search,
.erp-sidebar.collapsed .sidebar-nav .nav-link span,
.erp-sidebar.collapsed .sidebar-nav .nav-section-title,
.erp-sidebar.collapsed .sidebar-nav .nav-link .badge,
.erp-sidebar.collapsed .sidebar-footer {
    display: none;
}

.erp-sidebar.collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 12px 0;
}

.erp-sidebar.collapsed .sidebar-nav .nav-link i {
    margin-right: 0;
    font-size: 1.1rem;
}

/* Sidebar Brand */
.sidebar-brand {
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--sidebar-border);
}

.brand-banner {
    display: flex;
    align-items: center;
    gap: 0;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.brand-warna {
    background: var(--brand-red);
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px 0 0 4px;
}

.brand-monitoring {
    background: var(--brand-blue);
    color: #fff;
    padding: 4px 12px;
    border-radius: 0 4px 4px 0;
}

.brand-subtitle {
    font-size: 0.7rem;
    color: var(--sidebar-text);
    margin-top: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    opacity: 0.7;
}

/* Sidebar Search */
.sidebar-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-search .input-group {
    border-radius: 6px;
    overflow: hidden;
}

.sidebar-search .input-group-text {
    background: var(--sidebar-bg-hover);
    border: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    padding: 6px 10px;
    font-size: 0.8rem;
}

.sidebar-search .form-control {
    background: var(--sidebar-bg-hover);
    border: 1px solid var(--sidebar-border);
    color: #fff;
    font-size: 0.8rem;
    padding: 6px 10px;
}

.sidebar-search .form-control::placeholder {
    color: var(--sidebar-text);
    opacity: 0.6;
}

.sidebar-search .form-control:focus {
    background: var(--sidebar-bg-hover);
    border-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
    border-radius: 4px;
}

.sidebar-nav .nav-section-title {
    color: var(--sidebar-text);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 16px 20px 6px;
    opacity: 0.5;
}

.sidebar-nav .nav-link {
    color: var(--sidebar-text);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 0;
    transition: all 0.2s ease;
    position: relative;
    text-decoration: none;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-bg-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
}

.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #fff;
    border-radius: 0 3px 3px 0;
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-nav .nav-link .badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    min-width: 20px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-server-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--sidebar-text);
    opacity: 0.5;
}

.sidebar-server-info i {
    font-size: 0.75rem;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
}

/* ============================================
   MAIN WRAPPER
   ============================================ */
.erp-main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.erp-main-wrapper.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* ============================================
   TOP HEADER BAR
   ============================================ */
.erp-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-toggle {
    color: #555;
    font-size: 1.1rem;
    padding: 4px 8px;
    text-decoration: none;
    border: none;
    background: none;
}

.topbar-toggle:hover {
    color: var(--primary-color);
}

.topbar-brand {
    font-weight: 700;
    color: #333;
    font-size: 1rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-brand:hover {
    color: var(--primary-color);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-clock {
    font-size: 0.8rem;
    color: #666;
}

.topbar-icon-btn {
    color: #555;
    font-size: 1rem;
    padding: 4px 8px;
    text-decoration: none;
    border: none;
    background: none;
    position: relative;
}

.topbar-icon-btn:hover {
    color: var(--primary-color);
}

.topbar-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.55rem;
    padding: 1px 4px;
    min-width: 14px;
    height: 14px;
    line-height: 12px;
    border-radius: 50%;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 12px;
    border-left: 1px solid var(--topbar-border);
}

.topbar-user-avatar {
    font-size: 1.5rem;
    color: #888;
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
}

.topbar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
    line-height: 1.2;
}

.topbar-user-email {
    font-size: 0.65rem;
    color: #888;
    line-height: 1.2;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.erp-content {
    flex: 1;
    padding: 20px 24px;
}

/* ============================================
   FOOTER
   ============================================ */
.erp-footer {
    background: var(--topbar-bg);
    border-top: 1px solid var(--topbar-border);
    padding: 10px 0;
    font-size: 0.75rem;
    color: #888;
}

/* ============================================
   BREADCRUMB (ERP Style)
   ============================================ */
.erp-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.erp-breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
}

.erp-breadcrumb a:hover {
    text-decoration: underline;
}

.erp-breadcrumb .separator {
    color: #ccc;
}

.erp-breadcrumb .current {
    color: #333;
    font-weight: 600;
}

/* ============================================
   PAGE HEADER (ERP Style)
   ============================================ */
.erp-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.erp-page-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a1d23;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.erp-page-header .subtitle {
    font-size: 0.8rem;
    color: #888;
    margin-top: 4px;
}

.erp-page-header .actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Action buttons — uniform style */
.btn-erp-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #495057;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-erp-action:hover {
    background: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
    box-shadow: 0 2px 6px rgba(13, 110, 253, 0.25);
}

.btn-erp-action:active {
    transform: scale(0.97);
}

.btn-erp-action i {
    font-size: 0.82rem;
}

/* ============================================
   ERP TABS (Browser Tab Style - Seamless)
   ============================================ */
.erp-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    list-style: none;
    margin-top: 0;
    flex-wrap: nowrap;
    border-bottom: none;
    position: relative;
}

.erp-tabs::-webkit-scrollbar {
    display: none;
}

.erp-tabs .nav-item {
    margin-bottom: 0;
}

.erp-tabs .erp-tab,
.erp-tabs .nav-link,
.erp-tabs .nav-item .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    font-size: 0.82rem;
    font-weight: 500;
    color: #6c757d;
    text-decoration: none;
    border: none;
    border-radius: 8px 8px 0 0;
    margin-bottom: 0;
    white-space: nowrap;
    transition: all 0.2s ease;
    background: #e2e6ea;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.erp-tabs .erp-tab:hover,
.erp-tabs .nav-link:hover,
.erp-tabs .nav-item .nav-link:hover {
    color: #0d6efd;
    background: #d6dce4;
}

.erp-tabs .erp-tab.active,
.erp-tabs .nav-link.active,
.erp-tabs .nav-item .nav-link.active,
.erp-tabs .erp-tab.show,
.erp-tabs .nav-link.show,
.erp-tabs .nav-item .nav-link.show {
    color: #fff !important;
    background: #0d6efd !important;
    border: none !important;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    box-shadow: none;
    z-index: 2;
    margin-bottom: 0;
}

.erp-tabs .erp-tab.active i,
.erp-tabs .nav-link.active i,
.erp-tabs .nav-item .nav-link.active i {
    color: #fff !important;
}

.erp-tabs .erp-tab .badge,
.erp-tabs .nav-link .badge {
    font-size: 0.65rem;
    padding: 2px 6px;
}

.erp-tabs + .stats-row,
.erp-tabs + .row,
.erp-tabs + .card,
.erp-tabs + h5,
.erp-tabs + div {
    margin-top: 16px;
}

/* ============================================
   CARDS (ERP Style)
   ============================================ */
.card {
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 0;
    word-wrap: break-word;
    background: var(--card-bg);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

.card-header {
    border-radius: 8px 8px 0 0 !important;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
}

.card-header h5, .card-header h6 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

/* ============================================
   STAT CARDS (ERP Style)
   ============================================ */
.stat-card {
    border-radius: 10px;
    color: #fff;
    padding: 12px 14px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    /* Dynamic font sizing — overridden by JS ResizeObserver */
    --sc-label-size: 0.82rem;
    --sc-value-size: 1.55rem;
    --sc-small-size: 0.75rem;
    --sc-icon-size: 1.8rem;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}

.stat-card .stat-label {
    font-size: var(--sc-label-size, 0.82rem);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.95;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    margin-bottom: 2px;
}

.stat-card .stat-value {
    font-size: var(--sc-value-size, 1.55rem);
    font-weight: 800;
    margin-top: 2px;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.5px;
    transition: all 0.3s ease;
}

/* Animasi untuk update nilai dinamis */
.stat-card .stat-value.updated {
    animation: pulseUpdate 0.6s ease;
}

@keyframes pulseUpdate {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.9; }
    100% { transform: scale(1); opacity: 1; }
}

/* Animasi untuk highlighting */
.stat-card .stat-value.highlight {
    animation: highlightPulse 1s ease infinite;
}

@keyframes highlightPulse {
    0% { text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 0 rgba(255, 255, 255, 0); }
    50% { text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 10px rgba(255, 255, 255, 0.8); }
    100% { text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 0 rgba(255, 255, 255, 0); }
}

.stat-card .stat-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--sc-icon-size, 2rem);
    opacity: 0.15;
}

.stat-card.bg-primary { background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%) !important; }
.stat-card.bg-success { background: linear-gradient(135deg, #198754 0%, #157347 100%) !important; }
.stat-card.bg-warning { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important; }
.stat-card.bg-info { background: linear-gradient(135deg, #0dcaf0 0%, #0da5ca 100%) !important; }
.stat-card.bg-danger { background: linear-gradient(135deg, #dc3545 0%, #bb2d3b 100%) !important; }
.stat-card.bg-secondary { background: linear-gradient(135deg, #6c757d 0%, #5c636a 100%) !important; }
.stat-card.bg-dark { background: linear-gradient(135deg, #1a1d23 0%, #2a2d35 100%) !important; }

/* ============================================
   BADGE & PROGRESS
   ============================================ */
.badge {
    font-size: 0.8rem;
    padding: 0.35em 0.6em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 4px;
}

.progress {
    border-radius: 6px;
    overflow: hidden;
    background: #e9ecef;
}

.progress-bar {
    transition: width 0.6s ease;
    border-radius: 6px;
}

/* ============================================
   BUTTONS (ERP Style)
   ============================================ */
.btn {
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 14px;
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* ============================================
   TABLE (ERP Style)
   ============================================ */
.table th {
    white-space: nowrap;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #666;
    background: #f8f9fa;
}

.table td {
    font-size: 0.85rem;
    vertical-align: middle;
}

/* ============================================
   CUSTOM SCROLLBAR
   ============================================ */
.table-responsive::-webkit-scrollbar {
    height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ============================================
   PANEL CARD CLICKABLE EFFECT - IMPROVED VISIBILITY
   ============================================ */
.panel-card-clickable {
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
}

.panel-card-clickable:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.15) !important;
    border-color: var(--primary-color);
}

.panel-card-clickable:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1) !important;
}

.panel-card-clickable .card-footer {
    background: linear-gradient(to right, #f8f9fa, #e9ecef) !important;
    border-top: 1px solid #dee2e6;
    font-weight: 600;
}

/* Enhanced text visibility in panel cards */
.panel-card-clickable .card-body p,
.panel-card-clickable .card-body small,
.panel-card-clickable .card-body strong,
.panel-card-clickable .card-body span {
    font-weight: 500;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

.panel-card-clickable .card-body h5,
.panel-card-clickable .card-body h6 {
    font-weight: 700;
    color: #212529;
    margin-bottom: 10px;
}

.panel-card-clickable .badge {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 5px 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Panel card animation for dynamic updates */
.panel-card-clickable.updated {
    animation: cardPulse 0.8s ease;
}

@keyframes cardPulse {
    0% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }
    50% { box-shadow: 0 6px 20px rgba(13, 110, 253, 0.25); }
    100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }
}

.panel-card-clickable:hover .card-footer {
    background: linear-gradient(to right, #e9ecef, #dee2e6) !important;
}

.panel-card-clickable * {
    user-select: none;
}

.panel-card-clickable .badge {
    transition: all 0.2s ease;
}

.panel-card-clickable::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.panel-card-clickable:active::after {
    width: 300px;
    height: 300px;
    opacity: 1;
    transition: 0s;
}

/* ============================================
   POWER & AKTIF HIGHLIGHT CARDS
   ============================================ */
.power-highlight-card {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-radius: 8px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.power-highlight-card::after {
    content: '';
    position: absolute;
    top: -15px;
    right: -15px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50%;
}

.power-highlight-card .power-icon {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-bottom: 2px;
    letter-spacing: 0.3px;
}

.power-highlight-card .power-value {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.power-highlight-card .power-unit {
    font-size: 0.7rem;
    opacity: 0.65;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.aktif-highlight-card {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-radius: 8px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.aktif-highlight-card::after {
    content: '';
    position: absolute;
    top: -15px;
    right: -15px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50%;
}

.aktif-highlight-card .aktif-icon {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-bottom: 2px;
    letter-spacing: 0.3px;
}

.aktif-highlight-card .aktif-value {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aktif-highlight-card .aktif-unit {
    font-size: 0.75rem;
    opacity: 0.65;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* ============================================
   PANEL CARD INTERNAL ELEMENTS
   ============================================ */
.panel-label {
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: 600;
}

.panel-value {
    font-size: 0.75rem;
    color: #343a40;
    font-weight: 600;
}

.panel-progress {
    height: 12px;
    border-radius: 6px;
    background: #e9ecef;
}

.panel-progress .progress-bar {
    border-radius: 6px;
    font-size: 0.6rem;
    min-width: 0;
    line-height: 12px;
}

.phase-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 4px;
    border-radius: 6px;
    color: #fff;
    min-width: 0;
}

.phase-badge .phase-letter {
    font-size: 0.7rem;
    font-weight: 700;
    opacity: 0.75;
    line-height: 1;
    text-transform: uppercase;
}

.phase-badge .phase-val {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
}

.info-chip {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 6px 8px;
}

.info-chip-label {
    display: block;
    font-size: 0.7rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.info-chip-value {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #343a40;
}

/* ============================================
   GAUGE ANIMATION
   ============================================ */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.status-pulse {
    animation: pulse 2s infinite;
}

/* ============================================
   RESPONSIVE GRID FIX
   ============================================ */
.row > div {
    min-width: 0;
}

/* ============================================
   STAT-CARDS ROW - Auto-sizing flex grid
   ============================================ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    width: 100%;
}

.stats-row > div {
    min-width: 0;
}

.stats-row .stat-card {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.stat-card small {
    font-size: var(--sc-small-size, 0.75rem);
    display: block;
    margin-top: 1px;
}

/* ============================================
   DATE NAVIGATION ROW
   ============================================ */
.date-nav-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.date-nav-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.date-nav-group input[type="date"] {
    min-width: 140px;
}

.date-nav-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

#selectedDayName {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

/* ============================================
   PANEL GRID - Better card sizing
   ============================================ */
.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.panel-grid > div {
    min-width: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.panel-grid > div:hidden {
    display: none;
}

.panel-grid > div.filter-hidden {
    display: none !important;
}

/* ============================================
   PANEL COLLAPSE TOGGLE (Improved & Centered)
   ============================================ */
.panel-collapse-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 22px !important;
    height: 22px !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 0 !important;
    border-radius: 50% !important;
    border: 1.5px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transition: all 0.25s ease;
    cursor: pointer;
    box-sizing: border-box;
    flex-shrink: 0;
}

.panel-collapse-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.panel-collapse-toggle i.collapse-icon {
    font-size: 0.65rem;
    line-height: 1 !important;
    margin: 0 !important;
    position: relative;
    top: 0 !important;
    left: 0 !important;
    transform: none;
    transition: transform 0.3s ease;
}

.panel-collapse-toggle[aria-expanded="true"] i.collapse-icon {
    transform: rotate(180deg);
}

.panel-collapse-toggle[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.25);
}

/* ============================================
   PANEL FILTER BAR
   ============================================ */
.filter-bar-container {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

#panelSearch {
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    padding-left: 32px !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#panelSearch:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

#panelStatusFilter,
#panelPhaseFilter {
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

#panelStatusFilter:focus,
#panelPhaseFilter:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

#filterInfo strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* Panel chip list */
.panel-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 16px;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    user-select: none;
    white-space: nowrap;
}

.panel-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.panel-chip.chip-normal {
    background: #e8f5e9;
    color: #2e7d32;
    border-color: #c8e6c9;
}

.panel-chip.chip-normal:hover,
.panel-chip.chip-normal.active {
    background: #2e7d32;
    color: #fff;
    border-color: #2e7d32;
}

.panel-chip.chip-medium {
    background: #fff8e1;
    color: #f57f17;
    border-color: #ffecb3;
}

.panel-chip.chip-medium:hover,
.panel-chip.chip-medium.active {
    background: #f57f17;
    color: #fff;
    border-color: #f57f17;
}

.panel-chip.chip-high {
    background: #ffebee;
    color: #c62828;
    border-color: #ffcdd2;
}

.panel-chip.chip-high:hover,
.panel-chip.chip-high.active {
    background: #c62828;
    color: #fff;
    border-color: #c62828;
}

.panel-chip .chip-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.panel-chip.chip-normal .chip-dot { background: #4caf50; }
.panel-chip.chip-medium .chip-dot { background: #ff9800; }
.panel-chip.chip-high .chip-dot { background: #f44336; }

.panel-chip.chip-normal.active .chip-dot,
.panel-chip.chip-medium.active .chip-dot,
.panel-chip.chip-high.active .chip-dot { background: #fff; }

.panel-chip.chip-offline {
    background: #f5f5f5;
    color: #9e9e9e;
    border-color: #e0e0e0;
}

.panel-chip.chip-offline .chip-dot { background: #9e9e9e; }

/* ============================================
   CHART CONTAINERS - Responsive sizing with proper height
   ============================================ */
.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

.chart-row > div {
    min-width: 0;
}

.chart-row .card-body {
    position: relative;
    min-height: 280px;
    padding: 0.25rem;
}

.chart-row .card-header {
    padding: 0.25rem 0.5rem;
}

.chart-row .card-header h6 {
    font-size: 0.8rem;
    margin-bottom: 0;
}

.chart-row canvas {
    width: 100% !important;
    height: 100% !important;
    min-height: 260px;
}

/* Chart Type Selector Dropdown */
.chart-type-selector {
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 3px 28px 3px 10px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23fff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.chart-type-selector:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.chart-type-selector:focus {
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}

.chart-type-selector option {
    background: #fff;
    color: #333;
}

/* Category Selector & Chart Type Selector — responsive dropdowns on card headers */
.category-selector,
.chart-type-selector {
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 3px 22px 3px 8px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%23fff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-color: rgba(255, 255, 255, 0.15);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-selector:hover,
.chart-type-selector:hover {
    background-color: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.category-selector:focus,
.chart-type-selector:focus {
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}

.category-selector option,
.chart-type-selector option {
    background: #fff;
    color: #333;
    font-size: 0.78rem;
}

/* Category color variants (dynamically extended via injectCategoryStyles) */
.category-selector.cat-Billboard { background-color: rgba(33, 150, 243, 0.25); border-color: rgba(33, 150, 243, 0.5); }
.category-selector.cat-Megatron { background-color: rgba(255, 152, 0, 0.25); border-color: rgba(255, 152, 0, 0.5); }
.category-selector.cat-NeonBox  { background-color: rgba(156, 39, 176, 0.25); border-color: rgba(156, 39, 176, 0.5); }

/* Chart Grid — auto-fit like panel monitoring */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.chart-grid > div {
    min-width: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chart-grid > div.filter-hidden {
    display: none !important;
}

/* Chart view container inside each card */
.chart-view-container {
    position: relative;
    min-height: 280px;
    height: 280px;
}

.chart-view-container > div {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.chart-view-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Category Icon — dynamic icon on card headers */
.category-icon {
    display: inline-flex;
    align-items: center;
    font-size: 1rem;
    vertical-align: middle;
    transition: color 0.15s ease;
    user-select: none;
}

/* Category dropdown popover */
.category-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1050;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 4px;
    min-width: 160px;
    display: none;
}

.category-dropdown.show {
    display: block;
}

.category-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.1s;
    color: #333;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.category-dropdown-item:hover {
    background: #f0f0f0;
}

.category-dropdown-item.active {
    background: #e3f2fd;
    font-weight: 600;
}

.category-dropdown-item .cat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.category-dropdown-item .cat-dot.dot-Billboard { background: #2196f3; }
.category-dropdown-item .cat-dot.dot-Megatron { background: #ff9800; }
.category-dropdown-item .cat-dot.dot-NeonBox { background: #9c27b0; }

/* ============================================
   PEAK ROW - Responsive
   ============================================ */
.peak-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.peak-row > div {
    min-width: 0;
}

/* ============================================
   DETAIL STATS ROW - Responsive
   ============================================ */
.detail-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.75rem;
}

.detail-stats-row > div {
    min-width: 0;
}

/* Detail stats cards - more compact */
.detail-stats-row .card {
    margin-bottom: 0;
}

.detail-stats-row .card-body {
    padding: 0.6rem;
}

.detail-stats-row h6 {
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
}

.detail-stats-row .badge {
    font-size: 0.75rem;
    padding: 0.3rem 0.4rem;
}

.detail-stats-row small {
    font-size: 0.65rem;
}

.detail-stats-row .progress {
    height: 16px;
}

.detail-stats-row .progress-bar {
    font-size: 0.7rem;
    line-height: 16px;
}

/* ============================================
   TAB CONTENT - Consistent padding
   ============================================ */
.tab-content {
    padding-top: 1rem;
}

.tab-content > .tab-pane {
    overflow: hidden;
}

/* ============================================
   FORM LAYOUT - Consistent spacing
   ============================================ */
.form-label {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.form-text, .text-muted small, small.text-muted {
    font-size: 0.75rem;
}

/* ============================================
   ANOMALY GRID - Horizontal scroll wrapper
   ============================================ */
.anomaly-grid-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================
   DATAGRID PAGES - Disable card hover
   ============================================ */
.dx-datagrid .card:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* ============================================
   FS-5 / FS-6 (Font size BS5)
   ============================================ */
.fs-5 { font-size: 1.25rem !important; }
.fs-6 { font-size: 1rem !important; }

/* ============================================
   ROUNDED-3 (BS5 border-radius)
   ============================================ */
.rounded-3 { border-radius: 0.5rem !important; }

/* ============================================
   RESPONSIVE - TABLET (≤992px)
   ============================================ */
@media (max-width: 992px) {
    .erp-sidebar {
        transform: translateX(-100%);
    }

    .erp-sidebar.show {
        transform: translateX(0);
    }

    .erp-main-wrapper {
        margin-left: 0 !important;
    }

    .erp-content {
        padding: 16px;
    }

    .erp-page-header h2 {
        font-size: 1.2rem;
    }
}

/* ============================================
   RESPONSIVE - MOBILE (≤768px)
   ============================================ */
@media (max-width: 768px) {
    body {
        font-size: 0.9rem;
    }

    .erp-content {
        padding: 12px;
    }

    .card-body {
        padding: 0.5rem;
    }

    .badge {
        font-size: 0.7rem !important;
        padding: 0.2em 0.4em;
    }

    h6 {
        font-size: 0.85rem;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .erp-page-header h2 {
        font-size: 1.1rem;
    }

    .erp-page-header .subtitle {
        font-size: 0.75rem;
    }

    .erp-page-header .actions {
        flex-wrap: wrap;
        gap: 4px;
    }

    .erp-page-header .actions .btn,
    .erp-page-header .actions .btn-erp-action {
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
    }

    .stats-row > div {
        min-width: 0;
    }

    .stats-row .h4 {
        font-size: var(--sc-value-size, 1.1rem);
    }

    .stats-row .h3 {
        font-size: var(--sc-value-size, 1.2rem);
    }

    .erp-tabs .erp-tab {
        padding: 7px 12px;
        font-size: 0.8rem;
    }

    .btn-erp-action {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .date-nav-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .date-nav-group {
        gap: 0.35rem;
    }

    .date-nav-info {
        gap: 0.5rem;
    }

    .date-nav-group .btn-sm {
        padding: 0.2rem 0.5rem;
        font-size: 0.8rem;
    }

    .date-nav-row input[type="date"] {
        min-width: 120px;
    }

    .date-nav-row .form-control {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }

    .date-nav-info .btn-sm {
        padding: 0.2rem 0.5rem;
        font-size: 0.8rem;
    }

    #selectedDayName {
        font-size: 0.78rem;
        white-space: nowrap;
    }

    .chart-row {
        grid-template-columns: 1fr;
    }

    .chart-row .card-body {
        min-height: 240px;
    }

    .panel-grid {
        grid-template-columns: 1fr;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .chart-view-container {
        min-height: 220px;
        height: 220px;
    }

    .peak-row {
        grid-template-columns: 1fr;
    }

    .table {
        font-size: 0.75rem;
    }

    .table th, .table td {
        padding: 0.3rem 0.4rem;
        font-size: 0.75rem;
    }

    .erp-footer .row > div {
        flex: 0 0 100%;
        max-width: 100%;
        text-align: center !important;
        font-size: 0.75rem;
    }

    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-lg, .modal-xl {
        max-width: 100%;
        margin: 0.5rem;
    }

    .pagination .page-link {
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
    }

    .card-header {
        padding: 0.5rem 0.75rem !important;
    }

    .card-header h5, .card-header h6 {
        font-size: 0.85rem;
    }

    .card-header .d-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .detail-stats-row {
        grid-template-columns: 1fr;
    }

    .detail-stats-row > div {
        min-width: 0;
    }

    /* Anomaly DataGrid: force horizontal scroll on mobile */
    .anomaly-grid-scroll-wrapper .dx-datagrid {
        min-width: 700px !important;
    }

    .peak-row > div {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .form-label {
        font-size: 0.85rem;
    }

    .position-fixed[style*="z-index: 9999"] {
        left: 10px !important;
        right: 10px !important;
        min-width: auto !important;
    }

    .topbar-user-info {
        display: none !important;
    }

    .topbar-clock {
        display: none !important;
    }
}

/* ============================================
   RESPONSIVE - SMALL MOBILE (≤576px)
   ============================================ */
@media (max-width: 576px) {
    .erp-content {
        padding: 8px;
    }

    .erp-page-header h2 {
        font-size: 1rem;
    }

    .erp-page-header .subtitle {
        font-size: 0.7rem;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr;
    }

    .stats-row-4 {
        grid-template-columns: 1fr 1fr;
    }

    .stats-row > div {
        min-width: 0;
    }

    .stats-row .h4 {
        font-size: var(--sc-value-size, 0.95rem);
    }

    .stats-row .h3 {
        font-size: var(--sc-value-size, 1.05rem);
    }

    .stats-row small {
        font-size: var(--sc-small-size, 0.75rem);
    }

    .btn {
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
    }

    .erp-tabs .erp-tab {
        font-size: 0.72rem;
        padding: 6px 10px;
    }

    .btn-erp-action {
        padding: 4px 8px;
        font-size: 0.72rem;
    }

    .card-body {
        padding: 0.4rem;
    }

    .panel-card-clickable .card-body p,
    .panel-card-clickable .card-body small {
        font-size: 0.65rem;
    }

    .progress {
        height: 10px !important;
    }

    .date-nav-row input[type="date"] {
        min-width: 105px !important;
    }

    .date-nav-row .form-control {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }

    .date-nav-group .btn-sm {
        padding: 0.15rem 0.4rem;
        font-size: 0.75rem;
    }

    .date-nav-info .btn-sm {
        padding: 0.15rem 0.4rem;
        font-size: 0.75rem;
    }

    .date-nav-info .btn-sm span {
        display: none;
    }

    #selectedDayName {
        font-size: 0.7rem;
    }

    .power-highlight-card .power-value,
    .aktif-highlight-card .aktif-value {
        font-size: 0.95rem;
    }

    .power-highlight-card .power-icon,
    .aktif-highlight-card .aktif-icon {
        font-size: 0.65rem;
    }

    .power-highlight-card .power-unit,
    .aktif-highlight-card .aktif-unit {
        font-size: 0.6rem;
    }

    .info-chip-label {
        font-size: 0.6rem;
    }

    .info-chip-value {
        font-size: 0.7rem;
    }

    .phase-badge .phase-letter {
        font-size: 0.6rem !important;
    }

    .phase-badge .phase-val {
        font-size: 0.7rem !important;
    }

    .panel-label, .panel-value {
        font-size: 0.75rem;
    }

    .panel-progress {
        height: 12px;
    }

    .panel-progress .progress-bar {
        line-height: 12px;
    }

    .stat-card .stat-value {
        font-size: var(--sc-value-size, 1.35rem);
    }

    .stat-card .stat-label {
        font-size: var(--sc-label-size, 0.75rem);
    }

    .stat-card {
        padding: 10px 12px;
    }
}

/* ============================================
   TOUCH-FRIENDLY ENHANCEMENTS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 38px;
        min-width: 38px;
    }

    .erp-tabs .erp-tab {
        min-height: 36px;
        padding: 0.5rem 0.8rem;
        font-size: 0.7rem;
    }

    .btn-erp-action {
        min-height: 32px;
        padding: 4px 8px;
        font-size: 0.7rem;
    }

    .page-link {
        min-height: 38px;
        min-width: 38px;
    }

    .panel-card-clickable:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }

    .card:hover {
        transform: none;
    }
}

/* ============================================
   DEVEXPRESS OVERRIDES (ERP Style)
   ============================================ */
.dx-datagrid {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.dx-datagrid .dx-datagrid-headers {
    background: #f8f9fa;
    border-bottom: 1px solid #e5e7eb;
}

.dx-datagrid .dx-row > td {
    font-size: 0.85rem;
}

.dx-datagrid .dx-header-row .dx-cell-focus-disabled {
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.3px;
}

/* ============================================
   BS3->BS5 SIZING FIXES (Panel & Chart)
   ============================================ */
/* Panel cards - make them proportional */
.panel-card-clickable .card-body {
    padding: 0.5rem;
}

.panel-card-clickable .card-footer {
    padding: 0.35rem 0.5rem;
    font-size: 0.65rem;
}

/* Chart containers - constrain height and ensure responsive width */
.chart-row canvas {
    max-height: 250px;
    width: 100% !important;
}

.dx-chart {
    max-height: 350px;
}

/* ============================================
   CARD CONSISTENCY
   ============================================ */
.card {
    overflow: hidden;
    word-wrap: break-word;
}

.card-header h5,
.card-header h6 {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   FOOTER - Consistent
   ============================================ */
.erp-footer {
    font-size: 0.75rem;
    padding: 8px 0;
}

.erp-footer .row {
    align-items: center;
}

/* ============================================
   DATA GRID CONTAINER - Full width
   ============================================ */
.dx-datagrid-container {
    width: 100% !important;
    overflow: hidden;
}

/* Disable card hover effect inside DataGrid */
.dx-datagrid .card {
    transform: none !important;
    box-shadow: none !important;
    transition: none !important;
}

.dx-datagrid .card:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* ============================================
   CHART - Global sizing for readability
   ============================================ */
canvas {
    max-width: 100%;
}

/* Chart.js containers need explicit height for proper rendering */
.card-body canvas {
    min-height: 260px;
}

/* ============================================
   PANEL CARD - Full width content, proper sizing
   ============================================ */
.panel-card-clickable .card-body {
    padding: 0.5rem;
}

.panel-card-clickable .card-footer {
    padding: 0.35rem 0.5rem;
}

/* Power & Aktif highlight cards - fill available space */
.power-highlight-card,
.aktif-highlight-card {
    padding: 0.4rem 0.5rem !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 80px;
}

.power-highlight-card .power-icon,
.aktif-highlight-card .aktif-icon {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-bottom: 1px;
    letter-spacing: 0.3px;
}

.power-highlight-card .power-value,
.aktif-highlight-card .aktif-value {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.1;
}

.power-highlight-card .power-unit,
.aktif-highlight-card .aktif-unit {
    font-size: 0.65rem;
    opacity: 0.8;
    margin-top: 2px;
}

/* Phase badges - fill available width */
.phase-badge {
    min-width: 0;
    flex: 1 1 0;
    padding: 4px 3px !important;
}

.phase-badge .phase-letter {
    font-size: 0.65rem !important;
}

.phase-badge .phase-val {
    font-size: 0.75rem !important;
}

/* Info chips - fill available space */
.info-chip {
    padding: 3px 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 35px;
}

.info-chip-label {
    font-size: 0.65rem;
    opacity: 0.8;
    margin-bottom: 1px;
}

.info-chip-value {
    font-size: 0.75rem;
}

/* Panel progress - compact */
.panel-progress {
    height: 14px;
}

.panel-progress .progress-bar {
    font-size: 0.65rem;
    line-height: 14px;
}

/* Stat cards - compact */
.stat-card {
    padding: 10px 12px;
}

.stat-card .stat-value {
    font-size: var(--sc-value-size, 1.35rem);
}

.stat-card .stat-icon {
    font-size: var(--sc-icon-size, 1.5rem);
    right: 10px;
}

/* Phase badges - compact */
.phase-badge .phase-val {
    font-size: 0.8rem;
}

/* Form controls - BS5 style */
.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    color: #212529;
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-control-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.25rem;
}

.form-control-lg {
    padding: 0.5rem 1rem;
    font-size: 1.25rem;
    border-radius: 0.5rem;
}

/* Button - BS5 style */
.btn {
    display: inline-block;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    border-radius: 0.375rem;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.25rem;
}

.btn-lg {
    padding: 0.5rem 1rem;
    font-size: 1.25rem;
    border-radius: 0.5rem;
}

/* Table - BS5 style */
.table {
    font-size: 0.9rem;
}

.table th {
    font-size: 0.8rem;
    padding: 0.5rem;
}

.table td {
    padding: 0.5rem;
}

/* Alert - BS5 style */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
}

/* Modal - BS5 style */
.modal-content {
    border-radius: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.125);
}

.modal-body {
    padding: 1rem;
}

/* Input group - BS5 style */
.input-group .form-control {
    border-radius: 0;
}

.input-group .form-control:first-child {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

.input-group .form-control:last-child {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

/* ============================================
   SETTINGS PAGE - Redesigned Layout
   ============================================ */

/* Settings Tabs - browser-tab style */
.settings-tabs .erp-tab {
    flex-direction: row;
    align-items: center;
    padding: 9px 18px;
    gap: 6px;
    font-size: 0.85rem;
    border-radius: 8px 8px 0 0;
}

.settings-tabs .erp-tab i {
    font-size: 0.82rem;
}

/* Settings Section List */
.settings-section-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 70px;
}

/* Settings Section */
.settings-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease;
}

.settings-section:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* Settings Section Header */
.settings-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafbfc;
    flex-wrap: wrap;
}

.settings-section-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.settings-section-title {
    flex: 1;
    min-width: 0;
}

.settings-section-title h5 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1a1d23;
    line-height: 1.3;
}

.settings-section-title p {
    margin: 1px 0 0;
    font-size: 0.78rem;
    color: #888;
    line-height: 1.3;
}

.settings-section-action {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Section Body */
.settings-section-body {
    padding: 16px 20px;
}

/* Section Footer */
.settings-section-footer {
    padding: 10px 20px;
    border-top: 1px solid #f0f0f0;
    background: #fafbfc;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Soft background colors for section icons */
.bg-primary-soft { background: rgba(13, 110, 253, 0.1); }
.bg-success-soft { background: rgba(25, 135, 84, 0.1); }
.bg-warning-soft { background: rgba(255, 193, 7, 0.15); }
.bg-info-soft { background: rgba(13, 202, 240, 0.1); }
.bg-danger-soft { background: rgba(220, 53, 69, 0.1); }
.bg-dark-soft { background: rgba(26, 29, 35, 0.1); }

/* Settings Grid — 4 columns fill to edge */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.settings-field-full {
    grid-column: 1 / -1;
}

.settings-field .form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #444;
    margin: 0;
}

.settings-field .form-control,
.settings-field .form-select {
    width: 100%;
    padding: 5px 10px;
    font-size: 0.88rem;
}

.settings-field .input-group .form-control {
    padding: 5px 10px;
    font-size: 0.88rem;
}

.settings-field .input-group .input-group-text {
    padding: 5px 10px;
    font-size: 0.82rem;
}

.settings-field .text-muted {
    font-size: 0.74rem;
    line-height: 1.3;
}

/* Settings Preview Box */
.settings-preview-box {
    margin-top: 14px;
    padding: 14px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.settings-preview-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Threshold Preview Cards */
.settings-threshold-card {
    background: #fff;
    border-radius: 6px;
    padding: 10px 12px;
    text-align: center;
    border: 1px solid #e9ecef;
}

.settings-threshold-card.settings-threshold-normal {
    border-left: 3px solid #198754;
}

.settings-threshold-card.settings-threshold-medium {
    border-left: 3px solid #ffc107;
}

.settings-threshold-card.settings-threshold-high {
    border-left: 3px solid #dc3545;
}

.settings-threshold-label {
    font-size: 0.72rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 3px;
}

.settings-threshold-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1a1d23;
    margin-bottom: 6px;
}

.settings-threshold-card.settings-threshold-normal .settings-threshold-value { color: #198754; }
.settings-threshold-card.settings-threshold-medium .settings-threshold-value { color: #e0a800; }
.settings-threshold-card.settings-threshold-high .settings-threshold-value { color: #dc3545; }

.settings-threshold-card small {
    font-size: 0.74rem;
    color: #999;
}

/* Settings Toggle Cards */
.settings-toggles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.settings-toggle-card {
    cursor: pointer;
    user-select: none;
}

.settings-toggle-card input[type="checkbox"] {
    display: none;
}

.settings-toggle-card-inner {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: #fff;
}

.settings-toggle-card-inner i {
    font-size: 1.05rem;
    margin-bottom: 1px;
}

.settings-toggle-card-inner strong {
    font-size: 0.85rem;
    color: #333;
}

.settings-toggle-card-inner small {
    font-size: 0.74rem;
    color: #888;
    line-height: 1.3;
}

.settings-toggle-card input:checked + .settings-toggle-card-inner {
    border-color: #0d6efd;
    background: rgba(13, 110, 253, 0.04);
}

.settings-toggle-card input:checked + .settings-toggle-card-inner strong {
    color: #0d6efd;
}

/* Settings Info Banner */
.settings-info-banner {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 0.82rem;
    line-height: 1.4;
}

.settings-info-banner i {
    margin-top: 2px;
    flex-shrink: 0;
}

.settings-info-banner-info {
    background: rgba(13, 202, 240, 0.08);
    border: 1px solid rgba(13, 202, 240, 0.2);
    color: #0b5ed7;
}

/* Settings Divider */
.settings-divider {
    border: none;
    border-top: 1px solid #e9ecef;
    margin: 14px 0;
}

/* Settings Button Group */
.settings-btn-group {
    display: inline-flex;
    gap: 0;
}

.settings-btn-group .btn {
    border-radius: 0;
    padding: 6px 14px;
    font-size: 0.82rem;
}

.settings-btn-group .btn:first-child {
    border-radius: 6px 0 0 6px;
}

.settings-btn-group .btn:last-child {
    border-radius: 0 6px 6px 0;
}

/* Settings Preset Grid */
.settings-preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.settings-preset-grid .btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 6px;
    text-align: center;
    font-size: 0.82rem;
    border-width: 2px;
    transition: all 0.2s ease;
}

.settings-preset-grid .btn i {
    font-size: 1rem;
}

.settings-preset-grid .btn small {
    font-size: 0.68rem;
    opacity: 0.7;
}

.settings-preset-grid .btn.preset-active {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.35);
    transform: translateY(-1px);
}

.settings-preset-grid .btn.preset-active i {
    color: #fff;
}

.settings-preset-grid .btn.preset-active small {
    color: rgba(255, 255, 255, 0.8);
    opacity: 1;
}

/* Settings Test Grid — full-width colored cards */
.settings-test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.settings-test-grid .btn {
    font-size: 0.82rem;
    padding: 8px 10px;
    border-radius: 6px;
    border: none;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: center;
}

.btn-test-danger {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.2) !important;
}
.btn-test-danger:hover {
    background: rgba(220, 53, 69, 0.2);
    color: #bb2d3b;
}

.btn-test-warning {
    background: rgba(255, 193, 7, 0.12);
    color: #e0a800;
    border: 1px solid rgba(255, 193, 7, 0.25) !important;
}
.btn-test-warning:hover {
    background: rgba(255, 193, 7, 0.22);
    color: #c69500;
}

.btn-test-success {
    background: rgba(25, 135, 84, 0.1);
    color: #198754;
    border: 1px solid rgba(25, 135, 84, 0.2) !important;
}
.btn-test-success:hover {
    background: rgba(25, 135, 84, 0.2);
    color: #157347;
}

.btn-test-info {
    background: rgba(13, 202, 240, 0.1);
    color: #0dcaf0;
    border: 1px solid rgba(13, 202, 240, 0.2) !important;
}
.btn-test-info:hover {
    background: rgba(13, 202, 240, 0.2);
    color: #0da5ca;
}

/* Sticky Save Bar */
.settings-save-bar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 1030;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
    padding: 8px 20px;
    transition: left 0.3s ease;
}

.erp-main-wrapper.sidebar-collapsed .settings-save-bar {
    left: var(--sidebar-collapsed-width);
}

.settings-save-bar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.settings-save-bar-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: #888;
}

.settings-save-bar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.settings-save-bar-actions .btn {
    font-size: 0.82rem;
}

/* Responsive */
@media (max-width: 991.98px) {
    .settings-save-bar {
        left: 0;
    }

    .settings-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .settings-toggles-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }

    .settings-preset-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .settings-test-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

@media (max-width: 575.98px) {
    .settings-section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .settings-section-action {
        width: 100%;
        justify-content: flex-start;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .settings-toggles-grid {
        grid-template-columns: 1fr;
    }

    .settings-save-bar-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .settings-save-bar-actions {
        justify-content: flex-end;
    }
}

/* ============================================
   EMA SETTINGS MODAL — Compact & Proportional
   ============================================ */
.ema-modal-dialog {
    max-width: 520px;
    margin: 1.75rem auto;
}

.ema-modal-content {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.ema-modal-body {
    padding: 0.85rem 1rem;
    max-height: 70vh;
    overflow-y: auto;
}

.ema-modal-body .nav-tabs {
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 0.5rem;
}

.ema-modal-body .nav-tabs .nav-link {
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    border: none;
    border-radius: 6px 6px 0 0;
    color: #6c757d;
    transition: all 0.15s;
    background: #e2e6ea;
}

.ema-modal-body .nav-tabs .nav-link:hover {
    color: #0d6efd;
    background: #d6dce4;
}

.ema-modal-body .nav-tabs .nav-link.active {
    color: #fff !important;
    background: #0d6efd !important;
    border: none !important;
    border-radius: 6px 6px 0 0;
    font-weight: 600;
    box-shadow: none;
    z-index: 2;
}

.ema-modal-body .nav-tabs .nav-link.active i {
    color: #fff !important;
}

/* Override BS3 .nav-tabs>li.active>a in EMA modal */
.ema-modal-body .nav-tabs > li.active > a,
.ema-modal-body .nav-tabs > li.active > a:focus,
.ema-modal-body .nav-tabs > li.active > a:hover {
    color: #fff !important;
    background: #0d6efd !important;
    border: none !important;
    border-radius: 6px 6px 0 0;
    font-weight: 600;
    z-index: 2;
}

/* Horizontally scrollable category sub-tabs in downtime section */
#downtimeCategoryTabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    gap: 0.25rem;
    padding-bottom: 2px;
    white-space: nowrap;
}

#downtimeCategoryTabs::-webkit-scrollbar {
    height: 4px;
}

#downtimeCategoryTabs::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

#downtimeCategoryTabs::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 2px;
}

#downtimeCategoryTabs .nav-item {
    flex: 0 0 auto;
    float: none;
}

#downtimeCategoryTabs .nav-link {
    white-space: nowrap;
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    border-radius: 20px;
    border: 1.5px solid #dee2e6;
    background: #fff;
    color: #495057;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

#downtimeCategoryTabs .nav-link:hover {
    background: #e8f0fe;
    color: #0d6efd;
    border-color: #0d6efd;
}

#downtimeCategoryTabs .nav-link.active {
    background: #0d6efd !important;
    color: #fff !important;
    border-color: #0d6efd !important;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(13, 110, 253, 0.3);
}

/* Override BS3 active state for pill-style category tabs */
#downtimeCategoryTabs > li.active > a,
#downtimeCategoryTabs > li.active > a:focus,
#downtimeCategoryTabs > li.active > a:hover {
    background: #0d6efd !important;
    color: #fff !important;
    border-color: #0d6efd !important;
    font-weight: 600;
}

.ema-info-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    background: #e8f4fd;
    border: 1px solid #b8daff;
    border-radius: 5px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #0c5460;
    margin-bottom: 0.6rem;
}

.ema-info-banner i {
    margin-top: 2px;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.ema-label {
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
    color: #495057;
}

.ema-hint {
    font-size: 0.7rem;
    display: block;
    margin-top: 0.1rem;
    line-height: 1.3;
}

.ema-btn-group .ema-btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.78rem;
}

/* --- CSS Grid auto-fill / auto-fit layouts --- */

/* 2-column grid: fields side by side, auto-fit so it collapses to 1 col on narrow */
.ema-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

/* 3-column grid: time selects, auto-fit collapses when space is tight */
.ema-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.5rem;
}

/* Preset buttons: auto-fill so they wrap naturally, 4 per row ideally */
.ema-grid-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.4rem;
}

/* Checkbox group: auto-fit, wraps when label is long */
.ema-check-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.2rem 0.75rem;
    padding: 0.35rem 0;
    margin-bottom: 0.2rem;
}

.ema-check-group .form-check {
    margin-bottom: 0;
    min-width: 0;
}

.ema-check-group .form-check-label {
    font-size: 0.78rem;
}

.ema-preset-btn {
    padding: 0.3rem 0.2rem !important;
    font-size: 0.72rem;
    line-height: 1.3;
    border-radius: 5px !important;
    text-align: center;
    transition: all 0.15s;
    border: 2px solid #dee2e6;
    background: #fff;
    color: #495057;
    cursor: pointer;
}

.ema-preset-btn:hover {
    background: #e8f0fe !important;
    color: #0d6efd !important;
    border-color: #0d6efd !important;
}

.ema-preset-btn.ema-preset-active {
    background: #0d6efd !important;
    color: #fff !important;
    border-color: #0d6efd !important;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.35);
}

.ema-preset-btn.ema-preset-active i,
.ema-preset-btn.ema-preset-active small {
    color: #fff;
}

.ema-preset-btn i {
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.1rem;
}

.ema-modal-body .form-control-sm,
.ema-modal-body .form-select-sm {
    font-size: 0.82rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.ema-modal-body .form-check-input {
    width: 0.95em;
    height: 0.95em;
}

.ema-modal-body .form-switch .form-check-input {
    width: 2em;
    height: 1.1em;
}

.ema-modal-body .badge {
    font-size: 0.65rem;
    padding: 0.2em 0.4em;
    vertical-align: middle;
}

@media (max-width: 576px) {
    .ema-modal-dialog {
        max-width: 95%;
        margin: 0.5rem;
    }

    .ema-modal-body {
        padding: 0.6rem;
        max-height: 80vh;
    }

    .ema-grid-2 {
        grid-template-columns: 1fr;
    }

    .ema-grid-3 {
        grid-template-columns: 1fr;
    }

    .ema-grid-presets {
        grid-template-columns: repeat(2, 1fr);
    }

    .ema-check-group {
        grid-template-columns: 1fr;
    }

    .ema-preset-btn {
        font-size: 0.65rem;
        padding: 0.2rem 0.1rem !important;
    }
}
