/* Modern Header Styles */
.modern-header {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 20px 0;
    position: relative;
    border-bottom: 2px solid rgba(100, 168, 181, 0.2);
    margin-bottom: 10px;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.header-container {
    width: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    gap: 20px;
}

.logo-left, .logo-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.logo-left {
    margin-left: 0;
}

.logo-right {
    margin-right: 45px;
}

.header-logo {
    height: 70px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.header-center {
    flex: 1;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.header-title {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: #64a8b5;
    margin: 0;
    letter-spacing: -0.5px;
    line-height: 1.2;
    background: #64a8b5;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}

/* Fallback for browsers that don't support text gradients */
@supports not (-webkit-background-clip: text) {
    .header-title {
        background: none;
        color: #4CAF50;
    }
}

.header-credit {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 13px;
    font-weight: 400;
    color: #7f8c8d;
    margin: 8px 0 0 0;
    font-style: italic;
}

/* Hide the old title div */
.title {
    display: none;
}



/* Responsive header adjustments */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .logo-left, .logo-right {
        margin: 0;
    }
    
    .header-logo {
        height: 60px;
    }
    
    .header-title {
        font-size: 20px;
    }
    
    .header-credit {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 18px;
    }
    
    .header-logo {
        height: 50px;
    }
}


body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #64a8b5;  /* Add this line */
    font-family: Arial, sans-serif;
    overflow: auto; 
    text-align: center; 
}
.title {
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    color: #333;
}
.svg-container {
    width: 100vw;
    height: 70vh;
    overflow: auto;
    border: 2px solid #ccc;
    background-color: #fff;
    position: relative;
    margin-bottom: 20px;
    flex-shrink: 0;
}
#file-input {
    display: none;
}
#custom-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 16px 32px;
    background: linear-gradient(135deg, #64a8b5 0%, #4a8a96 100%);
    color: white;
    cursor: pointer;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(100, 168, 181, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 250px;
    justify-content: center;
}

#custom-button:hover {
    background: linear-gradient(135deg, #4a8a96 0%, #3a7a86 100%);
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 8px 25px rgba(100, 168, 181, 0.5);
}

#custom-button:active {
    transform: translate(-50%, -50%) scale(1.02);
    box-shadow: 0 4px 15px rgba(100, 168, 181, 0.4);
}


.upload-icon {
    width: 32px;
    height: 32px;
    fill: currentColor;
}

/* Hide button after successful upload */
#custom-button.hidden {
    display: none !important;
}

