/* Desktop: 1025px and above */
@media (min-width: 1025px) {

    /* Hide sidebar overlay on desktop */
    .hess-sidebar-overlay {
        display: none !important;
    }
    
    
    /* Hide filter toggle button on desktop */
    .hess-filter-toggle {
        display: none !important;
    }

    /* Ensure filters are always expanded on desktop */
    .hess-grid-filter-collapsed form,
    .hess-graph-parameters.hess-grid-filter-collapsed form {
        display: flex !important;
    }
}

/* Tablet responsive styles */
@media (min-width: 769px) and (max-width: 1024px) {
    .hess-sidebar-filters {
        width: 260px !important;
    }

    #map_canvas {
        left: 260px !important;
        width: calc(100% - 260px) !important;
    }

    .hess-map-key-overlay {
        left: 280px !important;
    }

    .hess-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .hess-sidebar.open {
        transform: translateX(0);
    }
    
    body.has-sidebar {
        margin-left: 0;
    }
}

/* TABLET & MOBILE NAVIGATION STYLES (Max-Width: 1024px) */

@media (max-width: 1024px) {

    body, html, .main-content, .login-main, .hess-body {
        transform: none !important;
        perspective: none !important;
        filter: none !important;
        contain: none !important;
        overflow-x: hidden !important; 
    }

    body, html {
        height: auto !important;
        min-height: 100% !important;
        overflow-y: auto !important;
    }
    
    .main-content {
        height: auto !important;
        overflow-y: hidden !important;
    }

    .main-content, .hess-detail-page{
        padding: 0.125rem !important;
    }

    /* Hamburger Menu Button */
    .hess-mobile-menu-toggle {
        display: block !important;
        position: fixed !important;
        top: 0.3rem !important;
        left: 0.75rem !important;
        z-index: 99997 !important;
        background-color: #FFFFFF !important;
        border: 1px solid #D1D5DB !important;
        border-radius: 0.25rem !important;
        padding: 0.5rem !important;
        cursor: pointer !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    }
    
    .hess-mobile-menu-toggle:hover {
        background-color: #F9FAFB;
    }
    
    /* Disable hover effects for mobile menu toggle */
    .hess-mobile-menu-toggle:hover {
        background-color: #FFFFFF !important;
    }
    
    .hess-mobile-menu-toggle svg {
        width: 24px;
        height: 24px;
        color: #374151;
    }
    
    /* Hide header center on mobile */
    .hess-header-center {
        display: none !important;
    }
    
    /* Sidebar - Mobile Overlay */
    #sidebar.hess-sidebar,
    nav#sidebar.hess-sidebar,
    .hess-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 50vw !important;
        max-width: 50vw !important; 
        height: 100vh !important;
        z-index: 99999 !important; 
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease-in-out !important;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15) !important;
        display: block !important;
        visibility: visible !important;
        overflow-y: auto !important;
        background-color: #FFFFFF !important; 
    }
    
    #sidebar.hess-sidebar.mobile-open,
    nav#sidebar.hess-sidebar.mobile-open,
    .hess-sidebar.mobile-open {
        transform: translateX(0) !important;
    }
    
    /* Mobile Close Button */
    .hess-sidebar-close-mobile {
        display: block;
        position: fixed !important;
        top: 0.75rem !important;
        right: 0.75rem !important;
        z-index: 999999 !important;
        background-color: #FFFFFF !important;
        border: 1px solid #D1D5DB !important;
        border-radius: 0.25rem !important;
        padding: 0.5rem !important;
        cursor: pointer !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .hess-sidebar-close-mobile:hover {
        background-color: #FFFFFF !important; /* Disable hover on mobile */
    }
    
    .hess-sidebar-close-mobile svg {
        width: 24px;
        height: 24px;
        color: #374151;
    }
    
    /* Disable hover effects on mobile - hover doesn't work well on touch devices */
    .hess-sidebar-parent-link:hover {
        background-color: inherit !important;
        color: inherit !important;
    }
    
    .hess-sidebar-menu > li.active > .hess-sidebar-parent-link:hover {
        background-color: #EFF6FF !important;
        color: #2563EB !important;
    }
    
    .hess-sidebar-submenu li a:hover {
        background-color: inherit !important;
        color: inherit !important;
    }
    
    .hess-sidebar-history-list a:hover {
        background-color: inherit !important;
        color: inherit !important;
    }
    
    .hess-sidebar-logo:hover {
        background-color: #FFFFFF !important;
    }
    
    .hess-sidebar-logo:hover img {
        opacity: 1 !important;
    }
    
    /* Sidebar font size increase for mobile */
    .hess-sidebar-parent-link {
        font-size: 1rem !important; /* Increased from 0.875rem */
    }
    
    .hess-sidebar-submenu li a {
        font-size: 0.9375rem !important; /* Increased from 0.875rem */
    }
    
    .hess-sidebar-history-list a {
        font-size: 0.9375rem !important; /* Increased from 0.8125rem */
    }
    
    /* Sidebar overlay backdrop */
    .hess-sidebar-overlay {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100vh !important;
        background-color: rgba(0, 0, 0, 0.5) !important;
        z-index: 99998 !important; 
        pointer-events: none !important; 
    }
    
    .hess-sidebar-overlay.active {
        display: block !important;
        pointer-events: auto !important;
    }
    
    /* Adjust body margin when sidebar is present */
    body.has-sidebar,
    body.hess-body.has-sidebar {
        margin-left: 0 !important;
    }
    
    /* Main content adjustments */
    .main-content.has-sidebar {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Header adjustments */
    .hess-header {
        width: 100% !important;
        margin-left: 0 !important;
    }
    
    /* Header right section */
    .hess-header-right {
        flex-direction: column;
        align-items: flex-end;
        gap: 0.5rem;
    }
    
    .hess-header-search-time-group {
        width: 100%;
        max-width: 100%;
    }
    
    .hess-header-search-input {
        width: 100%;
        max-width: 100%;
    }
    
    /* Login page adjustments - Keep split layout until 768px */
    /* No changes needed here - right panel stays visible */
    
    .login-card {
        width: 100%;
        padding: 1rem;
    }
    
    .login-title {
        font-size: 1rem;
        padding: 0.5rem;
        line-height: 1.4;
        margin-bottom: 1rem;
    }
    
    .login-title sup {
        font-size: 0.6em;
    }
    
    .login-form {
        gap: 0.75rem;
    }
    
    .login-input {
        font-size: 16px; 
    }
    
    .login-button {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    .login-text {
        font-size: 0.875rem;
    }
    
    .error-box {
        margin-top: 1rem;
        padding: 1rem;
    }
    
    /* Utility selection page adjustments */
    .utility-select-container {
        padding: 0.5rem;
        margin-top: 0;
    }
    
    .utility-select-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
        padding: 0.75rem 0;
    }
    
    .utility-header-controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .utility-search-container {
        width: 100%;
    }
    
    .utility-search-input {
        width: 100%;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .utility-select-title {
        font-size: 1.125rem;
        margin: 0;
    }
    
    .utility-view-toggle {
        width: 100%;
        justify-content: flex-start;
        gap: 0.5rem;
    }
    
    .utility-radio-label {
        flex: 1;
    }
    
    .utility-radio-text {
        font-size: 0.875rem;
    }
    
    .utility-selection-content {
        padding: 0.5rem 0;
        width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
        max-height: calc(100vh - 150px);
    }
    
    /* Utility selection content - make tables/grids responsive */
    .utility-selection-content table {
        width: 100% !important;
        max-width: 100% !important;
        font-size: 0.875rem;
        table-layout: auto;
        border-collapse: collapse;
        display: block;
    }
    
    .utility-selection-content table tbody {
        display: block;
        width: 100%;
    }
    
    .utility-selection-content table tr {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 0.5rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Default: 2 columns on mobile */
    .utility-selection-content table td {
        display: block;
        width: calc(50% - 1rem) !important;
        max-width: calc(50% - 1rem) !important;
        padding: 0.75rem !important;
        margin: 0.5rem;
        box-sizing: border-box;
        text-align: center;
    }
    
    @media (max-width: 480px) {
        .utility-selection-content table td {
            width: calc(100% - 1rem) !important;
            max-width: calc(100% - 1rem) !important;
            margin: 0.5rem;
        }
    }
    
    /* Handle section headers */
    .utility-selection-content table tr:has(td:only-child) {
        display: block;
    }
    
    .utility-selection-content table tr td:only-child {
        width: 100% !important;
        max-width: 100% !important;
        text-align: left !important;
        font-weight: bold;
        background-color: #E5E7EB;
        padding: 0.75rem !important;
        margin: 0.5rem 0 !important;
    }
    
    /* Fallback for browsers without :has() */
    .utility-selection-content table tr td[colspan="4"],
    .utility-selection-content table tr td[colspan="5"] {
        width: 100% !important;
        max-width: 100% !important;
        text-align: left !important;
        font-weight: bold;
        background-color: #E5E7EB;
        padding: 0.75rem !important;
        margin: 0.5rem 0 !important;
    }
    
    .utility-selection-content img {
        max-width: 100% !important;
        width: auto !important;
        height: auto !important;
        max-height: 150px;
        display: block;
        margin: 0 auto;
    }
    
    /* Grid page adjustments */
    .hess-grid-page-container {
        padding: 0.5rem;
    }
    
    .hess-grid-page-title {
        font-size: 1rem;
        padding:0 !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Collapsible Filter Styles */
    .hess-grid-filter,
    .hess-graph-parameters {
        flex-direction: column;
        gap: 0.5rem;
        position: relative;
    }
    
    .hess-filter-toggle {
        width: 100%;
        background-color: #4B5563;
        color: #FFFFFF;
        border: none;
        border-radius: 0.375rem;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        font-weight: bold;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 0rem;
        transition: background-color 0.2s;
    }
    
    .hess-filter-toggle:hover {
        background-color: #374151;
    }
    
    /* Disable hover effects for filter toggle */
    .hess-filter-toggle:hover {
        background-color: #4B5563 !important;
    }
    
    .hess-filter-toggle:active {
        background-color: #1F2937;
    }
    
    .hess-filter-toggle-icon {
        font-size: 0.75rem;
        transition: transform 0.2s;
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }
    
    .hess-filter-toggle-text {
        flex: 1;
        text-align: left;
    }
    
    .hess-grid-filter-collapsed form,
    .hess-graph-parameters.hess-grid-filter-collapsed form {
        display: none !important;
    }
    
    .hess-grid-filter:not(.hess-grid-filter-collapsed) form,
    .hess-graph-parameters:not(.hess-grid-filter-collapsed) form {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 1rem !important;
        align-items: flex-start !important;
    }
    
    .hess-grid-filter-select {
        width: 100%;
    }
    
    .hess-grid-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .hess-grid-action-button {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    
    .hess-grid-filter form > .hess-grid-filter-button:not(.hess-grid-filter-row .hess-grid-filter-button) {
        position: static !important;
        width: 100%;
        margin: 1rem auto 0;
        text-align: center;
        justify-content: center;
        right: auto !important;
        bottom: auto !important;
    }
    
    /* Footer adjustments */
    .hess-footer {
        width: 100% !important;
        margin-left: 0 !important;
        padding: 0.1rem !important;
        font-size: 0.75rem;
        position: static !important;
        bottom: auto !important;
    }
    
    /* User dropdown menu adjustments */
    .hess-header-user-dropdown {
        position: relative;
    }
    
    .hess-header-user-dropdown-menu {
        right: 0;
        left: auto;
    }
    
    
    .hess-detail-image {
        display: block !important;
        visibility: visible !important;
    }
    
    .hess-detail-title {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .hess-detail-title-content {
        width: 100%;
        margin-bottom: 0rem;
    }
    
    .hess-detail-navigation {
        width: 100%;
        flex-wrap: wrap;
    }

    .hess-detail-column-left,
    .hess-detail-column-right{
        padding-right: 0px !important;
        gap: 0 !important;
    }
    
    /* Alert Summary Cards */
    .alert-summary-container {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 0.375rem !important;
        margin: 0.5rem 0 !important;
    }
    
    .alert-summary-card {
        flex: 0 0 auto !important;
        min-width: auto !important;
        width: calc(33% - 0.1875rem) !important;
        max-width: calc(33% - 0.1875rem) !important;
        padding: 0.375rem 0.5rem !important;
        margin: 0 !important;
    }
    
    .alert-summary-card .count {
        font-size: 14pt !important;
        line-height: 1.1 !important;
        margin: 0 !important;
    }
    
    .alert-summary-card .label {
        font-size: 12px !important;
        margin-bottom: 0.125rem !important;
        line-height: 1.1 !important;
    }
    
    /* Dashboard Tabs */
    .dashboard-tabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        flex-wrap: nowrap !important;
        white-space: nowrap !important;
    }
    
    .dashboard-tab {
        padding: 10px 16px !important;
        font-size: 12px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }
    
    .filter-grid {
        gap: 12px !important;
    }
    
    /* Modal adjustments */
    .hess-alert-modal {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 90vh !important;
        margin: 1rem !important;
    }
    
    .hess-alert-modal-header {
        padding: 0.625rem 0.875rem !important;
    }
    
    .hess-alert-modal-title {
        font-size: 1rem !important;
    }
    
    .hess-alert-modal-body {
        padding: 1rem !important;
    }
    
    .hess-alert-modal-body .alert-summary-container {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    
    .hess-alert-modal-body .alert-summary-card {
        width: 100% !important;
        min-width: auto !important;
    }
    
    /* YouTrack modal mobile adjustments */
    .youtrack-modal {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 90vh !important;
        margin: 0.5rem !important;
    }
    
    .youtrack-modal-header {
        padding: 0.625rem 0.75rem !important;
    }
    
    .youtrack-modal-title {
        font-size: 0.9375rem !important;
    }
    
    .youtrack-modal-body {
        min-height: 350px !important;
    }

    .hess-device-summary-sidebar {
        height: 50vh;
    }
    
    .hess-device-summary-sidebar.active ~ .hess-map-key-overlay {
        bottom: 50vh;
    }
    
    /* Chart responsive styles */
    .hess-chart-container {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .hess-chart-container > div[id^="chart-"],
    .hess-chart-container > div[id*="chart-"] {
        min-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        min-height: 200px !important;
        max-width: 100% !important;
    }
    
    .hess-chart-linkout {
        top: 5px !important;
        left: 5px !important;
    }
    
    .hess-detail-graph-item {
        box-shadow: none !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .hess-detail-card-header{
        justify-content: center !important;
    }


    /* 2. As a failsafe, aggressively contain the entire main content area on these pages. */
    /* This ensures the sidebar's 90% calculation is always based on the device screen width. */
    .main-content {
        overflow-x: hidden !important;
    }

    /* 1. Default State: Visible when sidebar is collapsed/closed */
    .hess-map-key-overlay,
    .hess-map-filter-toggle-btn {
        display: block !important; /* Add !important to override default display: none from hess.css */
        /* You might want 'display: flex' or 'display: inline-block' 
           depending on their original layout, but 'block' is safe 
           if you just need them visible.
        */
    }

    /* 2. State when Sidebar is EXPANDED (has the .mobile-open class) */
    /* HIDE the elements by using the combined selector */
    .hess-sidebar.mobile-open ~ .main-content .hess-map-key-overlay,
    .hess-sidebar.mobile-open ~ .main-content .hess-map-filter-toggle-btn,
    .hess-sidebar.mobile-open + .hess-map-key-overlay, /* If overlay is an immediate sibling */
    .hess-sidebar.mobile-open + .hess-map-filter-toggle-btn {
        display: none !important;
    }
    
   
    /* Based on your existing code: .hess-device-summary-sidebar.active ~ .hess-map-key-overlay */
    /* If the elements are siblings of the main-content (~) and children of the body, use: */
    #sidebar.mobile-open ~ .hess-map-key-overlay,
    #sidebar.mobile-open ~ .hess-map-filter-toggle-btn {
        display: none !important;
    }
    
    /* Final catch-all for the mobile-open state on the sidebar itself */
    #sidebar.hess-sidebar.mobile-open ~ .main-content .hess-map-key-overlay,
    #sidebar.hess-sidebar.mobile-open ~ .main-content .hess-map-filter-toggle-btn {
        display: none !important;
    }

    .hess-detail-page {
        grid-template-columns: 1fr;
    }
    
    .hess-detail-title,
    .hess-detail-image,
    .hess-detail-card,
    .hess-detail-navigation,
    .hess-detail-graphs {
        grid-column: 1;
    }
    
    .hess-detail-navigation {
        display: flex !important;
        visibility: visible !important;
        flex-wrap: wrap;
        gap: 0.25rem;
        margin-top: 0.5rem;
    }
    
    .hess-detail-image {
        display: block !important;
        visibility: visible !important;
    }
    
    .hess-detail-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .hess-detail-title-content {
        width: 100%;
    }
    
    .hess-detail-navigation {
        width: 100%;
        justify-content: flex-start;
    }
    
    .hess-detail-navigation input[type="button"],
    .hess-detail-navigation button {
        font-size: 0.6875rem;
        padding: 0.25rem 0.5rem;
        min-width: 2rem;
        height: 1.75rem;
    }
    
    .hess-detail-navigation select {
        font-size: 0.6875rem;
        padding: 0.25rem 0.5rem;
        height: 1.75rem;
        max-width: 150px;
    }

    .hess-header-container {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .hess-header-center {
        width: 100%;
        align-items: flex-start;
    }
    
    .hess-header-right {
        width: 100%;
        align-items: flex-start;
    }
    
    .hess-support-button {
        position: relative;
        top: auto;
        right: auto;
        margin-top: 0.5rem;
    }

    .hess-detail-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .hide-mobile {
        display: none !important;
    }

}

/*  PHONE & SMALL DEVICE STYLES (Max-Width: 768px) */
@media (max-width: 768px) {

    body, html {
        height: auto !important;
        min-height: 100% !important;
        overflow-y: auto !important; 
        font-size: 1rem !important;
    }

    .login-container,
    .login-container-reset {
        padding: 0;
        margin-top: 0;
        height: 100vh;
        overflow: hidden;
    }
    
    .login-main-content,
    .login-main {
        flex-direction: column;
        padding: 0;
        min-height: 100vh;
        height: 100vh;
        gap: 0;
        overflow: hidden;
    }
    
    /* Left panel - full width on mobile, not fixed */
    .login-left-panel {
        position: relative !important;
        width: 100% !important;
        height: 100vh !important;
        min-height: 100vh !important;
        padding: 0rem !important;
        margin-left: 0 !important;
        box-shadow: none !important;
        order: 1;
        overflow: hidden;
    }
    
    /* Hide right panel (image) on mobile */
    .login-right-panel {
        display: none !important;
    }
    
    /* Hide support overlay on mobile */
    .login-support-overlay {
        display: none !important;
    }
    
    .hess-detail-page{
        gap: 0 !important;
    }
    .hess-detail-navigation {
        display: none !important;
    }

    .login-card{
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
        border-radius: 0.75rem !important;
    }
    
    body:has(.utility-select-container) .hess-header-right {
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        flex-direction: row !important;
        align-items: center !important;
        width: auto !important;
        max-width: 50% !important;
        z-index: 9999; 
        
    }

    .utility-select-header{
        display: none !important;
    }
    
    /* Sidebar - Mobile Overlay */
    #sidebar.hess-sidebar,
    nav#sidebar.hess-sidebar,
    .hess-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important; 
        height: 100vh !important;
        z-index: 99999 !important; 
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease-in-out !important;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15) !important;
        display: block !important;
        visibility: visible !important;
        overflow-y: auto !important;
        background-color: #FFFFFF !important; 
        font-size: 1rem !important;
    }

    /* --- PART A: DABLE STYLES (Original) --- */

    /* 1. Reset Table Structure to Block Elements */
    div[id$="Dable"] table, 
    div[id$="Dable"] table thead, 
    div[id$="Dable"] table tbody, 
    div[id$="Dable"] table th, 
    div[id$="Dable"] table td, 
    div[id$="Dable"] table tr {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    /* 2. Hide Table Headers (Visual only) */
    div[id$="Dable"] table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    /* 3. Style Rows as "Cards" */
    div[id$="Dable"] table tbody tr {
        background-color: #fff;
        border-radius: 0rem;
        margin-bottom: 0rem;
        box-shadow: 0 1px 1px rgba(0,0,0,0.1);
        border-bottom: 3px solid #eee !important;
        padding: 0rem;
    }

    div[id$="Dable"] table tbody tr:nth-child(even),
    div[id$="Dable"] table tbody tr:nth-child(odd) {
        background-color: #fff; 
    }
    
    /* Keep status colors */
    div[id$="Dable"] table tbody tr.inactive { border-left: 5px solid #991B1B; }
    div[id$="Dable"] table tbody tr.autoactivate { border-left: 5px solid #D97706; }
    div[id$="Dable"] table tbody tr.retired { border-left: 5px solid #000; }

    /* 4. Style Cells */
    div[id$="Dable"] table td {
        border: none !important;
        border-bottom: 1px solid #eee !important;
        position: relative;
        padding: 0.5rem 0.75rem !important;
        text-align: left !important;
        min-height: auto;
        display: block !important;
    }
    
    /* Make all direct children of TD inline so they flow on one line */
    /* EXCEPT for dable-group-header which uses flexbox */
    div[id$="Dable"] table td:not(.dable-group-header) > * {
        display: inline !important;
        white-space: nowrap !important;
    }
    
    /* Ensure dable-group-header children work with flexbox */
    .dable-group-header > * {
        display: inline-flex !important;
        align-items: center !important;
        white-space: normal !important;
    }
    
    /* Ensure all content inside stays inline */
    div[id$="Dable"] table td a,
    div[id$="Dable"] table td span {
        display: inline !important;
        white-space: nowrap !important;
    }
    
    /* Images should be inline 
    div[id$="Dable"] table td img {
        display: inline !important;
        vertical-align: middle;
        margin-left: 8px !important;
    }*/
    
    /* Disable hover effects for Dable tables on mobile */
    div[id$="Dable"] table tbody tr:hover {
        background-color: inherit !important;
    }
    
    div[id$="Dable"] table tbody tr.inactive:hover,
    div[id$="Dable"] table tbody tr.autoactivate:hover,
    div[id$="Dable"] table tbody tr.retired:hover,
    div[id$="Dable"] table tbody tr.upgrade-successful:hover,
    div[id$="Dable"] table tbody tr.upgrade-pending:hover,
    div[id$="Dable"] table tbody tr.upgrade-in-progress:hover,
    div[id$="Dable"] table tbody tr.upgrade-failed:hover,
    div[id$="Dable"] table tbody tr.upgrade-cancelled:hover {
        background-color: inherit !important;
    }
    
    div[id$="Dable"] table a:hover {
        text-decoration: none !important;
        color: inherit !important;
    }
    
    div[id$="Dable"] table td img:hover {
        transform: none !important;
        filter: none !important;
        opacity: inherit !important;
    }
    
    div[id$="Dable_footer"] li.table-page input[type="button"]:hover:not(:disabled),
    div[id$="Dable_footer"] li.hess-dable-pager-btn input[type="button"]:hover:not(:disabled) {
        background-color: #FFFFFF !important;
        border-color: #9CA3AF !important;
    }
    
    .dable-group-header:hover {
        background-color: inherit !important;
    }
    
    .dable-group-header:hover .dable-arrow {
        transform: none !important;
    }

    /* Fix dable-arrow vertical alignment in mobile view */
    .dable-group-header {
        display: flex !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        min-height: 2.5em !important;
    }
    
    .dable-arrow-wrapper {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
        width: 12px !important;
        height: 1.5em !important;
        min-height: 1.5em !important;
        line-height: 1.5em !important;
        margin-right: 12px !important;
    }
    
    .dable-arrow {
        margin: 0 !important;
        vertical-align: middle !important;
        width: 0 !important;
        height: 0 !important;
    }
    
    .dable-group-label {
        display: inline-flex !important;
        align-items: center !important;
        flex: 1 1 auto !important;
    }


    .hess-dable-pager-btn input[type="button"]:hover,
    .dable-reset-sort:hover {
        background-color: inherit !important;
        border-color: inherit !important;
    }
    
    .dable-column-selector-btn:hover {
        background-color: inherit !important;
    }
    
    .dable-column-selector-btn-disabled:hover {
        background-color: inherit !important;
    }
    
    .dable-column-selector-popup label:hover {
        background-color: inherit !important;
    }

    /* Keep hidden columns hidden in mobile card view */
    div[id$="Dable"] table td.dable-column-hidden,
    div[id$="Dable"] table th.dable-column-hidden {
        display: none !important;
    }
    
    div[id$="Dable"] table td:last-child {
        border-bottom: none !important;
    }

    /* 5. Add "Fake" Headers using CSS Content - Stacked on top */
    div[id$="Dable"] table td::before {
        position: static !important;
        order: -1;
        width: 100% !important;
        padding: 0 !important;
        margin-bottom: 0.25rem !important;
        white-space: nowrap;
        transform: none !important;
        text-align: left;
        font-weight: bold;
        color: #374151;
        content: attr(data-label);
        display: block;
    }
    
    /* 7. Stack Header/Footer Controls */
    div[id$="Dable_header"], 
    div[id$="Dable_footer"] {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    div[id$="Dable_header"] > div,
    div[id$="Dable_footer"] > div {
        width: 100%;
        justify-content: space-between;
        margin-bottom: 0.5rem;
    }
    
    /* Override: Keep hess-dable-header columns and search on same line */
    .hess-dable-header {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
    }
    
    .hess-dable-header > div {
        width: auto !important;
        margin-bottom: 0 !important;
        flex-shrink: 0;
    }
    
    /* Float left for columns selector (first div) */
    .hess-dable-header > div:first-child {
        float: left;
        margin-right: auto;
    }
    
    /* Float right for search (last div) */
    .hess-dable-header > div:last-child {
        float: right;
        margin-left: auto;
    }
    
    div[id$="Dable_footer"] ul {
        justify-content: center;
        width: 100%;
    }

    /* --- PART B: DETAIL CARD STACKING (View Mode ONLY) --- */

    /* 1. Target the TABLES */
    .hess-detail-card table,
    .hess-detail-card-nested table {
        display: block !important;
        width: 100% !important;
        border: none !important;
        background: transparent !important;
    }

    /* 2. Target the TBODY & Hide THEAD */
    .hess-detail-card table tbody,
    .hess-detail-card-nested table tbody {
        display: block !important;
        width: 100% !important;
    }
    .hess-detail-card table thead,
    .hess-detail-card-nested table thead {
        display: none !important;
    }
    
    /* 3. ROW STYLES - The "Card" Container */
    .hess-detail-card table tr,
    .hess-detail-card-nested table tr {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        margin-bottom: 0.5rem !important;
        background-color: #ffffff !important;
        border: 1px solid #E5E7EB !important;
        box-shadow: none !important;
        overflow: hidden !important;
    }

    /* 4. HEADER CELL STYLES (Parameter Name) */
    .hess-detail-card table tr td:first-child,
    .hess-detail-card-nested table tr td:first-child {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
        background-color: #e4e7eb !important;
        color: #111827 !important;
        font-weight: 800 !important;
        text-transform: uppercase;
        font-size: 0.85rem !important;
        padding: 0.3rem !important;
        border-bottom: 1px solid #E5E7EB !important;
        text-align: left !important;
        line-height: 1.2 !important;
    }
    .hess-detail-card table tr td:first-child strong {
        font-weight: 800 !important;
        color: inherit !important;
    }

    /* 5. DATA CELLS (Side-by-Side Read-Only Layout) */
    .hess-detail-card table tr td:not(:first-child),
    .hess-detail-card-nested table tr td:not(:first-child) {
        display: flex !important;
        flex-wrap: nowrap !important; /* CRITICAL: Prevents unwanted wrapping here */
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 0.55rem !important;
        border-bottom: 1px solid #F9FAFB !important;
        text-align: right !important;
        font-size: 1rem !important;
        min-height: 3rem !important;
        background-color: #fff !important;
    }
    .hess-detail-card table tr td:last-child {
        border-bottom: none !important;
    }

    /* 6. INJECT LABELS */
    .hess-detail-card table tr td:not(:first-child)::before {
        font-weight: 600;
        color: #6B7280;
        font-size: 0.85rem;
        margin-right: auto;
        white-space: nowrap !important; 
        flex-shrink: 0;
        content: attr(data-label);
    }


    /* 7. Fix for Unit Spans and Alerts */
    .hess-unit {
        color: #9CA3AF;
        font-size: 0.75rem;
        margin-left: 4px;
        display: inline-block;
    }
    .hess-detail-card table td span {
        display: inline-flex;
        align-items: center;
    }


    /* --- PART C: EDIT FORM SPECIFIC STYLES (Clean Stacked Layout) --- */
    #transformereditForm .hess-detail-card table tr td:not(:first-child)::before,
    #dtmeditForm .hess-detail-card table tr td:not(:first-child)::before {
        display: none !important;
    }

    #transformereditForm .hess-detail-card table tr td:not(:first-child),
    #dtmeditForm .hess-detail-card table tr td:not(:first-child) {
        /* OVERRIDE: Allow items to wrap, removing the space-between effect */
        flex-wrap: wrap !important;
        justify-content: flex-start !important; 
        align-items: flex-start !important; /* Stacked content aligns top-left */
        gap: 8px !important;
        height: auto !important;
        padding-bottom: 1rem !important;
        text-align: left !important;
    }

    /* Mobile line break div - forces line breaks in flexbox containers */
    #transformereditForm .hess-detail-card table tr td:not(:first-child) .hess-mobile-line-break,
    #dtmeditForm .hess-detail-card table tr td:not(:first-child) .hess-mobile-line-break,
    .hess-detail-card table tr td:not(:first-child) .hess-mobile-line-break {
        flex-basis: 100% !important;
        width: 100% !important;
        height: 0 !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        line-height: 0 !important;
    }

    #transformereditForm table input,
    #transformereditForm table select,
    #transformereditForm table textarea,
    #dtmeditForm table input,
    #dtmeditForm table select,
    #dtmeditForm table textarea {
        flex: 1 0 100% !important; /* Forces the input to take 100% width and wrap to new row */
        width: 100% !important;
        max-width: 100% !important;
        height: 44px !important; 
        padding: 0.5rem !important;
        box-sizing: border-box !important;
        font-size: 16px !important; 
        border: 1px solid #D1D5DB !important;
        border-radius: 0.375rem !important;
        display: block !important;
        margin-top: 0.25rem !important; /* Small space under any helper text */
    }

    #dtmeditForm .alert-section table input,
    #transformereditForm .alert-section table input,
    #gfmeditForm .alert-section table input{
        max-width: 85px !important;
    }

    /* Allow buttons to shrink and wrap in polyphase sections */
    #transformereditForm .hess-detail-card table tr td:not(:first-child) button.hess-detail-form-button-small {
        flex: 1 1 auto !important; /* Allow buttons to shrink and grow */
        min-width: 0 !important; /* Allow shrinking below content size */
        max-width: 100% !important;
        word-wrap: break-word !important;
        white-space: normal !important;
    }

    #transformereditForm table button,
    #dtmeditForm table button,
    #transformereditForm table .btn,
    #dtmeditForm table .btn,
    #transformereditForm table span,
    #dtmeditForm table span {
        flex: 0 0 auto !important; /* Ensure these elements don't stretch */
        display: inline-block !important; 
        margin-top: 0.5rem !important;
        text-align: left !important;
    }

    .mobile-block-link-fix {
        display: block !important;
    }

    /* Fix transformeredit.jsp scrolling issues on mobile */
    /* Make the map dialog responsive */
    #SetLatLongMap {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 95vw !important;
        max-width: 800px !important;
        height: auto !important;
        max-height: 90vh !important;
    }
    
    #SetLatLongMap #map-canvas {
        width: 100% !important;
        max-width: 100% !important;
        height: 400px !important;
    }
    
    /* Make error box responsive */
    #errorbox {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90vw !important;
        max-width: 600px !important;
        min-height: auto !important;
    }

    
    /* Ensure your main content container does not prevent the body from scrolling */
    .main-content {
        height: auto !important;
        overflow-y: hidden !important;
    }

    /* Ensure main content doesn't cause overflow */
    .main-content.has-sidebar {
        overflow-x: hidden !important;
    }

    .mobile-link-stacker {
        display: flex;
        flex-direction: column; 
        align-items: flex-start;
        width: 100%;
        gap: 0.5rem;
        margin-top: 0.25rem;
    }

    .mobile-link-stacker a{
        display: block;
        width: 100%; 
        box-sizing: border-box;
        text-align: center !important;
    }

    li[data-menu="analytics"] {
        display: none !important;
    }

    #hess-extremes-history-table td:first-child{
        width: 100% !important;
    }

    .hess-detail-card {
        background-color: inherit !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0px !important;
        padding: 0.1rem !important;
        margin-bottom: 0.5rem !important;
    }

    .hess-detail-card h2, .hess-detail-card h3{
        text-align: center !important;
        justify-content: center !important;
    }

    .hess-detail-title-content{
        text-align: center !important;
        justify-content: center !important;
    }

    .hess-detail-card tbody tr:nth-child(even){
        background-color: #fff !important;
    }
    .secondary-button{
        border: 1px solid #9CA3AF;
    }
    .hess-dable-pager-btn input{
        padding: 0.2rem!important;
    }

    .stack-mobile {
        display: block !important; 
        white-space: normal !important; 
    }
    
    .stack-mobile .stacked-value {
        display: block !important; 
        margin-bottom: 2px;
    }

    .login-title {
        font-size: 1.75rem;
    }

    .error-box {
        right: auto;
        width: 100%;
    }

    .utility-select-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .utility-view-toggle {
        width: 100%;
        justify-content: flex-start;
    }
    
    .utility-radio-custom {
        min-width: 70px;
    }
    
    .utility-view-icon {
        height: 24px;
    }

    .hess-map-filter-toggle-btn {
        display: block !important; /* Add !important to ensure it's visible and overrides default display: none */
    }

    .hess-sidebar-filters {
        position: fixed !important;
        left: auto !important;
        right: -300px !important;
        top: 50px !important;
        width: 280px !important;
        height: calc(100vh - 60px) !important;
        max-height: calc(100vh - 60px) !important;
        z-index: 98 !important;
        border-right: none !important;
        border-left: 1px solid #ddd !important;
        transition: right 0.3s ease-in-out;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    }

    .hess-sidebar-filters.mobile-active {
        right: 0 !important;
    }

    #map_canvas {
        left: 0 !important;
        width: 100% !important;
        height: calc(100vh - 125px) !important;
        min-height: calc(100vh - 125px) !important;
        box-sizing: border-box !important;
    }
    
    .hess-map-container {
        min-height: calc(100vh - 125px) !important;
        height: calc(100vh - 125px) !important;
    }

    .hess-map-key-overlay {
        left: 20px !important;
        bottom: 20px !important;
        right: auto !important;
        max-width: calc(100vw - 40px);
    }

    .hess-map-filter-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 97;
    }

    .hess-map-filter-overlay.active {
        display: block;
    }

    .hess-device-summary-sidebar {
        height: 50vh !important;
    }
    
    .hess-device-summary-sidebar.active ~ .hess-map-key-overlay {
        bottom: 50vh !important;
    }
    
    .hess-device-summary-content > div {
        grid-template-columns: 1fr !important;
        gap: 0.1rem !important;
    }

    .hess-device-summary-footer {
        padding: 0.25rem;
    }

    .hess-graph-page {
        flex-direction: column;
        height: calc(100vh - 200px);
        min-height: calc(100vh - 200px);
        display: flex;
    }
    .hess-graph-parameters {
        flex: 0 0 auto;
        max-height: 400px;
        overflow-y: auto;
    }
    .hess-graph-area {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .hess-graph-area iframe {
        flex: 1;
        min-height: 0;
    }

    .hess-footer {
        position: static !important;
        bottom: auto !important;
    }


    .login-container,
    .login-container-reset,
    .login-main-content,
    .login-main,
    .login-left-panel {
        box-sizing: border-box !important;
    }

    .hide-mobile img {
        display: none !important;
    } /*for dable link images in tables*/


    .dable-reset-sort {
        font-weight: 500 !important;
        font-size: 0.875rem !important;
    }
    .critical-section{
        padding: 0.1rem !important;
    }
}

@media (min-width: 1024px) {
    .login-main-content,
    .login-main {
        flex-direction: row;
        gap: 1.5rem;
        align-items: center;
    }

    .slideshow-container {
        display: block;
    }
}