/* Optional: Add icons to export buttons */
.export-btn::before {
    content: '';
    width: 20px;
    height: 20px;
    display: inline-block;
    margin-right: 8px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.export-btn.pdf-btn::before {
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" fill="white" viewBox="0 0 24 24"%3E%3Cpath d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18.5,9H13V3.5L18.5,9M6,20V4H11V10H18V20H6Z"/%3E%3C/svg%3E');
}

.export-btn.excel-btn::before {
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" fill="white" viewBox="0 0 24 24"%3E%3Cpath d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M15.8,20H14L12,16.6L10,20H8.2L11.1,15L8.2,10H10L12,13.4L14,10H15.8L12.9,15L15.8,20M13,9V3.5L18.5,9H13Z"/%3E%3C/svg%3E');
}


.link,
.link.SAPOHLLink,
.mlink {
    fill: none;
    stroke: #07df58; 
    stroke-width: 2px;
    transition: stroke 0.3s;
    cursor: pointer;
}
.link.open,
.link.SAPOHLLink.open,
.mlink.open {
    stroke: black; 
}
.hv-station rect {
    fill: rgb(255, 255, 0); 
    stroke: black;
    transition: stroke 0.3s;
}
.mv-station rect {
    fill: #fff; 
    stroke: black;
    transition: stroke 0.3s;
}
.cb-square {
    fill: #ff7272; 
    stroke: black;
    cursor: pointer;
    transition: fill 0.3s;
}
.fuse-switch {
    fill: #07df58; 
    stroke: black;
    cursor: pointer;
    transition: fill 0.3s;
}
.fuse-switch.transformer {
    fill: #ff7272; 
}
.iso-circle {
    fill: #75d5f9; 
    stroke: black;
    cursor: pointer;
    transition: fill 0.3s;
}
.cb-square.open, 
.fuse-switch.open, 
.iso-circle.open {
    fill: white; 
}
.fuse-switch.transformer.open {
    fill: white; 
}
.iso-circle.ring-off {
    fill: #f49adb; 
    stroke: red;
    stroke-width: 3px; 
    transition: fill 0.3s;
}
.iso-circle.ring-off.open {
    fill: white; 
    stroke: red;
    stroke-width: 3px; 
}
.mv-station.energized rect {
    stroke: #07df58; 
}
.mv-station.de-energized rect {
    stroke: black; 
}
.textPM {
    font-size: 10px;
    fill: black;
}
.transformer-text {
    font-size: 8px;
    fill: black;
}
.occurrence-log {
    width: 90vw;
    border-collapse: collapse;
    background-color: white;
    margin-bottom: 20px;
    
}
.occurrence-log td, .occurrence-log th {
    border: solid 2pt black;
    padding: 5px;
    min-width: 90px;
}
.occurrence-log tr td {
    color: #3556a9;
    text-align: center;
    font-weight: 500;
}
.occurrence-log p {
    margin: 0;
    font-family: Arial, sans-serif;
    font-size: 11pt;
}
.controls {
    display: flex;
    gap: 20px;
    padding: 15px 25px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.controls label {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #64a8b5;
    margin-right: 8px;
}

.controls select {
    padding: 8px 12px;
    font-size: 14px;
    border: 2px solid #64a8b5;
    border-radius: 6px;
    background-color: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
}

.controls select:hover {
    border-color: #4a8a96;
    box-shadow: 0 2px 8px rgba(100, 168, 181, 0.2);
}

.controls select:focus {
    outline: none;
    border-color: #4a8a96;
    box-shadow: 0 0 0 3px rgba(100, 168, 181, 0.1);
}
.context-menu {
    position: fixed;
    background-color: white;
    border: 2px solid #64a8b5;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    display: none;
    min-width: 180px;
}

.context-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.context-menu li {
    padding: 12px 16px;
    cursor: pointer;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.context-menu li:last-child {
    border-bottom: none;
}

.context-menu li:hover {
    background: linear-gradient(135deg, #64a8b5 0%, #4a8a96 100%);
    color: white;
}

.context-menu li:active {
    background: linear-gradient(135deg, #4a8a96 0%, #3a7a86 100%);
}

.context-menu li.location-context-action {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    background: linear-gradient(135deg, #64a8b5 0%, #2d132d 100%);
}

.context-menu li#hv-location-action {
    color: #ffffff;
}

.context-menu li.location-context-action::before {
    content: '📍';
    font-size: 16px;
    line-height: 1;
}

.context-menu li.location-context-action:hover {
    background: linear-gradient(135deg, #4a8a96 0%, #2d132d 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.context-menu li#hv-location-action:hover {
    color: #ffffff;
}

/* Add attention icon to Report items */
.context-menu li[id^="report"]::before {
    content: '⚠️';
    font-size: 16px;
    margin-right: 4px;
}
.efi-bulb {
    pointer-events: none;
}
.efi-bulb.red {
    fill: red;
}
.efi-bulb.gray {
    fill: gray;
}
.efi-label {
    pointer-events: none;
    user-select: none;
}
.parallel-ring {
    fill: rgb(255, 202, 135) !important; 
}
.iso-circle.ring-off.parallel-ring {
    stroke: red;
    stroke-width: 3px;
}
.reset-button-group {
    pointer-events: all;
}
.reset-button-text {
    pointer-events: none;
    user-select: none;
}
.reset-button:hover {
    background-color: #45a049;
}
g.node rect[sstype="Feeder"] {
    width: 65px !important;  
    height: 45px !important; 
}
.svg-container {
    position: relative;
    overflow: auto;
    width: 100vw;
    height: 70vh;
    border: 2px solid #ccc;
    background-color: #fff;
    margin-bottom: 20px;
}
.occurrence-log td, .occurrence-log th {
    border: solid 2pt black;
    padding: 5px;
    min-width: 90px;
    text-align: center; 
}
.Occurrence-page1 {
    width: 90vw;
    padding-top: 10px;
    margin-bottom: 20px;
    margin-left: auto;
    margin-right: auto;
    margin: 0 !important;  /* Add this to override any shifts */
    padding-left: 0 !important;  /* Add this */
}
.Occurrence-page1 table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    margin-bottom: 20px;
}
.Occurrence-page1 td, 
.Occurrence-page1 th {
    border: solid 2pt black;
    padding: 5px;
    min-width: 90px;
    text-align: center;
}
.Occurrence-page1 p {
    margin: 0;
    font-family: Arial, sans-serif;
    font-size: 10pt;
    text-align: center !important;
    ;
}

.tables-container {
    width: 90vw;
    background-color: #ffffff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    margin: 20px auto !important;  /* Force center alignment */
    border: 1px solid #e5e7eb;
}

/* Header for the tables container */
.tables-container-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.tables-container-title {
    font-size: 20px;
    font-weight: 700;
    color: #64a8b5;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Ensure tables fit nicely within container */
.tables-container .occurrence-log,
.tables-container .Occurrence-page1 {
    width: 99%;
    margin: 0 !important;
    background-color: transparent !important;
}

.tables-container .Occurrence-page1 {
    margin-bottom: 20px !important;
}

/* Remove duplicate padding from Occurrence-page1 */
.tables-container .Occurrence-page1 {
    padding-top: 30px !important;
    width: 99% !important;
}

/* Adjust table styles within container */
.tables-container table {
    width: 99%;
    background-color: white;
    margin-bottom: 15px;
}
.export-buttons {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    justify-content: center;
    background-color: #ffffff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    margin-left: auto;
    margin-right: auto;
    margin-top: 20px;
    border: 1px solid #e5e7eb;
}
.export-btn {
    padding: 12px 40px;
    background: linear-gradient(135deg, #64a8b5 0%, #4a8a96 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    min-width: 200px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(100, 168, 181, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.export-btn:hover {
    background: linear-gradient(135deg, #4a8a96 0%, #3a7a86 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(100, 168, 181, 0.4);
}
.export-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(100, 168, 181, 0.3);
}
#table-context-menu {
    position: fixed;
    background-color: white;
    border: 1px solid #ccc;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
    display: none;
}
#table-context-menu ul {
    list-style: none;
    margin: 0;
    padding: 5px 0;
}
#table-context-menu li {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
}
#table-context-menu li:hover {
    background-color: #f0f0f0;
}
.no-select {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}
.minimized {
    display: none;
}
/* Add separator line between tables */
.tables-container .occurrence-log {
    padding-bottom: 20px;
    margin-bottom: 30px;
}

/* Zoom Controls */
/* Zoom Controls - Fixed position in container */
.zoom-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.zoom-controls.visible {
    opacity: 1;
    pointer-events: all;
}

.zoom-btn {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #64a8b5 0%, #4a8a96 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(100, 168, 181, 0.4);
    transition: all 0.3s ease;
    user-select: none;
}

.zoom-btn:hover {
    background: linear-gradient(135deg, #4a8a96 0%, #3a7a86 100%);
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(100, 168, 181, 0.5);
}

.zoom-btn:active {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(100, 168, 181, 0.3);
}

.zoom-btn:disabled {
    background: linear-gradient(135deg, #9ba8ae 0%, #7a8a96 100%);
    cursor: not-allowed;
    opacity: 0.6;
}

.zoom-btn:disabled:hover {
    transform: scale(1);
    box-shadow: 0 4px 10px rgba(100, 168, 181, 0.4);
}

.zoom-level {
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #64a8b5;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 45px;
}

/* Zoom is applied instantly (no transition) so the scale and the matching
   scroll compensation stay in sync and the diagram does not drift while zooming. */
.ringContainer {
    transition: none;
    transform-origin: 0 0;
    transform: scale(1);
}
#content-placeholder {
    display: block;
    overflow: visible;
    padding-top: 200px;
    min-width: 100%;
    min-height: 100%;
}
.svg-container svg {
    display: block;
    margin: 0 auto;
}

/* AI Summary Button */
.ai-summary-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.ai-summary-button {
    padding: 12px 32px;
    background: linear-gradient(135deg, #64a8b5 0%, #4a8a96 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(100, 168, 181, 0.3);
}

.ai-summary-button:hover {
    background: linear-gradient(135deg, #4a8a96 0%, #3a7a86 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(100, 168, 181, 0.4);
}

.ai-summary-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(100, 168, 181, 0.3);
}

.ai-icon {
    width: 24px;
    height: 24px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    background-color: #ffffff;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 95%;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: linear-gradient(135deg, #64a8b5 0%, #4a8a96 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    align-items: center;

}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    transition: transform 0.2s ease;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.close-modal:hover {
    transform: scale(1.2);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #64a8b5;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

.loading-spinner p {
    margin-top: 20px;
    color: #64a8b5;
    font-size: 16px;
    font-weight: 500;
}

.summary-content {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 15px;
    line-height: 1.8;
    color: #333;
}

.summary-content h3 {
    color: #64a8b5;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 18px;
}

.summary-content ul {
    margin-left: 20px;
}

.summary-content li {
    margin-bottom: 8px;
}

.summary-content strong {
    color: #4a8a96;
}

/* Controls Wrapper - Container for both left and right sections */
.controls-wrapper {
    display: flex;
    gap: 12px;
    /* Align this toolbar with the .tables-container card below so the
       save-load-container's left edge lines up with the card's left edge
       instead of touching the screen. The card is width:90vw centered with
       25px padding + 1px border each side (content-box), so its outer box is
       90vw + 52px; matching that and centering gives identical left edges. */
    width: calc(90vw + 52px);
    max-width: 100%;
    margin: 20px auto;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

/* Toolbar order across the card width: save-load on the left (aligned with the
   tables-container left edge), action buttons centered, and controls on the
   right (aligned with the tables-container right edge via space-between). */
.controls-wrapper .save-load-container { order: 1; }
.controls-wrapper .controls { order: 2; }
.controls-wrapper .action-buttons-container { order: 3; }
/* In the horizontal toolbar, neutralize .controls' auto side-margins so
   space-between can push it flush to the right edge (aligned with the
   tables-container). The auto-margin centering is kept for stacked/mobile. */
@media (min-width: 1180px) {
    /* Keep the toolbar on a single compact row and split it into three:
       save-load on the left, the Locations button on the right (both aligned
       with the tables-container edges), and action-buttons centered between
       them. Now that .controls holds a single button (not two dropdowns) the
       three groups fit on one row from ~1180px. */
    /* Three exactly-equal-width columns (save/load left, Locations centre,
       action buttons right). CSS Grid 1fr columns are equal regardless of each
       group's content; min-width:0 lets the content fit inside its column. */
    .controls-wrapper {
        display: grid;
        grid-template-columns: 34fr 30fr 36fr;
        gap: 10px;
        align-items: center;
    }
    .controls-wrapper .save-load-container,
    .controls-wrapper .controls,
    .controls-wrapper .action-buttons-container {
        width: auto;
        min-width: 0;
        box-sizing: border-box;
        justify-content: center;
        margin: 0;
    }
    /* Compact so the widest group (action buttons) fits within its third. */
    .controls-wrapper .save-load-container,
    .controls-wrapper .action-buttons-container {
        padding: 8px 10px;
        gap: 4px;
    }
    .controls-wrapper .controls {
        padding: 6px;
    }
    .controls-wrapper .save-load-button,
    .controls-wrapper .action-button,
    .controls-wrapper .locations-button {
        padding: 8px;
        font-size: 14px;
        gap: 4px;
    }
    .controls-wrapper .action-button {
        padding: 8px 6px;
        font-size: 13px;
        gap: 3px;
    }
    .controls-wrapper .action-icon {
        width: 13px;
        height: 13px;
    }
}

@media (max-width: 1179px) {
    .save-load-container > #save-btn,
    .save-load-container > #load-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Left Container - now holds only the Locations button */
.controls {
    display: flex;
    gap: 8px;
    padding: 6px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    width: fit-content;
}

/* Locations button — teal→purple gradient (matches the requested styling). */
.locations-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border: none;
    border-radius: 10px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    cursor: pointer;
    white-space: nowrap;
    background: linear-gradient(135deg, #64a8b5 0%, #2d132d 100%);
    box-shadow: 0 4px 10px rgb(201 78 210 / 30%);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    flex: 1;
    justify-content: center;
}
.locations-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgb(201 78 210 / 40%);
}
.locations-button .action-icon {
    width: 18px;
    height: 18px;
}

.controls label {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #64a8b5;
    margin-right: 8px;
}

.controls select {
    padding: 8px 12px;
    font-size: 14px;
    border: 2px solid #64a8b5;
    border-radius: 6px;
    background-color: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
}

.controls select:hover {
    border-color: #4a8a96;
    box-shadow: 0 2px 8px rgba(100, 168, 181, 0.2);
}

.controls select:focus {
    outline: none;
    border-color: #4a8a96;
    box-shadow: 0 0 0 3px rgba(100, 168, 181, 0.1);
}

/* Right Container - Action Buttons */
.action-buttons-container {
    display: flex;
    gap: 15px;
    padding: 15px 25px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    width: fit-content;
}

/* Action Buttons Styling */
.action-button {
    padding: 10px 24px;
    background: linear-gradient(135deg, #64a8b5 0%, #4a8a96 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(100, 168, 181, 0.3);
    white-space: nowrap;
}

.action-button:hover {
    background: linear-gradient(135deg, #4a8a96 0%, #3a7a86 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(100, 168, 181, 0.4);
}

.action-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(100, 168, 181, 0.3);
}

.action-icon {
    width: 20px;
    height: 20px;
}

/* Link wrapper for button */
.action-button-link {
    text-decoration: none;
}

/* Remove old AI summary container styles */
.ai-summary-container {
    display: none; /* This is now integrated into action-buttons-container */
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .controls-wrapper {
        flex-direction: column;
    }
    
    .controls,
    .action-buttons-container {
        width: 90%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .action-buttons-container {
        flex-direction: column;
        width: 100%;
    }
    
    .action-button {
        width: 100%;
        justify-content: center;
    }
}

/* Larger modal - TRIPLE size */
.modal-large .modal-content {
    width: 95%;
    max-width: 1600px;
    height: 85vh;
    max-height: 900px;
}

/* Only for Report Equipment modal */
#remarks-modal .modal-body {
    overflow: hidden;
    display: flex;
    gap: 30px;
    flex-direction: column;
}

/* Keep original styling for AI Summary modal */
#ai-summary-modal .modal-body {
    padding: 30px;
    height: calc(85vh - 100px);
    overflow: hidden;
    display: flex;
    gap: 30px;
}



/* Left side - Chart and Summary */
.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding-right: 15px;
}

/* Right side - Chat */
.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-left: 2px solid #e5e7eb;
    padding-left: 30px;
}

/* Chart container */
.chart-container {
    position: relative;
    height: 350px;
    margin-bottom: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Summary section styling - PARAGRAPH format */
#summary-section {
    padding: 20px;
    background: #ffffff;
    border-left: 4px solid #64a8b5;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

#summary-section h3 {
    color: #64a8b5;
    margin-bottom: 15px;
    font-size: 18px;
}

#summary-section .summary-text {
    line-height: 1.8;
    color: #333;
    font-size: 15px;
}

#summary-section .summary-text strong {
    color: #4a8a96;
    font-weight: 600;
}

/* Chat section - takes full right panel */
#chat-section {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#chat-section h3 {
    color: #64a8b5;
    margin-bottom: 15px;
    font-size: 18px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    background: #f8f9fa;
}

.chat-message {
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease;
}

.chat-message.user {
    text-align: right;
}

.chat-message.assistant {
    text-align: left;
}

.chat-bubble {
    display: inline-block;
    max-width: 80%;
    padding: 14px 18px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 15px;
}

.chat-message.user .chat-bubble {
    background: linear-gradient(135deg, #64a8b5 0%, #4a8a96 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .chat-bubble {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #333;
    border-bottom-left-radius: 4px;
}

/* Format bold text in chat */
.chat-bubble strong,
.chat-bubble b {
    font-weight: 700;
    color: inherit;
}

.chat-message.user .chat-bubble strong,
.chat-message.user .chat-bubble b {
    color: #fff;
}

.chat-message.assistant .chat-bubble strong,
.chat-message.assistant .chat-bubble b {
    color: #4a8a96;
}

.chat-input-container {
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #64a8b5;
    border-radius: 8px;
    font-size: 15px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.chat-input:focus {
    outline: none;
    border-color: #4a8a96;
    box-shadow: 0 0 0 3px rgba(100, 168, 181, 0.1);
}

.chat-send-btn {
    padding: 14px 24px;
    background: linear-gradient(135deg, #64a8b5 0%, #4a8a96 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-send-btn:hover {
    background: linear-gradient(135deg, #4a8a96 0%, #3a7a86 100%);
    transform: translateY(-2px);
}

.chat-send-btn svg {
    width: 22px;
    height: 22px;
}

.chat-typing {
    padding: 10px;
    color: #64a8b5;
    font-style: italic;
}

/* Responsive */
@media (max-width: 1200px) {

    
    .right-panel {
        border-left: none;
        border-top: 2px solid #e5e7eb;
        padding-left: 0;
        padding-top: 30px;
    }
}

/* Save/Load Container Styles */
.save-load-container {
    display: flex;
    gap: 15px;
    align-items: center;
    padding: 15px 25px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    width: fit-content;
}

.save-load-button {
    padding: 10px 24px;
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.3);
    white-space: nowrap;
}

.save-load-button:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(40, 167, 69, 0.4);
}

.save-load-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.dropdown-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.saved-states-select {
    padding: 10px 16px;
    font-size: 14px;
    border: 2px solid #64a8b5;
    border-radius: 6px;
    background-color: white;
    color: #333;
    cursor: pointer;
    min-width: 250px;
    transition: all 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.saved-states-select:hover {
    border-color: #4a8a96;
    box-shadow: 0 2px 8px rgba(100, 168, 181, 0.2);
}

.saved-states-select:focus {
    outline: none;
    border-color: #4a8a96;
    box-shadow: 0 0 0 3px rgba(100, 168, 181, 0.1);
}

.delete-btn {
    padding: 10px;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3);
    width: 42px;
    height: 42px;
}

.delete-btn:hover {
    background: linear-gradient(135deg, #c82333 0%, #bd2130 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(220, 53, 69, 0.4);
}

.delete-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.delete-btn svg {
    width: 20px;
    height: 20px;
}

.delete-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.5;
}

.delete-btn:disabled:hover {
    transform: none;
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .controls-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    
    .save-load-container {
        width: 100%;
        flex-direction: column;
    }
    
    .dropdown-wrapper {
        width: 100%;
    }
    
    .saved-states-select {
        flex: 1;
    }
}

/* Report Context Menu Styles */
#report-context-menu {
    position: fixed;
    background-color: white;
    border: 2px solid #64a8b5;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    display: none;
    min-width: 180px;
}

#report-context-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#report-context-menu li {
    padding: 12px 16px;
    cursor: pointer;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

#report-context-menu li:last-child {
    border-bottom: none;
}

#report-context-menu li:hover {
    background: linear-gradient(135deg, #64a8b5 0%, #4a8a96 100%);
    color: white;
}

#report-context-menu li:active {
    background: linear-gradient(135deg, #4a8a96 0%, #3a7a86 100%);
}

#report-text {
    align-items: center;
    gap: 8px;
}

.copyright {
    text-align: center;
    color: #64a8b5;
    font-size: 0.85rem;
    padding: 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: white;
    font-family: 'Inter', 'Helvetica Neue', sans-serif;
    width: 100%;
}

.copyright-icon {
    font-size: 0.9rem;
}
/* SAP Export Button */
.export-btn.sap-btn::before {
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" fill="white" viewBox="0 0 24 24"%3E%3Cpath d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20M12,19L8,15H10.5V12H13.5V15H16L12,19Z"/%3E%3C/svg%3E');
}

/* SAP Modal specific styles */
#sap-export-modal .modal-content {
    animation: slideIn 0.3s ease;
}

#primary-voltage-select {
    transition: border-color 0.3s ease;
}

#primary-voltage-select:focus {
    outline: none;
    border-color: #4a8a96;
    box-shadow: 0 0 0 3px rgba(100, 168, 181, 0.1);
}

#export-sap-btn:disabled {
    background: linear-gradient(135deg, #9ba8ae 0%, #7a8a96 100%);
    cursor: not-allowed;
    opacity: 0.6;
}

#hv-station-info {
    font-size: 14px;
    line-height: 1.6;
}

/* Keep wide content inside its own panel instead of widening the whole page. */
.header-container {
    box-sizing: border-box;
}

body .svg-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

body .tables-container {
    width: calc(90vw + 52px);
    max-width: calc(100% - 24px);
    box-sizing: border-box;
    overflow-x: auto;
}

.controls-wrapper,
.save-load-container,
.action-buttons-container {
    box-sizing: border-box;
}

.controls-wrapper {
    max-width: calc(100% - 24px);
}

@media (min-width: 1180px) {
    /* Let the primary controls share each group evenly while Undo/Redo stay compact. */
    body .controls-wrapper .save-load-container,
    body .controls-wrapper .action-buttons-container {
        flex-direction: row;
        align-items: stretch;
        gap: 6px;
    }

    body .controls-wrapper .action-buttons-container {
        display: grid;
        grid-template-columns: minmax(0, 25.5fr) minmax(0, 32fr) minmax(0, 42.5fr);
        height: 48px;
        padding: 6px 10px;
    }

    body .controls-wrapper .controls {
        height: 48px;
    }

    .save-load-container > #save-btn,
    .save-load-container > #load-btn {
        flex: 1 1 0;
        min-width: 0;
        justify-content: center;
    }

    .save-load-container > #undo-btn,
    .save-load-container > #redo-btn {
        flex: 0 0 29px;
        width: 29px;
        min-width: 29px;
        padding-right: 6px;
        padding-left: 6px;
    }

    .action-buttons-container > .action-button,
    .action-buttons-container > .action-button-link {
        flex: 1 1 0;
        min-width: 0;
        width: 100%;
    }

    .action-buttons-container > .action-button-link {
        display: flex;
    }

    .action-buttons-container > .action-button,
    .action-buttons-container > .action-button-link > .action-button {
        width: 100%;
        height: 100%;
        padding: 1px 3px;
        gap: 2px;
        font-size: 12px;
        justify-content: center;
        text-align: center;
        white-space: nowrap;
        line-height: 1.15;
    }

    .action-buttons-container .action-icon {
        width: 12px;
        height: 12px;
    }
}
